Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings isn't futureproofed against future category declaration #12101

Open
p5pRT opened this issue May 14, 2012 · 8 comments
Open

warnings isn't futureproofed against future category declaration #12101

p5pRT opened this issue May 14, 2012 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented May 14, 2012

Migrated from rt.perl.org#112920 (status was 'open')

Searchable as RT112920$

@p5pRT
Copy link
Author

p5pRT commented May 14, 2012

From Perl@ResonatorSoft.org

Created by Perl@ResonatorSoft.org

It looks like warnings will fatally error with flags for future
catagories​:

Unknown warnings category 'non_unicode'

This makes it rather hard to use any of the newer categories
without figuring out exactly which version of Perl the category
came from.

Perl Info

Flags:
    category=library
    severity=low
    module=warnings

Site configuration information for perl 5.12.1:

Configured by 1 at Thu Jul 29 16:39:48 2010.

Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
   
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname='Win32 strawberryperl 5.12.1.0 #1 Thu Jul 29 10:08:11 2010 i386'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=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='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT  -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields -DPERL_MSVCRT_READFIX',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"'
    libpth=C:\strawberry\c\lib C:\strawberry\c\i686-w64-mingw32\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl512.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"'

Locally applied patches:
    


@INC for perl 5.12.1:
    C:/STRAWBERRY/perl/site/lib/MSWin32-x86-multi-thread
    C:/STRAWBERRY/perl/site/lib
    C:/STRAWBERRY/perl/vendor/lib
    C:/STRAWBERRY/perl/lib
    .


Environment for perl 5.12.1:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Windows\SYSTEM32;C:\Windows;C:\Windows\SYSTEM32\WBEM;C:\Windows\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\PROGRAM FILES\INTEL\DMIX;C:\PROGRAM FILES\INTEL\WIFI\BIN\;C:\PROGRAM FILES\COMMON FILES\INTEL\WIRELESSCOMMON\;C:\PROGRAM FILES\NTRU CRYPTOSYSTEMS\NTRU TCG SOFTWARE STACK\BIN\;C:\PROGRAM FILES\WAVE SYSTEMS CORP\GEMALTO\ACCESS CLIENT\V5\;C:\PROGRAM FILES\COMMON FILES\ROXIO SHARED\DLLSHARED\;C:\PROGRAM FILES\COMMON FILES\ROXIO SHARED\10.0\DLLSHARED\;C:\STRAWBERRY\C\BIN;C:\STRAWBERRY\PERL\SITE\BIN;C:\STRAWBERRY\PERL\BIN;C:\CYGWIN\USR\BIN;C:\PROGRAM FILES\IBM\TIVOLI\NETCOOL\PLATFORM\WIN32\BIN;C:\PROGRAM FILES\IBM\TIVOLI\NETCOOL\OMNIBUS\PLATFORM\WIN32\BIN;C:\PROGRAM FILES\IBM\TIVOLI\NETCOOL\PLATFORM\WIN32\LIB;C:\CYGWIN\BIN;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Lua\5.1;C:\Program Files\Lua\5.1\clibs;C:\Program Files\Nmap
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented May 17, 2012

From @cpansprout

On Mon May 14 05​:30​:47 2012, Perl@​ResonatorSoft.org wrote​:

It looks like warnings will fatally error with flags for future
catagories​:

Unknown warnings category 'non_unicode'

This makes it rather hard to use any of the newer categories
without figuring out exactly which version of Perl the category
came from.

But what do we do if someone mistypes a warnings category?

I’m not trying to suggest that your concern is not valid. It *is* a
valid concern, but it is not clear how to proceed.

We also have a problem with custom-registered warnings categories. (See
<https://rt-archive.perl.org/perl5/Ticket/Display.html?id=108778>.)

It should be possible for someone to say ‘use warnings "foo"’, before
the foo module registers itself as a warnings category.

Now, if such a foo module never registers itself, or was actually called
fooo and was mistyped, should we get a warning, or not? (The warning
could be delayed until the main program’s run time, which is how ‘used
once’ warnings work.)

If we do have a warning, then disabling it would be weird​:

no warnings "warnings"; # warnings about misuse of warnings.pm
use warnings "foo";

Or​:

BEGIN {
  local $SIG{__WARN__} = sub {};
  require warnings;
  import warnings "foo";
}

So, it looks to me as though, while it’s nice to have a typo check, it
conflicts with valid usage in actual practice.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented May 17, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 17, 2012

From tchrist@perl.com

"Father Chrysostomos via RT" <perlbug-followup@​perl.org> wrote
  on Thu, 17 May 2012 13​:09​:58 PDT​:

But what do we do if someone mistypes a warnings category?

I’m not trying to suggest that your concern is not valid. It *is* a
valid concern, but it is not clear how to proceed.

Is this a reason to have

  use if $] >= 5.014, warnings => "non_unicode";

Do I dare floating-point there, or should that be doing some $^V dance?
I notice I have some code that reads​:

  if $^V >= v5.11.3, qw[ feature unicode_strings ];

Which I hope will work. I'm a bit fuzzy on v-strings and versioning,
and which operators one can use vs cannot use.

