Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Locale-Maketext CPAN distribution.

Report information
The Basics
Id: 34182
Status: resolved
Priority: 0/
Queue: Locale-Maketext

People
Owner: TODDR [...] cpan.org
Requestors: allter [...] gmail.com
yorhel [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.12
Fixed in: 1.15_01



Subject: local $@ in "sub maketext" prevents perl-ish exeptions dispatch
Localization of $@ in "maketext" in v1.12 has a side-effect of cancelling standard way of how Perl programs handle exceptions (script deaths). This is due to two Carp::croak calls placed after "local $@". Of course, there is $handle->fail_with( ... ) callback to overcome this issue, but the less-surprise behavior is to not discard _standard_ exception information on death so the programmer has at least an option to know why the script has failed. Previous Locale::Maketext (e.g. 1.09) do not suffer from this issue. Solution is to croak off the localization scope, for example: my $exception; TRY: { local $@; # ... $exception = "First exception"; last TRY; # ... $exception = "Second exception"; last TRY; return $value; # Successful exit } $exception and Carp::croak( $exception );
Also, in line 184 of version 1.13, you have: # Don't interefere with $@ in case that's being interpolated into the msg. local $@; Later on, it calls the $fail handler, but any errors thrown by the fail handler get swallowed by the localised $@; Any chance of having this failure call outside the scope of the localised $@? thanks Clint
Subject: $@ not set on error
The attached Perl script demonstrates the issue. When calling the maketext method from inside eval(), $@ is not set when it throws an exception. Output of the script: Locale::Maketext version 1.13 This works fine Trying via eval: eval failed $@ = Trying directly: Unbalanced ']', in: this is ] an error ========^ near there via TEST::en, as used at test.pl line 35 After some browsing in the code, I found that commenting Maketext.pm:184 (the 'local $@;' line in sub maketext) did the trick. The output of the script is then as expected: Locale::Maketext version 1.13 This works fine Trying via eval: eval failed $@ = Unbalanced ']', in: this is ] an error ========^ near there via TEST::en, as used at test.pl line 28 Trying directly: Unbalanced ']', in: this is ] an error ========^ near there via TEST::en, as used at test.pl line 35 Using perl v5.10.0 built for x86_64-linux-thread-multi.
Subject: test.pl
#!/usr/bin/perl use strict; use warnings; { package TEST; use base 'Locale::Maketext'; } { package TEST::en; use base 'TEST'; our %Lexicon = ( _AUTO => 1, ); } package main; my $t = TEST->get_handle('en'); print "Locale::Maketext version $Locale::Maketext::VERSION\n"; print $t->maketext("This works fine\n"); print "\nTrying via eval:\n"; print eval { $t->maketext('this is ] an error'); "eval executed correctly\n"; } || "eval failed\n"; print "\$@ = $@\n"; print "\nTrying directly:\n"; $t->maketext('this is ] an error');
Isn't this the same as rt 34182 ? http://rt.cpan.org/Public/Bug/Display.html?id=34182 if so, you might want to close this one and maybe attche your test case to that rt since the maintainer is already aware of that rt and to avoid hime having to spend time sorting out duplication :)
This bug is going on two plus years. Has a resolution been decided? And can someone explain why $@ is localized in the first place? When is that ever a good idea? # Don't interefere with $@ in case that's being interpolated into the msg. local $@; Oh, that comment implies someone might call $lh->maketext( 'The error is [_1]', $@ ); But still the message might not compile and would want to catch that exception message -- that is, might want to wrap the maketext call in an eval and do something with $@.
Subject: Re: [rt.cpan.org #34182] local $@ in "sub maketext" prevents perl-ish exeptions dispatch
Date: Mon, 2 Aug 2010 16:01:28 +0400
To: bug-Locale-Maketext [...] rt.cpan.org
From: Andrey Smirnov <allter [...] gmail.com>
On Mon, Aug 2, 2010 at 10:16 AM, Bill Moseley via RT < bug-Locale-Maketext@rt.cpan.org> wrote: Show quoted text
> And can someone explain why $@ is localized in the first place? When is > that ever a good idea? > >
Localizing $@ before eval is generally good idea, because that piece of code might be itself called the exception catching code ruining previous $@: sub something { local $@; eval { # ... }; if ( $@ ) { # ... } } # somewhere: eval { # ... }; if ( $@ ) { something(); # $@ here is still good, which would not be so without "local $@" in &something. } But one who localizes $@ must always remember that his code must either never raise error/exception condition or rethrow it like I suggested in a bug report. P.S. It's sorrow to see that bug is not fixed. I should not mention work-around in a bug report, then it would be fixed faster. %) -- -- Sincerly yours, Andrey.
This is the wrong RT queue. a ticket has been opened in perl's RT to address it with a patch and tests http://rt.perl.org/rt3/Ticket/Display.html?id=78108
This is the wrong RT queue. a ticket has been opened in perl's RT to address it with a patch and tests http://rt.perl.org/rt3/Ticket/Display.html?id=78108
A fix for this was accepted into blead under this commit. http://perl5.git.perl.org/perl.git/commit/9961f4dd2912b4ce1be748ce46a7bbd36ac60251
1.15_02 is the RC for 1.16. No issues so far. closing ticket.