New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tie $scalar can tie a handle #10609
Comments
From @cpansprouttie() does not distinguish between $scalar and *$scalar if $scalar happens to hold a glob. Flags: Site configuration information for perl 5.13.4: Configured by sprout at Sun Aug 29 17:21:22 PDT 2010. Summary of my perl5 (revision 5 version 13 subversion 4 patch v5.13.4-30-g9b47cdd) configuration: Locally applied patches: @INC for perl 5.13.4: Environment for perl 5.13.4: |
From @cpansproutOn Sep 5, 2010, at 1:19 PM, Father Chrysostomos wrote:
Here is a patch for it. It won’t apply without the patches for #77362 and #77496 applied first. |
From @cpansproutFrom: Father Chrysostomos <sprout@cpan.org> [perl #77688] tie $scalar can tie a handle Make tie() distinguish between $scalar and *$scalar when $scalar holds Inline Patchdiff -Nup blead-77362-glob2lv10.glob-assign-and-magick/op.c blead-77362-glob2lv11.tie/op.c
--- blead-77362-glob2lv10.glob-assign-and-magick/op.c 2010-08-27 23:17:55.000000000 -0700
+++ blead-77362-glob2lv11.tie/op.c 2010-09-04 14:34:25.000000000 -0700
@@ -7156,7 +7156,12 @@ Perl_ck_fun(pTHX_ OP *o)
#endif
listkids(o);
- if (type == OP_TIED && cLISTOPo->op_first->op_type == OP_RV2GV)
+ if ((type == OP_TIED && cLISTOPo->op_first->op_type == OP_RV2GV)
+ || (
+ type == OP_TIE
+ && cLISTOPo->op_first->op_sibling->op_type == OP_RV2GV
+ )
+ )
o->op_flags |= OPf_SPECIAL;
}
else if (PL_opargs[type] & OA_DEFGV) {
diff -Nup blead-77362-glob2lv10.glob-assign-and-magick/op.h blead-77362-glob2lv11.tie/op.h
--- blead-77362-glob2lv10.glob-assign-and-magick/op.h 2010-08-27 23:18:02.000000000 -0700
+++ blead-77362-glob2lv11.tie/op.h 2010-09-04 06:24:30.000000000 -0700
@@ -139,7 +139,7 @@ Deprecated. Use C<GIMME_V> instead.
/* On OP_ANONHASH and OP_ANONLIST, create a
reference to the new anon hash or array */
/* On OP_ENTER, store caller context */
- /* On OP_TIED, RHS is a handle */
+ /* On OP_TIE(D), RHS is a handle */
/* On OP_HELEM and OP_HSLICE, localization will be followed
by assignment, so do not wipe the target if it is special
(e.g. a glob or a magic SV) */
diff -Nup blead-77362-glob2lv10.glob-assign-and-magick/pp_sys.c blead-77362-glob2lv11.tie/pp_sys.c
--- blead-77362-glob2lv10.glob-assign-and-magick/pp_sys.c 2010-08-27 23:18:20.000000000 -0700
+++ blead-77362-glob2lv11.tie/pp_sys.c 2010-09-04 14:34:59.000000000 -0700
@@ -826,7 +826,8 @@ PP(pp_tie)
break;
case SVt_PVGV:
case SVt_PVLV:
- if (isGV_with_GP(varsv)) {
+ if (isGV_with_GP(varsv)
+ && (!SvFAKE(varsv) || PL_op->op_flags & OPf_SPECIAL)) {
methname = "TIEHANDLE";
how = PERL_MAGIC_tiedscalar;
/* For tied filehandles, we apply tiedscalar magic to the IO
diff -rup blead-77362-glob2lv10.glob-assign-and-magick/t/op/tie.t blead-77362-glob2lv11.tie/t/op/tie.t
--- blead-77362-glob2lv10.glob-assign-and-magick/t/op/tie.t 2010-08-27 23:18:42.000000000 -0700
+++ blead-77362-glob2lv11.tie/t/op/tie.t 2010-09-04 06:09:29.000000000 -0700
@@ -953,3 +953,14 @@ print ref tied *$rin, "\n";
EXPECT
main
f
+########
+
+# tie $glob_copy vs tie *$glob_copy
+sub TIESCALAR { print "TIESCALAR\n" }
+sub TIEHANDLE{ print "TIEHANDLE\n" }
+$f = *foo;
+tie *$f, "";
+tie $f, "";
+EXPECT
+TIEHANDLE
+TIESCALAR |
From @cpansproutOn Sun Sep 05 13:39:43 2010, sprout wrote:
Change 2acc331 allows a much simpler fix, which has been applied |
From [Unknown Contact. See original ticket]On Sun Sep 05 13:39:43 2010, sprout wrote:
Change 2acc331 allows a much simpler fix, which has been applied |
@cpansprout - Status changed from 'new' to 'resolved' |
@cpansprout - Status changed from 'resolved' to 'open' |
From @cpansproutI’ve re-opened this, since the fix was reverted for 5.14. See #79528. |
From @cpansproutOn Wed Apr 20 14:34:14 2011, sprout wrote:
And now the revert has been reverted as 8bb5f78. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#77688 (status was 'resolved')
Searchable as RT77688$
The text was updated successfully, but these errors were encountered: