New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"use base" masks $SIG{__DIE__} #8851
Comments
From @schwernCreated by @schwernIf a module sets a global $SIG{__DIE__} handler and is loaded with "use base" that $SIG{__DIE__} handler will be localized and thus not set. This is because of this code in base.pm. local $SIG{__DIE__}; aliased.pm had a similar problem and I propose a similar fix. Patch forthcoming. Perl Info
|
From @schwernAttached is the patch. |
From @schwernbase_sigdie.patch--- lib/base.pm 2006-10-23 01:52:58.000000000 -0700
+++ lib/base.pm 2007-03-28 21:42:53.000000000 -0700
@@ -82,21 +82,30 @@
unless defined ${$base.'::VERSION'};
}
else {
- local $SIG{__DIE__};
- eval "require $base";
- # Only ignore "Can't locate" errors from our eval require.
- # Other fatal errors (syntax etc) must be reported.
- die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
- unless (%{"$base\::"}) {
- require Carp;
- Carp::croak(<<ERROR);
+ my $sigdie;
+ {
+ local $SIG{__DIE__};
+ eval "require $base";
+ $sigdie = $SIG{__DIE__};
+
+ # Only ignore "Can't locate" errors from our eval require.
+ # Other fatal errors (syntax etc) must be reported.
+ die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
+ unless (%{"$base\::"}) {
+ require Carp;
+ Carp::croak(<<ERROR);
Base class package "$base" is empty.
(Perhaps you need to 'use' the module which defines that package first.)
ERROR
+ }
}
+
${$base.'::VERSION'} = "-1, set by base.pm"
unless defined ${$base.'::VERSION'};
+
+ # Make sure a global $SIG{__DIE__} makes it out of the localization
+ $SIG{__DIE__} = $sigdie if defined $sigdie;
}
push @{"$inheritor\::ISA"}, $base;
--- lib/base/t/base.t 2006-10-23 01:52:58.000000000 -0700
+++ lib/base/t/base.t 2007-03-28 21:42:47.000000000 -0700
@@ -1,7 +1,8 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 11;
+use Test::More tests => 13;
+use lib 't/lib';
use_ok('base');
@@ -85,3 +86,21 @@
'Base class empty error message');
}
+
+
+# Test that a global sigdie is preserved.
+{
+ local $SIG{__DIE__};
+ {
+ package Test::HasSigDie;
+ eval q[use base 'HasSigDie'];
+ }
+
+ ::ok $SIG{__DIE__}, 'sigdie set';
+ eval {
+ die "Testing sigdie handler";
+ };
+ package HasSigDie;
+ our $Sigdie_ran;
+ ::is $Sigdie_ran, 1;
+}
--- /dev/null 2007-03-28 21:42:35.000000000 -0700
+++ t/lib/HasSigDie.pm 2007-03-28 21:01:09.000000000 -0700
@@ -0,0 +1,5 @@
+package HasSigDie;
+
+$SIG{__DIE__} = sub { $Sigdie_ran++ };
+
+1;
|
@schwern - Status changed from 'new' to 'open' |
From @smpetersOn Wed, Mar 28, 2007 at 08:50:28PM -0700, Michael G Schwern wrote:
Since you are listed as the maintainer of base on CPAN, would you be Steve Peters |
From @schwernSteve Peters via RT wrote:
I'm not particularly interested in maintaining that module anymore and would |
From @rgarciaOn 29/03/07, Michael G Schwern <schwern@pobox.com> wrote:
I could do it, if you give me the rights on pause. |
From @schwernRafael Garcia-Suarez wrote:
Done, but only for base. Ilya has primary maintenance of fields which ships |
From nospam-abuse@ilyaz.orgOn Fri, Mar 30, 2007 at 03:26:35AM -0700, Michael G Schwern wrote:
Looks like a misprint. I have never used fields, so I doubt I Yours, |
From @andk
> Looks like a misprint. I have never used fields, so I doubt I I seem to recall that this was a consequence of one of your OS2 "Made RGARCIA primary maintainer of fields." -- |
From @rgarciaOn 30/03/07, Andreas J. Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de> wrote:
Thanks. I'll upload a new version before the next stable perl :) |
From @rgsThis problem has been fixed in bleadperl by change #31163. |
@rgs - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#42163 (status was 'resolved')
Searchable as RT42163$
The text was updated successfully, but these errors were encountered: