Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 50902
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

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



Subject: Here-docs not stringifying. Also deep weirdness.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1256713112-3617-544"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 525
Download (untitled) / with headers
text/plain 525b
The attached program shows two bugs. Here-docs do not stringify, at least not when dumped as part of a sub. The second is really weird. This prints the routine: print PPI::Document->new($0)->find_first("PPI::Statement::Sub")->block; This does not. my $sub = PPI::Document->new($0)->find_first("PPI::Statement::Sub"); print $sub->block; They should be exactly equivalent. PPI shouldn't even see the difference. I hope its not a perl bug. This is perl, v5.10.1 (*) built for darwin-thread-multi-64int-ld-2level
Subject: test.plx
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1256713112-3617-543"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/octet-stream; name="test.plx"
Content-Disposition: inline; filename="test.plx"
Content-Transfer-Encoding: base64
Content-Length: 336
Download test.plx
application/octet-stream 336b

Message body not shown because it is not plain text.

MIME-Version: 1.0 (Apple Message framework v936)
X-Spam-Status: No, hits=0.0 required=8.0 tests=
In-Reply-To: <rt-3.6.HEAD-3617-1256713117-353.50902-4-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.936)
References: <RT-Ticket-50902 [...] rt.cpan.org> <rt-3.6.HEAD-3617-1256713117-353.50902-4-0 [...] rt.cpan.org>
Message-ID: <4F374574-07EF-4A94-A803-4AAFC1FE6424 [...] chrisdolan.net>
Content-Type: text/plain; charset="utf-8"; delsp="yes"; format="flowed"
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by diesel.bestpractical.com (Postfix) with SMTP id D07F519B81E0 for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 06:00:47 -0400 (EDT)
Received: (qmail 6033 invoked by uid 103); 28 Oct 2009 10:00:46 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Oct 2009 10:00:46 -0000
Received: from caibbdcaaaaf.dreamhost.com (HELO spaceymail-a3.g.dreamhost.com) (208.113.200.5) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Wed, 28 Oct 2009 03:00:39 -0700
Received: from [192.168.0.2] (h69-129-202-174.mdsnwi.broadband.dynamic.tds.net [69.129.202.174]) by spaceymail-a3.g.dreamhost.com (Postfix) with ESMTP id 3D777194EA0; Wed, 28 Oct 2009 03:00:18 -0700 (PDT)
Delivered-To: cpan-bug+PPI [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
Return-Path: <chris [...] chrisdolan.net>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-PPI [...] rt.cpan.org
Date: Wed, 28 Oct 2009 05:00:14 -0500
X-Spam-Level: *
To: bug-PPI [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Chris Dolan <chris [...] chrisdolan.net>
RT-Message-ID: <rt-3.6.HEAD-3617-1256724059-308.50902-0-0 [...] rt.cpan.org>
Content-Length: 2371
Download (untitled) / with headers
text/plain 2.3k
Reproduced with PPI 1.203 and Apple's stock Perl 5.8.8 on Mac 10.5 If you stick the following at the end of Schwern's program, you get similarly surprising results: use Data::Dumper; print Dumper($sub); print Dumper(PPI::Document->new($0)- Show quoted text
>find_first("PPI::Statement::Sub"));
$VAR1 = bless( {}, 'PPI::Statement::Sub' ); $VAR1 = bless( { ... lots of content ... }, 'PPI::Structure::Sub' ); This change DOES make a difference, to my surprise: print "Third\n"; my $doc = PPI::Document->new($0); my $sub2 = $doc->find_first("PPI::Statement::Sub"); print $sub2->block; I tried saving to @sub instead of $sub, but that didn't help I tried reordering code to make sure it wasn't a caching issue, but that didn't help. I tried renaming "$sub" to a non-keyword, but that didn't help. I tried moving "sub foo {...}" to a separate file, but that didn't help. I tried messing with the interior of "sub foo { ... }" but that didn't help. I wondered if wantarray() could be involved, but PPI::Node::find_first and PPI::Document::new don't use that. Is there something special about PPI::Statement::Sub? I didn't test this idea. Could PPI::XS be involved? I tried reordering the code to put "sub foo {...}" at the top, followed by "BEGIN { $PPI::XS_DISABLE=1; }" followed by the "use" statements, but that didn't help. Chris On Oct 28, 2009, at 1:58 AM, Michael G Schwern via RT wrote: Show quoted text
> Wed Oct 28 02:58:37 2009: Request 50902 was acted upon. > Transaction: Ticket created by MSCHWERN > Queue: PPI > Subject: Here-docs not stringifying. Also deep weirdness. > Broken in: 1.206 > Severity: Normal > Owner: Nobody > Requestors: mschwern@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50902 > > > > The attached program shows two bugs. Here-docs do not stringify, at > least not when dumped as part of a sub. > > The second is really weird. This prints the routine: > > print PPI::Document->new($0)->find_first("PPI::Statement::Sub")-
> >block;
> > This does not. > > my $sub = PPI::Document->new($0)->find_first("PPI::Statement::Sub"); > print $sub->block; > > They should be exactly equivalent. PPI shouldn't even see the > difference. I hope its not a perl bug. > > This is perl, v5.10.1 (*) built for darwin-thread-multi-64int- > ld-2level > > <test.plx>
MIME-Version: 1.0 (Apple Message framework v936)
X-Spam-Status: No, hits=0.0 required=8.0 tests=
In-Reply-To: <rt-3.6.HEAD-3617-1256713117-353.50902-4-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.936)
References: <RT-Ticket-50902 [...] rt.cpan.org> <rt-3.6.HEAD-3617-1256713117-353.50902-4-0 [...] rt.cpan.org>
Message-ID: <17DE44E9-FD9D-495E-994E-E22939957B4D [...] chrisdolan.net>
Content-Type: text/plain; charset="utf-8"; delsp="yes"; format="flowed"
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by diesel.bestpractical.com (Postfix) with SMTP id 3FC4B19B81E0 for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 06:03:30 -0400 (EDT)
Received: (qmail 15090 invoked by uid 103); 28 Oct 2009 10:03:29 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Oct 2009 10:03:29 -0000
Received: from caibbdcaaaaf.dreamhost.com (HELO spaceymail-a6.g.dreamhost.com) (208.113.200.5) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Wed, 28 Oct 2009 03:03:28 -0700
Received: from [192.168.0.2] (h69-129-202-174.mdsnwi.broadband.dynamic.tds.net [69.129.202.174]) by spaceymail-a6.g.dreamhost.com (Postfix) with ESMTP id 17CF1CA81D; Wed, 28 Oct 2009 03:03:19 -0700 (PDT)
Delivered-To: cpan-bug+PPI [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
Return-Path: <chris [...] chrisdolan.net>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-PPI [...] rt.cpan.org
Date: Wed, 28 Oct 2009 05:03:16 -0500
X-Spam-Level: *
To: bug-PPI [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Chris Dolan <chris [...] chrisdolan.net>
RT-Message-ID: <rt-3.6.HEAD-3617-1256724225-1736.50902-0-0 [...] rt.cpan.org>
Content-Length: 1379
Download (untitled) / with headers
text/plain 1.3k
Aha! Never mind my last message. Here's the source of the problem: PPI::Node::add_element contains: Scalar::Util::weaken( $_PARENT{refaddr $Element} = $self ); So, in the inline code the PPI::Document instance still exists while in the $sub version, the PPI::Document instance has already been garbage collected. Chris On Oct 28, 2009, at 1:58 AM, Michael G Schwern via RT wrote: Show quoted text
> Wed Oct 28 02:58:37 2009: Request 50902 was acted upon. > Transaction: Ticket created by MSCHWERN > Queue: PPI > Subject: Here-docs not stringifying. Also deep weirdness. > Broken in: 1.206 > Severity: Normal > Owner: Nobody > Requestors: mschwern@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50902 > > > > The attached program shows two bugs. Here-docs do not stringify, at > least not when dumped as part of a sub. > > The second is really weird. This prints the routine: > > print PPI::Document->new($0)->find_first("PPI::Statement::Sub")-
> >block;
> > This does not. > > my $sub = PPI::Document->new($0)->find_first("PPI::Statement::Sub"); > print $sub->block; > > They should be exactly equivalent. PPI shouldn't even see the > difference. I hope its not a perl bug. > > This is perl, v5.10.1 (*) built for darwin-thread-multi-64int- > ld-2level > > <test.plx>
MIME-Version: 1.0
X-Spam-Status: No, hits=-0.0 required=8.0 tests=DK_SIGNED,DK_VERIFIED,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-3617-1256724059-308.50902-6-0 [...] rt.cpan.org>
References: <RT-Ticket-50902 [...] rt.cpan.org> <rt-3.6.HEAD-3617-1256713117-353.50902-4-0 [...] rt.cpan.org> <4F374574-07EF-4A94-A803-4AAFC1FE6424 [...] chrisdolan.net> <rt-3.6.HEAD-3617-1256724059-308.50902-6-0 [...] rt.cpan.org>
Message-ID: <4AE8C52F.20300 [...] pobox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by diesel.bestpractical.com (Postfix) with SMTP id B64BD19B81E0 for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 18:27:04 -0400 (EDT)
Received: (qmail 22349 invoked by uid 103); 28 Oct 2009 22:27:04 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Oct 2009 22:27:04 -0000
Received: from a-pb-sasl-sd.pobox.com (HELO sasl.smtp.pobox.com) (64.74.157.62) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Wed, 28 Oct 2009 15:27:01 -0700
Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 4D72989D70 for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 18:26:58 -0400 (EDT)
Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 4A7F189D6E for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 18:26:58 -0400 (EDT)
Received: from [10.23.42.2] (unknown [69.64.236.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id CE36089D6D for <bug-PPI [...] rt.cpan.org>; Wed, 28 Oct 2009 18:26:57 -0400 (EDT)
Delivered-To: cpan-bug+PPI [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812)
Domainkey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=message-id:date :from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; q=dns; s=sasl; b=Q/kYTn bmg+Zrc5/WlCjx7z3NRQIj9IvMxzDc55OP/916pXtX8aw73JcLBJoa6d9WucMjLs ZZMOK0s0Rusfra3rlbBy4ViRuTd/5H7kQ49wa06WHCbSYEwkYdwCvla7JwMhd0Ne 5eVEh4T2ug3l/cKCf6G0tvO0C2XDB/iGS2vJ8=
Return-Path: <schwern [...] pobox.com>
Dkim-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=message-id :date:from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; s=sasl; bh=w/MmgGCpctjM stQUKaEEUxt4gn8=; b=hlkxu4FsPeD32HYarUd6Ig5If0blsR508giCIbE1WESR tuuTKfjiuQRaEes1f+ooSthRAXX/+0tEkXZukI1qmnV+jKFrt0F3/QwLnuVRGgfP 9Y4s/DtJU8BlrpY5/IzUr3HeVYcok6v5tIRIHfCumYoYYSbxj1Jr2/XLyK0l60g=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-PPI [...] rt.cpan.org
Date: Wed, 28 Oct 2009 15:26:55 -0700
X-Spam-Level: *
To: bug-PPI [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
X-Pobox-Relay-ID: 014640CC-C411-11DE-981E-A67CBBB5EC2E-02258300!a-pb-sasl-sd.pobox.com
From: Michael G Schwern <schwern [...] pobox.com>
RT-Message-ID: <rt-3.6.HEAD-3617-1256768836-541.50902-0-0 [...] rt.cpan.org>
Content-Length: 415
Download (untitled) / with headers
text/plain 415b
Chris Dolan via RT wrote: Show quoted text
> Could PPI::XS be involved? I tried reordering the code to put "sub > foo {...}" at the top, followed by "BEGIN { $PPI::XS_DISABLE=1; }" > followed by the "use" statements, but that didn't help.
I don't have PPI::XS installed. -- 44. I am not the atheist chaplain. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-14818-1266733503-1533.50902-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 236
Download (untitled) / with headers
text/plain 236b
In the second case, you allowed the document as a whole to be garbage collected. For the moment, this behaviour is expected. If you wish to keep a part of a document when the rest of the document is destroyed, you need to ->remove it.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.