develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #118105] filehandle promotion to IO::Handle not acting correctly

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
May 21, 2013 21:40
Subject:
[perl #118105] filehandle promotion to IO::Handle not acting correctly
Message ID:
rt-3.6.HEAD-2650-1369172446-1818.118105-15-0@perl.org
On Tue May 21 11:39:28 2013, mattp@cpan.org wrote:
> This is a bug report for perl from mattp@cpan.org,
> generated with the help of perlbug 1.39 running under perl 5.14.2.
> 
> 
> -----------------------------------------------------------------
> 
> Filehandles should automatically be blessed into IO::Handle objects.

Why should they?

> Although this does happen, $fh->can does not report correctly.
> 

It's not clear to me that such promotion happens in this case:


>  Below is a simple test case to demonstrate this:
> 
> $ perl -E 'open my $fh, "|-", "rev" or die $!; $fh->print("Hey");
>    print "Can print" if $fh->can("print"); close $fh'
> yeH
> $
> 

##########
$ cat 118105_fh.pl 
#!/usr/env/perl
use strict;
use warnings;
use 5.10.1;
use Data::Dumper;
use Scalar::Util qw( reftype );
use Test::More qw( no_plan );

open my $fh, "|-", "rev" or die $!;
say STDERR "ref:     ", ref($fh);
say STDERR "retypef: ", reftype($fh);
say STDERR Dumper $fh;
isa_ok($fh, "IO::Handle");
##########
Output:
##########
$ perl 118105_fh.pl 
ref:     GLOB
retypef: GLOB
$VAR1 = \*{'::$fh'};

not ok 1 - The object isa IO::Handle
#   Failed test 'The object isa IO::Handle'
#   at 118105_fh.pl line 13.
#     The object isn't a 'IO::Handle' it's a 'GLOB'
1..1
# Looks like you failed 1 test of 1.
##########

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118105

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