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

[perl #128588] Tied hash magic ignored in references the first time'round

Thread Previous | Thread Next
Father Chrysostomos via RT
July 10, 2016 01:59
[perl #128588] Tied hash magic ignored in references the first time'round
Message ID:
On Sat Jul 09 17:46:33 2016, wrote:
> But given that that is a visible part of what it does,
> it seems necessary for it to handle magic on the referent.

The attached patch fixes it, but causes two test failures.

This code in Test::Builder fails with the attached patch:

sub is_fh {
    my $self     = shift;
    my $maybe_fh = shift;
    return 0 unless defined $maybe_fh;

    return 1 if ref $maybe_fh  eq 'GLOB';    # its a glob ref
    return 1 if ref \$maybe_fh eq 'GLOB';    # its a glob

    return eval { $maybe_fh->isa("IO::Handle") } ||
           eval { tied($maybe_fh)->can('TIEHANDLE') };

The test in question is cpan/Test-Simple/t/Legacy/Builder/is_fh.t, which does:

ok( Test::Builder->is_fh(\*OUT) );

after tying *OUT to a handle package with no FETCH method.

I think there is some other bug here, because FETCH should not be called on a typeglob that was tied as such, because only its IO slot should have the magic.

The other failing test is ext/Hash-Util-FieldHash/t/11_hashassign.t, which gives me:

Rogue call of 'HUF_watch_key_safe' at lib/Test/ line 689.

Line 689 of is:

    return unless ref $$thing;

which seems pretty innocuous.

The error is coming from ext/Hash-Util-FieldHash.xs.  I have not looked into why.

As I feared, fixing this is not so simple, as code seems to be relying on the existing behaviour.

Also, the patch as it is does not account for FETCH undefining the reference.  I think it will crash in that case.


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