Skip Menu |
 

This queue is for tickets about the File-Path CPAN distribution.

Report information
The Basics
Id: 53178
Status: resolved
Priority: 0/
Queue: File-Path

People
Owner: RICHE [...] cpan.org
Requestors: david.schmidt [...] fm5.at
Cc:
AdminCc:

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

Attachments
0001-add-a-failing-test-for-Path-Class-use.patch
0002-do-not-treat-blessed-hashes-as-argument-hashes.patch



Subject: bug when only 1 path present and no \%opts
Date: Mon, 28 Dec 2009 13:09:11 +0100
To: bug-File-Path [...] rt.cpan.org
From: David Schmidt <david.schmidt [...] fm5.at>
Download (untitled) / with headers
text/plain 328b
make_path($path); # path is not created make_path($path, {}); # path is created remove_tree($path); # path is not deleted remove_tree($path, {}); # path is deleted version 2.08 Linux kvm6 2.6.28-17-server #58-Ubuntu SMP Tue Dec 1 22:13:36 UTC 2009 x86_64 GNU/Linux Sincerely, david -- David Schmidt | http://www.fm5.at
Subject: Re: [rt.cpan.org #53178] bug when only 1 path present and no \%opts
Date: Sun, 03 Jan 2010 12:03:13 +0100
To: bug-File-Path [...] rt.cpan.org
From: David Landgren <david [...] landgren.net>
Download (untitled) / with headers
text/plain 828b
David Schmidt via RT wrote: Show quoted text
> Mon Dec 28 07:09:35 2009: Request 53178 was acted upon. > Transaction: Ticket created by david.schmidt@fm5.at > Queue: File-Path > Subject: bug when only 1 path present and no \%opts > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: david.schmidt@fm5.at > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=53178 > > > > make_path($path); # path is not created > make_path($path, {}); # path is created > > remove_tree($path); # path is not deleted > remove_tree($path, {}); # path is deleted > > version 2.08 > Linux kvm6 2.6.28-17-server #58-Ubuntu SMP Tue Dec 1 22:13:36 UTC 2009 > x86_64 GNU/Linux > > Sincerely, david >
Gah! That's horrible! I'll see what's going on and fix that up pronto. Thanks, David
Subject: Re: [rt.cpan.org #53178] bug when only 1 path present and no \%opts
Date: Sun, 03 Jan 2010 13:28:57 +0100
To: bug-File-Path [...] rt.cpan.org
From: David Landgren <david [...] landgren.net>
Download (untitled) / with headers
text/plain 876b
David Schmidt via RT wrote: Show quoted text
> Mon Dec 28 07:09:35 2009: Request 53178 was acted upon. > Transaction: Ticket created by david.schmidt@fm5.at > Queue: File-Path > Subject: bug when only 1 path present and no \%opts > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: david.schmidt@fm5.at > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=53178 > > > > make_path($path); # path is not created > make_path($path, {}); # path is created > > remove_tree($path); # path is not deleted > remove_tree($path, {}); # path is deleted > > version 2.08 > Linux kvm6 2.6.28-17-server #58-Ubuntu SMP Tue Dec 1 22:13:36 UTC 2009 > x86_64 GNU/Linux
Hmm, I cannot reproduce this problem. What does $path contain at the moment of the call, and what is your cwd and the rights therein (chmod)? Thanks, David
Download (untitled) / with headers
text/plain 359b
What the OP did not show was that he was probably using an object as the $path. This *is* a horrible bug, and it happens when the single argument to the routines is an object that is a blessed hash, like a Path::Class object. I have attached a test and a fix. The fix will treat only an unblessed hashref as a set of arguments, not a blessed one. -- rjbs
Subject: 0001-add-a-failing-test-for-Path-Class-use.patch
From bc6516f2677387e9e82233d7c7da97350356fabd Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Tue, 19 Jul 2011 10:39:59 -0400 Subject: [PATCH 1/2] add a failing test for Path::Class use --- t/Path-Class.t | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) create mode 100644 t/Path-Class.t diff --git a/t/Path-Class.t b/t/Path-Class.t new file mode 100644 index 0000000..c3542d6 --- /dev/null +++ b/t/Path-Class.t @@ -0,0 +1,49 @@ +use strict; +use warnings; +use Test::More; + +eval "require Path::Class"; +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; + +use File::Path qw(remove_tree make_path); +Path::Class->import; + +my $name = 'test'; +my $dir = dir($name); + +sub test { + my ($dir, $pass_arg) = @_; + + my $args = [ $dir, ($pass_arg ? {} : ()) ]; + my $desc = sprintf( + 'dir isa %s, second arg is %s', + (ref($dir) || 'string'), + ($pass_arg ? '{}' : 'not passed') + ); + + return ($args, $desc); +} + +for my $mk_dir ($name, dir($name)) { + for my $mk_pass_arg (0, 1) { + + for my $rm_dir ($name, dir($name)) { + for my $rm_pass_arg (0, 1) { + remove_tree($name) if -e $name; + + my ($mk_args, $mk_desc) = test($mk_dir, $mk_pass_arg); + make_path(@$mk_args); + + if (ok( -d $dir, "we made $dir ($mk_desc)")) { + my ($rm_args, $rm_desc) = test($rm_dir, $rm_pass_arg); + remove_tree(@$rm_args); + ok( ! -d $dir, "...then we removed $dir ($rm_desc)"); + } else { + fail("...can't remove it if we didn't create it"); + } + } + } + } +} + +done_testing; -- 1.7.4.4
Subject: 0002-do-not-treat-blessed-hashes-as-argument-hashes.patch
From 6620faa02586eb41db7deea4a12e6545150cb58a Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Tue, 19 Jul 2011 10:46:48 -0400 Subject: [PATCH 2/2] do not treat blessed hashes as argument hashes --- Path.pm | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Path.pm b/Path.pm index 387cdb1..790405b 100644 --- a/Path.pm +++ b/Path.pm @@ -6,6 +6,7 @@ use strict; use Cwd 'getcwd'; use File::Basename (); use File::Spec (); +use Scalar::Util (); BEGIN { if ($] < 5.006) { @@ -58,13 +59,19 @@ sub _error { } } +sub __is_arg { + my ($arg) = @_; + return (Scalar::Util::reftype($arg) || '') eq 'HASH' + && ! Scalar::Util::blessed($arg); +} + sub make_path { - push @_, {} unless @_ and UNIVERSAL::isa($_[-1],'HASH'); + push @_, {} unless @_ and __is_arg($_[-1]); goto &mkpath; } sub mkpath { - my $old_style = !(@_ and UNIVERSAL::isa($_[-1],'HASH')); + my $old_style = !(@_ and __is_arg($_[-1])); my $arg; my $paths; @@ -162,7 +169,7 @@ sub _mkpath { } sub remove_tree { - push @_, {} unless @_ and UNIVERSAL::isa($_[-1],'HASH'); + push @_, {} unless @_ and __is_arg($_[-1]); goto &rmtree; } @@ -185,7 +192,7 @@ sub _is_subdir { } sub rmtree { - my $old_style = !(@_ and UNIVERSAL::isa($_[-1],'HASH')); + my $old_style = !(@_ and __is_arg($_[-1])); my $arg; my $paths; -- 1.7.4.4
Subject: Re: [rt.cpan.org #53178] bug when only 1 path present and no \%opts
Date: Tue, 19 Jul 2011 21:38:50 +0200
To: bug-File-Path [...] rt.cpan.org
From: David Schmidt <david.schmidt [...] fm5.at>
Download (untitled) / with headers
text/plain 552b
awesome, thanks ;) On Tue, Jul 19, 2011 at 4:54 PM, Ricardo Signes via RT <bug-File-Path@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=53178 > > > What the OP did not show was that he was probably using an object as the > $path.  This *is* a horrible bug, and it happens when the single > argument to the routines is an object that is a blessed hash, like a > Path::Class object. > > I have attached a test and a fix.  The fix will treat only an unblessed > hashref as a set of arguments, not a blessed one. > > -- > rjbs >
Subject: Re: [rt.cpan.org #53178] bug when only 1 path present and no \%opts
Date: Thu, 21 Jul 2011 16:31:50 +0200
To: bug-File-Path [...] rt.cpan.org
From: David Landgren <david [...] landgren.net>
Download (untitled) / with headers
text/plain 833b
On 19/07/2011 21:39, David Schmidt via RT wrote: Show quoted text
> Queue: File-Path > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=53178> > > awesome, thanks ;) > > On Tue, Jul 19, 2011 at 4:54 PM, Ricardo Signes via RT > <bug-File-Path@rt.cpan.org> wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=53178> >> >> What the OP did not show was that he was probably using an object as the >> $path. This *is* a horrible bug, and it happens when the single >> argument to the routines is an object that is a blessed hash, like a >> Path::Class object.
oog. Show quoted text
>> I have attached a test and a fix. The fix will treat only an unblessed >> hashref as a set of arguments, not a blessed one.
I'll fold this into the distrib and push out a new release this weekend. Thanks for the detective work, David Show quoted text
>> -- >> rjbs >>
> >
Did this get pushed up? I just ran into this, on 2.08_01.
Download (untitled) / with headers
text/plain 195b
On Thu Mar 29 19:52:01 2012, ETHER wrote: Show quoted text
> Did this get pushed up? I just ran into this, on 2.08_01.
I don't think the patches were applied. I find no evidence of rjbs's patch in version 2.09.
From: tommylutz [...] gmail.com
Download (untitled) / with headers
text/plain 408b
On Wed Apr 15 21:48:54 2015, JKEENAN wrote: Show quoted text
> On Thu Mar 29 19:52:01 2012, ETHER wrote:
> > Did this get pushed up? I just ran into this, on 2.08_01.
> > I don't think the patches were applied. I find no evidence of rjbs's > patch in version 2.09.
Pull request should be coming shortly to fix this issue. The patch provided above will be used, with the exception of adding the dependency on Scalar::Util.
From: tommylutz [...] gmail.com
Download (untitled) / with headers
text/plain 546b
On Sat May 02 13:56:59 2015, tommylutz@gmail.com wrote: Show quoted text
> On Wed Apr 15 21:48:54 2015, JKEENAN wrote:
> > On Thu Mar 29 19:52:01 2012, ETHER wrote:
> > > Did this get pushed up? I just ran into this, on 2.08_01.
> > > > I don't think the patches were applied. I find no evidence of rjbs's > > patch in version 2.09.
> Pull request should be coming shortly to fix this issue. The patch > provided above will be used, with the exception of adding the > dependency on Scalar::Util.
Pull request created: https://github.com/rpcme/File-Path/pull/2
RT-Send-CC: tommylutz [...] gmail.com
Download (untitled) / with headers
text/plain 109b
This issue has been resolved in dev release http://search.cpan.org/~riche/File-Path/Path.pm version 2.10_001.


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.