In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/086d291379a28ceb3cd7cc6416747be8c426476b?hp=f4adce6b773b2b6071e0d1627f4dce6ec0c3caa7>
- Log ----------------------------------------------------------------- commit 086d291379a28ceb3cd7cc6416747be8c426476b Author: Nicholas Clark <[email protected]> Date: Mon Jun 14 09:44:49 2010 +0200 Note why pp_tie can't use call_method() for a package name. Plus a test that would fail if it did. ----------------------------------------------------------------------- Summary of changes: pp_sys.c | 6 ++++-- t/op/tie.t | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pp_sys.c b/pp_sys.c index 1dadea8..a6d356e 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -855,8 +855,10 @@ PP(pp_tie) call_method(methname, G_SCALAR); } else { - /* Not clear why we don't call call_method here too. - * perhaps to get different error message ? + /* Can't use call_method here, else this: fileno FOO; tie @a, "FOO" + * will attempt to invoke IO::File::TIEARRAY, with (best case) the + * wrong error message, and worse case, supreme action at a distance. + * (Sorry obfuscation writers. You're not going to be given this one.) */ STRLEN len; const char *name = SvPV_nomg_const(*MARK, len); diff --git a/t/op/tie.t b/t/op/tie.t index 38c5cff..5628694 100644 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -929,3 +929,11 @@ print "fetch=$fetch\ncalled=$called\n"; EXPECT fetch=2 called=2 +######## +# tie mustn't attempt to call methods on bareword filehandles. +sub IO::File::TIEARRAY { + die "Did not want to invoke IO::File::TIEARRAY"; +} +fileno FOO; tie @a, "FOO" +EXPECT +Can't locate object method "TIEARRAY" via package "FOO" at - line 5. -- Perl5 Master Repository
