summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/autodie
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-04-26 22:16:26 +0000
committerKarl Berry <karl@freefriends.org>2015-04-26 22:16:26 +0000
commit342e672574c4e67d510e46ab6acd0e21a7d0cf54 (patch)
tree79e04202d08c0404bbd780bd26c1e34710e539b6 /Master/tlpkg/tlperl/lib/autodie
parentbe2706af7c57a0ef0f4d4e9f684ca4ef74922a82 (diff)
(tl)perl 5.20.2 for windows, from siep
git-svn-id: svn://tug.org/texlive/trunk@37064 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/autodie')
-rw-r--r--Master/tlpkg/tlperl/lib/autodie/exception.pm32
-rw-r--r--Master/tlpkg/tlperl/lib/autodie/exception/system.pm4
-rw-r--r--Master/tlpkg/tlperl/lib/autodie/hints.pm6
-rw-r--r--Master/tlpkg/tlperl/lib/autodie/skip.pm54
4 files changed, 87 insertions, 9 deletions
diff --git a/Master/tlpkg/tlperl/lib/autodie/exception.pm b/Master/tlpkg/tlperl/lib/autodie/exception.pm
index 45c723d56ac..00818605762 100644
--- a/Master/tlpkg/tlperl/lib/autodie/exception.pm
+++ b/Master/tlpkg/tlperl/lib/autodie/exception.pm
@@ -4,6 +4,9 @@ use strict;
use warnings;
use Carp qw(croak);
+our $VERSION = '2.23'; # VERSION: Generated by DZP::OurPkg:Version
+# ABSTRACT: Exceptions from autodying functions.
+
our $DEBUG = 0;
use overload
@@ -14,8 +17,6 @@ use overload
use if ($] >= 5.010), overload => '~~' => "matches";
-our $VERSION = '2.13';
-
my $PACKAGE = __PACKAGE__; # Useful to have a scalar for hash keys.
=head1 NAME
@@ -131,12 +132,21 @@ sub line { return $_[0]->{$PACKAGE}{line}; }
my $context = $E->context;
-The context in which the subroutine was called. This can be
-'list', 'scalar', or undefined (unknown). It will never be 'void', as
-C<autodie> always captures the return value in one way or another.
+The context in which the subroutine was called by autodie; usually
+the same as the context in which you called the autodying subroutine.
+This can be 'list', 'scalar', or undefined (unknown). It will never
+be 'void', as C<autodie> always captures the return value in one way
+or another.
+
+For some core functions that always return a scalar value regardless
+of their context (eg, C<chown>), this may be 'scalar', even if you
+used a list context.
=cut
+# TODO: The comments above say this can be undefined. Is that actually
+# the case? (With 'system', perhaps?)
+
sub context { return $_[0]->{$PACKAGE}{context} }
=head3 return
@@ -210,7 +220,7 @@ For a string that does start with a colon, if the subroutine
throwing the exception I<does> that behaviour. For example, the
C<CORE::open> subroutine does C<:file>, C<:io> and C<:all>.
-See L<autodie/CATEGORIES> for futher information.
+See L<autodie/CATEGORIES> for further information.
=back
@@ -394,6 +404,8 @@ sub _format_open_with_mode {
elsif ($mode eq '>') { $wordy_mode = 'writing'; }
elsif ($mode eq '>>') { $wordy_mode = 'appending'; }
+ $file = '<undef>' if not defined $file;
+
return sprintf _FORMAT_OPEN, $file, $wordy_mode, $error if $wordy_mode;
Carp::confess("Internal autodie::exception error: Don't know how to format mode '$mode'.");
@@ -444,7 +456,7 @@ sub _format_open {
}
}
- # Localising $! means perl make make it a pretty error for us.
+ # Localising $! means perl makes it a pretty error for us.
local $! = $this->errno;
return $this->_format_open_with_mode($mode, $file, $!);
@@ -672,6 +684,12 @@ sub _init {
next if $package->isa('Fatal');
next if $package->isa($class);
next if $package->isa(__PACKAGE__);
+
+ # Anything with the 'autodie::skip' role wants us to skip it.
+ # https://github.com/pjf/autodie/issues/15
+
+ next if ($package->can('DOES') and $package->DOES('autodie::skip'));
+
next if $file =~ /^\(eval\s\d+\)$/;
last;
diff --git a/Master/tlpkg/tlperl/lib/autodie/exception/system.pm b/Master/tlpkg/tlperl/lib/autodie/exception/system.pm
index 0489b61d113..2d734fe7f25 100644
--- a/Master/tlpkg/tlperl/lib/autodie/exception/system.pm
+++ b/Master/tlpkg/tlperl/lib/autodie/exception/system.pm
@@ -5,7 +5,9 @@ use warnings;
use base 'autodie::exception';
use Carp qw(croak);
-our $VERSION = '2.13';
+our $VERSION = '2.23'; # VERSION: Generated by DZP::OurPkg:Version
+
+# ABSTRACT: Exceptions from autodying system().
my $PACKAGE = __PACKAGE__;
diff --git a/Master/tlpkg/tlperl/lib/autodie/hints.pm b/Master/tlpkg/tlperl/lib/autodie/hints.pm
index 36715e979d1..17c898a9008 100644
--- a/Master/tlpkg/tlperl/lib/autodie/hints.pm
+++ b/Master/tlpkg/tlperl/lib/autodie/hints.pm
@@ -5,7 +5,9 @@ use warnings;
use constant PERL58 => ( $] < 5.009 );
-our $VERSION = '2.13';
+our $VERSION = '2.23'; # VERSION: Generated by DZP::OurPkg:Version
+
+# ABSTRACT: Provide hints about user subroutines to autodie
=head1 NAME
@@ -595,4 +597,6 @@ same terms as Perl itself.
L<autodie>, L<Class::DOES>
+=for Pod::Coverage get_hints_for load_hints normalise_hints sub_fullname
+
=cut
diff --git a/Master/tlpkg/tlperl/lib/autodie/skip.pm b/Master/tlpkg/tlperl/lib/autodie/skip.pm
new file mode 100644
index 00000000000..af40662810a
--- /dev/null
+++ b/Master/tlpkg/tlperl/lib/autodie/skip.pm
@@ -0,0 +1,54 @@
+package autodie::skip;
+use strict;
+use warnings;
+
+our $VERSION = '2.23'; # VERSION
+
+# This package exists purely so people can inherit from it,
+# which isn't at all how roles are supposed to work, but it's
+# how people will use them anyway.
+
+if ($] < 5.010) {
+ # Older Perls don't have a native ->DOES. Let's provide a cheap
+ # imitation here.
+
+ *DOES = sub { return shift->isa(@_); };
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+autodie::skip - Skip a package when throwing autodie exceptions
+
+=head1 SYNPOSIS
+
+ use parent qw(autodie::skip);
+
+=head1 DESCRIPTION
+
+This dummy class exists to signal that the class inheriting it should
+be skipped when reporting exceptions from autodie. This is useful
+for utility classes like L<Path::Tiny> that wish to report the location
+of where they were called on failure.
+
+If your class has a better way of doing roles, then you should not
+load this class and instead simply say that your class I<DOES>
+C<autodie::skip> instead.
+
+=head1 AUTHOR
+
+Copyright 2013, Paul Fenwick <pjf@cpan.org>
+
+=head1 LICENSE
+
+This module is free software. You may distribute it under the same
+terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<autodie>, L<autodie::exception>
+
+=cut