Hello community, here is the log from the commit of package perl-Lexical-SealRequireHints for openSUSE:Factory checked in at 2015-04-15 16:23:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Lexical-SealRequireHints (Old) and /work/SRC/openSUSE:Factory/.perl-Lexical-SealRequireHints.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Lexical-SealRequireHints" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Lexical-SealRequireHints/perl-Lexical-SealRequireHints.changes 2014-02-28 19:04:51.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Lexical-SealRequireHints.new/perl-Lexical-SealRequireHints.changes 2015-04-15 16:23:56.000000000 +0200 @@ -1,0 +2,44 @@ +Mon Apr 13 19:32:52 UTC 2015 - co...@suse.com + +- updated to 0.009 + see /usr/share/doc/packages/perl-Lexical-SealRequireHints/Changes + + version 0.009; 2015-03-20 + + * in test of require for version checking, work around [perl #124135] + which was introduced in Perl 5.21.4 + + version 0.008; 2015-03-20 + + * bugfix: don't localise hints around a version-number require, so that + "use v5.10.0" can have its intentional effect of setting feature flags + + * bugfix: in pure Perl implementation, use a ($) prototype on + CORE::GLOBAL::require, so that the argument expression will be in + the correct context + + * better error message for refusing to use pure Perl implementation + on Perl 5.9.4 to 5.10.0 + + * document that the pure Perl implementation breaks the use of the + implicit $_ parameter with require + + * in swash test, don't fail if utf8.pm was loaded unexpectedly early, + as has been seen to happen on some systems + + * test idempotence + + * fix test for thread safety, which risked false negatives + + * when preemptively loading Carp and Carp::Heavy, avoid the Perl core + bug regarding the context applied to file scope of required modules, + in case of future versions of those modules becoming vulnerable and + running on an old Perl + + * declare correct version for Test::More dependency + + * typo fix in documentation + + * typo fix in a comment + +------------------------------------------------------------------- Old: ---- Lexical-SealRequireHints-0.007.tar.gz New: ---- Lexical-SealRequireHints-0.009.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Lexical-SealRequireHints.spec ++++++ --- /var/tmp/diff_new_pack.0AUhFh/_old 2015-04-15 16:23:56.000000000 +0200 +++ /var/tmp/diff_new_pack.0AUhFh/_new 2015-04-15 16:23:56.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Lexical-SealRequireHints # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-Lexical-SealRequireHints -Version: 0.007 +Version: 0.009 Release: 0 %define cpan_name Lexical-SealRequireHints Summary: prevent leakage of lexical hints @@ -68,7 +68,9 @@ systems that can't handle XS modules. The XS version has a better chance of playing nicely with other modules that modify 'require' handling. The pure Perl version can't work at all on some Perl versions; users of those -versions must use the XS. +versions must use the XS. On all Perl versions suffering the underlying +hint leakage bug, pure Perl hooking of 'require' breaks the use of +'require' without an explicit parameter (implicitly using '$_'). %prep %setup -q -n %{cpan_name}-%{version} ++++++ Lexical-SealRequireHints-0.007.tar.gz -> Lexical-SealRequireHints-0.009.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/Build.PL new/Lexical-SealRequireHints-0.009/Build.PL --- old/Lexical-SealRequireHints-0.007/Build.PL 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/Build.PL 2015-03-20 23:17:44.000000000 +0100 @@ -68,7 +68,7 @@ }, build_requires => { "Module::Build" => 0, - "Test::More" => 0, + "Test::More" => "0.41", "perl" => "5.006", "strict" => 0, "warnings" => 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/Changes new/Lexical-SealRequireHints-0.009/Changes --- old/Lexical-SealRequireHints-0.007/Changes 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/Changes 2015-03-20 23:17:44.000000000 +0100 @@ -1,3 +1,41 @@ +version 0.009; 2015-03-20 + + * in test of require for version checking, work around [perl #124135] + which was introduced in Perl 5.21.4 + +version 0.008; 2015-03-20 + + * bugfix: don't localise hints around a version-number require, so that + "use v5.10.0" can have its intentional effect of setting feature flags + + * bugfix: in pure Perl implementation, use a ($) prototype on + CORE::GLOBAL::require, so that the argument expression will be in + the correct context + + * better error message for refusing to use pure Perl implementation + on Perl 5.9.4 to 5.10.0 + + * document that the pure Perl implementation breaks the use of the + implicit $_ parameter with require + + * in swash test, don't fail if utf8.pm was loaded unexpectedly early, + as has been seen to happen on some systems + + * test idempotence + + * fix test for thread safety, which risked false negatives + + * when preemptively loading Carp and Carp::Heavy, avoid the Perl core + bug regarding the context applied to file scope of required modules, + in case of future versions of those modules becoming vulnerable and + running on an old Perl + + * declare correct version for Test::More dependency + + * typo fix in documentation + + * typo fix in a comment + version 0.007; 2012-02-11 * be thread-safe, by mutex control on op check hooking diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/MANIFEST new/Lexical-SealRequireHints-0.009/MANIFEST --- old/Lexical-SealRequireHints-0.007/MANIFEST 2012-02-11 12:16:35.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/MANIFEST 2015-03-20 23:17:44.000000000 +0100 @@ -15,9 +15,12 @@ t/context_1.pm t/context_2.pm t/context_pp.t +t/defsv.t t/eval.t t/eval_0.pm t/eval_pp.t +t/idempotent.t +t/idempotent_pp.t t/override.t t/override_pp.t t/package.t @@ -38,4 +41,8 @@ t/swash_pp.t t/threads.t t/threads_pp.t +t/version_check.t +t/version_check_pp.t +t/version_feature.t +t/version_feature_pp.t SIGNATURE Added here by Module::Build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/META.json new/Lexical-SealRequireHints-0.009/META.json --- old/Lexical-SealRequireHints-0.007/META.json 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/META.json 2015-03-20 23:17:44.000000000 +0100 @@ -4,7 +4,7 @@ "Andrew Main (Zefram) <zef...@fysh.org>" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.112621", + "generated_by" : "Module::Build version 0.4205", "license" : [ "perl_5" ], @@ -16,27 +16,27 @@ "prereqs" : { "build" : { "requires" : { - "Module::Build" : 0, - "Test::More" : 0, + "Module::Build" : "0", + "Test::More" : "0.41", "perl" : "5.006", - "strict" : 0, - "warnings" : 0 + "strict" : "0", + "warnings" : "0" } }, "configure" : { "requires" : { - "Module::Build" : 0, + "Module::Build" : "0", "perl" : "5.006", - "strict" : 0, - "warnings" : 0 + "strict" : "0", + "warnings" : "0" } }, "runtime" : { "conflicts" : { - "B::Hooks::OP::Check" : 0 + "B::Hooks::OP::Check" : "< 0.19" }, "recommends" : { - "XSLoader" : 0 + "XSLoader" : "0" }, "requires" : { "perl" : "5.006" @@ -46,7 +46,7 @@ "provides" : { "Lexical::SealRequireHints" : { "file" : "lib/Lexical/SealRequireHints.pm", - "version" : "0.007" + "version" : "0.009" } }, "release_status" : "stable", @@ -55,5 +55,5 @@ "http://dev.perl.org/licenses/" ] }, - "version" : "0.007" + "version" : "0.009" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/META.yml new/Lexical-SealRequireHints-0.009/META.yml --- old/Lexical-SealRequireHints-0.007/META.yml 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/META.yml 2015-03-20 23:17:44.000000000 +0100 @@ -3,33 +3,33 @@ author: - 'Andrew Main (Zefram) <zef...@fysh.org>' build_requires: - Module::Build: 0 - Test::More: 0 - perl: 5.006 - strict: 0 - warnings: 0 + Module::Build: '0' + Test::More: '0.41' + perl: '5.006' + strict: '0' + warnings: '0' configure_requires: - Module::Build: 0 - perl: 5.006 - strict: 0 - warnings: 0 + Module::Build: '0' + perl: '5.006' + strict: '0' + warnings: '0' conflicts: - B::Hooks::OP::Check: 0 + B::Hooks::OP::Check: '< 0.19' dynamic_config: 1 -generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.112621' +generated_by: 'Module::Build version 0.4205, CPAN::Meta::Converter version 2.131560' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + version: '1.4' name: Lexical-SealRequireHints provides: Lexical::SealRequireHints: file: lib/Lexical/SealRequireHints.pm - version: 0.007 + version: '0.009' recommends: - XSLoader: 0 + XSLoader: '0' requires: - perl: 5.006 + perl: '5.006' resources: license: http://dev.perl.org/licenses/ -version: 0.007 +version: '0.009' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/Makefile.PL new/Lexical-SealRequireHints-0.009/Makefile.PL --- old/Lexical-SealRequireHints-0.007/Makefile.PL 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/Makefile.PL 2015-03-20 23:17:44.000000000 +0100 @@ -1,4 +1,4 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.3800 +# Note: this file was auto-generated by Module::Build::Compat version 0.4205 require 5.006; unless (eval "use Module::Build::Compat 0.02; 1" ) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/README new/Lexical-SealRequireHints-0.009/README --- old/Lexical-SealRequireHints-0.007/README 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/README 2015-03-20 23:17:44.000000000 +0100 @@ -55,7 +55,7 @@ COPYRIGHT -Copyright (C) 2009, 2010, 2011, 2012 +Copyright (C) 2009, 2010, 2011, 2012, 2015 Andrew Main (Zefram) <zef...@fysh.org> LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/SIGNATURE new/Lexical-SealRequireHints-0.009/SIGNATURE --- old/Lexical-SealRequireHints-0.007/SIGNATURE 2012-02-11 12:16:41.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/SIGNATURE 2015-03-20 23:17:52.000000000 +0100 @@ -1,5 +1,5 @@ This file contains message digests of all files listed in MANIFEST, -signed via the Module::Signature module, version 0.68. +signed via the Module::Signature module, version 0.73. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: @@ -15,26 +15,29 @@ Hash: SHA1 SHA1 6950821fe34951e6170552099d0de2ee22e43714 .gitignore -SHA1 cc637451b4394bbe449e558c2865bcfbb2698996 Build.PL -SHA1 1561b6b5e01725c2adeacdf97940981180de6bc1 Changes -SHA1 675cada784cd0ada13c868f959abab084f281d75 MANIFEST -SHA1 31362999f1729383f21c3d4452c3be1c2d062b5b META.json -SHA1 a29e34b013c3e2e60b3fe2d9a4bfe087334476ea META.yml -SHA1 2157ae40589595d6cc1585fd7279b25bcf8f5852 Makefile.PL -SHA1 5c7f6f24dbb8f162baf840f1c5c98861b19bed74 README -SHA1 70e3750058671c254a36aa4f86bf88d129895953 lib/Lexical/SealRequireHints.pm -SHA1 61d65de0636ca2ecb3c775bda849e5f125f363ee lib/Lexical/SealRequireHints.xs +SHA1 cd9729601cf687ddd61f76175d4aaae77c89be3e Build.PL +SHA1 d7013975ca8dd0bdc62762310f2fee0d0671868c Changes +SHA1 8a0fd294cf9c6c2a0aa73eb594811f6ff9d4ad2a MANIFEST +SHA1 420110294ca08a77f892b26f21ead15e7e99295a META.json +SHA1 c2b3c2080c3ef9d87770c908ffd9ea3ebb9f6b53 META.yml +SHA1 01014dbee096cf5abd3f05069cefa9c907a4aea1 Makefile.PL +SHA1 e220c3530b5f359a04b0eca0c76ffe38e4b8e7c5 README +SHA1 365f2fbb42b1aa995f0cdbc1d7d0863c92ffbf87 lib/Lexical/SealRequireHints.pm +SHA1 b37bc49474485b81053e6140531279187db2c1ff lib/Lexical/SealRequireHints.xs SHA1 85aaf18e006530f42082c756aa1040649c8b09a0 t/before_warnings.t SHA1 61999cf7732bd0ae59043f1718b294598366bdeb t/before_warnings_pp.t -SHA1 c6cc59cef58e4667494227ff90035fc292521a0d t/context.t +SHA1 3df41730d40647226f508e56d154aa432491d004 t/context.t SHA1 d40cabac0840b217bd9790fcf9c61f53d84561ec t/context_0.pm SHA1 c38cbea405a2738de1e144063993d9958934b828 t/context_1.pm SHA1 f13b20d1b34f6765fa222a387c022e4543aef945 t/context_2.pm SHA1 82657c96b6ed89ce7bdb6285dbcfbb05d68eaeb3 t/context_pp.t +SHA1 18a96f78b97cc043c8ced0aceefb8216a50e44b0 t/defsv.t SHA1 cafd4c3b6c5ea236bc2abec70b819b730cb90c4c t/eval.t -SHA1 a310c06c38797639dc5967a43c4e317ae10210d7 t/eval_0.pm +SHA1 e9a4397c1e339f95671c1b5e609426f624784efe t/eval_0.pm SHA1 b110d57bc147139e44f07d931e3d3698b404c244 t/eval_pp.t -SHA1 0109e5dfa9cd027eb8c5dddeb3ffe6eefa45939c t/override.t +SHA1 bba5f7f0083a8575478ddb642d80e27d6bf111c9 t/idempotent.t +SHA1 ef1eea9ae1774a96b0955b0da0d703de32bbcfe2 t/idempotent_pp.t +SHA1 1c2bfdf067bb2215729fe8ff60990c875799a22a t/override.t SHA1 d151cfac8c90f19137177b72eb2bff07488401ea t/override_pp.t SHA1 b064a061f38ee4924c7100180e8e8ff877bb25d1 t/package.t SHA1 8f88eba8be8441c0e078f3279b9220a2fdcd7c7c t/package_0.pm @@ -50,14 +53,18 @@ SHA1 e8478e388c78af43a2f3b50dd4c2d647dbd3b9ef t/seal_4.pm SHA1 bf9f3734c090121ff387eb85351b8abe17d6cff6 t/seal_pp.t SHA1 f8bd31bc8099cbb21c36cddc0508652fd092e332 t/setup_pp.pl -SHA1 fb608255d353cd98087a1b014b327f65d3acb6c2 t/swash.t +SHA1 6912741c04aa7b1a080bbe9216e453e489e9c218 t/swash.t SHA1 c2be3b40bb344403ac14899f5dfe05196373d1f9 t/swash_pp.t -SHA1 188f8f22b5b2304027a9bb374be67f62322be25a t/threads.t +SHA1 923e318828faaccdd2585f228535f44fae8b1842 t/threads.t SHA1 3dcc432bbe2d8f67f875e68d6501fd69683fab9f t/threads_pp.t +SHA1 0ec3dd0164e1e852b1be5f78bbacebd4990f085e t/version_check.t +SHA1 ed1cbf6ff3eed2268c517087e01814a940da658e t/version_check_pp.t +SHA1 cbff8c2d9481b01beb691a498ae98511d0b25cbe t/version_feature.t +SHA1 04c0a2e7e2291f9e74f8add832caa29eb2b538d4 t/version_feature_pp.t -----BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (GNU/Linux) +Version: GnuPG v1.4.12 (GNU/Linux) -iEYEARECAAYFAk82ThMACgkQOV9mt2VyAVEMEwCfW4fb0GfXrM9aadSuV9WE/pjg -/D8AnjcMTCb31yJNMccwSCUU8sfUWP1M -=IQMc +iEYEARECAAYFAlUMnIgACgkQOV9mt2VyAVGo8gCdEl9TWsnI/5dj5/o4o1krfFf9 +bKQAn0BXT0KTTLj/kiOqfB/9oJW6yrlq +=l4Ln -----END PGP SIGNATURE----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/lib/Lexical/SealRequireHints.pm new/Lexical-SealRequireHints-0.009/lib/Lexical/SealRequireHints.pm --- old/Lexical-SealRequireHints-0.007/lib/Lexical/SealRequireHints.pm 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/lib/Lexical/SealRequireHints.pm 2015-03-20 23:17:44.000000000 +0100 @@ -44,10 +44,12 @@ This module is implemented in XS, with a pure Perl backup version for systems that can't handle XS modules. The XS version has a better chance of playing nicely with other modules that modify C<require> handling. -The pure Perl version can't work at all on some Perl versions; users of -those versions must use the XS. +The pure Perl version can't work at all on some Perl versions; users +of those versions must use the XS. On all Perl versions suffering the +underlying hint leakage bug, pure Perl hooking of C<require> breaks the +use of C<require> without an explicit parameter (implicitly using C<$_>). -=head1 PERL VERION DIFFERENCES +=head1 PERL VERSION DIFFERENCES The history of the C<%^H> bugs is complex. Here is a chronological statement of the relevant changes. @@ -143,7 +145,7 @@ # Also don't "use strict", because of consequences of compiling # strict.pm's code. -our $VERSION = "0.007"; +our $VERSION = "0.009"; if("$]" >= 5.012) { # bug not present @@ -161,9 +163,13 @@ # may be subject to delayed require statements in XSLoader or # things that it loaded. foreach(qw(Carp.pm Carp/Heavy.pm)) { - eval { local $SIG{__DIE__}; require($_); }; + eval { local $SIG{__DIE__}; require($_); 1; }; } -} elsif("$]" >= 5.007002 && !("$]" >= 5.009004 && "$]" < 5.010001)) { +} elsif("$]" < 5.007002) { + die "pure Perl version of @{[__PACKAGE__]} can't work on pre-5.8 perl"; +} elsif("$]" >= 5.009004 && "$]" < 5.010001) { + die "pure Perl version of @{[__PACKAGE__]} can't work on perl 5.10.0"; +} else { my $done; *import = sub { die "$_[0] does not take any importation arguments\n" @@ -189,15 +195,36 @@ $CORE::GLOBAL::{require} = $grequire; return scalar($requirer->($arg)); }; - *CORE::GLOBAL::require = sub { + *CORE::GLOBAL::require = sub ($) { die "wrong number of arguments to require\n" unless @_ == 1; my($arg) = @_; # Some reference to $next_require is required # at this level of subroutine so that it will # be closed over and hence made available to - # the string eval below. + # the string eval. my $nr = $next_require; + my $requirer = eval qq{ + package @{[scalar(caller(0))]}; + sub { scalar(\$next_require->(\$_[0])) }; + }; + # We must localise %^H when performing a require + # with a filename, but not a require with a + # version number. This is because on Perl 5.9.5 + # and above require with a version number does an + # internal importation from the "feature" module, + # which is intentional behaviour that must be + # allowed to affect %^H. (That's logically the + # wrong place for the feature importation, but + # it's too late to change how old Perls do it.) + # A version number is an argument that is either + # numeric or, from Perl 5.9.2 onwards, a v-string. + my $must_localise = ($arg^$arg) ne "0" && + !("$]" >= 5.009002 && ref(\$arg) eq "VSTRING"); + # On Perl 5.11 we need to set the HINT_LOCALIZE_HH + # bit to get proper restoration of %^H by the + # swash loading code. + $^H |= 0x20000 if "$]" >= 5.011 && $must_localise; # Compile-time %^H gets localised by the # "local %^H". Runtime %^H doesn't exist prior # to Perl 5.9.4, and on Perl 5.10.1 and above is @@ -206,21 +233,12 @@ # correctly localise runtime %^H in pure Perl, # short of putting an eval frame around the # require, so we don't use this implementation in - # that region. On Perl 5.11 we need to set the - # HINT_LOCALIZE_HH bit to get proper restoration - # of %^H by the swash loading code. - my $requirer = eval qq{ - package @{[scalar(caller(0))]}; - sub { scalar(\$next_require->(\$_[0])) }; - }; - $^H |= 0x20000 if "$]" >= 5.011; - local %^H; + # that region. + local %^H if $must_localise; return scalar($requirer->($arg)); }; }; *unimport = sub { die "$_[0] does not support unimportation\n" }; -} else { - die "pure Perl version of @{[__PACKAGE__]} can't work on pre-5.8 perl"; } =head1 BUGS @@ -230,6 +248,18 @@ a C<require> statement that was compiled before this module was invoked. Where problems occur, this module must be invoked earlier. +On all Perl versions that need a fix for the lexical hint leakage bug, +the pure Perl implementation of this module unavoidably breaks the use +of C<require> without an explicit parameter (implicitly using C<$_>). +This is due to another bug in the Perl core, fixed in Perl 5.15.5, and is +inherent to the mechanism by which pure Perl code can hook C<require>. +The use of implicit C<$_> with C<require> is rare, so although this +state of affairs is faulty it will actually work for most programs. +Perl versions 5.12.0 and greater, despite having the C<require> hooking +bug, don't actually exhibit a problem with the pure Perl version of this +module, because with the lexical hint leakage bug fixed there is no need +for this module to hook C<require>. + =head1 SEE ALSO L<perlpragma> @@ -240,7 +270,7 @@ =head1 COPYRIGHT -Copyright (C) 2009, 2010, 2011, 2012 +Copyright (C) 2009, 2010, 2011, 2012, 2015 Andrew Main (Zefram) <zef...@fysh.org> =head1 LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/lib/Lexical/SealRequireHints.xs new/Lexical-SealRequireHints-0.009/lib/Lexical/SealRequireHints.xs --- old/Lexical-SealRequireHints-0.007/lib/Lexical/SealRequireHints.xs 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/lib/Lexical/SealRequireHints.xs 2015-03-20 23:17:44.000000000 +0100 @@ -41,15 +41,53 @@ } # endif /* !wrap_op_checker */ +# ifndef SvVOK +# define SvVOK(sv) 0 +# endif /* !SvVOK */ + # define refcounted_he_free(he) Perl_refcounted_he_free(aTHX_ he) -static OP *pp_squashhints(pTHX) +# define newDEFSVOP() THX_newDEFSVOP(aTHX) +static OP *THX_newDEFSVOP(pTHX) +{ +# if PERL_VERSION_GE(5,9,1) + /* hope nothing overrides the meaning of defined() */ + OP *dop = newOP(OP_DEFINED, 0); + if(dop->op_type == OP_DEFINED && (dop->op_flags & OPf_KIDS)) { + OP *op = cUNOPx(dop)->op_first; + cUNOPx(dop)->op_first = op->op_sibling; + if(!op->op_sibling) dop->op_flags &= ~OPf_KIDS; + op->op_sibling = NULL; + op_free(dop); + return op; + } + op_free(dop); +# endif /* >=5.9.1 */ + return newSVREF(newGVOP(OP_GV, 0, PL_defgv)); +} + +# define op_scalar(op) THX_op_scalar(aTHX_ op) +static OP *THX_op_scalar(pTHX_ OP *op) +{ + OP *sop = newUNOP(OP_SCALAR, 0, op); + if(!(sop->op_type == OP_SCALAR && (sop->op_flags & OPf_KIDS))) + return sop; + op = cUNOPx(sop)->op_first; + cUNOPx(sop)->op_first = op->op_sibling; + if(!op->op_sibling) sop->op_flags &= ~OPf_KIDS; + op->op_sibling = NULL; + op_free(sop); + return op; +} + +# define pp_squashhints() THX_pp_squashhints(aTHX) +static OP *THX_pp_squashhints(pTHX) { /* * SAVEHINTS() won't actually localise %^H unless the * HINT_LOCALIZE_HH bit is set. Normally that bit would be set if * there were anything in %^H, but when affected by [perl #73174] - * the core's swash-loading code clears $^H without # changing + * the core's swash-loading code clears $^H without changing * %^H, so we set the bit here. We localise $^H while doing this, * in order to not clobber $^H across a normal require where the * bit is legitimately clear, except on Perl 5.11, where the bit @@ -70,22 +108,75 @@ return PL_op->op_next; } -#define gen_squashhints_op() THX_gen_squashhints_op(aTHX) +# define gen_squashhints_op() THX_gen_squashhints_op(aTHX) static OP *THX_gen_squashhints_op(pTHX) { OP *squashhints_op = newOP(OP_PUSHMARK, 0); squashhints_op->op_type = OP_RAND; - squashhints_op->op_ppaddr = pp_squashhints; + squashhints_op->op_ppaddr = THX_pp_squashhints; return squashhints_op; } +# define pp_maybesquashhints() THX_pp_maybesquashhints(aTHX) +static OP *THX_pp_maybesquashhints(pTHX) +{ + dSP; + SV *arg = TOPs; + return SvNIOKp(arg) || (PERL_VERSION_GE(5,9,2) && SvVOK(arg)) ? + PL_op->op_next : pp_squashhints(); +} + +# define gen_maybesquashhints_op(argop) THX_gen_maybesquashhints_op(aTHX_ argop) +static OP *THX_gen_maybesquashhints_op(pTHX_ OP *argop) +{ + OP *msh_op = newUNOP(OP_NULL, 0, argop); + msh_op->op_type = OP_RAND; + msh_op->op_ppaddr = THX_pp_maybesquashhints; + return msh_op; +} + static OP *(*nxck_require)(pTHX_ OP *op); static OP *myck_require(pTHX_ OP *op) { - op = nxck_require(aTHX_ op); - op = append_list(OP_LINESEQ, (LISTOP*)gen_squashhints_op(), - (LISTOP*)op); + OP *argop; + if(!(op->op_flags & OPf_KIDS)) { + /* + * We need to expand the implicit-parameter case + * to an explicit parameter that we can operate on. + * This duplicates what ck_fun() would do, including + * its invocation of a fresh chain of op checkers. + */ + op_free(op); + return newUNOP(OP_REQUIRE, 0, newDEFSVOP()); + } + argop = cUNOPx(op)->op_first; + if(argop->op_type == OP_CONST && (argop->op_private & OPpCONST_BARE)) { + /* + * Bareword argument gets special handling in standard + * checker, which we'd rather not interfere with by the + * process that we'd need to use a maybesquashhints op. + * Fortunately, we don't need access to the runtime + * argument in this case: we know it must be a module + * name, so we definitely want to squash hints at runtime. + * So build op tree with an unconditional squashhints op. + */ + op = nxck_require(aTHX_ op); + op = append_list(OP_LINESEQ, (LISTOP*)gen_squashhints_op(), + (LISTOP*)op); + } else { + /* + * Whether we want to squash hints depends on whether + * the argument at runtime is a version number or not. + * So we wrap the argument op, separating it from the + * require op. + */ + OP *sib = argop->op_sibling; + argop->op_sibling = NULL; + argop = gen_maybesquashhints_op(op_scalar(argop)); + argop->op_sibling = sib; + cUNOPx(op)->op_first = argop; + } op = prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), op); op->op_type = OP_LEAVE; op->op_ppaddr = PL_ppaddr[OP_LEAVE]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/context.t new/Lexical-SealRequireHints-0.009/t/context.t --- old/Lexical-SealRequireHints-0.007/t/context.t 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/context.t 2015-03-20 23:17:44.000000000 +0100 @@ -1,7 +1,7 @@ use warnings; use strict; -use Test::More tests => 11; +use Test::More tests => 14; BEGIN { use_ok "Lexical::SealRequireHints"; } @@ -29,4 +29,14 @@ eval { require t::context_2; 1 }; is $@, ""; +sub diecxt() { + die wantarray ? "ARRAY\n" : defined(wantarray) ? "SCALAR\n" : "VOID\n"; +} +eval { $retval = require(diecxt()); 1 }; +is $@, "SCALAR\n"; +eval { $retval = [ require(diecxt()) ]; 1 }; +is $@, "SCALAR\n"; +eval { require(diecxt()); 1 }; +is $@, "SCALAR\n"; + 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/defsv.t new/Lexical-SealRequireHints-0.009/t/defsv.t --- old/Lexical-SealRequireHints-0.007/t/defsv.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/defsv.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,29 @@ +use warnings; +use strict; + +use Test::More tests => 5; + +BEGIN { use_ok "Lexical::SealRequireHints"; } + +SKIP: { + skip "CORE::GLOBAL::require breaks require() on this perl", 4 + if defined(&CORE::GLOBAL::require) && "$]" < 5.015005; + my $retval; + eval q{ our $_ = "t/context_0.pm"; $retval = require; 1 }; + is $@, ""; + is $retval, "t::context_0 return"; + SKIP: { + skip "no lexical \$_ on this perl", 2 if "$]" < 5.009001; + eval q{ + no warnings "$]" >= 5.017009 ? "experimental" : + "deprecated"; + my $_ = "t/context_1.pm"; + $retval = require; + 1; + }; + is $@, ""; + is $retval, "t::context_1 return"; + } +} + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/eval_0.pm new/Lexical-SealRequireHints-0.009/t/eval_0.pm --- old/Lexical-SealRequireHints-0.007/t/eval_0.pm 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/eval_0.pm 2015-03-20 23:17:44.000000000 +0100 @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More; +use Test::More 0.41; sub _ok_no_eval() { my $lastsub = ""; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/idempotent.t new/Lexical-SealRequireHints-0.009/t/idempotent.t --- old/Lexical-SealRequireHints-0.007/t/idempotent.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/idempotent.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,9 @@ +use warnings; +use strict; + +alarm 10; + +use Lexical::SealRequireHints; +do "t/seal.t" or die $@ || $!; + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/idempotent_pp.t new/Lexical-SealRequireHints-0.009/t/idempotent_pp.t --- old/Lexical-SealRequireHints-0.007/t/idempotent_pp.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/idempotent_pp.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,7 @@ +use warnings; +use strict; + +do "t/setup_pp.pl" or die $@ || $!; +do "t/idempotent.t" or die $@ || $!; + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/override.t new/Lexical-SealRequireHints-0.009/t/override.t --- old/Lexical-SealRequireHints-0.007/t/override.t 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/override.t 2015-03-20 23:17:44.000000000 +0100 @@ -44,7 +44,8 @@ my $next_require = defined(&CORE::GLOBAL::require) ? \&CORE::GLOBAL::require : sub { CORE::require($_[0]) }; no warnings "redefine"; - *CORE::GLOBAL::require = sub { + no warnings "prototype"; + *CORE::GLOBAL::require = sub ($) { push @require_activity, "b"; return $next_require->(@_); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/swash.t new/Lexical-SealRequireHints-0.009/t/swash.t --- old/Lexical-SealRequireHints-0.007/t/swash.t 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/swash.t 2015-03-20 23:17:44.000000000 +0100 @@ -28,7 +28,14 @@ %^H = ( foo=>1, bar=>2 ); $^H |= 0x20000; is_deeply [ sort keys(%^H) ], [qw(bar foo)]; - ok !exists($INC{"utf8.pm"}); + if(exists $INC{"utf8.pm"}) { + SKIP: { + skip "utf8.pm loaded too early ". + "(breaking following tests)", 1; + } + } else { + pass; + } } BEGIN { # Up to Perl 5.7.0, it is the compilation of this regexp match diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/threads.t new/Lexical-SealRequireHints-0.009/t/threads.t --- old/Lexical-SealRequireHints-0.007/t/threads.t 2012-02-11 12:16:34.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/threads.t 2015-03-20 23:17:44.000000000 +0100 @@ -16,12 +16,18 @@ require Test::More; Test::More::plan(skip_all => "Thread::Semaphore unavailable"); } + eval { require threads::shared; }; + if($@ ne "") { + require Test::More; + Test::More::plan(skip_all => "threads::shared unavailable"); + } } use threads; use Test::More tests => 3; use Thread::Semaphore (); +use threads::shared; alarm 10; # failure mode may involve an infinite loop @@ -30,26 +36,30 @@ my $done2 = Thread::Semaphore->new(0); my $exit2 = Thread::Semaphore->new(0); -my $ok1 = 1; +my $ok1 :shared; my $thread1 = threads->create(sub { + my $ok = 1; eval(q{ use Lexical::SealRequireHints; require t::context_1; 1; - }) or $ok1 = 0; + }) or $ok = 0; + $ok1 = $ok; $done1->up; $exit1->down; }); $done1->down; ok $ok1; -my $ok2 = 1; +my $ok2 :shared; my $thread2 = threads->create(sub { + my $ok = 1; eval(q{ use Lexical::SealRequireHints; require t::context_2; 1; - }) or $ok2 = 0; + }) or $ok = 0; + $ok2 = $ok; $done2->up; $exit2->down; }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/version_check.t new/Lexical-SealRequireHints-0.009/t/version_check.t --- old/Lexical-SealRequireHints-0.007/t/version_check.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/version_check.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,44 @@ +use warnings; +use strict; + +use Test::More tests => 19; + +BEGIN { use_ok "Lexical::SealRequireHints"; } + +no warnings "portable"; + +foreach( + q{ use 5.006; }, + q{ use 5.6.0; }, + q{ use v5.6.0; }, + q{ require 5.006; }, + q{ require 5.6.0; }, + q{ require v5.6.0; }, + q{ require(5.006); }, + ("$]" >= 5.009002 ? ( + q{ my $v = 5.6.0; require($v); }, + q{ my $v = 5.6.0; require($v); }, + ) : ("", "")), +) { + eval $_; + is $@, ""; +} + +foreach( + q{ use 6.006; }, + q{ use 6.6.0; }, + q{ use v6.6.0; }, + q{ require 6.006; }, + q{ require 6.6.0; }, + q{ require v6.6.0; }, + q{ require(6.006); }, + ("$]" >= 5.009002 ? ( + q{ my $v = 6.6.0; require($v); }, + q{ my $v = 6.6.0; require($v); }, + ) : ("use 6.006;", "use 6.006;")), +) { + eval $_; + like $@, qr/\APerl v6\.6\.0 required/; +} + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/version_check_pp.t new/Lexical-SealRequireHints-0.009/t/version_check_pp.t --- old/Lexical-SealRequireHints-0.007/t/version_check_pp.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/version_check_pp.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,7 @@ +use warnings; +use strict; + +do "t/setup_pp.pl" or die $@ || $!; +do "t/version_check.t" or die $@ || $!; + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/version_feature.t new/Lexical-SealRequireHints-0.009/t/version_feature.t --- old/Lexical-SealRequireHints-0.007/t/version_feature.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/version_feature.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,36 @@ +use warnings; +use strict; + +BEGIN { + if("$]" < 5.009005) { + require Test::More; + Test::More::plan(skip_all => + "no version-implied features on this perl"); + } +} + +use Test::More tests => 4; + +BEGIN { use_ok "Lexical::SealRequireHints"; } + +eval q{ + use 5.009005; + sub t0 { say "foo"; } +}; +is $@, ""; + +eval q{ + no warnings "portable"; + use 5.9.5; + sub t1 { say "foo"; } +}; +is $@, ""; + +eval q{ + no warnings "portable"; + use v5.9.5; + sub t2 { say "foo"; } +}; +is $@, ""; + +1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Lexical-SealRequireHints-0.007/t/version_feature_pp.t new/Lexical-SealRequireHints-0.009/t/version_feature_pp.t --- old/Lexical-SealRequireHints-0.007/t/version_feature_pp.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Lexical-SealRequireHints-0.009/t/version_feature_pp.t 2015-03-20 23:17:44.000000000 +0100 @@ -0,0 +1,7 @@ +use warnings; +use strict; + +do "t/setup_pp.pl" or die $@ || $!; +do "t/version_feature.t" or die $@ || $!; + +1;