diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-10-31 17:02:44 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-31 17:25:09 -0700 |
commit | f64c9ac53bc4a5fa5967c92e98d7b42cca1ce97b (patch) | |
tree | 10136ffc3693709c80e4c0ef25908bf779d18413 | |
parent | a9aeb2f17bf8f278290ca5bb590566f31b78ffb1 (diff) | |
download | perl-f64c9ac53bc4a5fa5967c92e98d7b42cca1ce97b.tar.gz |
[perl #78580] Stop a simple *glob from calling get-magic
This also happens to apply to *{ $::{glob} }, but not to *{\*glob} or
*{$thing = *glob}.
In other words, it’s only when the operand is a real glob, and not a
reference or a SVt_FAKE glob.
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | t/op/gmagic.t | 15 |
2 files changed, 15 insertions, 2 deletions
@@ -139,7 +139,7 @@ PP(pp_rv2gv) { dVAR; dSP; dTOPss; - SvGETMAGIC(sv); + if (!isGV(sv) || SvFAKE(sv)) SvGETMAGIC(sv); if (SvROK(sv)) { wasref: tryAMAGICunDEREF(to_gv); diff --git a/t/op/gmagic.t b/t/op/gmagic.t index 65441a6f98..bc8a926d70 100644 --- a/t/op/gmagic.t +++ b/t/op/gmagic.t @@ -6,7 +6,7 @@ BEGIN { @INC = '../lib'; } -print "1..22\n"; +print "1..24\n"; my $t = 1; tie my $c => 'Tie::Monitor'; @@ -60,6 +60,19 @@ $c = *strat; $s = $c; ok_string $s, *strat, 1, 1; +# A plain *foo should not call get-magic on *foo. +# This method of scalar-tying an immutable glob relies on details of the +# current implementation that are subject to change. This test may need to +# be rewritten if they do change. +my $tyre = tie $::{gelp} => 'Tie::Monitor'; +# Compilation of this eval autovivifies the *gelp glob. +eval '$tyre->init(0); () = \*gelp'; +my($rgot, $wgot) = $tyre->init(0); +print "not " unless $rgot == 0; +print "ok ", $t++, " - a plain *foo causes no get-magic\n"; +print "not " unless $wgot == 0; +print "ok ", $t++, " - a plain *foo causes no set-magic\n"; + # adapted from Tie::Counter by Abigail package Tie::Monitor; |