develooper Front page | perl.perl5.porters | Postings from January 2013

[perl #116599] IO::File->open should respect use open()

Thread Next
From:
Michael Joyce
Date:
January 30, 2013 18:18
Subject:
[perl #116599] IO::File->open should respect use open()
Message ID:
rt-3.6.HEAD-27190-1359569902-565.116599-75-0@perl.org
# New Ticket Created by  Michael Joyce 
# Please include the string:  [perl #116599]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116599 >


This is a bug report for perl from michael@negativespace.net,
generated with the help of perlbug 1.39 running under perl 5.16.2.


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

IO::File->open() isn't affected by use open(:std :utf8). I understand
that use open() is lexical in scope, but IO::File's open could at
least present a warning. And if that's not possible the documentation
for IO::File should be changed.

Schwern suggests this is related to autodie, and can be fixed in a
similar manner. If it cannot be fixed, then an error message or
warning would be very welcome (and would have saved a great deal of
frustration).

See also:

http://stackoverflow.com/questions/14595624/perls-iofile-and-use-open-qwutf8/14595721

https://rt.cpan.org/Public/Bug/Display.html?id=54777

Here is a test case:

#!/usr/local/bin/perl

use utf8;
use v5.16;
use strict;
use warnings;
use warnings qw(FATAL utf8);
use diagnostics;
use open qw(:std :utf8);
use charnames qw(:full :short);

use Test::More tests => 3;

my $str = "Hello ȓ (r-caret)";

eval {
  open(my $fh, '<', \$str);
  print while ($_ = $fh->getc());
  close($fh);
  pass("read utf from opened string");
};
if ($@) {
  fail("read utf8 from opened() string");
}

eval {
  use IO::File;
  my $fh = IO::File->new();
  $fh->open(\$str, '<');
  print while ($_ = $fh->getc());
  $fh->close();
  pass("read utf8 from IO::File->open() string");
};
if ($@) {
  fail("read utf8 from IO::File->open() string");
}

eval {
  use IO::File;
  my $fh = IO::File->new();
  $fh->open(\$str, '<:encoding(UTF-8)');
  print while ($_ = $fh->getc());
  $fh->close();
  pass("read utf8 from IO::File->open() string with encoding");
};
if ($@) {
  fail("read utf8 from IO::File->open() string with encoding");
}


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=medium
    module=IO::File
---
Site configuration information for perl 5.16.2:

Configured by michael at Wed Nov 21 10:46:56 PST 2012.

Summary of my perl5 (revision 5 version 16 subversion 2) configuration:
   
  Platform:
    osname=darwin, osvers=12.2.0, archname=darwin-2level
    uname='darwin bernard.local 12.2.0 darwin kernel version 12.2.0: sat aug 25 00:48:52 pdt 2012; root:xnu-2050.18.24~1release_x86_64 x86_64 '
    config_args='-de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include',
    optimize='-O3',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/opt/local/lib'
    libpth=/opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/opt/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.16.2:
    /usr/local/lib/perl5/site_perl/5.16.2/darwin-2level
    /usr/local/lib/perl5/site_perl/5.16.2
    /usr/local/lib/perl5/5.16.2/darwin-2level
    /usr/local/lib/perl5/5.16.2
    .

---
Environment for perl 5.16.2:
    DYLD_LIBRARY_PATH=:/usr/local/pgsql/lib
    HOME=/Users/michael
    LANG=en_CA
    LANGUAGE (unset)
    LC_ALL=C
    LD_LIBRARY_PATH=:/usr/local/pgsql/lib
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/local/mysql/bin:/usr/local/pgsql/bin:/Users/michael/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


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