Author: Armin Rigo <[email protected]>
Branch: py3.7
Changeset: r98411:112b3a20f382
Date: 2019-12-30 09:08 +0000
http://bitbucket.org/pypy/pypy/changeset/112b3a20f382/
Log: Merged in py3.7-bpo-30399 (pull request #689)
Implement bpo-30399: Get rid of trailing comma in the repr of
BaseException
diff --git a/pypy/interpreter/test/test_error.py
b/pypy/interpreter/test/test_error.py
--- a/pypy/interpreter/test/test_error.py
+++ b/pypy/interpreter/test/test_error.py
@@ -42,7 +42,7 @@
val = operr.get_w_value(space)
assert space.isinstance_w(val, space.w_AttributeError)
w_repr = space.repr(val)
- assert space.text_w(w_repr) == "AttributeError(\"no attribute 'foo'\",)"
+ assert space.text_w(w_repr) == "AttributeError(\"no attribute 'foo'\")"
def test_oefmt_T(space):
operr = oefmt(space.w_AttributeError,
@@ -110,7 +110,7 @@
operr = OperationError(space.w_ValueError, space.wrap("message"))
assert operr.errorstr(space) == "ValueError: message"
assert operr.errorstr(space, use_repr=True) == (
- "ValueError: ValueError('message',)")
+ "ValueError: ValueError('message')")
operr = OperationError(space.w_ValueError, space.w_None)
assert operr.errorstr(space) == "ValueError"
operr = OperationError(space.w_ValueError,
diff --git a/pypy/module/cpyext/test/test_cpyext.py
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -751,7 +751,7 @@
module = self.import_module(name='foo', body=body)
# uncaught interplevel exceptions are turned into SystemError
- expected = "ZeroDivisionError('integer division or modulo by zero',)"
+ expected = "ZeroDivisionError('integer division or modulo by zero')"
exc = raises(SystemError, module.crash1)
assert exc.value.args[0] == expected
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
@@ -149,11 +149,16 @@
return space.call_function(space.w_unicode, w_tup)
def descr_repr(self, space):
- if self.args_w:
+ lgt = len(self.args_w)
+ if lgt == 0:
+ args_repr = b"()"
+ elif lgt == 1:
+ args_repr = (b"(" +
+ space.utf8_w(space.repr(self.args_w[0])) +
+ b")")
+ else:
args_repr = space.utf8_w(
space.repr(space.newtuple(self.args_w)))
- else:
- args_repr = b"()"
clsname = self.getclass(space).getname(space)
return space.newtext(clsname + args_repr)
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
@@ -10,7 +10,7 @@
assert repr(BaseException()) == 'BaseException()'
raises(AttributeError, getattr, BaseException(), 'message')
raises(AttributeError, getattr, BaseException(3), 'message')
- assert repr(BaseException(3)) == 'BaseException(3,)'
+ assert repr(BaseException(3)) == 'BaseException(3)'
assert str(BaseException(3)) == '3'
assert BaseException().args == ()
assert BaseException(3).args == (3,)
@@ -328,7 +328,7 @@
assert ModuleNotFoundError("message", name="x").name == "x"
assert ModuleNotFoundError("message", path="y").path == "y"
raises(TypeError, ModuleNotFoundError, invalid="z")
- assert repr(ModuleNotFoundError('test')) ==
"ModuleNotFoundError('test',)"
+ assert repr(ModuleNotFoundError('test')) ==
"ModuleNotFoundError('test')"
def test_blockingioerror(self):
args = ("a", "b", "c", "d", "e")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit