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

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

Thread Previous | Thread Next
Father Chrysostomos via RT
July 7, 2013 05:12
[perl #118105] filehandle promotion to IO::Handle not acting correctly
Message ID:
On Tue May 21 15:21:02 2013, LeonT wrote:
> On Tue May 21 11:39:28 2013, 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

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About