Change 15251 by ams@lustre on 2002/03/16 02:38:08
Subject: [PATCH @15047] Use of inherited AUTOLOAD for non-method
*::DESTROY() is deprecated
From: Ilya Zakharevich <[EMAIL PROTECTED]>
Date: Thu, 14 Mar 2002 18:39:22 -0500
Message-Id: <[EMAIL PROTECTED]>
Subject: Re: [PATCH @15047] Use of inherited AUTOLOAD for non-method
*::DESTROY() is deprecated
From: Dave Mitchell <[EMAIL PROTECTED]>
Date: Fri, 15 Mar 2002 19:22:49 +0000
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/gv.c#168 edit
.... //depot/perl/t/op/method.t#20 edit
Differences ...
==== //depot/perl/gv.c#168 (text) ====
Index: perl/gv.c
--- perl/gv.c.~1~ Fri Mar 15 19:45:05 2002
+++ perl/gv.c Fri Mar 15 19:45:05 2002
@@ -1412,6 +1412,7 @@
{
MAGIC *mg;
AMT *amtp;
+ CV *ret;
if (!stash)
return Nullcv;
@@ -1425,8 +1426,21 @@
if ( amtp->was_ok_am != PL_amagic_generation
|| amtp->was_ok_sub != PL_sub_generation )
goto do_update;
- if (AMT_AMAGIC(amtp))
- return amtp->table[id];
+ if (AMT_AMAGIC(amtp)) {
+ ret = amtp->table[id];
+ if (ret && isGV(ret)) { /* Autoloading stab */
+ /* Passing it through may have resulted in a warning
+ "Inherited AUTOLOAD for a non-method deprecated", since
+ our caller is going through a function call, not a method call.
+ So return the CV for AUTOLOAD, setting $AUTOLOAD. */
+ GV *gv = gv_fetchmethod(stash, (char*)PL_AMG_names[id]);
+
+ if (gv && GvCV(gv))
+ return GvCV(gv);
+ }
+ return ret;
+ }
+
return Nullcv;
}
==== //depot/perl/t/op/method.t#20 (xtext) ====
Index: perl/t/op/method.t
--- perl/t/op/method.t.~1~ Fri Mar 15 19:45:05 2002
+++ perl/t/op/method.t Fri Mar 15 19:45:05 2002
@@ -9,7 +9,7 @@
@INC = '../lib';
}
-print "1..73\n";
+print "1..74\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -249,4 +249,20 @@
] || $@, 'ok'
);
+# An autoloaded, inherited DESTROY may be invoked differently than normal
+# methods, and has been known to give rise to spurious warnings
+# eg <[EMAIL PROTECTED]>
+
+{
+ use warnings;
+ my $w = '';
+ local $SIG{__WARN__} = sub { $w = $_[0] };
+
+ sub AutoDest::Base::AUTOLOAD {}
+ @AutoDest::ISA = qw(AutoDest::Base);
+ { my $x = bless {}, 'AutoDest'; }
+ $w =~ s/\n//g;
+ test($w, '');
+}
+
print "# $cnt tests completed\n";
End of Patch.