Skip Menu |

This queue is for tickets about the XML-Parser CPAN distribution.

Report information
The Basics
Id: 13204
Status: resolved
Priority: 0/
Queue: XML-Parser

People
Owner: Nobody in particular
Requestors: at [...] altlinux.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.34
Fixed in: (no value)



Subject: Parser/Style/Subs.pm ignores user exceptions
Hello, When using Style => "Subs", user exceptions are silently ignored in Start and End handlers, i.e. there's no way to catch runtime errors. I think this behavior is certainly not desired. The attached patch fixes the problem. -- Alexey Tourbin ALT Linux Team
--- XML-Parser-2.34/Parser/Style/Subs.pm- 2003-07-27 16:07:49 +0000 +++ XML-Parser-2.34/Parser/Style/Subs.pm 2005-06-11 08:54:03 +0000 @@ -7,7 +7,7 @@ sub Start { my $expat = shift; my $tag = shift; my $sub = $expat->{Pkg} . "::$tag"; - eval { &$sub($expat, $tag, @_) }; + &$sub($expat, $tag, @_) if defined &$sub; } sub End { @@ -15,7 +15,7 @@ sub End { my $expat = shift; my $tag = shift; my $sub = $expat->{Pkg} . "::${tag}_"; - eval { &$sub($expat, $tag) }; + &$sub($expat, $tag) if defined &$sub; } 1; --- XML-Parser-2.34/t/styles.t- 2003-08-18 20:52:32 +0000 +++ XML-Parser-2.34/t/styles.t 2005-06-11 09:13:19 +0000 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 13 } +BEGIN { plan tests => 14 } use XML::Parser; use IO::File; @@ -43,8 +43,11 @@ my $xmlstr = '<foo>bar</foo>'; { # Subs style - my $parser = XML::Parser->new(Style => 'Subs'); + sub MySubs::foo_ { die "unexpected\n"; } + my $parser = XML::Parser->new(Style => 'Subs', Pkg => 'MySubs'); ok($parser); + eval { $parser->parse($xmlstr); }; + ok($@ eq "unexpected\n"); } {
Ticket migrated to github as https://github.com/toddr/XML-Parser/issues/32