develooper Front page | perl.perl5.changes | Postings from March 2012

[perl.git] branch blead, updated. v5.15.9-64-g25dc25e

From:
Father Chrysostomos
Date:
March 31, 2012 13:20
Subject:
[perl.git] branch blead, updated. v5.15.9-64-g25dc25e
Message ID:
E1SE4mQ-00015O-9U@camel.ams6.corp.booking.com
In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/25dc25e774abbe993644899cf4d9f9925a9fb9a8?hp=6ca94f4195fb0098aa03840e9e36566404e034c5>

- Log -----------------------------------------------------------------
commit 25dc25e774abbe993644899cf4d9f9925a9fb9a8
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Mar 31 13:17:40 2012 -0700

    Safe.pm: Don’t eval code under ‘no strict’
    
    Instead of evaluating code under ‘no strict’, we should be evaluating
    it with no pragmata at all by default.
    
    This allows ‘use 5.012’ to enable strictures in reval.  It also
    has the side effect of suppressing the ‘Unbalanced string table
    refcount’ warnings, at least in some cases.  This was brought up in
    ticket #107000.

M	dist/Safe/Safe.pm
M	dist/Safe/t/safeload.t
M	dist/Safe/t/safeops.t

commit 96f88f6986b520357b9f1f3a9edf8761beb8e217
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Mar 31 11:35:11 2012 -0700

    Convert safeops.t to test.pl
    
    For the sake of tests in the next commit, it needs runperl(), which
    test.pl provides.  Since this script is only run in the perl core, it
    should be fine.

M	dist/Safe/t/safeops.t

commit 9ff92c368c69e5df824457dc6b238feafd4afb6b
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Mar 31 09:51:08 2012 -0700

    Increase $Safe::VERSION to 2.32

M	dist/Safe/Safe.pm
-----------------------------------------------------------------------

Summary of changes:
 dist/Safe/Safe.pm      |    8 ++++----
 dist/Safe/t/safeload.t |    9 ++++++++-
 dist/Safe/t/safeops.t  |   23 ++++++++++++++++++++---
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm
index 9335dc6..b578bc7 100644
--- a/dist/Safe/Safe.pm
+++ b/dist/Safe/Safe.pm
@@ -1,10 +1,9 @@
 package Safe;
 
 use 5.003_11;
-use strict;
 use Scalar::Util qw(reftype refaddr);
 
-$Safe::VERSION = "2.31";
+$Safe::VERSION = "2.32";
 
 # *** Don't declare any lexicals above this point ***
 #
@@ -22,10 +21,11 @@ sub lexless_anon_sub {
     # Uses a closure (on $__ExPr__) to pass in the code to be executed.
     # (eval on one line to keep line numbers as expected by caller)
     eval sprintf
-    'package %s; %s strict; sub { @_=(); eval q[my $__ExPr__;] . $__ExPr__; }',
-                $_[0], $_[1] ? 'use' : 'no';
+    'package %s; %s sub { @_=(); eval q[my $__ExPr__;] . $__ExPr__; }',
+                $_[0], $_[1] ? 'use strict;' : '';
 }
 
+use strict;
 use Carp;
 BEGIN { eval q{
     use Carp::Heavy;
diff --git a/dist/Safe/t/safeload.t b/dist/Safe/t/safeload.t
index 2d2c3cc..6ff7a76 100644
--- a/dist/Safe/t/safeload.t
+++ b/dist/Safe/t/safeload.t
@@ -18,9 +18,16 @@ BEGIN {
 use strict;
 use Test::More;
 use Safe;
-plan(tests => 1);
+plan(tests => 2);
 
 my $c = new Safe;
 $c->permit(qw(require caller entereval unpack));
 my $r = $c->reval(q{ use version; 1 });
 ok( defined $r, "Can load version.pm in a Safe compartment" ) or diag $@;
+
+# Does this test really belong here?  We are testing the "loading" of
+# a perl version number.
+# This should died because of strictures under 5.12+ and because of the
+# perl version in 5.10-.
+ok !$c->reval(q{use 5.012; $undeclared; 1}),
+   'reval does not prevent use 5.012 from enabling strict';
diff --git a/dist/Safe/t/safeops.t b/dist/Safe/t/safeops.t
index 616a848..885b0db 100644
--- a/dist/Safe/t/safeops.t
+++ b/dist/Safe/t/safeops.t
@@ -12,10 +12,13 @@ BEGIN {
     if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
         print "1..0\n"; exit 0;
     }
+
+    # We need test.pl for runperl().  Since this test script is only run in
+    # the perl core, this should be fine:
+    require '../../t/test.pl';
 }
 
 use strict;
-use Test::More;
 use Safe;
 
 # Read the op names and descriptions directly from opcode.pl
@@ -37,7 +40,7 @@ while (<$fh>) {
 }
 close $fh;
 
-plan(tests => scalar @op);
+plan(tests => scalar @op + 1);
 
 sub testop {
     my ($op, $opname, $code) = @_;
@@ -53,11 +56,25 @@ foreach (@op) {
     if ($_->[2]) {
 	testop @$_;
     } else {
-	local $TODO = "No test yet for $_->[1]";
+	local our $TODO = "No test yet for $_->[1]";
 	fail();
     }
 }
 
+# Test also that the errors resulting from disallowed ops do not cause
+# ‘Unbalanced’ warnings.
+{
+    local $ENV{PERL_DESTRUCT_LEVEL}=2;
+    unlike
+	runperl(
+	    switches => [ '-MSafe', '-w' ],
+	    prog     => 'Safe->new->reval(q(use strict))',
+	    stderr   => 1,
+	),
+	qr/Unbalanced/,
+	'No Unbalanced warnings when disallowing ops';
+}
+
 # things that begin with SKIP are skipped, for various reasons (notably
 # optree modified by the optimizer -- Safe checks are done before the
 # optimizer modifies the optree)

--
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About