Skip Menu |

This queue is for tickets about the Sub-WrapPackages CPAN distribution.

Report information
The Basics
Id: 54409
Status: resolved
Priority: 0/
Queue: Sub-WrapPackages

People
Owner: Nobody in particular
Requestors: lee.johnson [...] netbanx.com
Cc:
AdminCc:

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



Subject: use constant breaks import, perl 5.10.1
Date: Mon, 8 Feb 2010 16:00:22 +0000
To: bug-Sub-WrapPackages [...] rt.cpan.org
From: Lee Johnson <lee.johnson [...] netbanx.com>
The module wraps any use of 'use constant' from calling packages as this is imported as a subroutine into the callers namespace by constant. This breaks in perl 5.10.1 as the optimiser changes the code ref to a scalar ref: Compare 5.8.8 (--> is debug): -->currencyconfig,*core_code::currencyconfig at /usr/lib/perl5/site_perl/5.8.8/Sub/WrapPackages.pm line 137. To 5.10.1: -->currencyconfig,SCALAR(0x956d218) at /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm line 137. Not a subroutine reference at /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm line 139. BEGIN failed--compilation aborted at Patch is as follows: Index: /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm =================================================================== --- /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm (revision 716) +++ /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm (working copy) @@ -134,7 +134,7 @@ foreach my $package (@targets) { no strict; while(my($k, $v) = each(%{$package})) { - push @subs, $package.$k if(defined(&{$v})); + push @subs, $package.$k if(ref($v) eq 'CODE' && defined(&{$v})); } } return @subs;
On Mon Feb 08 11:02:10 2010, lee.johnson@netbanx.com wrote: Show quoted text
> The module wraps any use of 'use constant' from calling packages as this > is imported as a subroutine into the callers namespace by constant. This > breaks in perl 5.10.1 as the optimiser changes the code ref to a scalar > ref ...
Thanks for the report and patch, I'll apply it soon and release a new version. Do you have a small test case that demonstrates the bug?
Subject: Re: [rt.cpan.org #54409] use constant breaks import, perl 5.10.1
Date: Tue, 9 Feb 2010 17:03:24 +0000
To: "bug-Sub-WrapPackages [...] rt.cpan.org" <bug-Sub-WrapPackages [...] rt.cpan.org>
From: Lee Johnson <lee.johnson [...] netbanx.com>
Test case attached. Pre patch: :!perl -Ilib 06_use_constant.t 1..1 1..1 Not a subroutine reference at /export/home/netbanx/base/usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm line 138. BEGIN failed--compilation aborted at 06_use_constant.t line 29. Post patch: :!perl -Ilib 06_use_constant.t 1..1 ok 1 use constant does not wrap Ta, Lee. On Tue, 2010-02-09 at 16:35 +0000, David Cantrell via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=54409 > > > On Mon Feb 08 11:02:10 2010, lee.johnson@netbanx.com wrote: >
> > The module wraps any use of 'use constant' from calling packages as this > > is imported as a subroutine into the callers namespace by constant. This > > breaks in perl 5.10.1 as the optimiser changes the code ref to a scalar > > ref ...
> > Thanks for the report and patch, I'll apply it soon and release a new > version. Do you have a small test case that demonstrates the bug? >

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Thanks, fixed in 1.31
Incidentally, version 2 is in the works, the big difference being that caller() works properly. There's also other exciting new craziness, to cope with 'use lib' buggering about with @INC. It *mostly* works, so if you want to have a play with it, it's in my git repo. Oh, and 5.10.0 was affected too :-)