Skip to content

Commit 33a9713

Browse files
committed
Adjust tests for a last minute Python 3.11 change in the traceback format
See python/cpython#93883 and python/cpython#93994
1 parent e723f05 commit 33a9713

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

c/test_c.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,11 +1342,11 @@ def test_callback_exception():
13421342
except ImportError:
13431343
import io as cStringIO # Python 3
13441344
import linecache
1345-
def matches(istr, ipattern, ipattern38, ipattern311):
1345+
def matches(istr, ipattern, ipattern38, ipattern311=None):
13461346
if sys.version_info >= (3, 8):
13471347
ipattern = ipattern38
13481348
if sys.version_info >= (3, 11):
1349-
ipattern = ipattern311
1349+
ipattern = ipattern311 or ipattern38
13501350
str, pattern = istr, ipattern
13511351
while '$' in pattern:
13521352
i = pattern.index('$')
@@ -1400,16 +1400,6 @@ def oops(*args):
14001400
File "$", line $, in check_value
14011401
$
14021402
ValueError: 42
1403-
""", """\
1404-
Exception ignored from cffi callback <function$Zcb1 at 0x$>:
1405-
Traceback (most recent call last):
1406-
File "$", line $, in Zcb1
1407-
$
1408-
$
1409-
File "$", line $, in check_value
1410-
$
1411-
$
1412-
ValueError: 42
14131403
""")
14141404
sys.stderr = cStringIO.StringIO()
14151405
bigvalue = 20000
@@ -1424,13 +1414,6 @@ def oops(*args):
14241414
File "$", line $, in test_callback_exception
14251415
$
14261416
OverflowError: integer 60000 does not fit 'short'
1427-
""", """\
1428-
Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
1429-
Traceback (most recent call last):
1430-
File "$", line $, in test_callback_exception
1431-
$
1432-
$
1433-
OverflowError: integer 60000 does not fit 'short'
14341417
""")
14351418
sys.stderr = cStringIO.StringIO()
14361419
bigvalue = 20000
@@ -1479,19 +1462,6 @@ def oops(*args):
14791462
File "$", line $, in test_callback_exception
14801463
$
14811464
TypeError: $integer$
1482-
""", """\
1483-
Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
1484-
Traceback (most recent call last):
1485-
File "$", line $, in test_callback_exception
1486-
$
1487-
$
1488-
OverflowError: integer 60000 does not fit 'short'
1489-
Exception ignored during handling of the above exception by 'onerror':
1490-
Traceback (most recent call last):
1491-
File "$", line $, in test_callback_exception
1492-
$
1493-
$
1494-
TypeError: $integer$
14951465
""")
14961466
#
14971467
sys.stderr = cStringIO.StringIO()
@@ -1526,7 +1496,6 @@ def oops(*args):
15261496
Traceback (most recent call last):
15271497
File "$", line $, in test_callback_exception
15281498
$
1529-
$
15301499
OverflowError: integer 60000 does not fit 'short'
15311500
Exception ignored during handling of the above exception by 'onerror':
15321501
Traceback (most recent call last):

0 commit comments

Comments
 (0)