LibreCat / Catmandu-MODS

Catmandu Importer for importing MODS records, with use of the CPAN module MODS::Record
Other
1 stars 0 forks source link

t/02_from_json.t test fails #6

Closed eserte closed 8 years ago

eserte commented 8 years ago

Test output looks like this:

malformed UTF-8 character in JSON string, at character offset 946 (before "\x{fffd}            ...") at /usr/perl5.16.3t/lib/site_perl/5.16.3/MODS/Record.pm line 2364, <GEN1> chunk 1.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 6.
t/02_from_json.t ........ 
Dubious, test returned 255 (wstat 65280, 0xff00)
All 6 subtests passed 

Statistical analysis shows that the problem might be triggered by MODS::Record 0.11 (0.09 was OK). It could also be (less likeley) caused by Catmandu 0.9403 and later.

nicolasfranck commented 8 years ago

Thanks for pointing this out.

Apparently MODS::Record changed its behaviour. In the past it parsed JSON with this:

JSON->new->utf8(0)->parse($source);

But that could not handle binary strings/filehandles, and you had to set the binmode of your filehandle yourself, as I did.

Starting from version 0.11, this behaviour was fixed:

JSON->new->utf8(1)->parse($source);

So it started decoding an already decoded string.

I update the code to support both versions of MODS::Record

eserte commented 8 years ago

Looks good so far (except on Windows, but this is probably a different issue): http://matrix.cpantesters.org/?dist=Catmandu-MODS+0.31