diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-04-29 13:02:01 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-04-29 13:02:01 +0200 |
commit | 554545435d592fa5ae8b79e031e59e9b09d6ff69 (patch) | |
tree | 9d89736792d508eb5c3540cd2a518b73e0bdbe80 /dist/Safe | |
parent | 4e26ee16e1f0f7dcd3b43b07d5857f023ab42f28 (diff) | |
download | perl-554545435d592fa5ae8b79e031e59e9b09d6ff69.tar.gz |
Wrap by default coderefs returned by rdo and reval
(suggested by Tim Bunce)
Diffstat (limited to 'dist/Safe')
-rw-r--r-- | dist/Safe/Safe.pm | 2 | ||||
-rw-r--r-- | dist/Safe/t/safesort.t | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm index 6fc8523d03..20efe17eb3 100644 --- a/dist/Safe/Safe.pm +++ b/dist/Safe/Safe.pm @@ -358,6 +358,7 @@ sub reval { ? Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub) : scalar Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub); _clean_stash($root.'::') if $sg != sub_generation(); + $obj->wrap_code_refs_within(@subret); return (wantarray) ? @subret : $subret[0]; } @@ -436,6 +437,7 @@ sub rdo { ? Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub) : scalar Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub); _clean_stash($root.'::') if $sg != sub_generation(); + $obj->wrap_code_refs_within(@subret); return (wantarray) ? @subret : $subret[0]; } diff --git a/dist/Safe/t/safesort.t b/dist/Safe/t/safesort.t index 797e155f06..2f1c204439 100644 --- a/dist/Safe/t/safesort.t +++ b/dist/Safe/t/safesort.t @@ -33,13 +33,7 @@ EOS is $@, '', 'reval should not fail'; is ref $func, 'CODE', 'reval should return a CODE ref'; -# $func1 will work in non-threaded perl -# but RT#60374 "Safe.pm sort {} bug with -Dusethreads" -# means the sorting won't work unless we wrap the code ref -# such that it's executed with Safe 'in effect' at runtime -my $func2 = $safe->wrap_code_ref($func1); - -my ($l_sorted, $p_sorted) = $func2->(3,1,2); +my ($l_sorted, $p_sorted) = $func1->(3,1,2); is $l_sorted, "1,2,3"; is $p_sorted, "1,2,3"; |