Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the YAML CPAN distribution.

Report information
The Basics
Id: 4910
Status: resolved
Priority: 0/
Queue: YAML

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.35
Fixed in: (no value)



Subject: YAML cannot dump objects that overload ""
When a class overloads "" (stringification), YAML::Dump dumps objects of the class as strings, hence with no internal structure.
[JV - Sun Jan 11 13:25:16 2004]: Show quoted text
> When a class overloads "" (stringification), YAML::Dump dumps objects > of the class as strings, hence with no internal structure.
I ran into this problem recently as well, turns out that YAML::Node::info() uses the stringified ref to determine the class, type and unique ID for a reference. This obviously breaks if the object has overloaded '"'. The attached patch works for me, though with the author in the middle a rewrite I don't know if it is that useful to him.
--- Node.pm~ Thu Jan 29 19:59:42 2004 +++ Node.pm Thu Jan 29 19:58:35 2004 @@ -7,6 +7,7 @@ use strict; use YAML::Family; use Carp; +use overload; sub ynode { my $self; @@ -23,7 +24,7 @@ } sub info { - ($_[0] =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o); + (overload::StrVal($_[0]) =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o); } sub new {
[CREIN - Tue Feb 3 00:17:03 2004]: overload::StrVal seems to be broken in various situations, this is a much more robust solution.
--- Node.pm~ Mon Jun 24 19:07:21 2002 +++ Node.pm Mon Jun 7 19:28:54 2004 @@ -7,6 +7,7 @@ use strict; use YAML::Family; use Carp; +use Scalar::Util (); sub ynode { my $self; @@ -23,7 +24,11 @@ } sub info { - ($_[0] =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o); + return ( + Scalar::Util::blessed($_[0]), + Scalar::Util::reftype($_[0]), + Scalar::Util::refaddr($_[0]), + ); } sub new {