Make Data::Dumper XS ignore Freezer return value
authorAaron Crane <arc@cpan.org>
Sun, 13 Jan 2013 10:08:02 +0000 (10:08 +0000)
committerAaron Crane <arc@cpan.org>
Sun, 13 Jan 2013 22:07:06 +0000 (22:07 +0000)
Fixes RT #116364

dist/Data-Dumper/Dumper.pm
dist/Data-Dumper/Dumper.xs
dist/Data-Dumper/t/freezer.t

index 4fefb72..8c8ae7e 100644 (file)
@@ -10,7 +10,7 @@
 package Data::Dumper;
 
 BEGIN {
-    $VERSION = '2.140'; # Don't forget to set version and release
+    $VERSION = '2.141'; # Don't forget to set version and release
 }                         # date in POD below!
 
 #$| = 1;
@@ -1359,7 +1359,7 @@ modify it under the same terms as Perl itself.
 
 =head1 VERSION
 
-Version 2.140  (December 30 2012)
+Version 2.141  (January 13 2013)
 
 =head1 SEE ALSO
 
index d7204e1..d0f7145 100644 (file)
@@ -344,7 +344,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
        {
            dSP; ENTER; SAVETMPS; PUSHMARK(sp);
            XPUSHs(val); PUTBACK;
-           i = perl_call_method(SvPVX_const(freezer), G_EVAL|G_VOID);
+           i = perl_call_method(SvPVX_const(freezer), G_EVAL|G_VOID|G_DISCARD);
            SPAGAIN;
            if (SvTRUE(ERRSV))
                warn("WARNING(Freezer method call failed): %"SVf"", ERRSV);
index c46d861..a67cc12 100644 (file)
@@ -25,6 +25,11 @@ ok($dumped_foo,
 like($dumped_foo, qr/frozed/, 
      "Dumped string has the key added by Freezer.");
 
+# test that list-context freeze return doesn't contain the freezer's return
+# value; RT #116364
+like(join(" ", Dumper($foo)), qr/\A\$VAR1 = /,
+     "Dumped list doesn't begin with Freezer's return value");
+
 # run the same tests with useperl.  this always worked
 {
     local $Data::Dumper::Useperl = 1;
@@ -34,6 +39,8 @@ like($dumped_foo, qr/frozed/,
        "Use of freezer sub which returns non-ref worked with useperl");
     like($dumped_foo, qr/frozed/, 
          "Dumped string has the key added by Freezer with useperl.");
+    like(join(" ", Dumper($foo)), qr/\A\$VAR1 = /,
+         "Dumped list doesn't begin with Freezer's return value with useperl");
 }
 
 # test for warning when an object doesn't have a freeze()