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

[PATCH] B::Deparse doesnt handle warnings register properly. #7915

Closed
p5pRT opened this issue May 18, 2005 · 10 comments
Closed

[PATCH] B::Deparse doesnt handle warnings register properly. #7915

p5pRT opened this issue May 18, 2005 · 10 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented May 18, 2005

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

Searchable as RT35857$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 18, 2005

From @demerphq

Created by @demerphq

B​:Deparse doesnt rending warnings neatly when warnings​::register is
in heavy use. The following program demonstrates that with one module
using warnings​::register the output is as expected, with two modules
using it the output changes to be an ugly assignment statement. The
attached patch fixes the problem.

package B​::Deparse​::Wrapper;
use strict;
use warnings;
use warnings​::register;
use B​::Deparse;
sub getcode {
  my $deparser=B​::Deparse->new();
  return $deparser->coderef2text(shift);
}

package main;
use strict;
use warnings;
sub test {
  my $val=shift;
  my $res=B​::Deparse​::Wrapper​::getcode($val);
  print $res,"\n",$res=~/use warnings/ ? '' : 'not ',"ok\n";
 
}
my ($a,$b);
my $x=sub { ++$a,++$b };
test($x);
eval <<EOFCODE and test($x);
  package bar;
  use strict;
  use warnings;
  use warnings​::register;
  package main;
  1
EOFCODE
__END__
{
  use warnings;
  use strict 'refs';
  ++$a, ++$b;
}
ok
{
  BEGIN {${^WARNING_BITS} = "UUUUUUUUUUUU\001"}
  use strict 'refs';
  ++$a, ++$b;
}
not ok
 

Perl Info

Flags:
    category=library
    severity=low

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:"D:\ASPerl\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:"D:\ASPerl\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:/ASPerl/811/lib
    D:/ASPerl/811/site/lib
    .


Environment for perl v5.8.6:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH= XXX
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 18, 2005

From @demerphq

--- lib\b\Deparse.pm.orig 2005-05-05 16​:55​:42.000000000 +0200
+++ lib\b\Deparse.pm 2005-05-18 09​:48​:27.517250000 +0200
@​@​ -1412,10 +1412,10 @​@​

sub declare_warnings {
  my ($from, $to) = @​_;
- if (($to & WARN_MASK) eq warnings​::bits("all")) {
+ if (($to & WARN_MASK) eq (warnings​::bits("all") & WARN_MASK)) {
  return "use warnings;\n";
  }
- elsif (($to & WARN_MASK) eq "\0"x length($to)) {
+ elsif (($to & WARN_MASK) eq ("\0"x length($to) & WARN_MASK)) {
  return "no warnings;\n";
  }
  return "BEGIN {\${^WARNING_BITS} = ".perlstring($to)."}\n";

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 19, 2005

From @demerphq

On 18 May 2005 08​:30​:44 -0000, via RT yves orton
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by yves orton
# Please include the string​: [perl #35857]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=35857 >

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]

B​:Deparse doesnt rending warnings neatly when warnings​::register is
in heavy use. The following program demonstrates that with one module
using warnings​::register the output is as expected, with two modules
using it the output changes to be an ugly assignment statement. The
attached patch fixes the problem.

Im just curious if there is a problem with the patch I included?
Should i have sent it somewhere else?

Cheers,
Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 19, 2005

From ams@wiw.org

At 2005-05-18 08​:30​:44 -0000, perlbug-followup@​perl.org wrote​:

The following program demonstrates that with one module using
warnings​::register the output is as expected, with two modules
using it the output changes to be an ugly assignment statement.
The attached patch fixes the problem.

Thanks, applied. (#24505)

Could you submit your test case as a patch to ext/B/t/deparse.t, please?

-- ams

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 19, 2005

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 23, 2005

From @demerphq

On 5/19/05, Abhijit Menon-Sen <ams@​wiw.org> wrote​:

At 2005-05-18 08​:30​:44 -0000, perlbug-followup@​perl.org wrote​:

The following program demonstrates that with one module using
warnings​::register the output is as expected, with two modules
using it the output changes to be an ugly assignment statement.
The attached patch fixes the problem.

Thanks, applied. (#24505)

Could you submit your test case as a patch to ext/B/t/deparse.t, please?

Hi, deparse.t patch attached. Sorry about the delay.

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 23, 2005

From @demerphq

deparse_t.patch
--- live_orig\ext\B\t\deparse.t	2004-12-29 13:28:45.000000000 +0100
+++ live\ext\B\t\deparse.t	2005-05-23 11:41:41.578125000 +0200
@@ -24,7 +24,7 @@
 use strict;
 use Config;
 
-print "1..37\n";
+print "1..39\n";
 
 use B::Deparse;
 my $deparse = B::Deparse->new() or print "not ";
@@ -130,6 +130,37 @@
 print "# [$a]\n\# vs expected\n# [$b]\nnot " if $a ne $b;
 print "ok " . $i++ . "\n";
 
+#Re: perlbug #35857, patch #24505 
+#handle warnings::register-ed packages properly.
+package B::Deparse::Wrapper;
+use strict;
+use warnings;
+use warnings::register;
+sub getcode {
+   my $deparser=B::Deparse->new();
+   return $deparser->coderef2text(shift);
+}
+
+package main;
+use strict;
+use warnings;
+sub test {
+   my $val=shift;
+   my $res=B::Deparse::Wrapper::getcode($val);
+   print $res=~/use warnings/ ? '' : 'not ',"ok\n";
+}
+my ($q,$p);
+my $x=sub { ++$q,++$p };
+test($x);
+eval <<EOFCODE and test($x);
+   package bar;
+   use strict;
+   use warnings;
+   use warnings::register;
+   package main;
+   1
+EOFCODE
+
 __DATA__
 # 2
 1;

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 24, 2005

From @rgs

demerphq wrote​:

Hi, deparse.t patch attached. Sorry about the delay.

Thanks, applied as 24559 to bleadperl.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 14, 2005

From @smpeters

[rgarciasuarez@​mandriva.com - Tue May 24 02​:12​:33 2005]​:

demerphq wrote​:

Hi, deparse.t patch attached. Sorry about the delay.

Thanks, applied as 24559 to bleadperl.

Great! Closed since patches were applied.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 14, 2005

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

@p5pRT p5pRT closed this Oct 14, 2005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant