tests: Modify tests that print repr of an exception with 1 arg.
In Python 3.7 the behaviour of repr() of an exception with one argument changed: it no longer prints a trailing comma in the argument list. See https://bugs.python.org/issue30399 This patch modifies tests that rely on this behaviour to not rely on it. And the python34.py test is updated to include a test for this behaviour with a .exp file.
This commit is contained in:
parent
4c4f81f8f2
commit
8f0147cf00
|
@ -27,7 +27,7 @@ print({1:1} == {2:1})
|
||||||
try:
|
try:
|
||||||
{}[0]
|
{}[0]
|
||||||
except KeyError as er:
|
except KeyError as er:
|
||||||
print('KeyError', er, repr(er), er.args)
|
print('KeyError', er, er.args)
|
||||||
|
|
||||||
# unsupported unary op
|
# unsupported unary op
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
print(repr(IndexError()))
|
print(repr(IndexError()))
|
||||||
print(str(IndexError()))
|
print(str(IndexError()))
|
||||||
|
|
||||||
print(repr(IndexError("foo")))
|
|
||||||
print(str(IndexError("foo")))
|
print(str(IndexError("foo")))
|
||||||
|
|
||||||
a = IndexError(1, "test", [100, 200])
|
a = IndexError(1, "test", [100, 200])
|
||||||
|
|
|
@ -7,4 +7,4 @@ print(next(g))
|
||||||
try:
|
try:
|
||||||
print(next(g))
|
print(next(g))
|
||||||
except StopIteration as e:
|
except StopIteration as e:
|
||||||
print(repr(e))
|
print(type(e), e.args)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# tests that differ when running under Python 3.4 vs 3.5/3.6
|
# tests that differ when running under Python 3.4 vs 3.5/3.6/3.7
|
||||||
|
|
||||||
try:
|
try:
|
||||||
exec
|
exec
|
||||||
|
@ -36,3 +36,7 @@ test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)
|
||||||
import sys
|
import sys
|
||||||
print(sys.version[:3])
|
print(sys.version[:3])
|
||||||
print(sys.version_info[0], sys.version_info[1])
|
print(sys.version_info[0], sys.version_info[1])
|
||||||
|
|
||||||
|
# from basics/exception1.py
|
||||||
|
# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
|
||||||
|
print(repr(IndexError("foo")))
|
||||||
|
|
|
@ -11,3 +11,4 @@ SyntaxError
|
||||||
SyntaxError
|
SyntaxError
|
||||||
3.4
|
3.4
|
||||||
3 4
|
3 4
|
||||||
|
IndexError('foo',)
|
||||||
|
|
|
@ -7,12 +7,12 @@ print(repr(e))
|
||||||
print(e.args)
|
print(e.args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise MyExc("Some error")
|
raise MyExc("Some error", 1)
|
||||||
except MyExc as e:
|
except MyExc as e:
|
||||||
print("Caught exception:", repr(e))
|
print("Caught exception:", repr(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise MyExc("Some error2")
|
raise MyExc("Some error2", 2)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Caught exception:", repr(e))
|
print("Caught exception:", repr(e))
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
try:
|
try:
|
||||||
raise ValueError(534)
|
raise ValueError(534)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(repr(e))
|
print(type(e), e.args)
|
||||||
|
|
||||||
# Var bound in except block is automatically deleted
|
# Var bound in except block is automatically deleted
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -9,7 +9,7 @@ def f():
|
||||||
print(sys.exc_info()[0:2])
|
print(sys.exc_info()[0:2])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
1/0
|
raise ValueError('value', 123)
|
||||||
except:
|
except:
|
||||||
print(sys.exc_info()[0:2])
|
print(sys.exc_info()[0:2])
|
||||||
f()
|
f()
|
||||||
|
|
Loading…
Reference in New Issue