develooper Front page | perl.perl5.porters | Postings from August 2001

[PATCH] Re: The coderef in @INC strikes back

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
August 25, 2001 06:50
Subject:
[PATCH] Re: The coderef in @INC strikes back
Message ID:
20010825145007.L41464@plum.flirble.org
On Wed, Aug 22, 2001 at 11:35:08PM +0200, Rafael Garcia-Suarez wrote:
> On 2001.08.22 22:38 Rafael Garcia-Suarez wrote:
> >
> > The Foo::INC method trick seems to work very well (see my reply to
> > J. Stowe). Just remember that INC should always be fully qualified.

Yes, I fell into that trap that first time :-)

> Strange. I can use blessed hashrefs and scalar refs in @INC, but
> not blessed arrayrefs :
> 
> #!/opt/perl/bin/perl5.7.2
> sub Foo::INC { print "@_\n"; undef }
> unshift @INC, bless([123], 'Foo');
> require Foo::Bar;
> 
> Output :
> 
> Undefined subroutine &main::123 called at /home/rafael/bin/quux line 5.
> 
> That's a case for the bug you were referring to.

This should cure it:

--- pp_ctl.c.orig	Mon Aug 13 00:50:50 2001
+++ pp_ctl.c	Sat Aug 25 14:30:12 2001
@@ -3153,7 +3153,8 @@
 		    int count;
 		    SV *loader = dirsv;
 
-		    if (SvTYPE(SvRV(loader)) == SVt_PVAV) {
+		    if (SvTYPE(SvRV(loader)) == SVt_PVAV
+                        && !sv_isobject(loader)) {
 			loader = *av_fetch((AV *)SvRV(loader), 0, TRUE);
 		    }
 


Thanks for the documentation patch. You mentioned in an earlier message about
tests - were you writing some? [I'd prefer not to write the tests, as I have
a preconceived idea about how it all should work, and might miss a way to
break it]

One thing that worries me is this comment in pp_ctl.c:

			    if (io) {
				tryrsfp = IoIFP(io);
				if (IoTYPE(io) == IoTYPE_PIPE) {
				    /* reading from a child process doesn't
				       nest -- when returning from reading
				       the inner module, the outer one is
				       unreadable (closed?)  I've tried to
				       save the gv to manage the lifespan of
				       the pipe, but this didn't help. XXX */
				    filter_child_proc = (GV *)arg;
				    (void)SvREFCNT_inc(filter_child_proc);
				}

Does anyone know exactly what the comment is about, and does anyone have
code to demonstrate the problem?

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About