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

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

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
July 7, 2013 05:12
Subject:
[perl #118105] filehandle promotion to IO::Handle not acting correctly
Message ID:
rt-3.6.HEAD-2552-1373173904-1167.118105-15-0@perl.org
On Tue May 21 15:21:02 2013, LeonT wrote:
> On Tue May 21 11:39:28 2013, mattp@cpan.org wrote:
> > Filehandles should automatically be blessed into IO::Handle objects.
> > Although this does happen, $fh->can does not report correctly.
> 
> Unblessed Globs aren't quite automatically blessed into IO::Handle,
> they're special cased in interesting ways that include autoloading
> IO::Handle and pretending they are IO::Handle's. This special case seems
> to leak.
> 
> I'm wondering if they shouldn't be auto-blessed instead of the current
> weirdness.

But then you would have to bless *foo when assigning *foo = *$fh{IO}. 
Since that is obviously not going to work very well (after all,
blessings only apply to refs and *foo->print involves none), we will
*still* have to support the old way, so the autoblessing would
accomplish nothing.

The bug is in UNIVERSAL::can.  This is actually a duplicate of #113932.
 (I don’t think it should be merged, as that ticket has other issues, too.)

> 
> >  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
> 
> It seems isa has similar issues.
> 
> Leon

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
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