From: Rafael Garcia-Suarez Date: Thu, 29 Apr 2010 11:02:01 +0000 (+0200) Subject: Wrap by default coderefs returned by rdo and reval X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=554545435d592fa5ae8b79e031e59e9b09d6ff69;p=p5sagit%2Fp5-mst-13.2.git Wrap by default coderefs returned by rdo and reval (suggested by Tim Bunce) --- diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm index 6fc8523..20efe17 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 797e155..2f1c204 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";