diff --git a/lib/Path/Tiny.pm b/lib/Path/Tiny.pm index 92f177b..8f40ac9 100644 --- a/lib/Path/Tiny.pm +++ b/lib/Path/Tiny.pm @@ -40,8 +40,7 @@ sub THAW { return path( $_[2] ) } my $HAS_UU; # has Unicode::UTF8; lazily populated sub _check_UU { - local $SIG{__DIE__} = sub { } - if $SIG{__DIE__}; # prevent outer handler from being called + local $SIG{__DIE__}; # prevent outer handler from being called !!eval { require Unicode::UTF8; Unicode::UTF8->VERSION(0.58); @@ -49,12 +48,14 @@ sub _check_UU { }; } -my $HAS_PU; # has PerlIO::utf8_strict; lazily populated +my $HAS_PU; # has PerlIO::utf8_strict; lazily populated sub _check_PU { - local $SIG{__DIE__} = sub { } - if $SIG{__DIE__}; # prevent outer handler from being called + local $SIG{__DIE__}; # prevent outer handler from being called !!eval { + # MUST preload Encode or $SIG{__DIE__} localization fails + # on some Perl 5.8.8 (maybe other 5.8.*) compiled with -O2. + require Encode; require PerlIO::utf8_strict; PerlIO::utf8_strict->VERSION(0.003); 1;