|
List Info
Thread: Universal::CAN warning from TT?
|
|
| Universal::CAN warning from TT? |

|
2006-11-22 02:14:20 |
Some of my tests give this warning, lots :
Called UNIVERSAL::can() as a function, not a method at
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
/Template/Provider.pm
line 277
Does anyone else see this warning a lot? could it be down to
how I am
using TT (in a very standard way, I think, but still ...) Is
it a
problem in TT?
I read the pod for UNIVERSAL::Can, which mentions this and
suggests
fixing the code ... but I've no idea what, where or how.
Just an annoyance, but I'd like to lose it.
cheers
Daniel
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
| Universal::CAN warning from TT? |

|
2006-11-22 16:25:54 |
Daniel McBrearty wrote:
> Some of my tests give this warning, lots :
>
> Called UNIVERSAL::can() as a function, not a method at
>
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
/Template/Provider.pm
>
> line 277
This is because you have installed chromatic's
UNIVERSAL::can module.
Maybe you installed Test::MockObject and it grabbed this
too? The
normal UNIVERSAL.pm that ships with perl doesn't do this.
- Perrin
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
| Universal::CAN warning from TT? |

|
2006-11-22 16:45:32 |
Daniel McBrearty wrote:
> Just an annoyance, but I'd like to lose it.
Yes, Test::MockObject loads a special UNIVERSAL::can that
warns you when
you use UNIVERSAL::can incorrectly. The problem with
calling
UNIVERSAL::can like:
UNIVERSAL::can($something, 'method')
is that $something doesn't have a chance to override the
'can' that it
inherits from UNIVERSAL. This obviously breaks
Test::MockObject, since
instances are Mock Objects and not real ones (method calls
are faked
with AUTOLOAD, which UNIVERSAL::can doesn't know how to deal
with).
Here's a rough equivalent:
package A;
sub foo { ... }
package C;
sub new { bless {} => 'C' }
our ISA = 'A';
package main;
my $bar = C->new;
C::foo($bar);
You would never call a class method directly like that
(because it won't
work), so you shouldn't do that with UNIVERSAL::can or
UNIVERSAL::isa.
I don't see this with my version of TT, though. If you're
using the
latest version, change
UNIVERSAL::can($object, 'method')
to
blessed $object && $object->can('method')
and send in a patch. Much cleaner.
--
package JAPH;use Catalyst
qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca
Rockway][$_].[split //,
";$;"]->[$_].q; ;for
1..4;$,=~s;^.;;;$,});$;->setup;
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
| Universal::CAN warning from TT? |

|
2006-11-22 18:20:08 |
* Jonathan Rockway <jon jrock.us> [2006-11-22
17:50]:
> You would never call a class method directly like that
(because
> it won't work), so you shouldn't do that with
UNIVERSAL::can or
> UNIVERSAL::isa.
For completeness’ sake, there is exactly one acceptable
use of
`UNIVERSAL::can` as a function:
!!UNIVERSAL::can( $foo, 'can' )
This is a cheap and highly backward compatible replacement
for
`Scalar::Util::blessed`.
There may be some esoteric cases where the result of that
expression will be incorrect, but they’re even more
bizarre than
the concept of quantum superposition and can probably never
happen without XS mischief.
--
*AUTOLOAD=*_;sub
_{s/(.*)::(.*)/print$2,(",$/","
")[defined wantarray]/e;$1}
&Just->another->Perl->hacker;
#Aristotle
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
| Universal::CAN warning from TT? |

|
2006-11-22 19:26:06 |
A. Pagaltzis wrote:
> For completeness’ sake, there is exactly one
acceptable use of
> `UNIVERSAL::can` as a function:
>
> !!UNIVERSAL::can( $foo, 'can' )
>
> This is a cheap and highly backward compatible
replacement for
> `Scalar::Util::blessed`.
It was done this was in Template Toolkit because
UNIVERSAL::isa is
unreliable, as noted in the comments. I'm not sure if
Scalar::Util::blessed has the same problem or not, but I've
definitely
seen the issue that Andy was trying to work around with
UNIVERSAL::isa.
- Perrin
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
| Universal::CAN warning from TT? |

|
2006-11-23 03:43:33 |
thanks - I'll try this when I get a chance and see.
On 11/22/06, Jonathan Rockway <jon jrock.us> wrote:
> Daniel McBrearty wrote:
> > Just an annoyance, but I'd like to lose it.
>
> Yes, Test::MockObject loads a special UNIVERSAL::can
that warns you when
> you use UNIVERSAL::can incorrectly. The problem with
calling
> UNIVERSAL::can like:
>
> UNIVERSAL::can($something, 'method')
>
> is that $something doesn't have a chance to override
the 'can' that it
> inherits from UNIVERSAL. This obviously breaks
Test::MockObject, since
> instances are Mock Objects and not real ones (method
calls are faked
> with AUTOLOAD, which UNIVERSAL::can doesn't know how to
deal with).
>
> Here's a rough equivalent:
>
> package A;
> sub foo { ... }
> package C;
> sub new { bless {} => 'C' }
> our ISA = 'A';
> package main;
> my $bar = C->new;
> C::foo($bar);
>
> You would never call a class method directly like that
(because it won't
> work), so you shouldn't do that with UNIVERSAL::can or
UNIVERSAL::isa.
>
> I don't see this with my version of TT, though. If
you're using the
> latest version, change
>
> UNIVERSAL::can($object, 'method')
>
> to
>
> blessed $object &&
$object->can('method')
>
> and send in a patch. Much cleaner.
>
> --
> package JAPH;use Catalyst
qw/-Debug/;($;=JAPH)->config(name => do {
> $,.=reverse qw[Jonathan tsu rehton lre rekca
Rockway][$_].[split //,
> ";$;"]->[$_].q; ;for
1..4;$,=~s;^.;;;$,});$;->setup;
>
> _______________________________________________
> List: Catalyst lists.rawmode.org
> Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
> Dev site: http://dev.catalyst.per
l.org/
>
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
_______________________________________________
List: Catalyst lists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalyst lists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/
|
|
[1-6]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|