Skip Menu |

This queue is for tickets about the Parse-CPAN-Distributions CPAN distribution.

Report information
The Basics
Id: 100237
Status: open
Priority: 0/
Queue: Parse-CPAN-Distributions

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

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



Subject: Distrubutions with underscore versions causes warnings "argument isn't numeric in numeric comparison"
$ perl -Ilib -MParse::CPAN::Distributions -e 'my $d=Parse::CPAN::Distributions->new(file=>q{/tmp/find-ls.gz}); print $d->latest_version(q{MooseX-Workers})' Argument "0.15_0100" isn't numeric in numeric comparison (<=>) at lib/Parse/CPAN/Distributions.pm line 160. Argument "0.14_0100" isn't numeric in numeric comparison (<=>) at lib/Parse/CPAN/Distributions.pm line 160. 0.23 Line 160 is is the first map() in this code: my @versions = map {$_->{external}} sort {$b->{internal} <=> $a->{internal}} map {my $v; eval {$v = version->new($_)}; {internal => $@ ? $_ : $v->numify, external => $_}} keys %{$distros{$distribution}}; I have `version' module 0.9907.
From: ppisar [...] redhat.com
Dne Po 10.lis.2014 08:30:27, ppisar napsal(a): Show quoted text
> $ perl -Ilib -MParse::CPAN::Distributions -e 'my > $d=Parse::CPAN::Distributions->new(file=>q{/tmp/find-ls.gz}); print > $d->latest_version(q{MooseX-Workers})' > Argument "0.15_0100" isn't numeric in numeric comparison (<=>) at > lib/Parse/CPAN/Distributions.pm line 160. > Argument "0.14_0100" isn't numeric in numeric comparison (<=>) at > lib/Parse/CPAN/Distributions.pm line 160. > 0.23 > > Line 160 is is the first map() in this code: > > my @versions = > map {$_->{external}} > sort {$b->{internal} <=> $a->{internal}} > map {my $v; eval {$v = version->new($_)}; {internal => $@ ? $_ : > $v->numify, external => $_}} keys %{$distros{$distribution}}; > > I have `version' module 0.9907.
One solution is to remove the numify() call. version objects overload the comparison operator. Or should numify() remove the underscore part?
Show quoted text
> One solution is to remove the numify() call. version objects overload > the comparison operator. Or should numify() remove the underscore > part?
numify() is evil and does totally different things than the name implies. It is best avoided.
From: ppisar [...] redhat.com
Dne Po 10.lis.2014 08:30:27, ppisar napsal(a): Show quoted text
> $ perl -Ilib -MParse::CPAN::Distributions -e 'my > $d=Parse::CPAN::Distributions->new(file=>q{/tmp/find-ls.gz}); print > $d->latest_version(q{MooseX-Workers})' > Argument "0.15_0100" isn't numeric in numeric comparison (<=>) at > lib/Parse/CPAN/Distributions.pm line 160. > Argument "0.14_0100" isn't numeric in numeric comparison (<=>) at > lib/Parse/CPAN/Distributions.pm line 160. > 0.23 > > Line 160 is is the first map() in this code: > > my @versions = > map {$_->{external}} > sort {$b->{internal} <=> $a->{internal}} > map {my $v; eval {$v = version->new($_)}; {internal => $@ ? $_ : > $v->numify, external => $_}} keys %{$distros{$distribution}}; >
The reason for calling numify() is that the sort() does not get in touch with a version object. If I remove the numify() call, then if the <=> operator gets a version object and non-parsable string, then it dies. (The overloaded operator attempts to parse the string by version module.) If I "fix" the sort() by checking for both operands being a version object and fall back to non-version comparison for other cases, then the sort() will use two incompatible sorting functions which will lead to non-deterministic output. However, because current implementation already drops the underscore suffixes or mixes strings and numbers when comparing, the output is non-deterministic too. Therefore I think the best approach is to skip version module incompatible strings completely. The same problem is with Parse::CPAN::Distributions::versions(). It tries to sort the versions even if this is not documented. I'd rather simplify the versions() and stop sorting the output of this function.