From: Slaven Rezic Date: Mon, 18 Nov 2002 10:41:36 +0000 (+0100) Subject: Re: Storable bug #1698 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87baa35a563d45b9921650f6d6957f8ce4f33b49;p=p5sagit%2Fp5-mst-13.2.git Re: Storable bug #1698 Message-ID: <87ptt343lb.fsf@vran.herceg.de> p4raw-id: //depot/perl@18178 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index efa441a..9c307a7 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -4125,7 +4125,14 @@ static SV *retrieve_ref(stcxt_t *cxt, char *cname) * an SX_OBJECT indication, a ref count increment was done. */ - sv_upgrade(rv, SVt_RV); + if (cname) { + /* Do not use sv_upgrade to preserve STASH */ + SvFLAGS(rv) &= ~SVTYPEMASK; + SvFLAGS(rv) |= SVt_RV; + } else { + sv_upgrade(rv, SVt_RV); + } + SvRV(rv) = sv; /* $rv = \$sv */ SvROK_on(rv); diff --git a/ext/Storable/t/blessed.t b/ext/Storable/t/blessed.t index 6a0a32d..af8dd49 100644 --- a/ext/Storable/t/blessed.t +++ b/ext/Storable/t/blessed.t @@ -25,7 +25,7 @@ sub ok; use Storable qw(freeze thaw); -print "1..10\n"; +print "1..12\n"; package SHORT_NAME; @@ -98,3 +98,11 @@ for (my $i = 0; $i < 10; $i++) { do { $good = 0; last } unless ref $y->[4*$i+3] eq "${name}_WITH_HOOK"; } ok 10, $good; + +{ + my $blessed_ref = bless \\[1,2,3], 'Foobar'; + my $x = freeze $blessed_ref; + my $y = thaw $x; + ok 11, ref $y eq 'Foobar'; + ok 12, $$$y->[0] == 1; +} diff --git a/ext/Storable/t/forgive.t b/ext/Storable/t/forgive.t index 109ba83..1c07a57 100644 --- a/ext/Storable/t/forgive.t +++ b/ext/Storable/t/forgive.t @@ -26,7 +26,7 @@ sub BEGIN { use Storable qw(store retrieve); # problems with 5.00404 when in an BEGIN block, so this is defined here -if (eval { require File::Spec; 1 } || $File::Spec::VERSION < 0.8) { +if (!eval { require File::Spec; 1 } || $File::Spec::VERSION < 0.8) { print "1..0 # Skip: File::Spec 0.8 needed\n"; exit 0; # Mention $File::Spec::VERSION again, as 5.00503's harness seems to have