develooper Front page | perl.perl5.porters | Postings from September 2005

[perl #37292] '-MModule=100' not identical to 'use Module 100;' when module doesnt use Exporter

From:
yves orton
Date:
September 27, 2005 08:41
Subject:
[perl #37292] '-MModule=100' not identical to 'use Module 100;' when module doesnt use Exporter
Message ID:
rt-3.0.11-37292-121640.13.1256488987321@perl.org
# New Ticket Created by  yves orton 
# Please include the string:  [perl #37292]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37292 >


This is a bug report for perl from demerphq@gmail.com,
generated with the help of perlbug 1.35 running under perl v5.8.6.


-----------------------------------------------------------------
[Please enter your report here]

It seems there is a discrepancy between how module version checks work
from the command line when the module does not use exporter.

Assuming the following modules are available:

package TestVersion::NoExporter;
$VERSION=1.0;
1;


package TestVersion::Exporter;
use base qw(Exporter);
$VERSION=1.0;
1;

Then

  perl -MTestVersion::NoExporter=100 -e1

will NOT throw an error. BUT

  perl -MTestVersion::Exporter=100 -e1

DOES throw an error.

However,

  perl -e"use TestVersion::NoExporter 100;"

and

  perl -e"use TestVersion::Exporter 100;"

are both ok as they both throw an error.

This behaviour is counterintuitive and potentially dangerous
and explains why -MModule=VERSION doesnt work consistantly.

EG:

    D:\Dev\test>perl -Id:\dev\test -MTestVersion::Exporter=100 -e1
    TestVersion::Exporter version 100 required--this is only version 1
        at E:/Perl/811/lib/Exporter/Heavy.pm line 121.
    BEGIN failed--compilation aborted.

    D:\Dev\test>perl -Id:\dev\test -MTestVersion::NoExporter=100 -e1

    D:\Dev\test>perl -Id:\dev\test -e "use TestVersion::NoExporter 100"
    TestVersion::NoExporter version 100 required--this is only version
1 at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.

    D:\Dev\test>perl -Id:\dev\test -e "use TestVersion::NoExporter qw(100)"

    D:\Dev\test>perl -Id:\dev\test -e "use TestVersion::Exporter 100"
    TestVersion::Exporter version 100 required--this is only version 1
at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.

    D:\Dev\test>perl -Id:\dev\test -e "use TestVersion::Exporter qw(100)"
    TestVersion::Exporter version 100 required--this is only version 1
        at E:/Perl/811/lib/Exporter/Heavy.pm line 121.
    BEGIN failed--compilation aborted at -e line 1.

    D:\Dev\test>

The error messages suggest to me that Exporter is more clever about handling
version checks than the core is. I guess this makes it a bug in
UNIVERSAL::VERSION().

cheers,
yves


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.6:

Configured by ActiveState at Mon Dec 13 09:51:32 2004.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    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='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DNO_HASH_SEED
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -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='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-libpath:"E:\Perl\811\lib\CORE"  -machine:x86'
    libpth=\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 ws2_32.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 ws2_32.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 -debug
-opt:ref,icf  -libpath:"E:\Perl\811\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    21540 Fix backward-compatibility issues in if.pm
    23565 Wrong MANIFEST.SKIP

---
@INC for perl v5.8.6:
    D:\ASPN\PDK\lib\
    E:/Perl/811/lib
    E:/Perl/811/site/lib
    .

---
Environment for perl v5.8.6:
    HOME=D:\home
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=E:\sybase\OLEDB;E:\sybase\ODBC;E:\sybase\ASEP_Win32;E:\sybase\OCS-12_5\dll;E:\sybase\OCS-12_5\lib3p;E:\sybase\OCS-12_5\bin;C:\dotNet\Common7\IDE;C:\dotNet\VC7\BIN;C:\dotNet\Common7\Tools;C:\dotNet\Common7\Tools\bin\prerelease;C:\dotNet\Common7\Tools\bin;C:\dotNet\FrameworkSDK\bin;C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\BIN;E:\uedit32;E:\Perl\811\bin;E:\Perl\638\bin;D:\ASPN\PDK\bin;D:\ASPN\Komodo;E:\cygwin\bin
    PERL5LIB=D:\ASPN\PDK\lib\
    PERLDB_OPTS=RemotePort=127.0.0.1:2000
    PERL_BADLANG (unset)
    SHELL (unset)




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