develooper Front page | perl.perl5.porters | Postings from April 2007

[perl #42601] Inconsistent warning of redefined subroutines in Exporter

Thread Next
From:
Colin Robertson
Date:
April 19, 2007 00:55
Subject:
[perl #42601] Inconsistent warning of redefined subroutines in Exporter
Message ID:
rt-3.6.HEAD-30201-1176913052-1264.42601-75-0@perl.org
# New Ticket Created by  Colin Robertson 
# Please include the string:  [perl #42601]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42601 >


Getting bounces if I send with perlbug, but that may be due to our mail
server configuration, so retrying manually:

This is a bug report for perl from colin.robertson@bbc.co.uk,
generated with the help of perlbug 1.35 running under perl v5.8.8.

There is an odd inconsistency in the behaviour of Exporter and the
points at which it warns about redefining subroutines. Consider the
following modules:

-- Foo.pm --

package Foo;

use base 'Exporter';
our @EXPORT_OK = qw( foobar );

sub foobar { print "Foo\n" };

1;

-- Bar.pm --

package Bar;

use base 'Exporter';
our @EXPORT_OK = qw( foobar );

sub foobar { print "Bar\n" };

1;

-- Once.pm --

package Once;

use Foo qw( foobar );
use Bar qw( foobar );

1;

-- Twice.pm --

package Twice;

use Foo qw( foobar );
use Bar qw( foobar );

1;

-- End --

Running "perl -we 'use Once;'" gives us no warnings, but running "perl
-we 'use Once; use Twice;'" gives us:

Subroutine Twice::foobar redefined at
/usr/local/lib/perl5/5.8.7/Exporter.pm line 65.
 at Twice.pm line 4

Ideally, there should have been a warning just when compiling Once.

This bug, or at least something related to it, was encountered in the
wild with code that effectively did:

use File::Temp;
use File::Slurp;

(with File::Temp version 0.16 and File::Slurp version 9999.11). This
gives us the warning:

Subroutine File::Slurp::O_RDWR redefined at
/usr/local/cps_perl5.8.7/site_perl/File/Slurp.pm line 7
Subroutine File::Slurp::O_CREAT redefined at
/usr/local/cps_perl5.8.7/site_perl/File/Slurp.pm line 7
Subroutine File::Slurp::O_EXCL redefined at
/usr/local/cps_perl5.8.7/site_perl/File/Slurp.pm line 7

On the other hand, when the use statements are reversed, there is no
warning:

use File::Slurp;
use File::Temp;

I think File::Slurp should actually be warning a lot, regardless of
anything else that happens, because the following lines import a bunch
of duplicated symbols:

use Fcntl qw( :DEFAULT ) ;
use POSIX qw( :fcntl_h ) ;

It happens that File::Temp makes some use of O_RDWR, O_CREAT and 0_EXCL,
which triggers the warning in File::Slurp.

---
Flags:
    category=library
    severity=low
---
Site configuration information for perl v5.8.8:

Configured by comand at Thu Mar 23 17:51:47 EST 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
    uname='sunos ra 5.8 generic_117350-28 sun4u sparc
sunw,sun-blade-1000'
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -xO3 -xarch=v8 -xspace -xildoff
-I/opt/csw/bdb43/include -I/opt/csw/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
    optimize='-xO3 -xarch=v8 -xspace -xildoff',
    cppflags='-D_REENTRANT -xO3 -xarch=v8 -xspace -xildoff
-I/opt/csw/bdb43/include -I/opt/csw/include'
    ccversion='Sun C 5.7 2005/01/07', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-xarch=v8 -L/opt/csw/bdb43/lib -L/opt/csw/lib
-L/usr/lib -L/usr/ccs/lib -L/lib'
    libpth=/usr/lib /usr/ccs/lib /lib /opt/csw/lib
    libs=-lsocket -lnsl -lgdbm -ldb-4.3 -ldl -lm -lpthread -lc
    perllibs=-lsocket -lnsl -ldb-4.3 -ldl -lm -lpthread -lc
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R
/opt/csw/lib'
    cccdlflags='-KPIC', lddlflags='-G -L/opt/csw/bdb43/lib
-L/opt/csw/lib -L/usr/lib -L/usr/ccs/lib -L/lib'

Locally applied patches:
    

---
@INC for perl v5.8.8:
    /home/colinr/lib
    /home/system/cgi-bin/lib
    /home/system/cgi-bin/lib/sun4-solaris
    /opt/csw/lib/perl/5.8.8
    /opt/csw/share/perl/5.8.8
    /opt/csw/lib/perl/site_perl
    /opt/csw/share/perl/site_perl
    /opt/csw/share/perl/site_perl
    /opt/csw/lib/perl/csw
    /opt/csw/share/perl/csw
    /opt/csw/share/perl/csw
    .

---
Environment for perl v5.8.8:
    HOME=/home/colinr
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
 
PATH=/home/colinr/bin:/home/system/scripts/devtools:/opt/csw/gcc3/bin:/u
sr/local/bin:/opt/csw/bin:/usr/sfw/bin:/usr/bin:/usr/ccs/bin:/usr/local/
scripts:/usr/ucb:/u01/app/oracle/product/9.2.0.1.0/bin:/u01/app/oracle/p
roduct/9.2.0.1.0/xsql/bin:/usr/openwin/bin:/usr/local/cps_perl5.6.1/bin:
/opt/xml-xalan/c/bin:/usr/local/mysql/bin
 
PERL5LIB=/home/colinr/lib:/home/system/cgi-bin/lib:/home/system/cgi-bin/
lib/sun4-solaris
    PERL_BADLANG (unset)
    SHELL=/usr/bin/bash


-- 
Colin Robertson
Software Engineer, Vision (Factual & Learning)
BBC Future Media & Technology
2507, White City
T: 0208 752 7295

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About