Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File::Copy fails on IO::Handle objects #10268

Open
p5pRT opened this issue Mar 31, 2010 · 6 comments
Open

File::Copy fails on IO::Handle objects #10268

p5pRT opened this issue Mar 31, 2010 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 31, 2010

Migrated from rt.perl.org#73930 (status was 'open')

Searchable as RT73930$

@p5pRT
Copy link
Author

p5pRT commented Mar 31, 2010

From philipp@cpan.org

I'm trying to use

File​::Copy(\*TIEDHANDLE, "/foo/bar");

and it's blowing out as​:

stat() on unopened filehandle FD at /usr/lib/perl5/5.10.0/File/Copy.pm line
  102,<F> line 1 (#1)
  (W unopened) You tried to use the stat() function on a filehandle that
  was either never opened or has since been closed.

so I'm thinking that the logic bracketing the stat($from) and stat($to) should test to see if either one is a file handle first (i.e. use !$from_a_handle and !$to_a_handle, respectively).

Same thing happens with IO​::Handle() arguments.

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2010

From @iabyn

Note this is still present in blead, and can be reproduced with the
following. Note that the file actually gets copied.

use Tie​::StdHandle;
tie *FH, 'Tie​::StdHandle', '/etc/hosts';
use File​::Copy;
copy(\*FH, "/tmp/hosts");

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2010

From philipp@cpan.org

On 04/08/2010 01​:45 PM, Dave Mitchell via RT wrote​:

Note this is still present in blead, and can be reproduced with the
following. Note that the file actually gets copied.

use Tie​::StdHandle;
tie *FH, 'Tie​::StdHandle', '/etc/hosts';
use File​::Copy;
copy(\*FH, "/tmp/hosts");

Well, in the test suite for Filesys​::SmbClient 3.99 it fails and had to
be commented out.

Probably because the IO​::Handle fileno() method in that case does a croak().

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2010

From philipp@cpan.org

On 04/08/2010 01​:45 PM, Dave Mitchell via RT wrote​:

Note this is still present in blead, and can be reproduced with the
following. Note that the file actually gets copied.

use Tie​::StdHandle;
tie *FH, 'Tie​::StdHandle', '/etc/hosts';
use File​::Copy;
copy(\*FH, "/tmp/hosts");

Well, it wasn't working when the tied handle was one of
Filesys​::SmbClient, despite the fact that this object has all of the
required methods... so apparently File​::Copy() has a dependency on other
methods.

@jkeenan
Copy link
Contributor

jkeenan commented Feb 22, 2020

From @iabyn

Note this is still present in blead, and can be reproduced with the
following. Note that the file actually gets copied.

use Tie​::StdHandle;
tie *FH, 'Tie​::StdHandle', '/etc/hosts';
use File​::Copy;
copy(*FH, "/tmp/hosts");

Still present in perl-5.30.0.

@xenu xenu removed the Severity Low label Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants