Skip Menu |

This queue is for tickets about the CPAN-Site CPAN distribution.

Report information
The Basics
Id: 68716
Status: resolved
Priority: 0/
Queue: CPAN-Site

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

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: workaround for errors when parsing package versions
sometimes one may need not to die when failed create version object from parsed lines of package code, here is my workaround --- Index.pm 2011-06-09 12:39:17.848930777 +0400 +++ /usr/lib64/perl5/site_perl/5.8.8/CPAN/Site/Index.pm 2011-06-04 02:16:44.000000000 +0400 @@ -229,16 +229,12 @@ $_ .= shift @lines while m/package|use|VERSION/ && !m/\;/; - my $line = $_; + if( m/^\s* package \s* ((?:\w+\:\:)*\w+) (?:\s+ (\S*))? \s* ;/ x ) { # second package in file? my $thispkg = $1; - my $thisversion = $2 ? eval{qv($2)} : undef; # HAKKK - my $err = $@; - if ($err){ - alert __x"error when creating version object from parsed chunk *** {line} *** : pkg: {pkg} vers: {vers} err: {err}" - , pkg => $thispkg, vers => $thisversion, line => $line, err => $err; - } + my $thisversion = $2 ? qv($2) : undef; + register $package, $VERSION, $dist if defined $package;
Subject: Re: [rt.cpan.org #68716] workaround for errors when parsing package versions
Date: Thu, 9 Jun 2011 11:30:10 +0200
To: Alexey Melezhik via RT <bug-CPAN-Site [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Alexey Melezhik via RT (bug-CPAN-Site@rt.cpan.org) [110609 09:02]: Show quoted text
> Thu Jun 09 05:02:43 2011: Request 68716 was acted upon. > Transaction: Ticket created by MELEZHIK > Queue: CPAN-Site > Subject: workaround for errors when parsing package versions > > sometimes one may need not to die when failed create version object > from parsed lines of package code, here is my workaround
For modules which come from CPAN, I would not expect problems (my algorithm is that of Pause). But of course, it's better to handle the situation in case... Can you live with this: $_ .= shift @lines while m/package|use|VERSION/ && !m/\;/; if( m/^\s* package \s* ((?:\w+\:\:)*\w+) (?:\s+ (\S*))? \s* ;/x ) { my ($thispkg, $v) = ($1, $2); my $thisversion; if($v) { $thisversion = eval {qv($v)}; alert __x"illegal version for {pkg}, found '{version}': {err}" , pkg => $thispkg, version => $v, err => $@ if $@; } # second package in file? Actually, it even triggers an error in the regression tests! But what I get puzzles me: when I run t/10index.t myself, i get no errors. However, when run with "make test", I get this t/10index.t .. 1/60 Invalid version format (dotted-decimal versions require at least three parts) at /usr/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/version.pm line 184. # Looks like you planned 60 tests but ran 1. # Looks like your test exited with 255 just after 1. t/10index.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 59/60 subtests ... to make it even worse: before I did a "make clean;perl Makefile.PL", it only complained about the second test script! (Running perl 5.12.3) Any ideas? -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Чтв Июн 09 05:30:24 2011, Mark@Overmeer.net писал: Show quoted text
> * Alexey Melezhik via RT (bug-CPAN-Site@rt.cpan.org) [110609 09:02]:
> > Thu Jun 09 05:02:43 2011: Request 68716 was acted upon. > > Transaction: Ticket created by MELEZHIK > > Queue: CPAN-Site > > Subject: workaround for errors when parsing package versions > > > > sometimes one may need not to die when failed create version object > > from parsed lines of package code, here is my workaround
> > For modules which come from CPAN, I would not expect problems > (my algorithm is that of Pause). But of course, it's better to > handle the situation in case... >
Show quoted text
> Can you live with this: > > $_ .= shift @lines > while m/package|use|VERSION/ && !m/\;/; > > if( m/^\s* package \s* ((?:\w+\:\:)*\w+) (?:\s+ (\S*))? \s* ;/x ) > { my ($thispkg, $v) = ($1, $2); > my $thisversion; > if($v) > { $thisversion = eval {qv($v)}; > alert __x"illegal version for {pkg}, found '{version}': > {err}" > , pkg => $thispkg, version => $v, err => $@ if $@; > } > > # second package in file? >
yes, this workaround is ok, at least some packages can contain not valid versions or even don not have them, it might be more flexible not to die in this case but just show warning. Show quoted text
> Actually, it even triggers an error in the regression tests! But > what I get puzzles me: when I run t/10index.t myself, i get no > errors. However, when run with "make test", I get this > > t/10index.t .. 1/60 Invalid version format (dotted-decimal versions > require at least three parts) at > /usr/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/version.pm > line 184. > # Looks like you planned 60 tests but ran 1. > # Looks like your test exited with 255 just after 1. > t/10index.t .. Dubious, test returned 255 (wstat 65280, 0xff00) > Failed 59/60 subtests > > ... to make it even worse: before I did a "make clean;perl > Makefile.PL", > it only complained about the second test script! (Running perl > 5.12.3) > Any ideas?
on my environment test goes ok: cpan[2]> look CPAN::Site cpan CPAN-Site-1.07-QqTnsp # perl Makefile.PL Writing Makefile for CPAN::Site cpan CPAN-Site-1.07-QqTnsp # make Skip blib/lib/CPAN/Site.pm (unchanged) Skip blib/lib/CPAN/Site/Index.pm (unchanged) cp bin/cpansite blib/script/cpansite /usr/bin/perl5.8.8 -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/ cpansite Manifying blib/man1/cpansite.1 cpan CPAN-Site-1.07-QqTnsp # make test PERL_DL_NONLAZY=1 /usr/bin/perl5.8.8 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/10index....ok t/20qv.......ok t/99pod......ok All tests successful. Files=3, Tests=72, 0 wallclock secs ( 0.22 cusr + 0.04 csys = 0.26 CPU) cpan CPAN-Site-1.07-QqTnsp # --- cpan[3]> m CPAN::Site Module id = CPAN::Site CPAN_USERID MARKOV (Mark Overmeer <mark@overmeer.net>) CPAN_VERSION 1.07 CPAN_FILE M/MA/MARKOV/CPAN-Site-1.07.tar.gz UPLOAD_DATE 2011-06-03 INST_FILE /usr/lib64/perl5/site_perl/5.8.8/CPAN/Site.pm INST_VERSION 1.07 --- but as you can see I have another perl than yours melezhik # perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi ---
Subject: Re: [rt.cpan.org #68716] workaround for errors when parsing package versions
Date: Mon, 20 Jun 2011 16:48:16 +0200
To: Alexey Melezhik via RT <bug-CPAN-Site [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Alexey Melezhik via RT (bug-CPAN-Site@rt.cpan.org) [110620 08:03]: Show quoted text
> yes, this workaround is ok, at least some packages can contain not > valid versions or even don not have them, it might be more flexible not > to die in this case but just show warning.
Released. Show quoted text
> on my environment test goes ok: > but as you can see I have another perl than yours
Arhhh, found it: I had an unpacked version of an older release in the same source tree. That confuses "make". Just released it as Cpan-Site-1.08 -- Thanks for the constribution, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Show quoted text
> > Released. >
Great!
Got released in 1.08, but fix was incorrect