Skip Menu |
Report information
Id: 132145
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: slaven [at] rezic.de
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Date: Fri, 22 Sep 2017 23:13:10 +0200
From: slaven [...] rezic.de
Subject: POSIX::localtime not identical to CORE::localtime
To: perlbug [...] perl.org
CC: srezic [...] cpan.org
Download (untitled) / with headers
text/plain 3.9k
This is a bug report for perl from slaven@rezic.de, generated with the help of perlbug 1.40 running under perl 5.27.4. ----------------------------------------------------------------- The POSIX Pod says for localtime: This is identical to Perl's builtin "localtime()" function for converting seconds since the epoch to a date see "localtime" in perlfunc. However, it is only identical if the optional argument is given --- POSIX::localtime fails if the argument is missing: $ perl5.27.4 -MPOSIX -e 'warn localtime(time); warn POSIX::localtime(time)' 5982322811752641 at -e line 1. 5982322811752641 at -e line 1. $ perl5.27.4 -MPOSIX -e 'warn localtime(); warn POSIX::localtime()' 2292322811752641 at -e line 1. Usage: POSIX::localtime(time) at -e line 1. This seems to be the case since 5.8.x, at least (checked with 5.8.8). I would expect that the documentation is adjusted, or that POSIX::localtime may deal with a missing argument. ----------------------------------------------------------------- --- Flags: category=library severity=low module=POSIX --- This perlbug was built using Perl 5.20.2 - Sat Jun 3 12:27:58 UTC 2017 It is being executed now by Perl 5.27.4 - Thu Sep 21 00:25:50 CEST 2017. Site configuration information for perl 5.27.4: Configured by eserte at Thu Sep 21 00:25:50 CEST 2017. Summary of my perl5 (revision 5 version 27 subversion 4) configuration: Platform: osname=linux osvers=3.16.0-4-amd64 archname=x86_64-linux uname='linux cabulja 3.16.0-4-amd64 #1 smp debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 gnulinux ' config_args='-ds -e -Dprefix=/opt/perl-5.27.4 -Dusedevel -Dusemallocwrap=no -Dcf_email=srezic@cpan.org' hint=recommended useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='cc' ccflags ='-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='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='' gccversion='4.9.2' 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-linux-gnu/4.9/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.19.so so=so useshrplib=false libperl=libperl.a gnulibc_version='2.19' 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' --- @INC for perl 5.27.4: /opt/perl-5.27.4/lib/site_perl/5.27.4/x86_64-linux /opt/perl-5.27.4/lib/site_perl/5.27.4 /opt/perl-5.27.4/lib/5.27.4/x86_64-linux /opt/perl-5.27.4/lib/5.27.4 --- Environment for perl 5.27.4: HOME=/home/eserte LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/eserte/bin/linux-gnu:/home/eserte/bin/sh:/home/eserte/bin:/home/eserte/bin/pistachio-perl/bin:/usr/games:/home/eserte/devel PERLDOC=-MPod::Perldoc::ToTextOverstrike PERL_BADLANG (unset) SHELL=/bin/zsh
RT-Send-CC: perl5-porters [...] perl.org
On Fri, 22 Sep 2017 21:13:47 GMT, slaven@rezic.de wrote: Show quoted text
> > This is a bug report for perl from slaven@rezic.de, > generated with the help of perlbug 1.40 running under perl 5.27.4. > > > ----------------------------------------------------------------- > The POSIX Pod says for localtime: > > This is identical to Perl's builtin "localtime()" function for > converting seconds since the epoch to a date see "localtime" in > perlfunc. > > However, it is only identical if the optional argument is given --- > POSIX::localtime fails if the argument is missing: > > $ perl5.27.4 -MPOSIX -e 'warn localtime(time); warn > POSIX::localtime(time)' > 5982322811752641 at -e line 1. > 5982322811752641 at -e line 1. > > $ perl5.27.4 -MPOSIX -e 'warn localtime(); warn POSIX::localtime()' > 2292322811752641 at -e line 1. > Usage: POSIX::localtime(time) at -e line 1. > > This seems to be the case since 5.8.x, at least (checked with 5.8.8). > > I would expect that the documentation is adjusted, or that > POSIX::localtime > may deal with a missing argument. > >
This is a problem more general than simply POSIX::localtime(). I suspect it affects all POSIX::*() functions which claim to be identical to the Perl builtins of the same name and which, in core, work with an implicit $_. The POSIX::* functions appear to require an explicit argument. This makes sense to me because the POSIX specifications don't have the equivalent of our topic variable. I grepped the CPAN POSIX documentation for those functions which are claimed to work the same in both places. See attachment 132145-posix-identical-to-perl.txt. I then began to write a test file comparing the builtins and the POSIX variants, with and without explicit arguments. See attachment 132145-core-vs-posix.t. (This test file should be extended to all functions named in the other attachment.) I think that we should simply change the documentation as needed to indicate this one difference in behaviour between builtins and POSIX. Thank you very much. -- James E Keenan (jkeenan@cpan.org)
Subject: 132145-core-vs-posix.t
# perl use strict; use warnings; use 5.10.1; use Carp; use POSIX (); use File::Spec; use File::Temp qw( tempfile ); use Cwd; use Test::More qw( no_plan ); my $val; { # abs $val = -3; $_ = $val; is(abs($val), POSIX::abs($val), 'abs and POSIX::abs match when each is provided with a value'); { local $@; eval { is(abs(), POSIX::abs(), 'abs with $_'); }; chomp($@); pass("POSIX::abs requires explicit argument: $@"); } } { # alarm my ($start_time, $end_time, $core_msg, $posix_msg); $val = 3; local $@; eval { local $SIG{ALRM} = sub { $end_time = time; die "ALARM!\n" }; $start_time = time; alarm $val; # perlfunc recommends against using sleep in combination with alarm. 1 while (($end_time = time) - $start_time < 6); alarm 0; }; alarm 0; $core_msg = $@; local $@; eval { local $SIG{ALRM} = sub { $end_time = time; die "ALARM!\n" }; $start_time = time; POSIX::alarm $val; # perlfunc recommends against using sleep in combination with POSIX::alarm. 1 while (($end_time = time) - $start_time < 6); POSIX::alarm 0; }; POSIX::alarm 0; $posix_msg = $@; is($posix_msg, $core_msg, "alarm and POSIX::alarm match when each is provided with a value"); ($posix_msg, $core_msg) = (undef) x 2; $_ = $val; local $@; eval { local $SIG{ALRM} = sub { $end_time = time; die "ALARM!\n" }; $start_time = time; alarm; # perlfunc recommends against using sleep in combination with alarm. 1 while (($end_time = time) - $start_time < 6); alarm 0; }; alarm 0; $core_msg = $@; { local $@; eval { local $SIG{ALRM} = sub { $end_time = time; die "ALARM!\n" }; $start_time = time; POSIX::alarm; }; chomp($@); pass("POSIX::alarm requires explicit argument: $@"); }; } { # atan2 my ($y, $x); ($y, $x) = (3, 1); is(POSIX::atan2($y, $x), atan2($y, $x), "atan2 and POSIX::atan2 match; need 2 args"); } { # chdir skip '$ENV{HOME} not found', 2 unless $ENV{HOME}; my $homedir = $ENV{HOME}; my $tdir = File::Spec->tmpdir(); my ($adir, $bdir); chdir($tdir) or croak "Unable to change to a different starting directory"; chdir($homedir); $adir = getcwd; chdir($tdir) or croak "Unable to change to a different starting directory"; POSIX::chdir($homedir); $bdir = getcwd; is($bdir, $adir, "chdir and POSIX::chdir match when each is provided with a value"); ($adir, $bdir) = (undef) x 2; chdir($tdir) or croak "Unable to change to a different starting directory"; chdir(); $adir = getcwd; { local $@; chdir($tdir) or croak "Unable to change to a different starting directory"; eval { POSIX::chdir(); }; chomp($@); pass("POSIX::chdir requires explicit argument: $@"); } } { # chmod my ($fh1, $tfile1) = tempfile(UNLINK => 1); my ($fh2, $tfile2) = tempfile(UNLINK => 1); my ($acount, $bcount); chmod 0644, $tfile1, $tfile2; $acount = chmod 0664, $tfile1, $tfile2; { chmod 0644, $tfile1, $tfile2; local $@; eval { $bcount = POSIX::chmod 0664, $tfile1, $tfile2; }; chomp($@); pass("POSIX::chmod appears to take only one argument after mode: $@"); } } { # localtime my (@lt, @plt); my $val; $val = 300_000; @lt = localtime($val); @plt = POSIX::localtime($val); is_deeply(\@plt, \@lt, "localtime and POSIX::localtime match when each is provided explicit value"); undef(@lt); undef(@plt); $_ = $val; @lt = localtime(); { local $@; eval { @plt = POSIX::localtime(); }; chomp($@); pass("POSIX::localtime requires explicit argument: $@"); } }
Subject: 132145-posix-identical-to-perl.txt
information on most features. Consult perlfunc for functions which are noted as being identical to Perl's builtin functions. "abs" This is identical to Perl's builtin "abs()" function, returning "alarm" This is identical to Perl's builtin "alarm()" function, either for "atan2" This is identical to Perl's builtin "atan2()" function, returning "chdir" This is identical to Perl's builtin "chdir()" function, allowing "chmod" This is identical to Perl's builtin "chmod()" function, allowing "chown" This is identical to Perl's builtin "chown()" function, allowing "closedir" This is identical to Perl's builtin "closedir()" function for "cos" This is identical to Perl's builtin "cos()" function, for "exit" This is identical to Perl's builtin "exit()" function for exiting "exp" This is identical to Perl's builtin "exp()" function for returning "fabs" This is identical to Perl's builtin "abs()" function for returning "fcntl" This is identical to Perl's builtin "fcntl()" function, see "fork" This is identical to Perl's builtin "fork()" function for "getc" This is identical to Perl's builtin "getc()" function, see "getc" "getgrgid" This is identical to Perl's builtin "getgrgid()" function for "getgrnam" This is identical to Perl's builtin "getgrnam()" function for "getlogin" This is identical to Perl's builtin "getlogin()" function for "getpgrp" This is identical to Perl's builtin "getpgrp()" function for "getppid" This is identical to Perl's builtin "getppid()" function for "getpwnam" This is identical to Perl's builtin "getpwnam()" function for "getpwuid" This is identical to Perl's builtin "getpwuid()" function for "gmtime" This is identical to Perl's builtin "gmtime()" function for "kill" This is identical to Perl's builtin "kill()" function for sending "link" This is identical to Perl's builtin "link()" function for creating "localtime" This is identical to Perl's builtin "localtime()" function for "log" This is identical to Perl's builtin "log()" function, returning "mkdir" This is identical to Perl's builtin "mkdir()" function for "readdir" This is identical to Perl's builtin "readdir()" function for "remove" This is identical to Perl's builtin "unlink()" function for "rename" This is identical to Perl's builtin "rename()" function for "rewinddir" This is identical to Perl's builtin "rewinddir()" function for "rmdir" This is identical to Perl's builtin "rmdir()" function for "sin" This is identical to Perl's builtin "sin()" function for returning "sleep" This is functionally identical to Perl's builtin "sleep()" "sqrt" This is identical to Perl's builtin "sqrt()" function. for "stat" This is identical to Perl's builtin "stat()" function for "strstr" This is identical to Perl's builtin "index()" function, see "system" This is identical to Perl's builtin "system()" function, see "time" This is identical to Perl's builtin "time()" function for "umask" This is identical to Perl's builtin "umask()" function for setting "unlink" This is identical to Perl's builtin "unlink()" function for "utime" This is identical to Perl's builtin "utime()" function for "wait" This is identical to Perl's builtin "wait()" function, see "wait"
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 229b
On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote: Show quoted text
> I think that we should simply change the documentation as needed to > indicate this one difference in behaviour between builtins and POSIX.
I agree. -- Father Chrysostomos
From: Sawyer X <xsawyerx [...] gmail.com>
Subject: Re: [perl #132145] POSIX::localtime not identical to CORE::localtime
Date: Mon, 25 Sep 2017 12:37:07 +0200
To: perlbug-followup [...] perl.org
CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 288b
On 09/24/2017 10:21 PM, Father Chrysostomos via RT wrote: Show quoted text
> On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote:
>> I think that we should simply change the documentation as needed to >> indicate this one difference in behaviour between builtins and POSIX.
> I agree. >
I agree as well.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.8k
On Mon, 25 Sep 2017 10:37:31 GMT, xsawyerx@gmail.com wrote: Show quoted text
> > > On 09/24/2017 10:21 PM, Father Chrysostomos via RT wrote:
> > On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote:
> >> I think that we should simply change the documentation as needed to > >> indicate this one difference in behaviour between builtins and POSIX.
> > I agree. > >
> > I agree as well.
So here is a plan. 1. We should work through the list of POSIX::* functions cited in attachment https://rt.perl.org/Ticket/Attachment/1493177/804012/132145-posix-identical-to-perl.txt, updating the documentation to indicate how the POSIX function differs from the core function. 2. Where necessary, we should add tests which demonstrate that difference. I say "where necessary" because it turns out that the fact that some POSIX::* functions fail if provided 0 arguments is already tested in ext/POSIX/t/usage.t. ##### $> cd t; ./perl harness -v ../ext/POSIX/t/usage.t; cd - ... ok 230 - POSIX::localtime for 0 arguments gives expected error ok 231 - POSIX::localtime(1, 2) fails ok 232 - POSIX::localtime for 2 arguments gives expected error ok 233 - POSIX::localtime(1, 2, 3) fails ok 234 - POSIX::localtime for 3 arguments gives expected error ##### 3. I'll start this off with the case of 'POSIX::localtime', since that was the original concern of this RT. Documentation updated in commit dc416353138cab69d334678ddd9a81b590030ef2. 4. Since there are quite a few POSIX::* functions whose documentation needs to be patched, we can do this in small batches. Anyone who hasn't had a commit to the core distribution recently (or ever) is encouraged to pick one of the remaining functions and write a documentation + test patch along the lines of mine for 'localtime' (assuming people don't have objections to that patch). Thank you very much. -- James E Keenan (jkeenan@cpan.org)
Date: Tue, 26 Sep 2017 15:21:01 +0200
To: James E Keenan via RT <perlbug-followup [...] perl.org>
Subject: Re: [perl #132145] POSIX::localtime not identical to CORE::localtime
From: Mark Overmeer <solutions [...] overmeer.net>
Download (untitled) / with headers
text/plain 947b
* James E Keenan via RT (perlbug-followup@perl.org) [170926 13:03]: Show quoted text
> 1. We should work through the list of POSIX::* functions cited in attachment https://rt.perl.org/Ticket/Attachment/1493177/804012/132145-posix-identical-to-perl.txt, updating the documentation to indicate how the POSIX function differs from the core function.
Do you know about this manual page: https://metacpan.org/pod/release/MARKOV/POSIX-1003-0.99_07/lib/POSIX/Overview.pod There are some warnings in there. It started off with my rewrite of the POSIX.pm manual page, which never went into core. Find attached. It may be of help to you. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Download POSIX.pod
text/plain 57.8k

Message body is not shown because sender requested not to inline it.

From: Sawyer X <xsawyerx [...] gmail.com>
Subject: Re: [perl #132145] POSIX::localtime not identical to CORE::localtime
CC: perl5-porters [...] perl.org
To: perlbug-followup [...] perl.org
Date: Wed, 27 Sep 2017 14:51:37 +0200
Download (untitled) / with headers
text/plain 2.3k
On 09/26/2017 03:03 PM, James E Keenan via RT wrote: Show quoted text
> On Mon, 25 Sep 2017 10:37:31 GMT, xsawyerx@gmail.com wrote:
>> >> On 09/24/2017 10:21 PM, Father Chrysostomos via RT wrote:
>>> On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote:
>>>> I think that we should simply change the documentation as needed to >>>> indicate this one difference in behaviour between builtins and POSIX.
>>> I agree. >>>
>> I agree as well.
> So here is a plan. > > 1. We should work through the list of POSIX::* functions cited in attachment https://rt.perl.org/Ticket/Attachment/1493177/804012/132145-posix-identical-to-perl.txt, updating the documentation to indicate how the POSIX function differs from the core function. > > 2. Where necessary, we should add tests which demonstrate that difference. I say "where necessary" because it turns out that the fact that some POSIX::* functions fail if provided 0 arguments is already tested in ext/POSIX/t/usage.t. > > ##### > $> cd t; ./perl harness -v ../ext/POSIX/t/usage.t; cd - > ... > ok 230 - POSIX::localtime for 0 arguments gives expected error > ok 231 - POSIX::localtime(1, 2) fails > ok 232 - POSIX::localtime for 2 arguments gives expected error > ok 233 - POSIX::localtime(1, 2, 3) fails > ok 234 - POSIX::localtime for 3 arguments gives expected error > ##### > > 3. I'll start this off with the case of 'POSIX::localtime', since that was the original concern of this RT. Documentation updated in commit dc416353138cab69d334678ddd9a81b590030ef2. > > 4. Since there are quite a few POSIX::* functions whose documentation needs to be patched, we can do this in small batches. Anyone who hasn't had a commit to the core distribution recently (or ever) is encouraged to pick one of the remaining functions and write a documentation + test patch along the lines of mine for 'localtime' (assuming people don't have objections to that patch).
That sounds like a good plan to me. With regards to step 2, it might be easier to add the test again automatically than curate every test to see if it covers that. Create a test for all of them in a new file. The testing part can at least be automated but perhaps some of the rest too. Adding a single line that indicates whether this uses zero or more parameters and how it compares to core (akin to the one you generarted) might be sufficient. I wish we could track this better. Perhaps with a GH issue? Thanks, Jim!
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.8k
On Wed, 27 Sep 2017 12:51:55 GMT, xsawyerx@gmail.com wrote: Show quoted text
> > On 09/26/2017 03:03 PM, James E Keenan via RT wrote:
> > On Mon, 25 Sep 2017 10:37:31 GMT, xsawyerx@gmail.com wrote:
> >> > >> On 09/24/2017 10:21 PM, Father Chrysostomos via RT wrote:
> >>> On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote:
> >>>> I think that we should simply change the documentation as needed > >>>> to > >>>> indicate this one difference in behaviour between builtins and > >>>> POSIX.
> >>> I agree. > >>>
> >> I agree as well.
> > So here is a plan. > > > > 1. We should work through the list of POSIX::* functions cited in > > attachment > > https://rt.perl.org/Ticket/Attachment/1493177/804012/132145-posix- > > identical-to-perl.txt, updating the documentation to indicate how the > > POSIX function differs from the core function. > > > > 2. Where necessary, we should add tests which demonstrate that > > difference. I say "where necessary" because it turns out that the > > fact that some POSIX::* functions fail if provided 0 arguments is > > already tested in ext/POSIX/t/usage.t. > > > > ##### > > $> cd t; ./perl harness -v ../ext/POSIX/t/usage.t; cd - > > ... > > ok 230 - POSIX::localtime for 0 arguments gives expected error > > ok 231 - POSIX::localtime(1, 2) fails > > ok 232 - POSIX::localtime for 2 arguments gives expected error > > ok 233 - POSIX::localtime(1, 2, 3) fails > > ok 234 - POSIX::localtime for 3 arguments gives expected error > > ##### > > > > 3. I'll start this off with the case of 'POSIX::localtime', since > > that was the original concern of this RT. Documentation updated in > > commit dc416353138cab69d334678ddd9a81b590030ef2. > > > > 4. Since there are quite a few POSIX::* functions whose documentation > > needs to be patched, we can do this in small batches. Anyone who > > hasn't had a commit to the core distribution recently (or ever) is > > encouraged to pick one of the remaining functions and write a > > documentation + test patch along the lines of mine for 'localtime' > > (assuming people don't have objections to that patch).
> > > That sounds like a good plan to me. > > With regards to step 2, it might be easier to add the test again > automatically than curate every test to see if it covers that. Create > a > test for all of them in a new file. >
The way I read the existing tests, it seems that this automation has already been accomplished by Nicholas Clark back in 2011 in ext/POSIX/t/usage.t. What do you think is needed above and beyond that? Show quoted text
> The testing part can at least be automated but perhaps some of the > rest > too. Adding a single line that indicates whether this uses zero or > more > parameters and how it compares to core (akin to the one you > generarted) > might be sufficient. > > I wish we could track this better. Perhaps with a GH issue? > > Thanks, Jim!
-- James E Keenan (jkeenan@cpan.org)
CC: perl5-porters [...] perl.org
To: perlbug-followup [...] perl.org
Date: Wed, 27 Sep 2017 19:02:26 +0200
Subject: Re: [perl #132145] POSIX::localtime not identical to CORE::localtime
From: Sawyer X <xsawyerx [...] gmail.com>
Download (untitled) / with headers
text/plain 2.6k
On 09/27/2017 04:07 PM, James E Keenan via RT wrote: Show quoted text
> On Wed, 27 Sep 2017 12:51:55 GMT, xsawyerx@gmail.com wrote:
>> On 09/26/2017 03:03 PM, James E Keenan via RT wrote:
>>> On Mon, 25 Sep 2017 10:37:31 GMT, xsawyerx@gmail.com wrote:
>>>> On 09/24/2017 10:21 PM, Father Chrysostomos via RT wrote:
>>>>> On Sun, 24 Sep 2017 11:17:07 -0700, jkeenan wrote:
>>>>>> I think that we should simply change the documentation as needed >>>>>> to >>>>>> indicate this one difference in behaviour between builtins and >>>>>> POSIX.
>>>>> I agree. >>>>>
>>>> I agree as well.
>>> So here is a plan. >>> >>> 1. We should work through the list of POSIX::* functions cited in >>> attachment >>> https://rt.perl.org/Ticket/Attachment/1493177/804012/132145-posix- >>> identical-to-perl.txt, updating the documentation to indicate how the >>> POSIX function differs from the core function. >>> >>> 2. Where necessary, we should add tests which demonstrate that >>> difference. I say "where necessary" because it turns out that the >>> fact that some POSIX::* functions fail if provided 0 arguments is >>> already tested in ext/POSIX/t/usage.t. >>> >>> ##### >>> $> cd t; ./perl harness -v ../ext/POSIX/t/usage.t; cd - >>> ... >>> ok 230 - POSIX::localtime for 0 arguments gives expected error >>> ok 231 - POSIX::localtime(1, 2) fails >>> ok 232 - POSIX::localtime for 2 arguments gives expected error >>> ok 233 - POSIX::localtime(1, 2, 3) fails >>> ok 234 - POSIX::localtime for 3 arguments gives expected error >>> ##### >>> >>> 3. I'll start this off with the case of 'POSIX::localtime', since >>> that was the original concern of this RT. Documentation updated in >>> commit dc416353138cab69d334678ddd9a81b590030ef2. >>> >>> 4. Since there are quite a few POSIX::* functions whose documentation >>> needs to be patched, we can do this in small batches. Anyone who >>> hasn't had a commit to the core distribution recently (or ever) is >>> encouraged to pick one of the remaining functions and write a >>> documentation + test patch along the lines of mine for 'localtime' >>> (assuming people don't have objections to that patch).
>> >> That sounds like a good plan to me. >> >> With regards to step 2, it might be easier to add the test again >> automatically than curate every test to see if it covers that. Create >> a >> test for all of them in a new file. >>
> The way I read the existing tests, it seems that this automation has already been accomplished by Nicholas Clark back in 2011 in ext/POSIX/t/usage.t. > > What do you think is needed above and beyond that?
Nothing, I guess. I thought you wanted to add more tests and documentation and I was commenting that it might not need to be a manual process.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.2k
On Sun, 24 Sep 2017 18:17:07 GMT, jkeenan wrote: Show quoted text
> On Fri, 22 Sep 2017 21:13:47 GMT, slaven@rezic.de wrote:
> > > > This is a bug report for perl from slaven@rezic.de, > > generated with the help of perlbug 1.40 running under perl 5.27.4. > > > > > > ----------------------------------------------------------------- > > The POSIX Pod says for localtime: > > > > This is identical to Perl's builtin "localtime()" function for > > converting seconds since the epoch to a date see "localtime" in > > perlfunc. > > > > However, it is only identical if the optional argument is given --- > > POSIX::localtime fails if the argument is missing: > > > > $ perl5.27.4 -MPOSIX -e 'warn localtime(time); warn > > POSIX::localtime(time)' > > 5982322811752641 at -e line 1. > > 5982322811752641 at -e line 1. > > > > $ perl5.27.4 -MPOSIX -e 'warn localtime(); warn POSIX::localtime()' > > 2292322811752641 at -e line 1. > > Usage: POSIX::localtime(time) at -e line 1. > > > > This seems to be the case since 5.8.x, at least (checked with 5.8.8). > > > > I would expect that the documentation is adjusted, or that > > POSIX::localtime > > may deal with a missing argument. > > > >
> > This is a problem more general than simply POSIX::localtime(). I > suspect it affects all POSIX::*() functions which claim to be > identical to the Perl builtins of the same name and which, in core, > work with an implicit $_. The POSIX::* functions appear to require an > explicit argument. > > This makes sense to me because the POSIX specifications don't have the > equivalent of our topic variable. > > I grepped the CPAN POSIX documentation for those functions which are > claimed to work the same in both places. See attachment 132145-posix- > identical-to-perl.txt. > > I then began to write a test file comparing the builtins and the POSIX > variants, with and without explicit arguments. See attachment 132145- > core-vs-posix.t. (This test file should be extended to all functions > named in the other attachment.) > > I think that we should simply change the documentation as needed to > indicate this one difference in behaviour between builtins and POSIX. > > Thank you very much.
Partially done in commit bda53d3ed47d5776c4a1b88c0b7cfb484f5644be. -- James E Keenan (jkeenan@cpan.org)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org