develooper Front page | perl.perl5.porters | Postings from July 2012

[perl #114334] Re-encoding gives unhelpful error message

From:
Darin McBride
Date:
July 30, 2012 15:26
Subject:
[perl #114334] Re-encoding gives unhelpful error message
Message ID:
rt-3.6.HEAD-11172-1343687177-1818.114334-75-0@perl.org
# New Ticket Created by  Darin McBride 
# Please include the string:  [perl #114334]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=114334 >



This is a bug report for perl from dmcbride@cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.4.


-----------------------------------------------------------------
[Please describe your issue here]

This is related to #113982, but not actually the same issue.

Because of the clobbering of PerlIO layers, I inserted some code to ensure
that STDOUT and STDERR always have the correct encoding.  However, this
code was being run even when the layers had not been clobbered.  This would
result in double-encoding, and then I'd get an error message that was less
than useful.

I would suggest, in increasing order of preference, one of:

a) Documentation for :raw indicating it is recommended for undoing all
other encodings (or, better, some other way of popping out any encoding
layer(s)), or

b) An error message when an encoding layer is added on top of another
encoding layer, or

b) Clobbering (such as with :raw) old encodings when adding a new
encoding layer.

Code:

#! /usr/bin/perl

use 5.10.1;

$text = "\x{65E0}\x{6CD5}\x{542F}\x{52A8}";

binmode STDOUT, ':encoding(eucCN)';
binmode STDOUT, ':encoding(eucCN)';

say "== $_" for PerlIO::get_layers(STDOUT);

say $text;

__END__

I'm suggesting that this should produce the same output whether there is
one or both of those binmode statements.  Note that if I change the
second binmode to include :raw before :encoding, I get the desired output
(see option (a) above).

(The Perl I'm using this on is 5.10.1, which is not the same as my local
system perl, but this also happens on 5.16.0.)

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.12.4:

Configured by Gentoo at Wed Sep 28 07:02:37 MDT 2011.

Summary of my perl5 (revision 5 version 12 subversion 4) configuration:
   
  Platform:
    osname=linux, osvers=2.6.39-gentoo-r3, archname=x86_64-linux-thread-multi
    uname='linux naboo 2.6.39-gentoo-r3 #1 smp sun jul 17 07:13:38 mdt 2011 x86_64 intel(r) core(tm) i7 cpu 930 @ 2.80ghz genuineintel gnulinux '
    config_args='-des -Duseshrplib -Darchname=x86_64-linux-thread -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-O3 -pipe -march=core2 -Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dsiteprefix=/usr -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.12.4 -Darchlib=/usr/lib64/perl5/5.12.4/x86_64-linux-thread-multi -Dsitelib=/usr/lib64/perl5/site_perl/5.12.4 -Dsitearch=/usr/lib64/perl5/site_perl/5.12.4/x86_64-linux-thread-multi -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.12.4 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux-thread-multi -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/share/man/man1 -Dsiteman3dir=/usr/share/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.12.4 -Dlocincpth=  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm -Di_gdbm 
 -Di_db -Dusethreads -DDEBUGGING=none -Dinc_version_list=5.12.3/x86_64-linux-thread-multi 5.12.3 5.12.2/x86_64-linux-thread-multi 5.12.2 5.12.1/x86_64-linux-thread-multi 5.12.1 5.12.0/x86_64-linux-thread-multi 5.12.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3 -pipe -march=core2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe'
    ccversion='', gccversion='4.5.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='x86_64-pc-linux-gnu-gcc', ldflags ='-Wl,-O1 -Wl,--as-needed'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.12.2.so, so=so, useshrplib=true, libperl=libperl.so.5.12.4
    gnulibc_version='2.12.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O3 -pipe -march=core2 -Wl,-O1 -Wl,--as-needed'

Locally applied patches:
    0001-gentoo_MakeMaker-RUNPATH.diff
    0002-gentoo_config_over.diff
    0003-gentoo_cpan_definstalldirs.diff
    0004-gentoo_cpanplus_definstalldirs.diff
    0005-gentoo_create-libperl-soname.diff
    0006-gentoo_MakeMaker-delete_packlist.diff
    0007-fixes_8d66b3f9_h2hp_fix.diff
    0008-fixes_f178b03b_h2ph_using_deprecated_goto.diff
    0009-gentoo_mod-paths.diff
    0010-gentoo_enc2xs.diff
    0011-gentoo_IO-Compress_AutoLoader_dropped_from_Compress-Zlib.diff
    0012-gentoo_drop-fstack-protector.diff

---
@INC for perl 5.12.4:
    /etc/perl
    /usr/lib64/perl5/site_perl/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.4
    /usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.4
    /usr/lib64/perl5/site_perl/5.12.3/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.3
    /usr/lib64/perl5/site_perl/5.12.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.12.2
    /usr/lib64/perl5/site_perl
    /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.3
    /usr/lib64/perl5/vendor_perl/5.12.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.12.2
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/5.12.4/x86_64-linux-thread-multi
    /usr/lib64/perl5/5.12.4
    /usr/local/lib/site_perl
    .

---
Environment for perl 5.12.4:
    HOME=/home/dmcbride
    LANG=en_US.utf8
    LANGUAGE=
    LC_ALL=en_US.utf8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/dmcbride/bin:/usr/lib/distcc/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.5.3:/share/cvs/bin:/usr/local/bin:/usr/games/bin:/share/bin:/share/darin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash




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