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 man page: 'enabled' has example for warnif #14905

Closed
p5pRT opened this issue Sep 14, 2015 · 8 comments
Closed

warnings man page: 'enabled' has example for warnif #14905

p5pRT opened this issue Sep 14, 2015 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 14, 2015

Migrated from rt.perl.org#126051 (status was 'resolved')

Searchable as RT126051$

@p5pRT
Copy link
Author

p5pRT commented Sep 14, 2015

From perl-diddler@tlinx.org

Created by perl-diddler@tlinx.org

The library module, "warnings" shows an example for 'warnif'
where there should be an example for warnings​:enabled as shown
in the extracted text​:

[quote]
  It is also possible to test whether the pre-defined warnings categories
  are set in the calling module with the "warnings​::enabled" function.
  Consider this snippet of code​:

  package MyMod​::Abc;

  sub open {
  warnings​::warnif("deprecated",
  "open is deprecated, use new instead");
[/quote]

Perl Info

Flags:
    category=library
    severity=medium

Site configuration information for perl 5.22.0:

Configured by law at Sun Sep 13 17:00:58 PDT 2015.

Summary of my perl5 (revision 5 version 22 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=4.1.0-isht-van, archname=x86_64-linux
    uname='linux ishtar 4.1.0-isht-van #2 smp preempt tue jun 23 07:52:09 pdt 2015 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Duse64bitall -Dprefix=/home/tools/perl/perl-5.22.0/usr -des -Dcc=gcc'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion='', gccversion='4.9.0', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector-strong'
    libpth=/usr/lib64/gcc/x86_64-suse-linux/4.9/include-fixed /usr/lib64/gcc/x86_64-suse-linux/4.9/../../../../x86_64-suse-linux/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -fstack-protector-strong'



@INC for perl 5.22.0:
    /home/tools/perl/perl-5.22.0/usr/lib/site_perl/5.22.0/x86_64-linux
    /home/tools/perl/perl-5.22.0/usr/lib/site_perl/5.22.0
    /home/tools/perl/perl-5.22.0/usr/lib/5.22.0/x86_64-linux
    /home/tools/perl/perl-5.22.0/usr/lib/5.22.0
    .


Environment for perl 5.22.0:
    HOME=/home/law
    LANG (unset)
    LANGUAGE (unset)
    LC_COLLATE=C
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH=/home/perl/perl-5.22/build/usr/lib/x86_64-linux-thread-multi-ld:/home/perl/perl-5.22/lib
    LOGDIR (unset)
    PATH=/home/tools/perl/perl-5.22.0/usr/bin:/home/perl/perl-5.22:/sbin:.::/home/law/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/sbin:/etc/local/func_lib:/home/law/lib:/home/law/bin/lib
    PERL5INC=/home/perl/perl-5.22/build/usr/lib/x86_64-linux-thread-multi-ld:/home/perl/perl-5.22/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 14, 2015

From @tonycoz

On Sun Sep 13 17​:18​:03 2015, LAWalsh wrote​:

The library module, "warnings" shows an example for 'warnif'
where there should be an example for warnings​:enabled as shown
in the extracted text​:

[quote]
It is also possible to test whether the pre-defined warnings
categories
are set in the calling module with the "warnings​::enabled"
function.
Consider this snippet of code​:

package MyMod​::Abc;

sub open {
warnings​::warnif("deprecated",
"open
is deprecated, use new instead");
[/quote]

It looks like this was changed by mistake in 7e6d00f which introduced warnings​::warnif() and changed most uses of warnings​::enabled() in core to use warnings​::warnig(), including this one.

I've attached two patches, one to sync the $VERSION of regen/warnings.pl and lib/warnings.pm, since the first generates the second, and two to partly revert the change to the example.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 14, 2015

From @tonycoz

0001-sync-regen-warnings.pl-and-warnings.pm-VERSION.patch
From 1489b6f27cfc1b1e6b26d118593007d6a69e95ca Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 14 Sep 2015 14:31:43 +1000
Subject: sync regen/warnings.pl and warnings.pm $VERSION

regen/warnings.pl's $VERSION was at 1.04 despite it being modified
each time warnings.pm is modified.

So make them use the same version number.
---
 lib/warnings.pm   |  2 +-
 regen/warnings.pl | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/warnings.pm b/lib/warnings.pm
index 332f7c1..3c31b60 100644
--- a/lib/warnings.pm
+++ b/lib/warnings.pm
@@ -5,7 +5,7 @@
 
 package warnings;
 
-our $VERSION = '1.33';
+our $VERSION = "1.34";
 
 # Verify that we're called correctly so that warnings will work.
 # see also strict.pm.
diff --git a/regen/warnings.pl b/regen/warnings.pl
index c4cc19c..0549af4 100644
--- a/regen/warnings.pl
+++ b/regen/warnings.pl
@@ -16,7 +16,7 @@
 #
 # This script is normally invoked from regen.pl.
 
-$VERSION = '1.03';
+$VERSION = '1.34';
 
 BEGIN {
     require 'regen/regen_lib.pl';
@@ -416,6 +416,13 @@ EOM
 }
 
 while (<DATA>) {
+    last if /^VERSION$/ ;
+    print $pm $_ ;
+}
+
+print $pm qq(our \$VERSION = "$::VERSION";\n);
+
+while (<DATA>) {
     last if /^KEYWORDS$/ ;
     print $pm $_ ;
 }
@@ -481,7 +488,7 @@ read_only_bottom_close_and_rename($pm);
 __END__
 package warnings;
 
-our $VERSION = '1.33';
+VERSION
 
 # Verify that we're called correctly so that warnings will work.
 # see also strict.pm.
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Sep 14, 2015

From @tonycoz

0002-perl-126051-make-the-warnings-enabled-example-use-wa.patch
From 5df471f553fe1018fa6cdccc91ae55835f4af26b Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 14 Sep 2015 14:32:07 +1000
Subject: [perl #126051] make the warnings::enabled example use
 warnings::enabled

7e6d00f88633 added the warnif() function and changed most uses of
warnings:enabled() to use warnif(), including this one.  Revert
just that part.
---
 lib/warnings.pm   | 6 ++++--
 regen/warnings.pl | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/warnings.pm b/lib/warnings.pm
index 3c31b60..9cc6e19 100644
--- a/lib/warnings.pm
+++ b/lib/warnings.pm
@@ -1020,8 +1020,10 @@ this snippet of code:
     package MyMod::Abc;
 
     sub open {
-        warnings::warnif("deprecated",
-                         "open is deprecated, use new instead");
+        if (warnings::enabled("deprecated")) {
+            warnings::warn("deprecated",
+                           "open is deprecated, use new instead");
+        }
         new(@_);
     }
 
diff --git a/regen/warnings.pl b/regen/warnings.pl
index 0549af4..d8006be 100644
--- a/regen/warnings.pl
+++ b/regen/warnings.pl
@@ -1146,8 +1146,10 @@ this snippet of code:
     package MyMod::Abc;
 
     sub open {
-        warnings::warnif("deprecated",
-                         "open is deprecated, use new instead");
+        if (warnings::enabled("deprecated")) {
+            warnings::warn("deprecated",
+                           "open is deprecated, use new instead");
+        }
         new(@_);
     }
 
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Sep 14, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Sep 16, 2015

From @jkeenan

On Sun Sep 13 21​:35​:47 2015, tonyc wrote​:

On Sun Sep 13 17​:18​:03 2015, LAWalsh wrote​:

The library module, "warnings" shows an example for 'warnif'
where there should be an example for warnings​:enabled as shown
in the extracted text​:

[quote]
It is also possible to test whether the pre-defined warnings
categories
are set in the calling module with the "warnings​::enabled"
function.
Consider this snippet of code​:

package MyMod​::Abc;

sub open {
warnings​::warnif("deprecated",
"open
is deprecated, use new instead");
[/quote]

It looks like this was changed by mistake in
7e6d00f which introduced
warnings​::warnif() and changed most uses of warnings​::enabled() in
core to use warnings​::warnig(), including this one.

I've attached two patches, one to sync the $VERSION of
regen/warnings.pl and lib/warnings.pm, since the first generates the
second, and two to partly revert the change to the example.

Tony

+1

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Oct 12, 2015

From @tonycoz

On Sun Sep 13 21​:35​:47 2015, tonyc wrote​:

On Sun Sep 13 17​:18​:03 2015, LAWalsh wrote​:

The library module, "warnings" shows an example for 'warnif'
where there should be an example for warnings​:enabled as shown
in the extracted text​:

[quote]
It is also possible to test whether the pre-defined warnings
categories
are set in the calling module with the "warnings​::enabled"
function.
Consider this snippet of code​:

package MyMod​::Abc;

sub open {
warnings​::warnif("deprecated",
"open
is deprecated, use new instead");
[/quote]

It looks like this was changed by mistake in
7e6d00f which introduced
warnings​::warnif() and changed most uses of warnings​::enabled() in
core to use warnings​::warnig(), including this one.

I've attached two patches, one to sync the $VERSION of
regen/warnings.pl and lib/warnings.pm, since the first generates the
second, and two to partly revert the change to the example.

Applied as 3d8ff82 and 4a21999, though I had to bump the version again.

Tony

@p5pRT p5pRT closed this as completed Oct 12, 2015
@p5pRT
Copy link
Author

p5pRT commented Oct 12, 2015

@tonycoz - Status changed from 'open' to 'resolved'

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

1 participant