--tom

@p5pRT
Copy link
Author

p5pRT commented May 17, 2012

From @cpansprout

On Thu May 17 13​:34​:54 2012, tom christiansen wrote​:

"Father Chrysostomos via RT" <perlbug-followup@​perl.org> wrote
on Thu, 17 May 2012 13​:09​:58 PDT​:

But what do we do if someone mistypes a warnings category?

I’m not trying to suggest that your concern is not valid. It *is* a
valid concern, but it is not clear how to proceed.

Is this a reason to have

use if $\] >= 5\.014\, warnings => "non\_unicode";

That’s a good used of if.pm that I hadn’t thought of.

Do I dare floating-point there, or should that be doing some $^V dance?
I notice I have some code that reads​:

if $^V >= v5\.11\.3\, qw\[ feature unicode\_strings \];

Which I hope will work. I'm a bit fuzzy on v-strings and versioning,
and which operators one can use vs cannot use.

Since 5.10, $^V can be used with either ge or >= with either vstring or
floating point as the other operand.

In 5.6 and 5.8, $^V is a dualvar, so either $^V >= 5.014 or $^V ge v5.14
will work, but not $^V &gt;= v5.14 or $^V ge 5.014 (which only work in 5.10+).

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented May 18, 2012

From zefram@fysh.org

Tom Christiansen wrote​:

use if $] >= 5.014, warnings => "non_unicode";

Do I dare floating-point there, or should that be doing some $^V dance?

The floating point will work fine. On sufficiently recent perls, $]
is effectively built as a string, and then converted for numeric use.
Your floating-point literal gets converted in an equivalent way, so that
all works.

On older perls, however, $] had a numeric value that was built up using
floating-point arithmetic, such as 5+0.006+0.000002. This would not
necessarily match the conversion of the complete value from string form
[perl #72210]. You can work around that by explicitly stringifying
$] (which produces a correct string) and having *that* numify (to a
correctly-converted floating point value) for comparison. I cultivate
the habit of always stringifying $] to work around this, regardless of
the threshold where the bug was fixed. So I'd write

  use if "$]" >= 5.014, warnings => "non_unicode";

-zefram

@p5pRT
Copy link
Author

p5pRT commented May 20, 2012

From Perl@ResonatorSoft.org

On Fri, May 18, 2012 at 9​:05 AM, Zefram via RT
<perlbug-followup@​perl.org> wrote​:

   use if "$]" >= 5.014, warnings => "non_unicode";

$] is old; don't use it. $^V has been around since Perl 5.6.0, which
is older than dirt now.

Steering this report back on topic, the warnings items could have some
sort of version tied to it​:

use warnings "v5.14-non_unicode"

Then "earlier" versions of warnings could parse that and ignore it if
it's a newer version than $^V. Of course, the cat's alright out of
the bag, so a fix to warnings.pm won't work until 5.16, not without
some heavy backporting.

My current workaround is checking %warnings​::Offsets, which is kinda
hacky. Of course, for something like a single declaration like "use
warnings non_unicode", a $^V check will work. However, it's the kind
of bug you don't really notice until somebody with an older version of
Perl chimes in with a bug report.

--
Brendan Byrd <Perl@​ResonatorSoft.org>
Brendan Byrd <BBYRD@​CPAN.org>

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2012

From belg4mit@pthbb.org

Created by belg4mit@pthbb.org

warnings croaks if it is given an unrecognized category.
This makes it difficult for code to easily support multiple
versions of perl where one possses a warning that the author
would like to disable, and the other does not.

For instance, Curses​::UI previously (now fixed, but the unfixed
version is still shipping on Fedora) had prototypes of I<@​;> for
many subroutines. Perl 5.12 introduced the illegalproto warning
against this.

  no warnings 'illegalproto';

can disable this warning, in 5.12+, but causes earlier versions
to die. Thus, if one does not want to fight the system package
manager (or those who are limited to its use rather than CPAN)
to keep a recent module version installed, an awkward workaround
is required like​:

  BEGIN{ if( $^V lt v5.12.0 ){
  eval "use Curses​::UI" }
  else{ eval "no warnings 'illegalproto'; use Curses​::UI" }
  }

Unfortunately a true fix for this issue may be difficult to fix in a
useful way since the design decision was made sometime ago and the
croaking version is widespread/core to older perls, but dual-lifeing
warnings on CPAN might help

Perl Info

Flags:
    category=library
    severity=medium

This perlbug was built using Perl v5.8.8 in the Red Hat build system.
It is being executed now by Perl v5.8.8 - Wed Feb 22 11:20:48 EST 2012.

Site configuration information for perl v5.8.8:

Configured by Red Hat, Inc. at Wed Feb 22 11:20:48 EST 2012.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.18-53.el5, archname=i386-linux-thread-multi
    uname='linux builder10.centos.org 2.6.18-53.el5 #1 smp mon nov 12 02:14:55 est 2007 i686 athlon i386 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux-thread-multi -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
    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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-52)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.8:
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/5.8.8
    .


Environment for perl v5.8.8:
    HOME=/home/belg4mit
    LANG=en_US
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/bin:/usr/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants