Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #24824] Problem with base.pm calling ->isa()

0 views
Skip to first unread message

Steve Hay

unread,
Jan 6, 2004, 6:05:54 AM1/6/04
to bugs-bi...@netlabs.develooper.com
# New Ticket Created by Steve Hay
# Please include the string: [perl #24824]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=24824 >


This is a bug report for perl from stev...@uk.radan.com,
generated with the help of perlbug 1.34 running under perl v5.8.2.

There is a problem importing isa() from UNIVERSAL:: when also using base.pm.
I don't understand what the problem is, but it seems to be related to the
fact that base.pm calls ->isa() itself.

Running this program:

=====
use strict;
use warnings;

BEGIN {
package Foo;
our $VERSION = '1.00';
}

use base qw(Foo);
use UNIVERSAL qw(isa);

my $hashref = {a => 1, b => 2};
if (isa($hashref, 'HASH')) {
print "It's a HASH reference\n";
}
else {
print "It's not a HASH reference\n";
}
=====

produces the error "Undefined subroutine &main::isa called at ... line 13."

Removing the "use UNIVERSAL ..." line and then calling UNIVERSAL::isa()
rather than just isa() fixes it.

Swapping around the "use base..." and "use UNIVERSAL..." lines also fixes
it!

The problem seems to be related to base.pm calling ->isa() itself. The line

use base qw(Foo);

is roughly equivalent (in this context) to

BEGIN {
our @ISA = qw(Foo) unless main->isa('Foo');
}

(That BEGIN block reproduces the error shown above.)

Changing it to just

BEGIN {
our @ISA = qw(Foo);
}

also fixes things.

---
Flags:
category=library
severity=medium
---
Site configuration information for perl v5.8.2:

Configured by steveh at Tue Nov 18 15:11:07 2003.

Summary of my perl5 (revision 5 version 8 subversion 2) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-perlio
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_DEBUGGING_MSTATS
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -release
-libpath:"C:\perl5\lib\CORE" -machine:x86'
libpth=C:\PROGRA~1\MICROS~2\VC98\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release
-libpath:"C:\perl5\lib\CORE" -machine:x86'

Locally applied patches:

---
@INC for perl v5.8.2:
C:/perl5/lib
C:/perl5/site/lib
.

---
Environment for perl v5.8.2:
HOME (unset)
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\perl5\bin
PERL5LIB (unset)
PERL_BADLANG (unset)
SHELL (unset)


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

Rafael Garcia-Suarez

unread,
Jan 11, 2004, 6:43:24 PM1/11/04
to perl5-...@perl.org
Steve Hay (via RT) wrote:
>
> There is a problem importing isa() from UNIVERSAL:: when also using base.pm.
> I don't understand what the problem is, but it seems to be related to the
> fact that base.pm calls ->isa() itself.

That's a strange problem. Here's a cut-down test case.
Uncommenting the second line fixes it.

main->isa('Foo');
#\&isa;
*isa = \&UNIVERSAL::isa;
if (isa({}, 'HASH')) { print "It's a HASH reference\n"; }

0 new messages