use constant MIN_IPC_SYS_SIMPLE_VER => 0.12;
# All the Fatal/autodie modules share the same version number.
-our $VERSION = '2.04';
+our $VERSION = '2.05';
our $Debug ||= 0;
':2.02' => [qw(:default)],
':2.03' => [qw(:default)],
':2.04' => [qw(:default)],
+ ':2.05' => [qw(:default)],
);
$TAGS{':all'} = [ keys %TAGS ];
our $VERSION;
BEGIN {
- $VERSION = '2.04';
+ $VERSION = '2.05';
}
use constant ERROR_WRONG_FATAL => q{
use if ($] >= 5.010), overload => '~~' => "matches";
-our $VERSION = '2.04';
+our $VERSION = '2.05';
my $PACKAGE = __PACKAGE__; # Useful to have a scalar for hash keys.
[^&] # Not an ampersand (which means a dup)
}x;
- # Have a funny mode? Use the default format.
- return $this->format_default if not defined $mode;
+ if (not $mode) {
+ # Maybe it's a 2-arg open without any mode at all?
+ # Detect the most simple case for this, where our
+ # file consists only of word characters.
+
+ if ( $file =~ m{^\s*\w+\s*$} ) {
+ $mode = '<'
+ }
+ else {
+ # Otherwise, we've got no idea what's going on.
+ # Use the default.
+ return $this->format_default;
+ }
+ }
# Localising $! means perl make make it a pretty error for us.
local $! = $this->errno;
return $sub->($this) . $this->add_file_and_line;
}
- return $this->format_default;
+ return $this->format_default . $this->add_file_and_line;
}
# Format our beautiful error.
- return "Can't $call(". join(q{, }, @args) . "): $!" .
- $this->add_file_and_line;
+ return "Can't $call(". join(q{, }, @args) . "): $!" ;
# TODO - Handle user-defined errors from hash.
use base 'autodie::exception';
use Carp qw(croak);
-our $VERSION = '2.04';
+our $VERSION = '2.05';
my $PACKAGE = __PACKAGE__;
use constant PERL58 => ( $] < 5.009 );
-our $VERSION = '2.04';
+our $VERSION = '2.05';
=head1 NAME
like($@, qr/for reading/, "Well-formatted 2-arg open failure");
unlike($@, qr/GLOB\(0x/, "No ugly globs in 2-arg open messsage");
+
+# RT 47520. 2-argument open without mode would repeat the file
+# and line number.
+
+eval {
+ use autodie;
+
+ open(my $fh, NO_SUCH_FILE);
+};
+
+isa_ok($@, 'autodie::exception');
+like( $@, qr/at \S+ line \d+/, "At least one mention");
+unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, "...but not too mentions");
+
+# RT 47520-ish. 2-argument open without a mode should be marked
+# as 'for reading'.
+like($@, qr/for reading/, "Well formatted 2-arg open without mode");
+
+# We also shouldn't get repeated messages, even if the default mode
+# was used. Single-arg open always falls through to the default
+# formatter.
+
+eval {
+ use autodie;
+
+ open( NO_SUCH_FILE . "" );
+};
+
+isa_ok($@, 'autodie::exception');
+like( $@, qr/at \S+ line \d+/, "At least one mention");
+unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, "...but not too mentions");