Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the XML-LibXML-SAX-ChunkParser CPAN distribution.

Report information
The Basics
Id: 94173
Status: resolved
Priority: 0/
Queue: XML-LibXML-SAX-ChunkParser

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

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



Subject: finish() explodes with "no document found!"

calling ->finish()  seems broken due to the "undef" handler set at the end of parse_chunk

 

As in attached example.fail.t , a "No document found!" exception is thrown, and the "end_document" handler never triggers.

You'll see that in the modified test example.t, which hacks around the problem by directly forcing the handler to be set, no exception is thrown, and the end_document handler triggers as expected.
 

Subject: example.fail.t
Download example.fail.t
text/x-perl 491b
use strict; use warnings; use Test::More; use Test::Fatal; use XML::LibXML::SAX::ChunkParser; my $parser = XML::LibXML::SAX::ChunkParser->new(); my $saw_end; my $saw_start; $parser->{Methods}->{start_document} = sub { $saw_start = 1; }; $parser->{Methods}->{end_document} = sub { $saw_end = 1; }; $parser->parse_chunk('<xml></xml>'); is( exception { $parser->finish }, undef, 'Finish does not bail' ); ok( $saw_start, "Saw start" ); ok( $saw_end, "Saw end" ); done_testing;
Subject: example.t
Download example.t
text/x-perl 552b
use strict; use warnings; use Test::More; use Test::Fatal; use XML::LibXML::SAX::ChunkParser; my $parser = XML::LibXML::SAX::ChunkParser->new(); my $saw_end; my $saw_start; $parser->{Methods}->{start_document} = sub { $saw_start = 1; }; $parser->{Methods}->{end_document} = sub { $saw_end = 1; }; $parser->parse_chunk('<xml></xml>'); $parser->{ParserOptions}->{LibParser}->set_handler($parser); is( exception { $parser->finish }, undef, 'Finish does not bail'); ok( $saw_start, "Saw start"); ok( $saw_end, "Saw end"); done_testing;
Download (untitled) / with headers
text/plain 152b
https://github.com/lestrrat/XML-LibXML-SAX-ChunkParser Care to check if the latest change work for you? I just punted the freeing until DESTROY() time.
Download (untitled) / with headers
text/plain 147b
Ah wait, it has a circular reference, so DESTROY won't be called. Grr. I hate myself. I guess I should just move it to finish(), instead of DESTROY
Changed it again. Please check the latest master, and see if it works for you.

On 2014-03-25 23:58:49, DMAKI wrote:
> Changed it again. Please check the latest master, and see if it works
> for you.

Works for me.

Though I'd probably have used weaken() here. Not sure if that would be better or not =).

Download (untitled) / with headers
text/plain 131b
Yeah, I thought about it too, but I was a bit lazy to add a dep. Maybe if the current impl becomes problematic, I'll go that route.
Download (untitled) / with headers
text/plain 131b
Yeah, I thought about it too, but I was a bit lazy to add a dep. Maybe if the current impl becomes problematic, I'll go that route.
Released 0.00007.


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.