[pypy-svn] pypy default: Fix for str(IOError(1, 2))
alex_gaynor
commits-noreply at bitbucket.org
Sun Feb 20 17:59:29 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r42187:e4ce179aeac2
Date: 2011-02-18 19:07 -0500
http://bitbucket.org/pypy/pypy/changeset/e4ce179aeac2/
Log: Fix for str(IOError(1, 2))
diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -381,14 +381,17 @@
def descr_str(self, space):
if (not space.is_w(self.w_errno, space.w_None) and
not space.is_w(self.w_strerror, space.w_None)):
+ errno = space.str_w(space.str(self.w_errno))
+ strerror = space.str_w(space.str(self.w_strerror))
if not space.is_w(self.w_filename, space.w_None):
return space.wrap("[Errno %s] %s: %s" % (
- space.str_w(space.str(self.w_errno)),
- space.str_w(self.w_strerror),
+ errno,
+ strerror,
space.str_w(space.repr(self.w_filename))))
- return space.wrap("[Errno %s] %s" %
- (space.str_w(space.str(self.w_errno)),
- space.str_w(self.w_strerror)))
+ return space.wrap("[Errno %s] %s" % (
+ errno,
+ strerror,
+ ))
return W_BaseException.descr_str(self, space)
W_EnvironmentError.typedef = TypeDef(
diff --git a/pypy/module/exceptions/test/test_exc.py b/pypy/module/exceptions/test/test_exc.py
--- a/pypy/module/exceptions/test/test_exc.py
+++ b/pypy/module/exceptions/test/test_exc.py
@@ -69,6 +69,7 @@
assert repr(Exception(3, "x")) == "Exception(3, 'x')"
assert str(IOError("foo", "bar")) == "[Errno foo] bar"
assert isinstance(IOError("foo", "bar"), IOError)
+ assert str(IOError(1, 2)) == "[Errno 1] 2"
def test_custom_class(self):
from exceptions import Exception, BaseException, LookupError
More information about the Pypy-commit
mailing list