From: Guido van Rossum Date: Tue, 11 Aug 1998 18:01:32 +0000 (+0000) Subject: Use repr() on the filename in EnvironmentError.__str__(). This X-Git-Tag: v1.5.2a1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be21d98cee17b21d71fa61d0b5f0fedb62dc4f43;p=python Use repr() on the filename in EnvironmentError.__str__(). This 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! --- diff --git a/Lib/exceptions.py b/Lib/exceptions.py index a81ec3cb0c..28711df630 100644 --- a/Lib/exceptions.py +++ b/Lib/exceptions.py @@ -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: