Skip Menu |

This queue is for tickets about the Archive-Tar CPAN distribution.

Report information
The Basics
Id: 59150
Status: resolved
Worked: 15 min
Priority: 0/
Queue: Archive-Tar

People
Owner: BINGOS [...] cpan.org
Requestors: Daphne.Pfister [...] genband.com
Cc:
AdminCc:

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



Subject: Assumes all references filename are IO::Handle's instead of trying to stringify.
Sample program showing the breakage: ( Given Getopt::Long ========================================= use Archive::Tar; package Foo; sub new { my $pkg = shift; bless { @_ }, $pkg; } sub name { my $self = shift; ''.$self->{name}; } use overload '""' => \&name; package main; my $fname = Foo->new( name => shift ); print "Tar file: ", $fname, "\n"; my $next = Archive::Tar->iter( $fname ); while ( my $f = $next->() ) { print "Tar member: ", $f->name, "\n"; } 1; ========================================= Output ( given a tar file ) ========================================= prog my.tar Tar file: my.tar Can't locate object method "read" via package "Foo" at <(...sitepath...) Show quoted text
>/lib/5.12.1/Archive/Tar.pm line 318.
========================================= I've attached a possible patch. ( See also Bug #59149 )
Subject: Archive-Tar.patch
diff -U3 -r Archive-Tar-1.62/lib/Archive/Tar.pm Archive-Tar-1.62-patch/lib/Archive/Tar.pm --- Archive-Tar-1.62/lib/Archive/Tar.pm 2010-06-28 16:50:19.000000000 -0400 +++ Archive-Tar-1.62-patch/lib/Archive/Tar.pm 2010-07-06 21:38:24.000000000 -0400 @@ -212,10 +212,15 @@ sub _get_handle { my $self = shift; my $file = shift; return unless defined $file; - return $file if ref $file; my $compress = shift || 0; my $mode = shift || READ_ONLY->( ZLIB ); # default to read only + ### Check if file is a file handle or IO glob + if ( ref $file ) { + return $file if eval{ *$file{IO} }; + return $file if eval{ $file->isa(q{IO::Handle}) }; + $file = q{}.$file; + } ### get a FH opened to the right class, so we can use it transparently ### throughout the program @@ -1246,7 +1251,12 @@ : do { seek $handle, 0, 0; local $/; <$handle> }; ### make sure to close the handle if we created it - close $handle unless ref($file); + if ( $file ne $handle ) { + unless( close $handle ) { + $self->_error( qq[Could not write tar] ); + return; + } + } return $rv; }
Hi, Thanks for the patch. According to my records this was applied and released as Archive-Tar-1.64 * important changes in version 1.64 09/07/2010 - Removed the PERL_CORE specific chdir from all the tests - Apply a patch from David Muir Sharnoff RT #58916, "skip files via a callback and limit memory use when skipping files" - Apply a patch from Daphne Pfister RT #59150 "Assumes all references filename are IO::Handle's instead of trying to stringify." Many thanks.