Code Monkey home page Code Monkey logo

autodie's People

Contributors

afresh1 avatar arc avatar autarch avatar bugdebugger avatar cebjyre avatar craigberry avatar dolmen avatar dsteinbrunner avatar fgasper avatar genio avatar haarg avatar hugmeir avatar iabyn avatar jdhedden avatar karenetheridge avatar kraai avatar lx avatar mauzo avatar mla avatar mvgrimes avatar nanis avatar nthykier avatar ntyni avatar oschwald avatar pjf avatar rsrchboy avatar schwern avatar stennie avatar toddr avatar tonycoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autodie's Issues

Make autodie work with objects.

nothingmuch had a great syntax for this:

(4:29:03 PM) nothingmuch: my $handle = autodie->wrap($file->openw, @import_args);
(4:29:11 PM) nothingmuch: $handle->print("foo");
(4:29:27 PM) nothingmuch: or something similar

kill(0, $pid) should not die [rt.cpan.org #86238]

Migrated from rt.cpan.org#86238 (status was 'open')

Requestors:

From [email protected] on 2013-06-18 14:54:44
:

kill(0, $pid) is often used to check if a process exists and can be signaled.  The current version of autodie (2.19) dies if $pid doesn't exist or can't be signaled by the current user.  When the signal number is 0, autodie should not die.

From [email protected] on 2014-10-07 15:12:11
:

On Tue Jun 18 10:54:44 2013, JSIRACUSA wrote:
> kill(0, $pid) is often used to check if a process exists and can be
> signaled.  The current version of autodie (2.19) dies if $pid doesn't
> exist or can't be signaled by the current user.  When the signal
> number is 0, autodie should not die.

For reference: This is (now?) also filed on github as issue #47[1]

~Niels

[1] https://github.com/pjf/autodie/issues/47



From [email protected] on 2019-06-05 16:17:51
:

On Tue Oct 07 11:12:11 2014, [email protected] wrote:

> For reference: This is (now?) also filed on github as issue #47[1]


Still happening nearly 5 years after this announcement.  Will the fix be rolled out any time soon?


From [email protected] on 2019-06-05 16:22:49
:

njh@microcenter:/tmp$ cat autodie 
#!/usr/bin/env perl

use strict;
use warnings;
use autodie qw(:all);

if(kill(0, 10000)) {
	print "there\n";
}

print "done\n";
njh@microcenter:/tmp$ ./autodie 
Can't kill('0', '10000'): No such process at ./autodie line 7
njh@microcenter:/tmp$ 



Installing failed

Hi, Paul!

I found that while installing module autodie module Pod::Coverage::TrustPod isn't being installed:(

Here's the log:

$ cpanm -v autodie
cpanm (App::cpanminus) 1.6922 on perl 5.016003 built for x86_64-linux-thread-multi
Work directory is /root/.cpanm/work/1493999664.44
You have make /usr/bin/make
You have LWP 6.05
You have /usr/bin/tar: tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching autodie on cpanmetadb ...
--> Working on autodie
Fetching http://www.cpan.org/authors/id/P/PJ/PJF/autodie-2.29.tar.gz ... OK
Unpacking autodie-2.29.tar.gz
autodie-2.29
autodie-2.29/AUTHORS
autodie-2.29/Changes
autodie-2.29/t
autodie-2.29/t/pod.t
autodie-2.29/LICENSE
autodie-2.29/dist.ini
autodie-2.29/t/args.t
autodie-2.29/t/exec.t
autodie-2.29/t/fork.t
autodie-2.29/t/kill.t
autodie-2.29/t/open.t
autodie-2.29/t/recv.t
autodie-2.29/t/skip.t
autodie-2.29/t/read.t
autodie-2.29/META.yml
autodie-2.29/MANIFEST
autodie-2.29/cpanfile
autodie-2.29/META.json
autodie-2.29/README.md
autodie-2.29/t/Fatal.t
autodie-2.29/t/chown.t
autodie-2.29/t/flock.t
autodie-2.29/t/hints.t
autodie-2.29/t/lex58.t
autodie-2.29/t/utime.t
autodie-2.29/t/chmod.t
autodie-2.29/t/mkdir.t
autodie-2.29/t/caller.t
autodie-2.29/t/critic.t
autodie-2.29/t/fileno.t
autodie-2.29/t/lethal.t
autodie-2.29/t/repeat.t
autodie-2.29/t/socket.t
autodie-2.29/t/touch_me
autodie-2.29/t/unlink.t
autodie-2.29/t/system.t
autodie-2.29/t/00-load.t
autodie-2.29/t/autodie.t
autodie-2.29/t/binmode.t
autodie-2.29/t/context.t
autodie-2.29/t/crickey.t
autodie-2.29/t/no_carp.t
autodie-2.29/t/sysopen.t
autodie-2.29/t/usersub.t
autodie-2.29/t/version.t
autodie-2.29/t/dbmopen.t
autodie-2.29/Makefile.PL
autodie-2.29/lib
autodie-2.29/lib/Fatal.pm
autodie-2.29/t/kwalitee.t
autodie-2.29/t/rt-74246.t
autodie-2.29/t/truncate.t
autodie-2.29/t/internal.t
autodie-2.29/MANIFEST.SKIP
autodie-2.29/t/utf8_open.t
autodie-2.29/lib/autodie.pm
autodie-2.29/t/backcompat.t
autodie-2.29/t/blog_hints.t
autodie-2.29/t/eval_error.t
autodie-2.29/t/scope_leak.t
autodie-2.29/t/exceptions.t
autodie-2.29/t/filehandles.t
autodie-2.29/t/version_tag.t
autodie-2.29/t/import-into.t
autodie-2.29/t/lib
autodie-2.29/t/lib/lethal.pm
autodie-2.29/t/hints_insist.t
autodie-2.29/t/pod-coverage.t
autodie-2.29/t/user-context.t
autodie-2.29/t/author-critic.t
autodie-2.29/benchmarks
autodie-2.29/benchmarks/call.pl
autodie-2.29/benchmarks/leak.pl
autodie-2.29/t/format-clobber.t
autodie-2.29/t/lib/my
autodie-2.29/t/lib/my/pragma.pm
autodie-2.29/lib/autodie
autodie-2.29/lib/autodie/skip.pm
autodie-2.29/lib/autodie/Util.pm
autodie-2.29/t/context_lexical.t
autodie-2.29/t/exception_class.t
autodie-2.29/t/autodie_skippy.pm
autodie-2.29/t/lib/OtherTypes.pm
autodie-2.29/t/lib/Hints_test.pm
autodie-2.29/t/lib/my/autodie.pm
autodie-2.29/lib/autodie/hints.pm
autodie-2.29/t/basic_exceptions.t
autodie-2.29/t/string-eval-leak.t
autodie-2.29/t/lib/Some
autodie-2.29/t/lib/Some/Module.pm
autodie-2.29/t/lib/pujHa
autodie-2.29/t/lib/pujHa/ghach.pm
autodie-2.29/t/string-eval-basic.t
autodie-2.29/t/release-pod-syntax.t
autodie-2.29/benchmarks/raw-call.pl
autodie-2.29/t/hints_pod_examples.t
autodie-2.29/t/hints_provider_isa.t
autodie-2.29/t/lib/Caller_helper.pm
autodie-2.29/benchmarks/benchmark.pl
autodie-2.29/t/hints_provider_does.t
autodie-2.29/t/internal-backcompat.t
autodie-2.29/t/release-pod-coverage.t
autodie-2.29/lib/autodie/exception.pm
autodie-2.29/t/autodie_test_module.pm
autodie-2.29/t/lib/autodie/test
autodie-2.29/t/lib/autodie/test/au.pm
autodie-2.29/t/core-trampoline-slurp.t
autodie-2.29/lib/autodie/Scope
autodie-2.29/lib/autodie/Scope/Guard.pm
autodie-2.29/t/lib/pujHa/ghach
autodie-2.29/t/lib/pujHa/ghach/Dotlh.pm
autodie-2.29/t/lib/Hints_pod_examples.pm
autodie-2.29/t/lib/Hints_provider_isa.pm
autodie-2.29/t/lib/Hints_provider_does.pm
autodie-2.29/t/lib/autodie/test/badname.pm
autodie-2.29/t/lib/autodie/test/missing.pm
autodie-2.29/lib/autodie/Scope/GuardStack.pm
autodie-2.29/lib/autodie/exception
autodie-2.29/lib/autodie/exception/system.pm
autodie-2.29/t/hints_provider_easy_does_it.t
autodie-2.29/t/lib/autodie/test/au
autodie-2.29/t/lib/autodie/test/au/exception.pm
autodie-2.29/benchmarks/Fatal_Leaky_Benchmark.pm
autodie-2.29/t/lib/Hints_provider_easy_does_it.pm
Entering autodie-2.29
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.24)
Configuring autodie-2.29 ... Running Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for autodie
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have Scalar::Util 0 ... Yes (1.45)
Checking if you have FindBin 0 ... Yes (1.51)
Checking if you have File::Spec 0 ... Yes (3.40)
Checking if you have IO::Handle 0 ... Yes (1.33)
Checking if you have Fcntl 0 ... Yes (1.11)
Checking if you have if 0 ... Yes (0.0602)
Checking if you have POSIX 0 ... Yes (1.30)
Checking if you have lib 0 ... Yes (0.63)
Checking if you have Socket 0 ... Yes (2.021)
Checking if you have File::Copy 0 ... Yes (2.23)
Checking if you have warnings 0 ... Yes (1.13)
Checking if you have parent 0 ... Yes (0.225)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.24)
Checking if you have overload 0 ... Yes (1.18)
Checking if you have constant 0 ... Yes (1.27)
Checking if you have B 0 ... Yes (1.35)
Checking if you have Exporter 5.57 ... Yes (5.68)
Checking if you have Carp 0 ... Yes (1.26)
Checking if you have Test::More 0 ... Yes (1.302049)
Checking if you have strict 0 ... Yes (1.07)
Checking if you have File::Temp 0 ... Yes (0.2301)
Checking if you have Tie::RefHash 0 ... Yes (1.39)
Building and testing autodie-2.29 ... cp lib/autodie/Util.pm blib/lib/autodie/Util.pm
cp lib/autodie/hints.pm blib/lib/autodie/hints.pm
cp lib/Fatal.pm blib/lib/Fatal.pm
cp lib/autodie/Scope/Guard.pm blib/lib/autodie/Scope/Guard.pm
cp lib/autodie/Scope/GuardStack.pm blib/lib/autodie/Scope/GuardStack.pm
cp lib/autodie/exception.pm blib/lib/autodie/exception.pm
cp lib/autodie/skip.pm blib/lib/autodie/skip.pm
cp lib/autodie.pm blib/lib/autodie.pm
cp lib/autodie/exception/system.pm blib/lib/autodie/exception/system.pm
Manifying 9 pod documents
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t ...................... ok
t/args.t ......................... ok
t/author-critic.t ................ skipped: these tests are for testing by the author
t/autodie.t ...................... ok
t/backcompat.t ................... ok
t/basic_exceptions.t ............. ok
t/binmode.t ...................... ok
t/blog_hints.t ................... ok
t/caller.t ....................... ok
t/chmod.t ........................ ok
t/chown.t ........................ ok
t/context.t ...................... ok
t/context_lexical.t .............. ok
t/core-trampoline-slurp.t ........ ok
t/crickey.t ...................... ok
t/critic.t ....................... skipped: Author test.  Set $ENV{AUTHOR_TESTING} to true to run.
t/dbmopen.t ...................... ok
t/eval_error.t ................... ok
t/exception_class.t .............. ok
t/exceptions.t ................... ok
t/exec.t ......................... ok
t/Fatal.t ........................ ok
t/filehandles.t .................. ok
t/fileno.t ....................... ok
t/flock.t ........................ ok
t/fork.t ......................... skipped: BSD::Resource required to test fork()
t/format-clobber.t ............... ok
# Sub::Identify is loaded
t/hints.t ........................ ok
t/hints_insist.t ................. ok
t/hints_pod_examples.t ........... ok
t/hints_provider_does.t .......... ok
t/hints_provider_easy_does_it.t .. ok
t/hints_provider_isa.t ........... ok
t/import-into.t .................. skipped: Test needs Import::Into >= 1.002004
t/internal-backcompat.t .......... ok
t/internal.t ..................... ok
t/kill.t ......................... skipped: Can unexpectedly signal process 1. Won't run as root.
t/kwalitee.t ..................... skipped: Test::Kwalitee not installed; skipping
t/lethal.t ....................... ok
t/lex58.t ........................ skipped: IPC::System::Simple required
t/mkdir.t ........................ ok
t/no_carp.t ...................... ok
t/open.t ......................... ok
t/pod-coverage.t ................. skipped: Author test.  Set $ENV{AUTHOR_TESTING} to true to run.
t/pod.t .......................... skipped: Author test.  Set $ENV{AUTHOR_TESTING} to true to run.
t/read.t ......................... ok
t/recv.t ......................... ok
Can't locate Pod/Coverage/TrustPod.pm in @INC (@INC contains: /root/.cpanm/work/1493999664.44/autodie-2.29/blib/lib /root/.cpanm/work/1493999664.44/autodie-2.29/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/release-pod-coverage.t line 13.
BEGIN failed--compilation aborted at t/release-pod-coverage.t line 13.
t/release-pod-coverage.t ......... 
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/release-pod-syntax.t ........... ok
t/repeat.t ....................... ok
t/rt-74246.t ..................... ok
t/scope_leak.t ................... ok
t/skip.t ......................... ok
t/socket.t ....................... skipped: Author test.  Set $ENV{AUTHOR_TESTING} to true to run.
t/string-eval-basic.t ............ ok
t/string-eval-leak.t ............. ok
t/sysopen.t ...................... ok
t/system.t ....................... skipped: IPC::System::Simple not installed
t/truncate.t ..................... ok
t/unlink.t ....................... ok
t/user-context.t ................. ok
t/usersub.t ...................... ok
t/utf8_open.t .................... ok
t/utime.t ........................ ok
t/version.t ...................... ok
t/version_tag.t .................. ok

