Skip Menu |

This queue is for tickets about the Sys-SigAction CPAN distribution.

Report information
The Basics
Id: 123132
Status: open
Priority: 0/
Queue: Sys-SigAction

People
Owner: lab [...] lincolnbaxter.com.MAKE.ME.VALID
Requestors: ilmari [...] ilmari.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: timeout_call warns on exception with string but not numeric overload
Date: Tue, 26 Sep 2017 17:02:18 +0100
To: bug-Sys-SigAction [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
Hi, If the code run by timeout_call() throws an exception object that has string overloading but not numeric overloading, a warning is triggered. See the attached test for a demonstration. One way to avoid this would be to check that the exception isn't blessed before comparing it to TIMEDOUT. -- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law
use strict; use warnings; use Test::More; use Sys::SigAction qw(timeout_call); { package MyException; use overload '""' => sub { $_[0]->{msg} }, fallback => 1; sub throw { die bless { msg => $_[1] }, $_[0] } } $SIG{__WARN__} = sub { fail "no warning"; diag $_[0] }; eval { timeout_call(0.1, sub { MyException->throw("Something went wrong"); }) }; my $err = $@; isa_ok($@, 'MyException', 'The exception'); done_testing;
On Tue Sep 26 12:36:13 2017, ilmari@ilmari.org wrote: Show quoted text
> Hi, > > If the code run by timeout_call() throws an exception object that has > string overloading but not numeric overloading, a warning is triggered. > See the attached test for a demonstration. > > One way to avoid this would be to check that the exception isn't blessed > before comparing it to TIMEDOUT. >
I'll try to get a new version out in the next week or so. Sorry it took so long for me to notice this.