]> granicus.if.org Git - python/commitdiff
Use repr() on the filename in EnvironmentError.__str__(). This
authorGuido van Rossum <guido@python.org>
Tue, 11 Aug 1998 18:01:32 +0000 (18:01 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Aug 1998 18:01:32 +0000 (18:01 +0000)
displays funny characters, like spaces or control characters, more
clearly (one of my pet peeves in error messages).  Also only suppress
the filename if it is None; display it if it is '', since that would
be a genuine (illegal) filename passed in!

Lib/exceptions.py

index a81ec3cb0ce9fc1eae14318ae671d5cad319730c..28711df63006628b5ea30d849f075cc5534254c3 100644 (file)
@@ -104,9 +104,9 @@ class EnvironmentError(StandardError):
             self.errno, self.strerror = args
 
     def __str__(self):
-        if self.filename:
+        if self.filename is not None:
             return '[Errno %s] %s: %s' % (self.errno, self.strerror,
-                                        self.filename)
+                                          repr(self.filename))
         elif self.errno and self.strerror:
             return '[Errno %s] %s' % (self.errno, self.strerror)
         else: