Skip Menu |

This queue is for tickets about the Params-Validate CPAN distribution.

Report information
The Basics
Id: 60467
Status: resolved
Priority: 0/
Queue: Params-Validate

People
Owner: Nobody in particular
Requestors: peter [...] morch.com
Cc:
AdminCc:

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



Subject: Params::Validate fails in __DIE__ handler with "Modification of a read-only value attempted"
I'm getting this error message: Show quoted text
> Modification of a read-only value attempted at script.pl line 8.
From the following script.pl . Why is that? #!/usr/bin/perl -w use strict; use Params::Validate; BEGIN { $SIG{__DIE__} = sub { my %args = Params::Validate::validate( @_, {}); }; } my $foo = $nonExistingVar; The error is misleading, as it is clear that the caller of validate(), script.pl, is not modifying any read-only value. This does what I expect: #!/usr/bin/perl -w use strict; BEGIN { $SIG{__DIE__} = sub { print "Normal __DIE__ handler: ", join("", @_); exit 1; }; } my $foo = $nonExistingVar; and outputs: Show quoted text
> Normal __DIE__ handler: Global symbol "$nonExistingVar" > requires explicit package name at normalDie.pl line 11. > Execution of normalDie.pl aborted due to compilation errors.
The reason I'm doing this is that I want to use Log::Log4Perl in my __DIE__ handler. It ends up calling Log::Dispatch's Log::Dispatch::Output::log method, and it in turn uses validate() which fails (it also has some more params to validate() etc.). But this is the minimal example I could come up with. I've tried various arrays instead of @_ and I've tried with the default debian libparams-validate-perl 0.91-2, the 0.95 from CPAN and the hg tip, all with the same result. Peter
On Wed Aug 18 07:02:55 2010, peter@morch.com wrote: Show quoted text
> I'm getting this error message: >
> > Modification of a read-only value attempted at script.pl line 8.
> > From the following script.pl . Why is that? > > #!/usr/bin/perl -w > use strict; > use Params::Validate; > BEGIN { > $SIG{__DIE__} = sub { > my %args = Params::Validate::validate( @_, {}); > }; > } > my $foo = $nonExistingVar; > > The error is misleading, as it is clear that the caller of validate(), > script.pl, is not modifying any read-only value. > > This does what I expect: > > #!/usr/bin/perl -w > use strict; > BEGIN { > $SIG{__DIE__} = sub { > print "Normal __DIE__ handler: ", join("", @_); > exit 1; > }; > } > my $foo = $nonExistingVar; > > and outputs: >
> > Normal __DIE__ handler: Global symbol "$nonExistingVar" > > requires explicit package name at normalDie.pl line 11. > > Execution of normalDie.pl aborted due to compilation errors.
> > The reason I'm doing this is that I want to use Log::Log4Perl in my > __DIE__ handler. It ends up calling Log::Dispatch's > Log::Dispatch::Output::log method, and it in turn uses validate() > which fails (it also has some more params to validate() etc.). But > this is the minimal example I could come up with. > > I've tried various arrays instead of @_ and I've tried with the default > debian libparams-validate-perl 0.91-2, the 0.95 from CPAN and the hg > tip, all with the same result. > > Peter
I don't know why this is happening, but if you can turn this into a simple test case I can add it to the test suite and look into it further. Thanks, -dave
Subject: Re: [rt.cpan.org #60467] Params::Validate fails in __DIE__ handler with "Modification of a read-only value attempted"
Date: Sat, 11 Sep 2010 07:09:21 +0200
To: bug-Params-Validate [...] rt.cpan.org
From: Peter Valdemar Mørch <peter [...] morch.com>
On 2010-09-11 03:40, Dave Rolsky via RT wrote: Show quoted text
>> #!/usr/bin/perl -w >> use strict; >> use Params::Validate; >> BEGIN { >> $SIG{__DIE__} = sub { >> my %args = Params::Validate::validate( @_, {}); >> }; >> } >> my $foo = $nonExistingVar;
> > I don't know why this is happening, but if you can turn this into a > simple test case I can add it to the test suite and look into it further.
How much more simple can it get? I don't have the time at the moment to turn it into a test suite test case. Feel free to ignore the bug. Peter -- Peter Valdemar Mørch http://www.morch.com
On 2010-09-11 01:09:50, peter@morch.com wrote: Show quoted text
> On 2010-09-11 03:40, Dave Rolsky via RT wrote:
> >> #!/usr/bin/perl -w > >> use strict; > >> use Params::Validate; > >> BEGIN { > >> $SIG{__DIE__} = sub { > >> my %args = Params::Validate::validate( @_, {}); > >> }; > >> } > >> my $foo = $nonExistingVar;
> > > > I don't know why this is happening, but if you can turn this into a > > simple test case I can add it to the test suite and look into it further.
> > How much more simple can it get? > > I don't have the time at the moment to turn it into a test suite test > case. Feel free to ignore the bug.
With recent Params::Validate the error message is different: Odd number of parameters in call to main::__ANON__ when named parameters were expected at /tmp/pp.pl line 22. main::__ANON__('Global symbol "$nonExistingVar" requires explicit package nam...') called at /tmp/pp.pl line 29 And adding a "local @_;" before the validate() call would produce: Global symbol "$nonExistingVar" requires explicit package name at /tmp/pp.pl line 25. Execution of /tmp/pp.pl aborted due to compilation errors.
On Sun Jan 10 10:33:02 2016, SREZIC wrote: Show quoted text
> On 2010-09-11 01:09:50, peter@morch.com wrote:
> > On 2010-09-11 03:40, Dave Rolsky via RT wrote:
> > >> #!/usr/bin/perl -w > > >> use strict; > > >> use Params::Validate; > > >> BEGIN { > > >> $SIG{__DIE__} = sub { > > >> my %args = Params::Validate::validate( @_, {}); > > >> }; > > >> } > > >> my $foo = $nonExistingVar;
> > > > > > I don't know why this is happening, but if you can turn this into a > > > simple test case I can add it to the test suite and look into it > > > further.
> > > > How much more simple can it get? > > > > I don't have the time at the moment to turn it into a test suite test > > case. Feel free to ignore the bug.
> > With recent Params::Validate the error message is different: > > Odd number of parameters in call to main::__ANON__ when named > parameters were expected > at /tmp/pp.pl line 22. > main::__ANON__('Global symbol "$nonExistingVar" requires > explicit package nam...') called at /tmp/pp.pl line 29
This seems about right, since $SIG{__DIE__} is not called with named parameters in most cases. Show quoted text
> And adding a "local @_;" before the validate() call would produce: > > Global symbol "$nonExistingVar" requires explicit package name at > /tmp/pp.pl line 25. > Execution of /tmp/pp.pl aborted due to compilation errors.
Right, because in this case the validate() call "works" (as in does absolutely nothing) and then the default Perl die handler kicks in and throws the actual message.