Subject: | XML::Simple breaks when the perl profiler is used |
If 'perl -d:DProf' is used on a script using XML::Simple, calls to
$xs->XMLin() will fail with 'Options must be name=>value pairs (odd
number supplied)'. This is because Devel::DProf injects code at the
start/end of subroutine calls, and it breaks the aliasing of @_ that
calling &_get_object depends upon.
However, a simply fixing _get_object() to explicitly be passed a ref to
the arg list (so it can still shift it) fixes the problem.
With this change, every call it must be changed to read:
my $self = _get_object(\@_);
(there are 2 such calls in 2.16 and 5 in 2.18)
--- XML-Simple/lib/XML/Simple.pm.orig 2006-10-30 03:28:13.000000000 -0500
+++ XML-Simple/lib/XML/Simple.pm 2007-11-29 11:02:34.000000000 -0500
@@ -137,9 +137,10 @@
#
sub _get_object {
- my $self;
- if($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) {
- $self = shift;
+ my $self = shift;
+
+ if($self->[0] and UNIVERSAL::isa($self->[0], 'XML::Simple')) {
+ $self = shift @$self;
}
else {
$self = XML::Simple->new();
@@ -160,7 +161,7 @@
#
sub XMLin {
- my $self = &_get_object; # note, @_ is passed implicitly
+ my $self = _get_object(\@_);
my $string = shift;
Subject: | XML-Simple.patch |
--- XML-Simple/lib/XML/Simple.pm.orig 2006-10-30 03:28:13.000000000 -0500
+++ XML-Simple/lib/XML/Simple.pm 2007-11-29 11:02:34.000000000 -0500
@@ -137,9 +137,10 @@
#
sub _get_object {
- my $self;
- if($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) {
- $self = shift;
+ my $self = shift;
+
+ if($self->[0] and UNIVERSAL::isa($self->[0], 'XML::Simple')) {
+ $self = shift @$self;
}
else {
$self = XML::Simple->new();
@@ -160,7 +161,7 @@
#
sub XMLin {
- my $self = &_get_object; # note, @_ is passed implicitly
+ my $self = _get_object(\@_);
my $string = shift;