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

Perl6::Say fails tests with perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32 #9789

Closed
p5pRT opened this issue Jul 7, 2009 · 7 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Jul 7, 2009

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

Searchable as RT67302$

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2009

From acme@astray.com

Perl6​::Say fails tests with
perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32 where they pass with a
real 5.10.0. It boils down to​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*]

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*
]

The outputs should be the same. They are different. That's as far as I have got.

The modules ar ethe same version on both​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; say $Perl6​::Say​::VERSION . ", " .
$IO​::Capture​::VERSION'
0.15, 0.05

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; say $Perl6​::Say​::VERSION . ", " .
$IO​::Capture​::VERSION'
0.15, 0.05

My 5.10.0​:

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=linux, osvers=2.6.28-11-generic, archname=i686-linux
  uname='linux tigger 2.6.28-11-generic #42-ubuntu smp fri apr 17
01​:57​:59 utc 2009 i686 gnulinux '
  config_args='-ds -e -Dprefix=/home/acme/perl-5.10.0'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.3.3', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.9'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
  USE_LARGE_FILES USE_PERLIO
  Built under linux
  Compiled at May 30 2009 09​:44​:46
  %ENV​:
  PERL5LIB=""
  PERL5OPT=""
  PERL5_CPANPLUS_IS_RUNNING="15515"
  PERL5_CPAN_IS_RUNNING="15515"
  @​INC​:
  /home/acme/perl-5.10.0/lib/5.10.0/i686-linux
  /home/acme/perl-5.10.0/lib/5.10.0
  /home/acme/perl-5.10.0/lib/site_perl/5.10.0/i686-linux
  /home/acme/perl-5.10.0/lib/site_perl/5.10.0
  .

My perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32​:

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:

  Platform​:
  osname=linux, osvers=2.6.28-13-generic, archname=i686-linux
  uname='linux tigger 2.6.28-13-generic #45-ubuntu smp tue jun 30
19​:49​:51 utc 2009 i686 gnulinux '
  config_args='-ds -e -Dprefix=/home/acme/perlsnapshot'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.3.3', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/lib64
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.9'
  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'

Characteristics of this binary (from libperl)​:
  Compile-time options​: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
  USE_LARGE_FILES USE_PERLIO
  Built under linux
  Compiled at Jul 7 2009 20​:13​:38
  %ENV​:
  PERL5LIB=""
  PERL5OPT=""
  PERL5_CPANPLUS_IS_RUNNING="15515"
  PERL5_CPAN_IS_RUNNING="15515"
  @​INC​:
  /home/acme/perlsnapshot/lib/5.10.0/i686-linux
  /home/acme/perlsnapshot/lib/5.10.0
  /home/acme/perlsnapshot/lib/site_perl/5.10.0/i686-linux
  /home/acme/perlsnapshot/lib/site_perl/5.10.0
  .

Enjoy, Léon

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2009

From p5p@spam.wizbit.be

On Tue Jul 07 13​:17​:33 2009, acme wrote​:

Perl6​::Say fails tests with
perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32 where they pass with a
real 5.10.0. It boils down to​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*]

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*
]

The outputs should be the same. They are different. That's as far as I
have got.

On perl-5.10.0 IO​::Handle​::say looked like​:

sub say {
  @​_ or croak 'usage​: $io->say(ARGS)';
  my $this = shift;
  print $this @​_, "\n";
}

This was not correct since now the output really is​: join("", @​_, $,
"\n", $\);

This changed and eventually ended with​:

http​://perl5.git.perl.org/perl.git/blobdiff/
85c5664..841835c​:/
ext/IO/lib/IO/Handle.pm

It now reads (in blead and maint)​:

sub say {
  @​_ or croak 'usage​: $io->say(ARGS)';
  my $this = shift;
  local $\ = "\n";
  print $this @​_;
}

Which is the correct behaviour.

But this change exposes a bug in Perl6​::Say​::say and in
IO​::Capture​::Tie_STDx​::PRINT.

1) Perl6​::Say​::say is implemented as​:
sub say {
  ...
  my $res = print {$handle} @​_, "\n";

Which is not correct when $, and $\ are not set to the default value.
For example​:

$ perl -MPerl6​::Say -we '$,=" FS ";$\=" RS ";say "foo";printf "\n";'
foo FS
RS

vs

$ perl-5.10.0 -wE '$,=" FS ";$\=" RS ";say "foo";printf "\n";'
foo

2) IO​::Capture​::Tie_STDx​::PRINT

