<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,16 @@
 Revision history for autodie
 
+        * BUGFIX: format_default() in autodie::exception no longer
+          returns a string with file and line attached.  This would
+          cause the file and line information to appear twice when
+          format handlers would choose to fall back to the defaults.
+          The file and line information is now always added by
+          stringify().  (RT #47520, thanks to Michael Schwern)
+
+        * BUGFIX: Exceptions thrown by 2-argument open() are more likely
+          to specify the mode as 'for reading' when no explicit
+          mode was given.  (RT #47520, thanks to Michael Schwern)
+
 2.04  Thu Jul  2 18:56:57 AUSEST 2009
 
         * TEST: Removed spurious warning about insufficient credit.</diff>
      <filename>Changes</filename>
    </modified>
    <modified>
      <diff>@@ -417,8 +417,20 @@ sub _format_open {
             [^&amp;]                # Not an ampersand (which means a dup)
         }x;
 
-        # Have a funny mode?  Use the default format.
-        return $this-&gt;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 = '&lt;'
+            }
+            else {
+                # Otherwise, we've got no idea what's going on.
+                # Use the default.
+                return $this-&gt;format_default;
+            }
+        }
 
         # Localising $! means perl make make it a pretty error for us.
         local $! = $this-&gt;errno;
@@ -517,7 +529,7 @@ sub stringify {
         return $sub-&gt;($this) . $this-&gt;add_file_and_line;
     }
 
-    return $this-&gt;format_default;
+    return $this-&gt;format_default . $this-&gt;add_file_and_line;
 
 }
 
@@ -568,8 +580,7 @@ sub format_default {
 
     # Format our beautiful error.
 
-    return &quot;Can't $call(&quot;.  join(q{, }, @args) . &quot;): $!&quot; .
-        $this-&gt;add_file_and_line;
+    return &quot;Can't $call(&quot;.  join(q{, }, @args) . &quot;): $!&quot; ;
 
     # TODO - Handle user-defined errors from hash.
 </diff>
      <filename>lib/autodie/exception.pm</filename>
    </modified>
    <modified>
      <diff>@@ -16,3 +16,34 @@ ok($@, &quot;2-arg opening non-existent file fails&quot;);
 
 like($@, qr/for reading/, &quot;Well-formatted 2-arg open failure&quot;);
 unlike($@, qr/GLOB\(0x/, &quot;No ugly globs in 2-arg open messsage&quot;);
+
+# 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+/, &quot;At least one mention&quot;);
+unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, &quot;...but not too mentions&quot;);
+
+# RT 47520-ish.  2-argument open without a mode should be marked
+# as 'for reading'.
+like($@, qr/for reading/, &quot;Well formatted 2-arg open without mode&quot;);
+
+# 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 . &quot;&quot; );
+};
+
+isa_ok($@, 'autodie::exception');
+like(  $@, qr/at \S+ line \d+/, &quot;At least one mention&quot;);
+unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, &quot;...but not too mentions&quot;);</diff>
      <filename>t/open.t</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>79a10c3a3e2f4cab5398e26684e6c0c0c2893d25</id>
    </parent>
  </parents>
  <author>
    <name>Paul Fenwick</name>
    <email>pjf@perltraining.com.au</email>
  </author>
  <url>http://github.com/pfenwick/autodie/commit/8b12854da6dab4b53ff5d47f462411c29b301859</url>
  <id>8b12854da6dab4b53ff5d47f462411c29b301859</id>
  <committed-date>2009-07-02T18:56:36-07:00</committed-date>
  <authored-date>2009-07-02T18:56:36-07:00</authored-date>
  <message>RT #47520 - No double file/line messages. Better 2-arg open messages.</message>
  <tree>0bca6df5f7693320cfa75dacbc0b81541b754504</tree>
  <committer>
    <name>Paul Fenwick</name>
    <email>pjf@perltraining.com.au</email>
  </committer>
</commit>
