Skip Menu |

This queue is for tickets about the Attribute-Protected CPAN distribution.

Report information
The Basics
Id: 1347
Status: new
Priority: 0/
Queue: Attribute-Protected

People
Owner: Nobody in particular
Requestors: drorbr [...] d.co.il
Cc:
AdminCc:

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



Subject: Problem with eval, use and inheritance
Hi, When you have a class A using Attribute::Protected and class B that extends class A, you get an error if you try you use B inside an eval block. Here is an example: A.pm ----- package Test::A; use Attribute::Protected; sub test : Protected { } 1; B.pm ----- package Test::B; use Attribute::Protected; use base qw(Test::A); 1; ab.pl ----- #!/usr/local/bin/perl56 use Attribute::Protected; eval "use Test::B"; die $@ if $@; this script produces the following error : Can't use string ("ANON") as a symbol ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5.6.1/Attribute/Protected.pm line 13. BEGIN failed--compilation aborted at Test/A.pm line 6. Compilation failed in require at (eval 2) line 3. ...propagated at /usr/local/lib/perl5/5.6.1/base.pm line 62. BEGIN failed--compilation aborted at Test/B.pm line 5. Compilation failed in require at (eval 1) line 2. BEGIN failed--compilation aborted at (eval 1) line 2. I'm using perl 5.6.1 on a Solaris 2.5 box.
[guest - Sun Jul 28 05:36:22 2002]: Show quoted text
> Hi, > > When you have a class A using Attribute::Protected and class B > that extends class A, you get an error if you try you use B inside > an eval block.
Show quoted text
> Can't use string ("ANON") as a symbol ref while "strict refs" in use > at /usr/local/lib/perl5/site_perl/5.6.1/Attribute/Protected.pm line > 13. > BEGIN failed--compilation aborted at Test/A.pm line 6. > Compilation failed in require at (eval 2) line 3. > ...propagated at /usr/local/lib/perl5/5.6.1/base.pm line 62. > BEGIN failed--compilation aborted at Test/B.pm line 5. > Compilation failed in require at (eval 1) line 2. > BEGIN failed--compilation aborted at (eval 1) line 2. > > I'm using perl 5.6.1 on a Solaris 2.5 box.
I can't reproduce this problem with perl5.6.1 or perl5.8.1 on FreeBSD, with Attribute::Protected. Do you mean this problem doesn't happen when you remove eval block?
[MIYAGAWA - Mon Jul 29 01:12:06 2002]: Show quoted text
> [guest - Sun Jul 28 05:36:22 2002]: >
> > Hi, > > > > When you have a class A using Attribute::Protected and class B > > that extends class A, you get an error if you try you use B inside > > an eval block.
>
> > Can't use string ("ANON") as a symbol ref while "strict refs" in use > > at /usr/local/lib/perl5/site_perl/5.6.1/Attribute/Protected.pm line > > 13. > > BEGIN failed--compilation aborted at Test/A.pm line 6. > > Compilation failed in require at (eval 2) line 3. > > ...propagated at /usr/local/lib/perl5/5.6.1/base.pm line 62. > > BEGIN failed--compilation aborted at Test/B.pm line 5. > > Compilation failed in require at (eval 1) line 2. > > BEGIN failed--compilation aborted at (eval 1) line 2. > > > > I'm using perl 5.6.1 on a Solaris 2.5 box.
> > I can't reproduce this problem with perl5.6.1 or perl5.8.1 on FreeBSD, > with Attribute::Protected. Do you mean this problem doesn't happen
when Show quoted text
> you remove eval block?
Yes, without the evel block everything is running smooth. I attach the tmon.out file created by running this script with DProf, maybe it will help. I also managed to reproduce this bug on a Red-Hat 6.2 (2.2.19) box with perl 5.6.1
#fOrTyTwO $hz=100; $XS_VERSION='DProf 20000000.00_00'; # All values are given in HZ $over_utime=9; $over_stime=1; $over_rtime=10; $over_tests=10000; $rrun_utime=5; $rrun_stime=0; $rrun_rtime=5; $total_marks=190 PART2 @ 1 0 1 & 2 main BEGIN + 2 & 3 Attribute::Protected BEGIN + 3 - 3 & 4 Attribute::Protected BEGIN + 4 & 5 strict import + 5 & 6 strict bits + 6 - 6 - 5 - 4 + 4 & 7 warnings BEGIN + 7 @ 1 0 1 & 8 Exporter import + 8 - 8 - 7 @ 1 0 1 & 9 warnings import + 9 & a warnings bits + a - a - 9 - 4 & b Attribute::Protected BEGIN + b & c Attribute::Handlers BEGIN + c - c & d Attribute::Handlers BEGIN + d + 8 - 8 - d & e Attribute::Handlers BEGIN + e + 9 + a - a - 9 - e @ 1 0 1 & f Attribute::Handlers BEGIN + f & 10 warnings unimport + 10 + a - a - 10 - f & 11 Attribute::Handlers BEGIN + 11 + 10 + a - a - 10 - 11 & 12 Attribute::Handlers _gen_handler_AH_ + 12 - 12 + 12 - 12 + 12 - 12 + 12 - 12 & 13 Attribute::Handlers import + 13 - 13 - b & 14 Attribute::Protected BEGIN + 14 + 10 + a - a - 10 - 14 & 15 Attribute::Protected BEGIN + 15 @ 1 0 1 & 16 attributes BEGIN + 16 + 5 + 6 - 6 - 5 - 16 & 17 attributes BEGIN + 17 & 18 attributes bootstrap + 18 - 18 - 17 & 19 attributes import + 19 & 1a attributes reftype + 1a - 1a & 1b UNIVERSAL can + 1b - 1b & 1c attributes _modify_attrs + 1c - 1c & 1d Attribute::Handlers __ANON__ + 1d & 1e Attribute::Handlers _resolve_lastattr + 1e - 1e - 1d & 1f attributes _warn_reserved + 1f - 1f - 19 - 15 & 20 Attribute::Protected BEGIN + 20 + 10 + a - a - 10 - 20 & 21 Attribute::Protected BEGIN + 21 + 19 + 1a - 1a + 1b - 1b + 1c - 1c + 1d + 1e & 22 Attribute::Handlers findsym + 22 - 22 - 1e - 1d + 1f - 1f - 19 - 21 & 23 Attribute::Protected BEGIN + 23 + 19 + 1a - 1a + 1b - 1b + 1c - 1c + 1d + 1e + 22 - 22 - 1e - 1d + 1f - 1f - 19 - 23 + 13 - 13 - 2 & 24 Attribute::Handlers CHECK + 24 + 1e + 22 - 22 - 1e - 24 & 25 Attribute::Handlers INIT + 25 - 25 & 26 main BEGIN + 26 @ 0 1 1 & 27 Test::B BEGIN + 27 + 13 - 13 - 27 & 28 Test::B BEGIN + 28 & 29 base BEGIN + 29 - 29 & 2a base import + 2a & 2b UNIVERSAL isa + 2b - 2b & 2c Test::A BEGIN + 2c + 13 - 13 - 2c & 2d Test::A BEGIN + 2d + 19 + 1a - 1a + 1b - 1b + 1c - 1c + 1d + 1e - 1e + 1b - 1b & 2e Attribute::Handlers _apply_handler_AH_ + 2e - 2e + 2e + 22 - 22 & 2f Test::A BEGIN + 2f + 10 + a - a - 10 - 2f + b / b / 2e / 1d / 19 / 2d / 2a / 28 / 26 & 30 Attribute::Handlers END + 30 - 30 + & Devel::DProf::write @ 0 1 1 - & Devel::DProf::write
Date: Mon, 29 Jul 2002 16:10:03 +0900
From: Tatsuhiko Miyagawa <miyagawa [...] edge.co.jp>
To: bug-Attribute-Protected [...] rt.cpan.org
Subject: Re: [cpan #1347] Problem with eval, use and inheritance
At Mon, 29 Jul 2002 02:46:36 -0400 (EDT), Guest via RT wrote: Show quoted text
> Yes, without the evel block everything is running smooth. > I attach the tmon.out file created by running this script with DProf, > maybe it will help. > > I also managed to reproduce this bug on a Red-Hat 6.2 (2.2.19) box with > perl 5.6.1
Try it on perl5.8, or install Class::Fields first via CPAN and then try again on perl 5.6.1. I mean I guess your base.pm is somewhat broken.
[miyagawa@edge.co.jp - Mon Jul 29 03:10:15 2002]: Show quoted text
> At Mon, 29 Jul 2002 02:46:36 -0400 (EDT), > Guest via RT wrote: >
> > Yes, without the evel block everything is running smooth. > > I attach the tmon.out file created by running this script with
> DProf,
> > maybe it will help. > > > > I also managed to reproduce this bug on a Red-Hat 6.2 (2.2.19) box
> with
> > perl 5.6.1
> > Try it on perl5.8, or install Class::Fields first via CPAN and then > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > broken. >
I intalled the lastest Class::Fields but it did not do any good.
[guest - Mon Jul 29 04:17:02 2002]: Show quoted text
> [miyagawa@edge.co.jp - Mon Jul 29 03:10:15 2002]: >
> > At Mon, 29 Jul 2002 02:46:36 -0400 (EDT), > > Guest via RT wrote: > >
> > > Yes, without the evel block everything is running smooth. > > > I attach the tmon.out file created by running this script with
> > DProf,
> > > maybe it will help. > > > > > > I also managed to reproduce this bug on a Red-Hat 6.2 (2.2.19) box
> > with
> > > perl 5.6.1
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and then > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > broken. > >
> > I intalled the lastest Class::Fields but it did not do any good. > >
When changing the eval line to: eval { use Test::B }; everything works OK. I guess the problem is with the difference between the way the interpreter treats eval ".." and eval {..}
Date: Mon, 29 Jul 2002 18:27:43 +0900
From: Tatsuhiko Miyagawa <miyagawa [...] edge.co.jp>
To: bug-Attribute-Protected [...] rt.cpan.org
Subject: Re: [cpan #1347] Problem with eval, use and inheritance
At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), Guest via RT wrote: Show quoted text
> > > Try it on perl5.8, or install Class::Fields first via CPAN and then > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > broken. > > >
> > > > I intalled the lastest Class::Fields but it did not do any good.
> > When changing the eval line to: > eval { use Test::B }; > everything works OK. > I guess the problem is with the difference between the way the > interpreter treats eval ".." and eval {..}
Yep, eval EXPR and eval BLOCK is totally different. But it doesn't explain why Attribute::Protected fails with it ;)
[miyagawa@edge.co.jp - Mon Jul 29 05:27:47 2002]: Show quoted text
> At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), > Guest via RT wrote:
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and
then Show quoted text
> > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > > broken. > > > >
> > > > > > I intalled the lastest Class::Fields but it did not do any good.
> > > > When changing the eval line to: > > eval { use Test::B }; > > everything works OK. > > I guess the problem is with the difference between the way the > > interpreter treats eval ".." and eval {..}
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > explain why Attribute::Protected fails with it ;) > >
For some reason I missed it, but I get the same error when doing : eval "use Test::A" so I guess it has nothing to do with base.pm
[miyagawa@edge.co.jp - Mon Jul 29 05:27:47 2002]: Show quoted text
> At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), > Guest via RT wrote:
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and
then Show quoted text
> > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > > broken. > > > >
> > > > > > I intalled the lastest Class::Fields but it did not do any good.
> > > > When changing the eval line to: > > eval { use Test::B }; > > everything works OK. > > I guess the problem is with the difference between the way the > > interpreter treats eval ".." and eval {..}
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > explain why Attribute::Protected fails with it ;) > >
For some reason I missed it, but I get the same error when doing : eval "use Test::A" so I guess it has nothing to do with base.pm
[miyagawa@edge.co.jp - Mon Jul 29 05:27:47 2002]: Show quoted text
> At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), > Guest via RT wrote:
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and
then Show quoted text
> > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > > broken. > > > >
> > > > > > I intalled the lastest Class::Fields but it did not do any good.
> > > > When changing the eval line to: > > eval { use Test::B }; > > everything works OK. > > I guess the problem is with the difference between the way the > > interpreter treats eval ".." and eval {..}
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > explain why Attribute::Protected fails with it ;) > >
Does this makes any sense : Since eval EXPR is first parsed, and if there weren't any errors, executed and since *foo{THING} returns undef if that particular THING hasn't been used yet, Attribute::Handlers cannot find the right coderef for the Protected method in the symbol table.
Date: Mon, 29 Jul 2002 20:13:11 +0900
From: Tatsuhiko Miyagawa <miyagawa [...] edge.co.jp>
To: bug-Attribute-Protected [...] rt.cpan.org
Subject: Re: [cpan #1347] Problem with eval, use and inheritance
At Mon, 29 Jul 2002 07:10:11 -0400 (EDT), Guest via RT wrote: Show quoted text
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > > explain why Attribute::Protected fails with it ;) > > > >
> Does this makes any sense : > > Since eval EXPR is first parsed, and if there weren't any errors, > executed and since *foo{THING} returns undef if that particular THING > hasn't been used yet, Attribute::Handlers cannot find the right coderef > for the Protected method in the symbol table.
Anyway, tell me your version of Attribute::Handlers and Attribute::Protected. I should have asked it in the very beginning ;)
[miyagawa@edge.co.jp - Mon Jul 29 05:27:47 2002]: Show quoted text
> At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), > Guest via RT wrote:
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and
then Show quoted text
> > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > > broken. > > > >
> > > > > > I intalled the lastest Class::Fields but it did not do any good.
> > > > When changing the eval line to: > > eval { use Test::B }; > > everything works OK. > > I guess the problem is with the difference between the way the > > interpreter treats eval ".." and eval {..}
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > explain why Attribute::Protected fails with it ;) > >
Does this makes any sense : Since eval EXPR is first parsed, and if there weren't any errors, executed and since *foo{THING} returns undef if that particular THING hasn't been used yet, Attribute::Handlers cannot find the right coderef for the Protected method in the symbol table.
[miyagawa@edge.co.jp - Mon Jul 29 05:27:47 2002]: Show quoted text
> At Mon, 29 Jul 2002 05:20:01 -0400 (EDT), > Guest via RT wrote:
> > > > Try it on perl5.8, or install Class::Fields first via CPAN and
then Show quoted text
> > > > try again on perl 5.6.1. I mean I guess your base.pm is somewhat > > > > broken. > > > >
> > > > > > I intalled the lastest Class::Fields but it did not do any good.
> > > > When changing the eval line to: > > eval { use Test::B }; > > everything works OK. > > I guess the problem is with the difference between the way the > > interpreter treats eval ".." and eval {..}
> > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > explain why Attribute::Protected fails with it ;) > >
Does this makes any sense : Since eval EXPR is first parsed, and if there weren't any errors, executed and since *foo{THING} returns undef if that particular THING hasn't been used yet, Attribute::Handlers cannot find the right coderef for the Protected method in the symbol table.
[miyagawa@edge.co.jp - Mon Jul 29 07:13:17 2002]: Show quoted text
> At Mon, 29 Jul 2002 07:10:11 -0400 (EDT), > Guest via RT wrote:
> > > Yep, eval EXPR and eval BLOCK is totally different. But it doesn't > > > explain why Attribute::Protected fails with it ;) > > > > > >
> > Does this makes any sense : > > > > Since eval EXPR is first parsed, and if there weren't any errors, > > executed and since *foo{THING} returns undef if that particular
THING Show quoted text
> > hasn't been used yet, Attribute::Handlers cannot find the right
coderef Show quoted text
> > for the Protected method in the symbol table.
> > Anyway, tell me your version of Attribute::Handlers and > Attribute::Protected. I should have asked it in the very beginning ;) >
Sorry fo the last two, a wrong refresh of the submit form. I use Attribute::Handlers 0.77 and Attribute::Protected 0.03