sub PRINT {
  my $self = shift;
  push @​$self, join '',@​_;
}

This is not correct.
It completly ignores the record separtor.
It should be​: push @​$self, join '',@​_,$\;

Best Regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2009

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

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2009

From p5p@spam.wizbit.be

On Tue Jul 07 14​:29​:45 2009, animator wrote​:

On Tue Jul 07 13​:17​:33 2009, acme wrote​:

Perl6​::Say fails tests with
perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32 where they pass with a
real 5.10.0. It boils down to​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*]

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*
]

The outputs should be the same. They are different. That's as far as
I
have got.

On perl-5.10.0 IO​::Handle​::say looked like​:

sub say {
@​_ or croak 'usage​: $io->say(ARGS)';
my $this = shift;
print $this @​_, "\n";
}

This was not correct since now the output really is​: join("", @​_, $,
"\n", $\);

This changed and eventually ended with​:

http​://perl5.git.perl.org/perl.git/blobdiff/

85c5664..841835c​:/

ext/IO/lib/IO/Handle.pm

It now reads (in blead and maint)​:

sub say {
@​_ or croak 'usage​: $io->say(ARGS)';
my $this = shift;
local $\ = "\n";
print $this @​_;
}

Which is the correct behaviour.

But this change exposes a bug in Perl6​::Say​::say and in
IO​::Capture​::Tie_STDx​::PRINT.

1) Perl6​::Say​::say is implemented as​:
sub say {
...
my $res = print {$handle} @​_, "\n";

Which is not correct when $, and $\ are not set to the default value.
For example​:

$ perl -MPerl6​::Say -we '$,=" FS ";$\=" RS ";say "foo";printf "\n";'
foo FS
RS

vs

$ perl-5.10.0 -wE '$,=" FS ";$\=" RS ";say "foo";printf "\n";'
foo

2) IO​::Capture​::Tie_STDx​::PRINT

sub PRINT {
my $self = shift;
push @​$self, join '',@​_;
}

This is not correct.
It completly ignores the record separtor.
It should be​: push @​$self, join '',@​_,$\;

One more thought on this​:

Perl6​::Say v0.02 used​:

print {$fh} @​_, defined $\ ? "" : "\n"

Perl6​::Say v0.03 uses​:

print {$handle} @​_, "\n";

The Changelog reads​:

Changed $\ interaction in line with changes in Perl 6 design (C<say
@​stuff> is now always equivalent to C<print @​stuff, "\n">)

So the real question​:

How does say behave in Perl 6? (And/or does Perl 6 has a field and
output record separator?)

Best regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2013

From @jkeenan

On Tue Jul 07 13​:17​:33 2009, acme wrote​:

Perl6​::Say fails tests with
perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32 where they pass with a
real 5.10.0. It boils down to​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*]

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; my $capture = IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*
]

The outputs should be the same. They are different. That's as far as I
have got.

The modules ar ethe same version on both​:

/home/acme/perlsnapshot/bin/perl -Ilib -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; say $Perl6​::Say​::VERSION . ", " .
$IO​::Capture​::VERSION'
0.15, 0.05

/home/acme/perl-5.10.0/bin/perl -e 'use Perl6​::Say; use
IO​::Capture​::Stdout; say $Perl6​::Say​::VERSION . ", " .
$IO​::Capture​::VERSION'
0.15, 0.05

My 5.10.0​:

Summary of my perl5 (revision 5 version 10 subversion 0)
configuration​:
Platform​:
osname=linux, osvers=2.6.28-11-generic, archname=i686-linux
uname='linux tigger 2.6.28-11-generic #42-ubuntu smp fri apr 17
01​:57​:59 utc 2009 i686 gnulinux '
config_args='-ds -e -Dprefix=/home/acme/perl-5.10.0'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define,
usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='4.3.3', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries​:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.9'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
Compile-time options​: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO
Built under linux
Compiled at May 30 2009 09​:44​:46
%ENV​:
PERL5LIB=""
PERL5OPT=""
PERL5_CPANPLUS_IS_RUNNING="15515"
PERL5_CPAN_IS_RUNNING="15515"
@​INC​:
/home/acme/perl-5.10.0/lib/5.10.0/i686-linux
/home/acme/perl-5.10.0/lib/5.10.0
/home/acme/perl-5.10.0/lib/site_perl/5.10.0/i686-linux
/home/acme/perl-5.10.0/lib/site_perl/5.10.0
.

