Skip Menu |

This queue is for tickets about the base CPAN distribution.

Report information
The Basics
Id: 60960
Status: resolved
Priority: 0/
Queue: base

People
Owner: Nobody in particular
Requestors: JJSCHUTZ [...] cpan.org
Cc: pause [...] tlinx.org
AdminCc:

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



Subject: base fails with multiple packages in same file
See test program below. This fails with: Can't locate object method "new" via package "SecondClass" at ./base-test.pl line 27 Uncomment 'use LWP::UserAgent' from FirstClass, and the error goes away. In short, there seems to be a condition under which base.pm detects the package has having already been loaded, when in fact it has not. Tracing through, with 'use LWP::UserAgent' (or 'use base qw/LWP::UserAgent/') in FirstClass, has_version() in base.pm finds that $vglob has a value, even though HTML::Parser is not in %INC, and thus 'eval "require $base"' is never called, leading to the error. LWP::UserAgent doesn't use HTML::Parser directly, though it does 'require HTML::HeadParser' which in turn does 'use base HTML::Parser'. I have not been able to track down exactly how VERSION has come to be set without the file being included in %INC. #! /usr/bin/perl use strict; use warnings; SecondClass->new(); package FirstClass; use strict; use warnings; use LWP::UserAgent; sub new { # ... whatever } package SecondClass; use strict; use warnings; use base qw/HTML::Parser/; sub new { my $class = shift; return $class->SUPER::new(); }
Subject: base fails with some combinations of packages
As an addendum, have discovered that the same happens even if SecondClass is moved into a separate file. Thus the problem appears to be caused by the combination of LWP::UserAgent and HTML::Parser. LWP::UserAgent version 5.836 HTML::Parser version 3.66
On Wed Sep 01 21:33:05 2010, JJSCHUTZ wrote: ------------- I can't reproduce this with v2.18 in perl 5.14.2: Show quoted text
perl> perl -d testme.pl
Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(testme.pl:6): SecondClass->new(); DB<1> p DB<1> l 6==> SecondClass->new(); 7 8 package FirstClass; 9: use strict; 10: use warnings; 11 12 #use LWP::UserAgent; 13 14: sub new { 15 # ... whatever DB<1> l 16 } 17 18 package SecondClass; 19: use strict; 20: use warnings; 21 22: use base qw/HTML::Parser/; 23 24 sub new { 25: my $class = shift; DB<1> l 26 27: return $class->SUPER::new(); 28 } 29 DB<1> s SecondClass::new(testme.pl:25): my $class = shift; DB<1> s SecondClass::new(testme.pl:27): return $class->SUPER::new(); DB<1> s HTML::Parser::new(/usr/lib/perl5/site_perl/5.14.2/x86_64-linux-thread-multi/HTML/Parser.pm:21): 21: my $class = shift; DB<1> c Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1> q ------------- Note I commented out the use LWP::Agent, which you said was necessary to trigger the bug (doesn't trigger with it included either). I list out the entire prog in the debugger, then single step to the first call -- seems to call the SUPER class just fine... Are you saying this didn't used to work? There were several bugs in perl fixed during this time concerning variable leaking between packages, which greatly changed behavior in this area. Perhaps one of those contributed to the problem and has now gone away?? Could you please verify this is either broken for you or fixed? Else I so no reason why this bug shouldn't be closed, do you?
Subject: Re: [rt.cpan.org #60960] base fails with some combinations of packages
Date: Mon, 21 May 2012 09:33:40 +0930
To: bug-base [...] rt.cpan.org
From: Jon Schutz <jon.schutz [...] youramigo.com>
Verified that the bug still occurs in 2.16 but not in 2.18, using perl 5.14.2: jon@christie ~]$ perl -MV=base base /usr/share/perl5/base.pm: 2.16 [jon@christie ~]$ ./testme.pl Can't locate object method "new" via package "SecondClass::SUPER" at ./testme.pl line 27. [jon@christie ~]$ sudo cpan base ... [jon@christie ~]$ perl -MV=base base /usr/share/perl5/base.pm: 2.18 [jon@christie ~]$ ./testme.pl (no error). So yes, I agree, whatever caused the problem appears to be fixed and there's no reason why the bug shouldn't be closed. Thanks, -- Jon Schutz CTO, YourAmigo Ltd 53 Gilbert St Adelaide SA 5000 Ph: +61 8 82119211 Fax: +61 8 8211 6356 http://www.youramigo.com On 21/05/12 05:44, Linda A Walsh via RT wrote: Show quoted text
> > There were several bugs in perl fixed during this time concerning > variable leaking between packages, which greatly changed behavior in > this area. > > Perhaps one of those contributed to the problem and has now gone away?? > > Could you please verify this is either broken for you or fixed? Else I > so no reason why this bug shouldn't be closed, do you? > > > >