Skip Menu |

This queue is for tickets about the Clone CPAN distribution.

Report information
The Basics
Id: 79730
Status: resolved
Priority: 0/
Queue: Clone

People
Owner: Nobody in particular
Requestors: colink [...] perlDreamer.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.31
Fixed in: (no value)



Subject: Scalar references touched by Data::Printer don't clone properly.
I'm not sure what Data::Printer does to the variables, but printing them causes scalar references to become something that Clone doesn't handle properly. At the risk of starting a finger pointing match, I'm going to cross post this to Data::Printer as well. I'd love to see Clone handle these kind of odd cases, but Data::Printer shouldn't be mucking about with my perl!
Subject: trial
Download trial
application/octet-stream 511b

Message body not shown because it is not plain text.

On Tue Sep 18 16:41:01 2012, colink@perlDreamer.com wrote: Show quoted text
> I'm not sure what Data::Printer does to the variables, but printing them > causes scalar references to become something that Clone doesn't handle > properly. > > At the risk of starting a finger pointing match, I'm going to cross post > this to Data::Printer as well. I'd love to see Clone handle these kind > of odd cases, but Data::Printer shouldn't be mucking about with my perl!
Hi there, I have absolutely no idea why this is happening but I confirm it. I'm not sure if this is a hint, but Data::Printer has been using Clone::PP since 0.30_03. In the code below: * switching from Clone to Clone::PP works; * using Clone but not calling p() works; * only calling p() after the call to clone() works. But after any call to p(), the call to clone() will give out the same reference. ---------------------- use strict; use warnings; use 5.010; use Clone qw(clone); use Data::Printer; my $a = { blue => '#0000ff', one => 1 }; say "before p: $a"; p $a; ### comment this line to make the world safe again say "after p, before clone: $a"; my $b = clone($a); say "after clone: $a"; say "cloned: $b"; if ($a == $b) { say "[---] bad stuff dude."; } else { say "[+++] The world works again"; } ------------------

Message body is not shown because it is too large.

Subject: references touched by (core) Hash::Util::FieldHash don't clone properly.

Message body is not shown because it is too large.

bug #67105 ("cloning of Moose object fails silently if the instance has been placed in a fieldhash") seems to be another symptom of this. Below is a simple way to reproduce the cloning problem using only Clone and Hash::Util::FieldHash: -----------8<----------- use strict; use warnings; use Hash::Util::FieldHash qw(fieldhash); use Clone qw(clone); my $var = {}; fieldhash my %hash; # this line is changing the # internal representation of $var exists $hash{ \$var }; my $cloned = clone($var); die "uh-oh" if $var == $cloned; ----------->8----------- Since Data::Printer (and Object::Id, and several other modules) uses fieldhashes to spot circular references, it might be best to change the ticket's subject so it is more accurate as to what's going on. I tried to, but it doesn't let me :( Anyway, hope this helps!
Florian Ragwitz worked on a patch for this, it's available in https://rt.cpan.org/Ticket/Display.html?id=80201 Cheers! On Sun Oct 07 01:44:16 2012, GARU wrote: Show quoted text
> bug #67105 ("cloning of Moose object fails silently if the instance has > been placed in a fieldhash") seems to be another symptom of this. > > Below is a simple way to reproduce the cloning problem using only Clone > and Hash::Util::FieldHash: > > -----------8<----------- > use strict; > use warnings; > > use Hash::Util::FieldHash qw(fieldhash); > use Clone qw(clone); > > my $var = {}; > > fieldhash my %hash; > > # this line is changing the > # internal representation of $var > exists $hash{ \$var }; > > my $cloned = clone($var); > > die "uh-oh" if $var == $cloned; > ----------->8----------- > > Since Data::Printer (and Object::Id, and several other modules) uses > fieldhashes to spot circular references, it might be best to change the > ticket's subject so it is more accurate as to what's going on. I tried > to, but it doesn't let me :( > > Anyway, hope this helps!
fixed in 0.32!