My perl-5.10.0-GitLive-maint-5.10-1551-gadd0c32​:

Summary of my perl5 (revision 5 version 10 subversion 0)
configuration​:

Platform​:
osname=linux, osvers=2.6.28-13-generic, archname=i686-linux
uname='linux tigger 2.6.28-13-generic #45-ubuntu smp tue jun 30
19​:49​:51 utc 2009 i686 gnulinux '
config_args='-ds -e -Dprefix=/home/acme/perlsnapshot'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define,
usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.3.3', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries​:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.9'
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'

Characteristics of this binary (from libperl)​:
Compile-time options​: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO
Built under linux
Compiled at Jul 7 2009 20​:13​:38
%ENV​:
PERL5LIB=""
PERL5OPT=""
PERL5_CPANPLUS_IS_RUNNING="15515"
PERL5_CPAN_IS_RUNNING="15515"
@​INC​:
/home/acme/perlsnapshot/lib/5.10.0/i686-linux
/home/acme/perlsnapshot/lib/5.10.0
/home/acme/perlsnapshot/lib/site_perl/5.10.0/i686-linux
/home/acme/perlsnapshot/lib/site_perl/5.10.0
.

Enjoy, L�on

I reviewed this older ticket tonight. I should first note that it is of
no practical consequence, since the 'say' function is a Perl built-in as
of Perl 5.10.0.

That being said, my hunch is that the problem Léon describes is a side
effect of the CPAN module he used to capture the output. For some
reason, IO​::Capture​::Stdout behaves differently pre- and post-Perl 5.10.
But if we use a different capturing mechanism, we get consistent
results both pre- and post-5.10.

Using IO​::Capture​::Stdout​:

##########

$ /usr/bin/perl -v
This is perl, v5.8.6 built for darwin-thread-multi-2level
(with 5 registered patches, see perl -V for more detail)
...

$ /usr/bin/perl -Ilib -I/usr/local/lib/perl5/site_perl/5.10.0
-MPerl6​::Say -MIO​::Capture​::Stdout -e 'my $capture =
IO​::Capture​::Stdout->new();$capture->start; say STDOUT "*";
$capture->stop; print "[" .
$capture->read . "]" '
[*
]

$ perl -v
This is perl 5, version 16, subversion 0 (v5.16.0) built for darwin-2level
...

$ perl -MPerl6​::Say -MIO​::Capture​::Stdout -e 'my $capture =
IO​::Capture​::Stdout->new();
$capture->start; say STDOUT "*"; $capture->stop; print "[" .
$capture->read . "]" '
[*]

##########

Now, using IO​::CaptureOutput​::capture()​:

Perl 5.8.6

$ /usr/bin/perl -I/usr/local/lib/perl5/site_perl/5.10.0 -MPerl6​::Say
-MIO​::CaptureOutput -e 'IO​::CaptureOutput​::capture(sub {say STDOUT
"*";}, \$stdout, \$stderr); print "[".$stdout."]";'
[*
]

Perl 5.16.0

$ perl -MPerl6​::Say -MIO​::CaptureOutput -e
'IO​::CaptureOutput​::capture(sub {say STDOUT "*";}, \$stdout, \$stderr);
print "[".$stdout."]";'
[*
]

##########

With IO​::CaptureOutput we get consistent results for Perl6​::Say across
Perl versions. Inference​: the problem lies in IO​::Capture​::Stdout more
than in Perl.

I will close this ticket in 7 days unless someone wishes to take it over.

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Mar 2, 2013

From @jkeenan

On Fri Feb 22 19​:30​:45 2013, jkeenan wrote​:

With IO​::CaptureOutput we get consistent results for Perl6​::Say across
Perl versions. Inference​: the problem lies in IO​::Capture​::Stdout more
than in Perl.

I will close this ticket in 7 days unless someone wishes to take it over.

Thank you very much.
Jim Keenan

Closing as scheduled.

@p5pRT
Copy link
Author

p5pRT commented Mar 2, 2013

@jkeenan - 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