From: Father Chrysostomos Date: Wed, 23 Nov 2011 20:47:50 +0000 (-0800) Subject: Use correct err msg in XS version check X-Git-Tag: accepted/trunk/20130322.191538~1982 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d31021d22e76a02635b33b5504e52db88adfc5f0;p=platform%2Fupstream%2Fperl.git Use correct err msg in XS version check When an XS module’s version is checked when it is loading, the string "version" should be treated the same way as "versions" and emit the ‘Invalid version format’ error, instead of being treated as a version object at first and then rejected by the validator with the ‘Invalid version object’ error. See also perl #102586. --- diff --git a/dist/XSLoader/t/XSLoader.t b/dist/XSLoader/t/XSLoader.t index 164e4e5..20ca32b 100644 --- a/dist/XSLoader/t/XSLoader.t +++ b/dist/XSLoader/t/XSLoader.t @@ -33,7 +33,7 @@ my %modules = ( 'Time::HiRes'=> q| ::can_ok( 'Time::HiRes' => 'usleep' ) |, # 5.7.3 ); -plan tests => keys(%modules) * 3 + 7; +plan tests => keys(%modules) * 3 + 8; # Try to load the module use_ok( 'XSLoader' ); @@ -89,3 +89,10 @@ for my $module (sort keys %modules) { } } +SKIP: { + skip "Needs 5.15.6", 1 unless $] > 5.0150051; + skip "List::Util not available", 1 if $extensions !~ /\bList::Util\b/; + eval 'package List::Util; XSLoader::load(__PACKAGE__, "version")'; + like $@, "/^Invalid version format/", + 'correct error msg for invalid versions'; +} diff --git a/util.c b/util.c index 4a170aa..052cb2c 100644 --- a/util.c +++ b/util.c @@ -6430,7 +6430,7 @@ Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p, } if (sv) { SV *xssv = Perl_newSVpvn_flags(aTHX_ xs_p, xs_len, SVs_TEMP); - SV *pmsv = sv_derived_from(sv, "version") + SV *pmsv = sv_derived_from(sv, "version") && SvROK(sv) ? sv : sv_2mortal(new_version(sv)); xssv = upg_version(xssv, 0); if ( vcmp(pmsv,xssv) ) {