Test Summary Report
-------------------
t/release-pod-coverage.t       (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=66, Tests=508,  4 wallclock secs ( 0.25 usr  0.08 sys +  3.60 cusr  0.57 csys =  4.50 CPU)
Result: FAIL
Failed 1/66 test programs. 0/508 subtests failed.
make: *** [test_dynamic] Error 255
FAIL
! Installing autodie failed. See /root/.cpanm/work/1493999664.44/build.log for details. Retry with --force to force install it.

Circular dependency prevents install of autodie, Fatal using 'cpanm'

We use 'cpanm' to install Perl modules into one of our Docker images. As of release 2.30, there is a circular dependency which prevents the install of Fatal.

Here is an attempted install, showing that Fatal requires Test::Perl::Critic, which requires Perl::Critic, which itself requires Fatal. If I repeat the below specifying cpanm [email protected], it fails in a similar fashion.
bash-4.2# cpanm Fatal --> Working on Fatal Fetching http://www.cpan.org/authors/id/T/TO/TODDR/autodie-2.31.tar.gz ... OK Configuring autodie-2.31 ... OK ==> Found dependencies: Test::Perl::Critic --> Working on Test::Perl::Critic Fetching http://www.cpan.org/authors/id/P/PE/PETDANCE/Test-Perl-Critic-1.04.tar.gz ... OK Configuring Test-Perl-Critic-1.04 ... OK ==> Found dependencies: Perl::Critic, Perl::Critic::Violation, Perl::Critic::Utils --> Working on Perl::Critic Fetching http://www.cpan.org/authors/id/P/PE/PETDANCE/Perl-Critic-1.136.tar.gz ... OK Configuring Perl-Critic-1.136 ... OK ==> Found dependencies: Fatal ! Installing the dependencies failed: Module 'Fatal' is not installed ! Bailing out the installation for Perl-Critic-1.136. ! Installing the dependencies failed: Module 'Perl::Critic' is not installed, Module 'Perl::Critic::Violation' is not installed, Module 'Perl::Critic::Utils' is not installed ! Bailing out the installation for Test-Perl-Critic-1.04. ! Installing the dependencies failed: Module 'Test::Perl::Critic' is not installed ! Bailing out the installation for autodie-2.31.

Admittedly, this is something that may need to be fixed in Perl::Critic as opposed to autodie, but assuming this is a project that is used by many others, it is likely more pressing that care be used in what dependencies you create.

Unexpected interaction with local::lib, List::Util

When 'use autodie' is invoked before 'use local::lib' then 'use List::Util' pulls in the core version instead of the local::lib version. Is this expected behaviour? If so, could it please be listed in the GOTCHA section?

For example with centos, perlbrew Perl version 5.24.3, List::Util core version 1.42

This dies with "List::Util version 1.5 required--this is only version 1.4202":

use strict;
use autodie;
use local::lib './local_lib'; # local_lib has List::Util 1.50 
use List::Util 1.50 ();
print "ok\n";

This compiles and runs:

use strict;
use local::lib './local_lib';
use autodie;
use List::Util 1.50 ();
print "ok\n";

Exclude functions from importing

It would be nice to have a syntax for importing "all functions except one".
Exporter.pm does this with '!' syntax, but unfortunately it's already taken by autodie::hints.
How about '-'?
So, use autodie qw(:all -read) would import everything except read.

This effect is hard to achieve by other means, see https://gist.github.com/2901998 for my attempts to avoid prototype conflicts with a method named read.

kill 0, $pid should probably not throw exception

kill 0, $pid is an effective way to determine whether a process is still running and can accept signals from this process (without actually killing it). If the process exists, this returns true, and if the process does not, it would normally return false.... unless autodie is in use in which case it throws an exception and kills the program.

Remove dependency on Scalar::Util

If I'm reading this right if we broke about that XS file, or reimplemented it in autodie we wouldn't have to load List::Utils, or Scalar::Utils, and we would have joy?

What would autodie save? In minimal cases at the very least we wouldn't have to map in these three pages from List/Util/Util.so (we'd still have to map in one page from Util.so but we'd reduce that by 3).

7efcc3ce7000-7efcc3cf1000 r-xp 00000000 fd:01 878942                     /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int/auto/List/Util/Util.so
7efcc3cf1000-7efcc3ef0000 ---p 0000a000 fd:01 878942                     /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int/auto/List/Util/Util.so
7efcc3ef0000-7efcc3ef1000 r--p 00009000 fd:01 878942                     /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int/auto/List/Util/Util.so
7efcc3ef1000-7efcc3ef2000 rw-p 0000a000 fd:01 878942                     /usr/local/cpanel/3rdparty/perl/528/lib/perl5/5.28.0/x86_64-linux-64int/auto/List/Util/Util.so

Perhaps we could get with Sub::Util, and have them break out the one function from the XS so Sub::Util doesn't require List::Util, and then we could update our own dependencies?

Scoping issue with "no autodie" and the "system" sub

Hi,

We saw a report in Debian (https://bugs.debian.org/798096), where autodie broke valid code.

The code can basically be reduced to:

#!/usr/bin/perl

use autodie;

use_system();

sub break_system {
    no autodie qw(system);
}

sub use_system {
    system('/bin/true');
}

A couple items to note:

  • The order of break_system and use_system is significant (reorder them and the problem disappears)
  • It appears to affect system() but not chdir() [have not tested other functions yet]
  • It also appears if you replace "no autodie qw(${sub})" with a plain "no autodie".

Our travis code does not work with perl 5.8 any more

Our travis build completely broken. I could make it work for perl 5.10 and later by removing the perlbrew use 5.14 line but that leaves perl 5.8 broken. I opted for disabling to make the travis build useful for now.

@pjf: Do you have an idea for solving the perl 5.8 issue on travis?

Copy Fatal.pm into autodie.pm? [rt.cpan.org #99778]

Migrated from rt.cpan.org#99778 (status was 'open')

Requestors:

From @karenetheridge on 2014-10-24 17:08:56
:
I've been receiving a bunch of failing cpantesters reports like this:

"Incorrect version of Fatal.pm loaded by autodie..."

http://www.cpantesters.org/cpan/report/09903146-5ad1-11e4-97a5-44010a8c9ca5

I'm wondering whether the time has come to simply copy the code in Fatal.pm into autodie.pm, and add a big deprecation warning into Fatal.pm?

From @toddr on 2020-01-08 07:02:11
:
I don't know the history here but I think this can be closed as complete, right?

From @karenetheridge on 2020-01-08 17:36:18
:

Fatal.pm still has a lot of guts in it, but it's unknown how many things are still
dependent on it. I would still add a '(DEPRECATED)' into Fatal's ABSTRACT (line 3),
and add some deprecation metadata though (since you're using dzil, [Deprecated] can do this).

Depending on how ugly Fatal's code is, it could even print a runtime warning when it is used (like Any::Moose and other obsolete things do).

Outstanding documentation (fixes, new)

Fixes:

  • remove "fail" key from autodie::hints code

Loose end:

  • explain whether you can have hints for different subroutine names if they are merely aliases to the same code.

Missing:

  • autodie hackers documentation

test (?) wants BSD::Resource in Windows [rt.cpan.org #131402]

Migrated from rt.cpan.org#131402 (status was 'new')

Requestors:

From [email protected] on 2020-01-09 14:48:18
:

Windows 10, Strawberry Perl 5.26.1 cpan upgrade of autodie 2.3.1 seems to go OK, but then "cpan" tries to install BSD::Resource (for testing?)...

Running install for module 'BSD::Resource'
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/J/JH/JHI/BSD-Resource-1.2911.tar.gz
Checksum for C:\STRAWB~1\cpan\sources\authors\id\J\JH\JHI\BSD-Resource-1.2911.tar.gz ok
Configuring J/JH/JHI/BSD-Resource-1.2911.tar.gz with Makefile.PL

Configuring BSD::Resource...

Checking whether you have certain header files...
The system cannot find the path specified.
The system cannot find the path specified.
Your operating system does not seem to have <sys/resource.h> or <sys/rusage.h>.

(Run "perl Makefile.PL" with the environment variable VERBOSE set to 1 (one)
 too see in more detail what went wrong.)

There is no way BSD::Resource is going to work.

I am awfully sorry but I cannot go further.

Aborting configuration of BSD::Resource.
Warning: No success on command[C:\Strawberry\perl\bin\perl.exe Makefile.PL]
  JHI/BSD-Resource-1.2911.tar.gz
  C:\Strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK
Running install for module 'BSD::Resource'
  JHI/BSD-Resource-1.2911.tar.gz
  Has already been unwrapped into directory C:\STRAWB~1\cpan\build\BSD-Resource-1.2911-0
  JHI/BSD-Resource-1.2911.tar.gz
  'C:\Strawberry\perl\bin\perl.exe Makefile.PL' returned status 512, not re-running
Failed during this command:
 (optional) JHI/BSD-Resource-1.2911.tar.gz    : writemakefile NO 'C:\Strawberry\perl\bin\perl.exe Makefile.PL' returned status 512

cpan> i autodie
Module id = autodie
    CPAN_USERID  TODDR (Todd Rinaldo <[email protected]>)
    CPAN_VERSION 2.31
    CPAN_FILE    T/TO/TODDR/autodie-2.31.tar.gz
    UPLOAD_DATE  2020-01-08
    MANPAGE      autodie - Replace functions with ones that succeed or die with lexical scope
    INST_FILE    C:\Strawberry\perl\site\lib\autodie.pm
    INST_VERSION 2.31

cpan> i BSD::Resource
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/J/JH/JHI/CHECKSUMS
Module id = BSD::Resource
    CPAN_USERID  JHI (Jarkko Hietaniemi <[email protected]>)
    CPAN_VERSION 1.2911
    CPAN_FILE    J/JH/JHI/BSD-Resource-1.2911.tar.gz
    UPLOAD_DATE  2017-04-09
    MANPAGE      BSD::Resource - BSD process resource limit and priority functions
    INST_FILE    (not installed)

It looks like autodie itself is trying to install BSD::Resource, and it appears to be uninstallable on Windows. You might want to consider bypassing this if you're not on a supported system.

Running make for T/TO/TODDR/autodie-2.31.tar.gz
---- Unsatisfied dependencies detected during ----
----         TODDR/autodie-2.31.tar.gz        ----
    BSD::Resource [build_requires,optional]
    Import::Into [build_requires,optional]

autodie seems to claim to be up to date, but I'm not sure if it completed its testing. If BSD::Resource is truly optional, I think it should be skipped on non-BSD systems so such alarming messages aren't given.

More: Scoping issue with "no autodie" and the "system" sub

I think this a new issue that looks like #69:

pvm92@peter:~> cat no-autodie-twice.pl 
#!/usr/bin/perl
{ no autodie; }
{ no autodie; }
system("echo something");

pvm92@peter:~> ./no-autodie-twice.pl 
Undefined subroutine called at ./no-autodie-twice.pl line 4.

pvm92@peter:~> perl -Mautodie -E 'say $autodie::VERSION'
2.29

# It doesn't help to use the git master HEAD
pvm92@peter:~> (cd autodie && git log -1)
commit 79f7f102680de60bbb6eaee0e89b4032bf4547c9
Merge: bbfe28c 933b8fc
Author: Niels Thykier <[email protected]>
Date:   Sun Sep 25 11:22:47 2016 +0200

    Merge pull request #74 from pjf/ack
    
    Ackrc: Ignore build directories

pvm92@peter:~> perl -Iautodie/lib ./no-autodie-twice.pl 
Undefined subroutine called at ./no-autodie-twice.pl line 4.

pvm92@peter:~> perl -V | grep ^Summary
Summary of my cperl (revision 5 version 29 subversion 0) configuration:

Same behavior occurs with debian stretch/9's default perl (5.24.1) with or without libautodie-perl installed.

unlink(@list)

Problem:

$ rm foo; rm bar
$ touch foo
$ perl -Mautodie -e'unlink("foo","bar")'

In the above, autodie should throw an exception because 'bar' does not exist, and hence cannot be unlinked. However because the internal code implements 'unlink or die' semantics, and unlink returns the number of items unlinked, autodie is not triggered:

Solution:

Autodie should check the return value of unlink is equal to the number of elements in unlink's argument list.

Breakdown of loadtime performance

This breakdown is based on the lazy-compile branch (#28), the benchmark.pl script and NYTProf. The 1001 "use autodie;" statements take about 3.83s under profiling. That is the entire "inclusive" time for the import sub. AFAICT, autodie/Fatal is spending its time on (exclusive timings):

  • Tie::RefHash::STORE: ~0.5s
  • _install_subs: ~0.5s
  • import: ~0.5s
  • _make_leak_guard: ~0.7s
  • _make_fatal: ~1.4s

I cannot spot any obvious code to be optimised, so I suspect our best bet is to looking to making more subs reusable (possibly using the %^H for newer versions of perl).

use Fatal qw(:lexical) throws autodie::exception

After a bit of testing (see commit dc33f2b), it turns out that the code:

use Fatal qw(:lexical open);

open(my $fd, '<', 'missing-file');

Thows an exception like "use autodie qw(open)" would have (in fact said exception is an autodie::exception). Using git bisect, I have determined this has happened since commit 54d2fbd, so this behaviour has been defacto standard since 2008. This leads to the question: If we separate autodie from Fatal (issue #60), how should "use Fatal qw(:lexical ...)" behave? I see the following options:

  1. Keep existing behaviour by "promoting" it to "autodie" (i.e. make use "Fatal qw(:lexical ... );" basically the same as "use autodie qw(...);").
  2. Have "use Fatal qw(:lexical ...);" throw "old-style" exceptions.
  3. Remove support for ":lexical" in Fatal completely (possibly with a "grace period" filled with deprecation warnings).

Note that the "Fatal" POD does not mention the ":lexical" tag at all (but it used to do). I suspect this to be by intention as the documentation suggests Fatal to be deprecated in favor of autodie. This begs the question, is ":lexical" now just an implementation-detail that we can change at will?

@pjf: Any suggestions? Otherwise, I will probably go with 1. as it seems to be the "most backwards compatible" option, given the lifetime of this bug.

Import to other namespace (not only to caller)

It would be useful to add possibility to specify namespace (as additional import() parameter) to which autodie should be imported. So we can re-export autodie from other package.

For example:

use autodie (':all', -caller => 'Some::Other::Namespace');

umask under MSWIN

From perldoc:

If umask(2) is not implemented on your system and you are trying
to restrict access for *yourself* (i.e., "(EXPR & 0700) > 0"),
raises an exception. If umask(2) is not implemented and you are
not trying to restrict access for yourself, returns "undef".

So, under MSWIN 'undef' is a legal value, not an error, and autodie shouldn't die.

Make autodie call subs from CORE::GLOBAL namespace

Is it possible to make autodie to call subroutines from CORE::GLOBAL namespace (if overrides exists) instead of CORE.

For example, in this code CORE::chmod called, but i expect, that CORE::GLOBAL::chmod will be called:

#!/usr/bin/env perl

package CORE::GLOBAL;

use strict;
use warnings;
use subs qw(chmod);

sub chmod {
    print qq{overrided chmod\n};

    return;
}

package main;

use autodie qw(chmod);

chmod 0777, './adsadas';

1;
__END__

How do I get autodie to know it's inside a wrapper method?

Let's say I'm writing a file class like oh... Path::Tiny and it uses autodie. The error messages come from inside Path::Tiny.

$ perl -wle 'use Path::Tiny;  path("/foo/bar")->openr'
Can't open '/foo/bar' for reading: 'No such file or directory' at /Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Path/Tiny.pm line 200

What I really want is this:

$ perl -wle 'use Path::Tiny;  path("/foo/bar")->openr'
Can't open '/foo/bar' for reading: 'No such file or directory' at -e line 1

How can I tell autodie that its in a wrapper method? Either by telling it to skip a level of the call stack or by skipping a namespace or by using a subclass of autodie::exception?

Skip File::Copy return tests on VMS

For all currently released versions of Perl (up to 5.10.0), spurious failures are reported from hints.t due to File::Copy not returning 0 when run on VMS.

Undefined subroutine Module::xxx when xxx exists in the CORE namespace [rt.cpan.org #70545]

Migrated from rt.cpan.org#70545 (status was 'open')

Requestors:

From [email protected] on 2011-08-28 09:06:24
:

Here is a simple examle which works good without autodie and dies with
message "Undefined subroutine &Config::Simpliest::read called" when
using autodie:

package main;

my $cfg = Config::Simpliest::read("/tmp/t.txt");

package Config::Simpliest;

use strict;
use autodie;

sub read {
	my $fname = shift;
	open my $fh, $fname;
	
	my %cfg;
	while (<$fh>) {
		chomp;
		my ($k, $v) = split /\s*=\s*/;
		$cfg{$k} = $v;
	}
	
	close $fh;
	return \%cfg;
}

From [email protected] on 2013-10-13 10:21:15
:

On Sun Aug 28 05:06:24 2011, OLEG wrote:
> Here is a simple examle which works good without autodie and dies with
> message "Undefined subroutine &Config::Simpliest::read called" when
> using autodie:
> 
> [...]

Seems related to github issue #11[1].

~Niels

[1] https://github.com/pjf/autodie/issues/11



autodie should exit($!) [rt.cpan.org #93716]

Migrated from rt.cpan.org#93716 (status was 'open')

Requestors:

From [email protected] on 2014-03-10 19:12:14
:

==================
root@felipe 14:08:36 case88745 /usr/local/cpanel
 > perl -e'open FH, "<", "yglzdfvxbfg" or die;'
Died at -e line 1.

ENOENT (2)
==================
root@felipe 14:06:08 case88745 /usr/local/cpanel
 > cat | perl -Mautodie
`perl -Mautodie -e'open FH, "<", "yglzdfvxbfg"'`;
print 0+$? . $/;
print $? . $/;
Can't open 'yglzdfvxbfg' for reading: 'No such file or directory' at -e 
line 1
65280
65280

OK
==================

When an exception from autodie causes perl to exit(), the exit code 
should correspond to the value of $! as perl �natively� does as in the 
first example above.


-Felipe Gasper
cPanel, Inc.


From [email protected] on 2014-03-10 19:22:20
:

On 2014-03-10 20:12, [email protected] via RT wrote:
> Mon Mar 10 15:12:14 2014: Request 93716 was acted upon.
> Transaction: Ticket created by [email protected]
>        Queue: autodie
>      Subject: autodie should exit($!)
>    Broken in: (no value)
>     Severity: (no value)
>        Owner: Nobody
>   Requestors: [email protected]
>       Status: new
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=93716 >
> 
> 
> [...]
> 
> When an exception from autodie causes perl to exit(), the exit code 
> should correspond to the value of $! as perl �natively� does as in the 
> first example above.
> 
> 
> -Felipe Gasper
> cPanel, Inc.
> 

Hi Felipe,

What version of autodie are you using?  Namely, I suspect that the
problem would be fixed in autodie 2.21 due to:

"""
        * INTERNAL : $" and $! are no longer arbitrarily messed with
          for no reason via autodie.  (They're still messed with when
          using Fatal.)
"""

Which would ensure that "$!" is (still) set to 2 and die should DTRT
from there.  Previously, $! would be "protected" by a local, causing it
to be reset to (in your example above) 0.

~Niels




From [email protected] on 2014-03-10 19:30:46
:

On 10.3.14, 2:22 PM, Niels Thykier via RT wrote:
> <URL: https://rt.cpan.org/Ticket/Display.html?id=93716 >
>
> On 2014-03-10 20:12, [email protected] via RT wrote:
>> Mon Mar 10 15:12:14 2014: Request 93716 was acted upon.
>> Transaction: Ticket created by [email protected]
>>         Queue: autodie
>>       Subject: autodie should exit($!)
>>     Broken in: (no value)
>>      Severity: (no value)
>>         Owner: Nobody
>>    Requestors: [email protected]
>>        Status: new
>>   Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=93716 >
>>
>>
>> [...]
>>
>> When an exception from autodie causes perl to exit(), the exit code
>> should correspond to the value of $! as perl �natively� does as in the
>> first example above.
>>
>>
>> -Felipe Gasper
>> cPanel, Inc.
>>
>
> Hi Felipe,
>
> What version of autodie are you using?  Namely, I suspect that the
> problem would be fixed in autodie 2.21 due to:
>
> """
>          * INTERNAL : $" and $! are no longer arbitrarily messed with
>            for no reason via autodie.  (They're still messed with when
>            using Fatal.)
> """
>
> Which would ensure that "$!" is (still) set to 2 and die should DTRT
> from there.  Previously, $! would be "protected" by a local, causing it
> to be reset to (in your example above) 0.
>

Hm. I was using 2.12. That sounds like it would fix the issue, but I 
tried updating my laptop�s autodie version to 2.22, to no avail:

felipe@Macintosh-19 14:25:15 /
 > perl -Mautodie -e'print $autodie::VERSION'
2.22
OK
felipe@Macintosh-19 14:26:53 /
 > cat | perl -Mautodie
`perl -Mautodie -e'open FH, "<", "yglzdfvxbfg"'`;
print ($? >> 8) . $/;
Can't open 'yglzdfvxbfg' for reading: 'No such file or directory' at -e 
line 1
255

-F


From [email protected] on 2020-01-08 15:48:53
:

Current Behavior:

$>perl -Ilib -Mautodie -e'open FH, "<", "qweqweqerwr"; print "Should not reach here\n"'; echo $?
Can't open 'qweqweqerwr' for reading: 'No such file or directory' at -e line 1
255

Felipe believes it should ext 2: "Normally Perl uses $! as the exit value when an exception ends the program."

#> perl -e'open FH, "<", "qweqweqerwr" or die'; echo $?
Died at -e line 1.
2



Make autodie pragma independent of Fatal

I believe we should separate autodie from Fatal on a code level (i.e. remove the ISA relationship to Fatal). This would solve both [RT#85801] and [RT#99778]. Please note that this issue is /not/ about deprecating or removing the Fatal module from the autodie distribution. I believe that to be a completely different issue.

The advantages:

  • One could import/use autodie even on very old Perls, where the Perl include path contains an old Fatal module (in CORE) in front of autodie.
  • I believe it could simplify a lot of code paths. Currently the majority of the module combines no less than 3 "cases" (Fatal regular, Fatal void and autodie). I would consider it a big win, if we could separate most (preferably all) of the Fatal code from the autodie code - especially on the code-generation level.

My proposed solution is to:

  • Move common ("class" independent?) code into a separate module that simply exports utility subroutines. This can be done regardless of the split and would be beneficial to keeping the size of Fatal.pm (or autodie.pm) down.
  • Reverse the ISA relationship between Fatal and autodie, so that class dependent code is in autodie and Fatal overwrites parts to retain backwards compatibility with the old Fatal.pm.

The concerns:

  • Reversal of the ISA relationship should not be a problem.
    • When the INC path is setup correctly (i.e. CPAN/vendor before CORE), it will be no different than today - both autodie and Fatal from CPAN (or a vendor) will completely overwrite the CORE version.
    • When the INC path is not setup correctly (i.e. CORE before CPAN), then on very old perls (5.8) the old Fatal will be independent and "just work(tm)". On the plus side, so will autodie since it is now a stand-alone module. On newer versions of Perl (if such exists with that INC setup), where autodie is included in CORE both autodie and Fatal from CPAN will be completely shadowed by the CORE version. In this case nothing will break.
  • Some of the wrappers (at least the reusable ones) may change from being compiled in the "Fatal" module to the "autodie" module. Though, if this was a problem, I believe we would have heard about it when we introduced "reusable" subs (where it changes from $caller to "Fatal").
  • Nothing in CORE depends on Fatal as far as I can tell.

@pjf: What do you think? Did I miss anything?

[RT#85801] https://rt.cpan.org/Public/Bug/Display.html?id=85801

[RT#99778] https://rt.cpan.org/Public/Bug/Display.html?id=99778

autodie fails to deduce filename for open FILEHANDLE [rt.cpan.org #99402]

Migrated from rt.cpan.org#99402 (status was 'new')

Requestors:

From [email protected] on 2014-10-09 20:36:53:

AFAIK, when open fails, autodie's intends to show an error message with the name of the file that could not be opened:

Error message from the following script should be "Can't open('does not exist'): ..."

$ cat 0.pl
#!/usr/bin/env perl

use autodie;
use strict;
use warnings;

our $FILE = 'does not exist';
open FILE;
$ ./0.pl
Can't open('FILE'): No such file or directory at ./0.pl line 8

On OSX, dtruss shows:

xxxx/yyyyyy:  open("does not exist\0", 0x0, 0x1B6) = -1 Err#2

On Linux, strace shows:

open("does not exist.txt", O_RDONLY) = -1 ENOENT (No such file or directory)

To my dismay, I found that perldoc -f open in most recent versions of Perl don't have this, but versions as recent as 5.18.2 explain what happens when open is invoked with a single argument:

If EXPR is omitted, the global (package) scalar variable of the same name as the FILEHANDLE contains the filename.

For other info, see:

http://blog.nu42.com/2014/10/a-bug-in-perls-autodie.html

http://blog.nu42.com/2014/10/why-was-documentation-for-single.html

Clearly, open FILENAME cannot be recommended, so I am putting very low priority on this, but FYI.

Thank you,

-- Sinan

Have autodie play nicely with Carp::Always

From @petdance (a year ago):

I'm getting to the point where I'm about to get the religion about autodie. Jacinta's talk just drove it home.

But the bummer that I just ran across is that autodie seems to not play well with Carp::Always. I use Carp::Always all the time to get stack traces on failures. So if I have

main {
read_this();
}

sub read_this() {
read_that();
}

sub read_that() {
open( …. ) or die "Can't open … $!";
}

when that fails with the die, I get the full stack trace more than just a line number. If I drop the "or die" and add autodie, I get the autodie exception, but no stack trace.

And in case you're not familiar with Carp::Always, it's a great tool that captures all your warn/die calls and puts a stack dump above them, basically turning them into cluck/confess. What makes Carp::Always great is that you can just tack it on to your command line with a -MCarp::Always and get the stack dumps on the fly without modifying code, so it's easier to debug unexpected failures.

Is there some magic to get autodie and Carp::Always to play together?

xoa

problem with truncate - prototype issue [rt.cpan.org #56316]

Migrated from rt.cpan.org#56316 (status was 'open')

Requestors:
@chorny

From @chorny on 2010-04-06 14:36:59

#perl -c -Mstrict -Mautodie=truncate -e 'truncate(F,0)'
Bareword "F" not allowed while "strict subs" in use at -e line 1.

#perl -c -Mstrict -e 'truncate(F,0)'
-e syntax OK

See also http://rt.perl.org/rt3/Ticket/Display.html?id=3311

From [email protected] on 2013-10-13 09:56:18
:

Hi,

This is caused by "prototype(q{CORE::truncate))" returning "$$". At the current time, I am not sure we can fix this in autodie.

~Niels

autodie does not trap errors in <> operator [rt.cpan.org #74606]

Migrated from rt.cpan.org#74606 (status was 'open')

Requestors:

From [email protected] on 2012-02-02 00:05:50
:

autodie does not catch errors in the implicit open done by the <> operator.

# perl -e 'use autodie qw(open); <>; print("did not autodie!\n");' foo

Can't open foo: No such file or directory at -e line 1.
did not autodie!

An explicit open with an error is caught.

# perl -e 'use autodie qw(open); open(FH, "foo"); print("did not autodie!\n");'
Can't open 'foo' for reading: 'No such file or directory' at -e line 1

Ubuntu 10.10,  perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi, 2.6.35-32-server #64-Ubuntu SMP Tue Jan 3 02:11:24 UTC 2012 x86_64 GNU/Linux, perl-modules 5.10.1-12ubuntu2.1


From [email protected] on 2020-01-08 07:12:26
:

Still a problem in 2.30

Exporting to parent module

Hello, many thanks for this useful module! I am trying to include it in my "best practices" module, which is included in all my modules and scripts so that common requirements such as 'import' or 'warnings' are not repeated endlessly.

I'd like to do the same with autodie, but I must say that although that I've been fiddling around for quite a while, I find myself totally unable to write the appropriate code. I wonder if you could give me a hint?

myapp.pl

#!/usr/bin/env perl
use Practices;                     # ----- load company's best practices

open my $fh, "nonexistent.file";   # ----- this should die

Practices.pm

package Practices;

use strict;
use warnings;
use autodie;

sub import {

    strict->import();
    warnings->import();

    # ----- TODO what for autodie ?
}

1;

autodie hides compile-time warnings

use warnings;
use autodie qw(:all);

open FH, '<:raw', 'file.txt';

I expect compile-time warning "Name "main::FH" used only once: possible typo at .... ", but got nothing.

Performance concerns of the autodie wrapper

I have been doing some ad-hoc benchmarking of the auto-generated wrapper. I simply cannot explain why it is spending so much time on its task.

call.pl takes about 5s for me at the current master branch (commit c8d79dc). But leak.pl takes 0.4s (vs. 0.2 for a raw call to the built-in without autodie at all). So we spend more than a factor 10 in those return value checkers.

I have taken (a trimmed down of) the binmode wrapper[1](admittedly without the leak guard, but from above we know it only takes about 0.2s). This wrapper takes "only" 1.7-18s. So there is a factor two runtime between difference between my hand-written / copy-wasted wrapper and the one autodie generates.

But even here, I noticed something interesting. If we take out the "local($", $!)" line, the runtime drops to about 0.7-0.8s (i.e ~1s disappears). The extra overhead (when profiled) will probably disappear from the "return" statement rather than the "local" line (based on earlier observations).

To sum up. The autodie wrapper subs are spending way too much time on (apparently) "nothing at all" and we should look into getting rid of some of that overhead.

[1]

sub binmode(*;$) {
    # TODO - Why do we do this?  It costs us a factor 2 here
    #  (at return).
    local($", $!) = (', ', 0);
    no warnings qw(unopened uninitialized numeric);
    no if $] >= 5.017011, warnings => "experimental::smartmatch";
    if (@_ == 1) {
        if (wantarray) {
            die("Not implemented...\n");
        } else {
            my $retval = CORE::binmode($_[0]);
            my $context = "scalar";
            return $retval ||
                die autodie->throw(
                    function => q{CORE::binmode}, args => [ $_[0] ],
                    pragma => q{autodie}, errno => $!,
                    context => $context, return => $retval,
                    eval_error => $@
                );
        }
    }
    die("Not implemented...\n");
}

Checking for process fails when autodie enabled

Example code:

#!/usr/bin/env perl

use strict;
use warnings;
use Carp;
use autodie qw/ :all /;

my $pid = fork;
if ($pid) {
  $SIG{CHLD} = 'IGNORE';

  sleep 5;
  my $alive = kill 0, $pid;
  print "Is PID $pid still alive? ", ($alive ? 'Yes' : 'No'), "\n";
} else {
  defined $pid or croak "fork failed: $!";
  exit;
}

Without autodie, the $alive test returns true or false (false in this case).

With autodie enabled for kill, it raises a "Can't kill('0', '823'): No such process at ./try2 line 13" exception when a process doesn't exist.

Check for error on implicit close. [rt.cpan.org #52985]

Migrated from rt.cpan.org#52985 (status was 'open')

Requestors:

From [email protected] on 2009-12-23 00:19:13
:

Wouldn't it be cool if...

    use autodie;

    {
        open my $fh, ">", $file;
        print $fh @a_lot_of_stuff;
    }

Failed when it ran out of disk space?  This does.

    use autodie;

    {
        open my $fh, ">", $file;
        print $fh @a_lot_of_stuff;
        close $fh;
    }

But because the implicit close of a lexical filehandle is so convenient
one would not bother with an explicit one.

I'm throwing this out there to see if there's a clever way to implement
it.  One is to have open() return a glob object which does an explicit
close() on DESTROY.

This would also offer a solution to another problem...

    Can't close(GLOB(0x803704)) filehandle: 'No space left on device'

It would allow open to attach the original filename to the filehandle
object which can be used to generate better error messages down the line.

On the down side, it will break code that expects open() to return a
non-blessed reference.  autodie is lexical, but filehandles get passed
around.

One work around would be to take advantage of the IO::Handle magic. 
autodie could treat the filehandle as an inside out object to store data
on it and put accessor methods into IO::Handle.  It could add an
IO::Handle::DESTROY to do the extra close.

From [email protected] on 2009-12-23 02:31:20
:

Blarf.  While the idea of using IO::Handle::DESTROY works A) Perl sends
out a "helpful" warning about it, which I suppose isn't so bad, but B)
$@ gets lost somewhere along the line and C) the eval block doesn't
fail, it looks at the last evaluated lexical statement inside.

  use IO::Handle;

  use warnings;
  no warnings "redefine";
  sub IO::Handle::DESTROY { die "DESTRRRRROY!" }

  print "Eval failed.\n" if !eval {
      open my $fh, "/dev/null";
  };
  print "Caught: $@\n";
  __END__
        (in cleanup) DESTRRRRROY! at - line 5.
Caught: 
	(in cleanup) DESTRRRRROY! at - line 5 during global destruction.



autodie=system system(qw[ grep -P . 2]) broken "grep: invalid option -- ," [rt.cpan.org #49740]

Migrated from rt.cpan.org#49740 (status was 'new')

Requestors:

Attachments:

From on 2009-09-16 13:46:01
:

"grep -P . 2" works from command line, and system, and
IPC::System::Simple, but not with autodie=system

echo >2
cat 2
grep -P . 2
perl -Mautodie=system -e " system qw[ grep -P . 2]"
perl -MIPC::System::Simple=system -e " system qw[ grep -P . 2]"
perl -Mautodie=system -MDevel::ModList -e 1
perl -Mautodie=:all -d:Trace -e " system qw[ grep -P . 2]"
>trace.autodie-2.06_01.txt 2>&1




D:\>echo >2

D:\>cat 2
ECHO is on.

D:\>grep -P . 2
ECHO is on.

D:\>perl -Mautodie=system -e " system qw[ grep -P . 2]"
Subroutine IPC::System::Simple::WIFEXITED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 109.
Subroutine IPC::System::Simple::WEXITSTATUS redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 110.
Subroutine IPC::System::Simple::WIFSIGNALED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 111.
Subroutine IPC::System::Simple::WTERMSIG redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 112.
grep: invalid option -- ,
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
"grep" unexpectedly returned exit value 2 at (eval 10) line 13
 at -e line 1

D:\>perl -MIPC::System::Simple=system -e " system qw[ grep -P . 2]"
Subroutine IPC::System::Simple::WIFEXITED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 109.
Subroutine IPC::System::Simple::WEXITSTATUS redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 110.
Subroutine IPC::System::Simple::WIFSIGNALED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 111.
Subroutine IPC::System::Simple::WTERMSIG redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 112.
ECHO is on.

D:\>perl -Mautodie=system -MDevel::ModList -e 1
Subroutine IPC::System::Simple::WIFEXITED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 109.
Subroutine IPC::System::Simple::WEXITSTATUS redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 110.
Subroutine IPC::System::Simple::WIFSIGNALED redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 111.
Subroutine IPC::System::Simple::WTERMSIG redefined at
C:/perl/site/5.10.1/lib/IPC/System/Simple.pm line 112.
AutoLoader             5.69
Carp                   1.11
Carp::Heavy
Config
Config_git.pl
Config_heavy.pl
Devel::ModList
DynaLoader             1.10
Exporter               5.63
Fatal                2.06_01
Fcntl                  1.06
File::Spec              3.3
File::Spec::Unix        3.3
File::Spec::Win32       3.3
IPC::System::Simple    1.18
List::Util             1.21
POSIX                  1.17
Scalar::Util           1.21
Tie::Hash              1.03
Tie::RefHash           1.38
Win32                  0.39
Win32::Process         0.14
XSLoader               0.10
autodie              2.06_01
autodie::exception   2.06_01
autodie::exception::system 2.06_01
base                   2.14
constant               1.19
if                     0.05
overload               1.07
re                     0.09
vars                   1.01
warnings               1.06
warnings::register     1.01

D:\>perl -Mautodie=:all -d:Trace -e " system qw[ grep -P . 2]"
>trace.autodie-2.06_01.txt 2>&1

D:\>
D:\>

Remove local $@; eval { ... } in autodie::exception

Try the following code (assuming you have Plack installed :D) and open the localhost:5000 in the browser:

plackup -e 'sub { use autodie; open my $fh, "<:utf8", "/tmp/x/y/z" }'

you'll get a stacktrace of:

Internal autodie::exception error: Don't know how to format mode '<:utf8'. at ...

This is fundamentally because autodie::exception internally localizes $@ and tries _format_open_with_mode() with eval, causing it to overwrite the captured error for StackTrace middleware.

There are probably two separate issues here:

  • Could it be rewritten so that it doesn't use local $@ and eval {}, like just returning undef (return;) instead of throwing errors in the _format_open_with_mode()? Fiddling with exceptions in autodie::exception sounds like a cause of troubles :)
  • The open mode detecter that is being discussed doesn't support PerlIO like this one <:utf8 - it would be nice if we detect that. Or at least you can change the $mode detector to be relaxed like using regexes instead of an exact match - IMO.

hash hint should not be used to store references

autodial::Scope::GuardStack::push_hook is using the hint hash %^H to store some references...
this is a bad idea.

The hints hash (%^H) cannot be used to store hashrefs as values,
so any implementation that relies on putting hashrefs in %^H is
intrinsically broken.

See "Implementation details" in the perlpragma manpage.
https://perldoc.perl.org/perlpragma.html#Implementation-details

noticed issues there:
https://github.com/pjf/autodie/blob/master/lib/autodie/Scope/GuardStack.pm#L28
and POD also suggest to store references in hash hint
https://github.com/pjf/autodie/blob/master/lib/autodie/Scope/Guard.pm#L35

Improve formating of chmod/mkdir (etc.) exceptions

The chmod and mkdir (among others?) accepts a "mode" argument. Most people will give an octal value here, but the autodie exception will always use a base 10 value.

Accordingly, a failed mkdir($dir, 0755) gives something like:

Can't mkdir($dir, 511): $!

While technically correct, I believe the user is generally better served with the octal form.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.