Skip to content

Commit 602a6b4

Browse files
committed
Modifiers.pm - localize $SIG{__DIE__} in sub _sub_attrs()
In Perl/perl5#20357 we fixed an inconsistency in how eval EXPR handles compile errors so that the behavior is consistent regardless of the number or type of compile errors that are encountered. This means that $SIG{__DIE__} is called if there is an error compiling the code regardless of how the code fails to compile. The _sub_attrs() function does not localize $SIG{__DIE__} when it probes to see if the coderef is an lvalue function. This then breaks modules like MIME::Signature, see fany/MIME-Signature#3 and Perl/perl5#20885 and also https://rt.cpan.org/Ticket/Display.html?id=146848 for relevant bug reports. This patch fixes these issues.
1 parent 0b5917c commit 602a6b4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

lib/Class/Method/Modifiers.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ sub _sub_attrs {
208208
my ($coderef) = @_;
209209
local *_sub = $coderef;
210210
local $@;
211+
local $SIG{__DIE__};
211212
# this assignment will fail to compile if it isn't an lvalue sub. we
212213
# never want to actually call the sub though, so we return early.
213214
(eval 'return 1; &_sub = 1') ? ':lvalue' : '';

0 commit comments

Comments
 (0)