Change 31473 by [EMAIL PROTECTED] on 2007/06/26 16:12:27

        Second patch from:
        Subject: Re: [perl #43357] *DESTROY = sub {} at runtime
        From: "Brandon Black" <[EMAIL PROTECTED]>
        Date: Tue, 26 Jun 2007 11:05:31 -0500
        Message-ID: <[EMAIL PROTECTED]>
        
        Fix MRO behaviour when one undefs @ISA

Affected files ...

... //depot/perl/av.c#119 edit
... //depot/perl/t/mro/basic.t#5 edit

Differences ...

==== //depot/perl/av.c#119 (text) ====
Index: perl/av.c
--- perl/av.c#118~31123~        2007-05-03 02:30:08.000000000 -0700
+++ perl/av.c   2007-06-26 09:12:27.000000000 -0700
@@ -469,17 +469,20 @@
 
     /* Give any tie a chance to cleanup first */
     if (SvTIED_mg((SV*)av, PERL_MAGIC_tied)) 
-       av_fill(av, -1);   /* mg_clear() ? */
+       av_fill(av, -1);
 
     if (AvREAL(av)) {
        register I32 key = AvFILLp(av) + 1;
        while (key)
            SvREFCNT_dec(AvARRAY(av)[--key]);
     }
+
     Safefree(AvALLOC(av));
     AvALLOC(av) = NULL;
     AvARRAY(av) = NULL;
     AvMAX(av) = AvFILLp(av) = -1;
+
+    if(SvRMAGICAL(av)) mg_clear((SV*)av);
 }
 
 /*

==== //depot/perl/t/mro/basic.t#5 (text) ====
Index: perl/t/mro/basic.t
--- perl/t/mro/basic.t#4~31472~ 2007-06-26 09:10:11.000000000 -0700
+++ perl/t/mro/basic.t  2007-06-26 09:12:27.000000000 -0700
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-require q(./test.pl); plan(tests => 18);
+require q(./test.pl); plan(tests => 21);
 
 {
     package MRO_A;
@@ -125,3 +125,22 @@
     undef $obj;
     is($x, 2);
 }
+
+# clearing @ISA in different ways
+{
+    no warnings 'uninitialized';
+    {
+        package ISACLEAR;
+        our @ISA = qw/XX YY ZZ/;
+    }
+    # baseline
+    ok(eq_array(mro::get_linear_isa('ISACLEAR'),[qw/ISACLEAR XX YY ZZ/]));
+
+    # this looks dumb, but it preserves existing behavior for compatibility
+    #  (undefined @ISA elements treated as "main")
+    $ISACLEAR::ISA[1] = undef;
+    ok(eq_array(mro::get_linear_isa('ISACLEAR'),[qw/ISACLEAR XX main ZZ/]));
+
+    undef @ISACLEAR::ISA;
+    ok(eq_array(mro::get_linear_isa('ISACLEAR'),[qw/ISACLEAR/]));
+}
End of Patch.

Reply via email to