Re: How best to "fix" a bug in a standard module?
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxx
- Date: 30 Mar 2007 15:22:22 GMT
kj <socyl@xxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
I frequently run into minor bugs in modules downloaded from CPAN.
Aside from the issue of reporting the bug to the modules' maintainers,
there's still the immediate problem of fixing the bug for our own
use.
AFAIC, it is out of the question to replace the installed module
with one I have fixed.
Why?
Therefore I have settled on just redefining
the buggy sub(s) in the calling code. For example, CGI::Carp::die
does not behave like CORE::die with respect to $@. To correct
this, I have this snippet at the beginning of my CGI script:
BEGIN {
no warnings 'redefine';
my $ccdie = \&CGI::Carp::die;
sub CGI::Carp::die {
@_ = $@ if !@_ and $@;
goto &$ccdie;
}
}
This seems to work fine, but somehow I'm not entirely comfortable
with doing something like this. What pitfalls am I overlooking?
I don't see any pitfalls. Under normal circumstances your approach
should work.
Is there a better approach?
I think there is. Use your own Perl library (~/lib/perl5/, for
instance), and make it known via $ENV{ PERL5LIB} or "use lib ...".
Then copy the broken module(s) to (an appropriate subdir of) your
lib and fix it there. Then send the author the diff. As they
say, "Patches speak louder than words".
If you want to be an even better member of the open source community,
add tests to the distributions .../t directory that discover the
behavior you have corrected, and also make sure that your fix
doesn't break any of the existing tests.
Anno
.
- Follow-Ups:
- References:
- Prev by Date: Re: readline - possible security hole
- Next by Date: Comprehensive Reference Books On Perl or CGI.
- Previous by thread: How best to "fix" a bug in a standard module?
- Next by thread: Re: How best to "fix" a bug in a standard module?
- Index(es):
Relevant Pages
|
|