You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
I believe I've found a bug in XML::Parser. A test is included below.
The problem is that XML::Parser is over-aggressve in trapping parse errors, and as a result the xpcroak() method in XML::Parser::Expat can not be used to raise a parse error.
This is frustrating since I would like to abort processing in large documents when certain conditions occur, and I would also like to know what happened. According to the documentation, xpcroak() should be the proper way to do that.
Versions in use:
XML::Parser: 2.36
XML::Parser::Expat: 2.36
Perl: v5.10.0
OS: OS X 10.6.2 (Mac Snow Leopard)
cheers
-- Kevin Frost
# It appears that XML::Parser 2.36 is not correctly handling
# XML::Parser::expat's xpcroak() method.
#
# The POD says, under parse: "A die call is thrown if a parse error occurs."
use strict;
use warnings;
use Test::More tests => 5;
BEGIN {
use_ok('XML::Parser');
cmp_ok( $XML::Parser::VERSION, '>=', 2.36, "version at least 2.36" );
}
test_bug();
sub test_bug {
# We do a simple parse:
my $xml = '<foo id="me">Hello World</foo>';
my $parser = XML::Parser->new( Style => 'Subs', Pkg => 'ParseBugDemo' );
my $res = $parser->parse($xml);
# We make sure our parse class behaved constently:
ok( $ParseBugDemo::I_DONE_CROAKED, "parsing should have croaked" );
ok( !$ParseBugDemo::CROAK_NOT_DEADLY, "croak aborted subroutine" );
# And here we see the bug, in that the following fails:
ok( !$res, "result of an xpcroaked parse is NOT true" );
}
# Here is our parser class for the "Subs" parsing style.
package ParseBugDemo;
our $I_DONE_CROAKED = 0;
our $CROAK_NOT_DEADLY = 0;
sub foo {
my $expat = shift;
$I_DONE_CROAKED = 1;
$expat->xpcroak("I croaketh.");
$CROAK_NOT_DEADLY = 1;
}
1;
The text was updated successfully, but these errors were encountered:
Migrated from rt.cpan.org#54225 (status was 'new')
Requestors:
From [email protected] on 2010-02-02 17:45:55
:
The text was updated successfully, but these errors were encountered: