Skip Menu |
 

This queue is for tickets about the Hash-Merge CPAN distribution.

Report information
The Basics
Id: 55978
Status: open
Priority: 0/
Queue: Hash-Merge

People
Owner: Nobody in particular
Requestors: sunnavy [...] gmail.com
Cc:
AdminCc:

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



Subject: to avoid the eval in _get_obj
Download (untitled) / with headers
text/plain 572b
Hi guys We've encountered a warning like "Can't call method "isa" on unblessed reference" at Hash/Merge.pm line 100 as I dug, the problem is we call _merge_hashes( $_[0], $_[1] ) when specify_behavior. well surely, since $_[0] is hashref, the warning pops out. _get_obj calls $_[0]->isa when ref $_[0] is not empty, though it's safe to call in an eval block, maybe we can get rid of eval by more testing before calling $_[0]->isa? I suggest use blessed in Scalar::Util or just skip the SCALAR|ARRAY|HASH. the patch for the latter one is attached. best wishes sunnavy
Subject: Merge.pm.diff
Download Merge.pm.diff
text/x-diff 510b
--- Merge.pm 2010-02-15 23:50:11.000000000 +0800 +++ Merge.pm.new 2010-03-27 00:36:02.000000000 +0800 @@ -96,8 +96,13 @@ $GLOBAL->{'clone'} = 1; sub _get_obj { - if ( my $type = ref $_[0] ) { - return shift() if $type eq __PACKAGE__ || eval { $_[0]->isa(__PACKAGE__) }; + my $type = ref $_[0]; + + if ( $type + && $type !~ /^(?:SCALAR|ARRAY|HASH)$/ + && ( $type eq __PACKAGE__ || $_[0]->isa(__PACKAGE__) ) ) + { + return shift(); } return $context;
From: heikki.j.laaksonen [...] kolumbus.fi
Download (untitled) / with headers
text/plain 790b
On Fri Mar 26 13:00:11 2010, SUNNAVY wrote: Show quoted text
> Hi guys > > We've encountered a warning like "Can't call method "isa" on unblessed > reference" at > Hash/Merge.pm line 100
Same problem. This prevents using Hash::Merge. For some reason it seems that the eval block dies on this line. If I run a simple example, this works. But when this is a part of bigger script, the problem appears and it must be my script. Unfortunately I cannot identify the root problem. Also, should the OR be AND on that line? I could also guess that the eval part is unnecessary? But at least using AND instead of OR prevents calling the eval block and seems to work for me. sub _get_obj { if ( my $type = ref $_[0] ) { return shift() if $type eq __PACKAGE__ || eval { $_[0]->isa(__PACKAGE__) }; }
From: hessu75
Download (untitled) / with headers
text/plain 790b
On Fri Mar 26 13:00:11 2010, SUNNAVY wrote: Show quoted text
> Hi guys > > We've encountered a warning like "Can't call method "isa" on unblessed > reference" at > Hash/Merge.pm line 100
Same problem. This prevents using Hash::Merge. For some reason it seems that the eval block dies on this line. If I run a simple example, this works. But when this is a part of bigger script, the problem appears and it must be my script. Unfortunately I cannot identify the root problem. Also, should the OR be AND on that line? I could also guess that the eval part is unnecessary? But at least using AND instead of OR prevents calling the eval block and seems to work for me. sub _get_obj { if ( my $type = ref $_[0] ) { return shift() if $type eq __PACKAGE__ || eval { $_[0]->isa(__PACKAGE__) }; }
Download (untitled) / with headers
text/plain 651b
Hi, This also causes issues with a __DIE__ handler as the eval generates errors, it ends up in the handler. The code should use Scalar::Util::blessed to test whether it's an object or not: diff Merge.pm.original Merge.pm 5a6 Show quoted text
> use Scalar::Util qw(blessed);
100c101 < return shift() if $type eq __PACKAGE__ || eval { $_[0]->isa(__PACKAGE__) }; --- Show quoted text
> return shift() if $type eq __PACKAGE__ || ( blessed $_[0] && $_[0]->isa(__PACKAGE__) );
otherwise please localise $@ and $SIG{__DIE__} to prevent the error to leak outside. Note that Scalar::Util is standard after perl 5.8 and it can be installed on the archaic 5.6. Thanks, Burak


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.