On 2018-02-05 16:32:03, SREZIC wrote:
Show quoted text> On 2018-01-20 12:38:13, sprout@cpan.org wrote:
> >
> > On Jan 20, 2018, at 6:02 AM, "Slaven_Rezic via RT" <bug-DBM-
> > Deep@rt.cpan.org> wrote:
> >
> >
> > Thank you for beating me to it. You just shrank my list of modules
> > to
> > patch. The patch looks fine. I will mention, though, that it could
> > be simpler. warnings::warnif_at_level already contains the warn/die
> > logic.
>
> Something like this?
>
> if(defined &warnings::warnif_at_level) { # perl >= 5.27.8
> warnings::warnif_at_level($_[0], $level-1, $_[1]);
> } else {
>
> However, the test suite still fails with this change, and there's a
> stray filehandle+line in the warning message:
>
> not ok 10 - assigning a stale reference to the DB dies w/FATAL
> warnings
> # Failed test 'assigning a stale reference to the DB dies w/FATAL
> warnings'
> # at t/39_singletons.t line 56.
> # got: 'Assignment of stale reference at t/39_singletons.t
> line 54, <$fh> line 0.
> # '
> # expected: 'Assignment of stale reference at t/39_singletons.t
> line 54.
> # '
> not ok 11 - assigning a stale reference back to the DB warns
> # Failed test 'assigning a stale reference back to the DB warns'
> # at t/39_singletons.t line 62.
> # got: 'Assignment of stale reference at t/39_singletons.t
> line 61, <$fh> line 0.
> # '
> # expected: 'Assignment of stale reference at t/39_singletons.t
> line 61.
> # '
"<$fh> line 0" seems to happen if a previously read filehandle was closed. To reproduce:
#!/usr/bin/perl
use strict;
{
package Bla;
sub xxx {
warnings::warnif_at_level("uninitialized", 0, "blubber bla");
}
}
open my $fh, "<", $0;
<$fh>;
close $fh;
use warnings;
Bla::xxx();
__END__
Output:
blubber bla at /tmp/warn.pl line 16, <$fh> line 0.
So maybe the filehandle stuff in warnings::__chk should be rewritten to
$stuff .= ", <" . *${^LAST_FH}{NAME} . "> line $." if $. && ${^LAST_FH};
?