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

[perl #128530] Cloning STDOUT looses encoding

From:
Chad Granum
Date:
July 3, 2016 18:36
Subject:
[perl #128530] Cloning STDOUT looses encoding
Message ID:
rt-4.0.18-3947-1467570957-980.128530-75-0@perl.org
# New Ticket Created by  Chad Granum 
# Please include the string:  [perl #128530]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128530 >


This is a bug report for perl from exodist7@gmail.com,
generated with the help of perlbug 1.40 running under perl 5.22.2.


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

The following script can demonstrate this issue:

>   use strict;
>   use warnings;
>
>   binmode *STDOUT, ":encoding(utf8)";
>
>   open(my $copy, '>&', STDOUT);
>   print $copy "\x{11e}\n";

Normal STDOUT:

>    $ perl test.pl
>    Wide character in print at test.pl line 7.
>    Ğ

Redirect STDOUT to file:

>    $ perl test.pl > temp
>    cat temp
>    Ğ

When STDOUT is a filehandle it behaves differently...

This was found because of a Test::More unit test which passes when run under
any harness, but fails when run directly with perl. This can have lots of
implications for testing in general, there are probably a lot of unit tests
that check encodings and such. These is also no good way to write a test for
this specific problem, the very fact that tests run in a harness could
prevent
issues from being seen.


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

Configured by exodist at Mon May  2 14:25:44 PDT 2016.

Summary of my perl5 (revision 5 version 22 subversion 2) configuration:

  Platform:
    osname=linux, osvers=4.5.1-1-arch, archname=x86_64-linux-thread-multi
    uname='linux abydos 4.5.1-1-arch #1 smp preempt thu apr 14 19:19:32
cest 2016 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/exodist/perl5/perlbrew/perls/main
-Dusethreads -Aeval:scriptdir=/home/exodist/perl5/perlbrew/perls/main/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv
-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='5.3.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='cc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed /usr/lib
/lib/../lib /usr/lib/../lib /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.23.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.23'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector-strong'

Locally applied patches:
    Devel::PatchPerl 1.38

---
@INC for perl 5.22.2:

/home/exodist/perl5/perlbrew/perls/main/lib/site_perl/5.22.2/x86_64-linux-thread-multi
    /home/exodist/perl5/perlbrew/perls/main/lib/site_perl/5.22.2

/home/exodist/perl5/perlbrew/perls/main/lib/5.22.2/x86_64-linux-thread-multi
    /home/exodist/perl5/perlbrew/perls/main/lib/5.22.2
    .

---
Environment for perl 5.22.2:
    HOME=/home/exodist
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/home/exodist/perl5/perlbrew/bin:/home/exodist/perl5/perlbrew/perls/main/bin:/home/exodist/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    PERLBREW_BASHRC_VERSION=0.73
    PERLBREW_HOME=/home/exodist/.perlbrew
    PERLBREW_MANPATH=/home/exodist/perl5/perlbrew/perls/main/man

PERLBREW_PATH=/home/exodist/perl5/perlbrew/bin:/home/exodist/perl5/perlbrew/perls/main/bin
    PERLBREW_PERL=main
    PERLBREW_ROOT=/home/exodist/perl5/perlbrew
    PERLBREW_VERSION=0.75
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh




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