summaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2022-02-01 08:00:11 +0100
committerArmin Rigo <arigo@tunes.org>2022-02-01 08:00:11 +0100
commitbd3b3909442c8c8836356eb9ed9d986866f7615d (patch)
tree8aaca70e0fb19911b208a86a7846a0b96fe54b25 /c
parent03fea60451afce2b0d30a1e37adc371526245af1 (diff)
downloadcffi-bd3b3909442c8c8836356eb9ed9d986866f7615d.tar.gz
apply patch from Tomáš on PR 111adapt-tests-for-python3.11
Diffstat (limited to 'c')
-rw-r--r--c/test_c.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/c/test_c.py b/c/test_c.py
index 654584d..906eb07 100644
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1331,9 +1331,11 @@ def test_callback_exception():
except ImportError:
import io as cStringIO # Python 3
import linecache
- def matches(istr, ipattern, ipattern38):
+ def matches(istr, ipattern, ipattern38, ipattern311):
if sys.version_info >= (3, 8):
ipattern = ipattern38
+ if sys.version_info >= (3, 11):
+ ipattern = ipattern311
str, pattern = istr, ipattern
while '$' in pattern:
i = pattern.index('$')
@@ -1387,6 +1389,16 @@ Traceback (most recent call last):
File "$", line $, in check_value
$
ValueError: 42
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>:
+Traceback (most recent call last):
+ File "$", line $, in Zcb1
+ $
+ $
+ File "$", line $, in check_value
+ $
+ $
+ValueError: 42
""")
sys.stderr = cStringIO.StringIO()
bigvalue = 20000
@@ -1401,6 +1413,13 @@ Traceback (most recent call last):
File "$", line $, in test_callback_exception
$
OverflowError: integer 60000 does not fit 'short'
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
+Traceback (most recent call last):
+ File "$", line $, in test_callback_exception
+ $
+ $
+OverflowError: integer 60000 does not fit 'short'
""")
sys.stderr = cStringIO.StringIO()
bigvalue = 20000
@@ -1449,6 +1468,19 @@ Traceback (most recent call last):
File "$", line $, in test_callback_exception
$
TypeError: $integer$
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
+Traceback (most recent call last):
+ File "$", line $, in test_callback_exception
+ $
+ $
+OverflowError: integer 60000 does not fit 'short'
+Exception ignored during handling of the above exception by 'onerror':
+Traceback (most recent call last):
+ File "$", line $, in test_callback_exception
+ $
+ $
+TypeError: $integer$
""")
#
sys.stderr = cStringIO.StringIO()
@@ -1478,6 +1510,19 @@ Traceback (most recent call last):
File "$", line $, in oops
$
AttributeError: 'str' object has no attribute 'append$
+""", """\
+Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
+Traceback (most recent call last):
+ File "$", line $, in test_callback_exception
+ $
+ $
+OverflowError: integer 60000 does not fit 'short'
+Exception ignored during handling of the above exception by 'onerror':
+Traceback (most recent call last):
+ File "$", line $, in oops
+ $
+ $
+AttributeError: 'str' object has no attribute 'append$
""")
finally:
sys.stderr = orig_stderr