Debian Codegraph @

pypy/tool/import_cffi.patch

raw
1 diff -u1 -r ../pypy-base/lib_pypy/cffi/_shimmed_dist_utils.py lib_pypy/cffi/_shimmed_dist_utils.py
2 --- ../pypy-base/lib_pypy/cffi/_shimmed_dist_utils.py 2024-02-12 13:18:08.632452561 +0000
3 +++ lib_pypy/cffi/_shimmed_dist_utils.py 2024-02-12 12:17:09.422614238 +0000
4 @@ -15,3 +15,3 @@
5 # Python 3.12 has no built-in distutils to fall back on, so any import problem is fatal
6 - raise Exception("This CFFI feature requires setuptools on Python >= 3.12. The setuptools module is missing or non-functional.") from ex
7 + raise Exception("This CFFI feature requires setuptools on Python >= 3.12. The setuptools module is missing or non-functional.")
8
9 @@ -35,6 +35,6 @@
10 if sys.version_info >= (3, 12):
11 - raise Exception("This CFFI feature requires setuptools on Python >= 3.12. Please install the setuptools package.") from ex
12 + raise Exception("This CFFI feature requires setuptools on Python >= 3.12. Please install the setuptools package.")
13
14 # anything older, just let the underlying distutils import error fly
15 - raise Exception("This CFFI feature requires distutils. Please install the distutils or setuptools package.") from ex
16 + raise Exception("This CFFI feature requires distutils. Please install the distutils or setuptools package.")
17
18 diff -u1 -r '--exclude=__pycache__' ../pypy-base/extra_tests/cffi_tests/cffi0/test_version.py extra_tests/cffi_tests/cffi0/test_version.py
19 --- ../pypy-base/extra_tests/cffi_tests/cffi0/test_version.py 2024-02-12 13:18:08.668450218 +0000
20 +++ extra_tests/cffi_tests/cffi0/test_version.py 2024-02-12 12:17:09.422614238 +0000
21 @@ -4,3 +4,3 @@
22 import cffi, _cffi_backend
23 -from pathlib import Path
24 +#from pathlib import Path --- but on pypy, this module should be skipped anyway
25
26 diff -u1 -r '--exclude=__pycache__' ../pypy-base/extra_tests/cffi_tests/cffi1/test_parse_c_type.py extra_tests/cffi_tests/cffi1/test_parse_c_type.py
27 --- ../pypy-base/extra_tests/cffi_tests/cffi1/test_parse_c_type.py 2024-02-12 13:18:08.688448917 +0000
28 +++ extra_tests/cffi_tests/cffi1/test_parse_c_type.py 2024-02-12 12:17:09.422614238 +0000
29 @@ -5,3 +5,2 @@
30 from cffi import cffi_opcode
31 -from pathlib import Path
32
33 @@ -15,3 +14,3 @@
34
35 -cffi_dir = str(Path(os.path.dirname(__file__)).parent.parent / "src/cffi")
36 +cffi_dir = os.path.dirname(cffi_opcode.__file__)
37
38 diff -u1 -r '--exclude=__pycache__' ../pypy-base/extra_tests/cffi_tests/test_c.py extra_tests/cffi_tests/test_c.py
39 --- ../pypy-base/extra_tests/cffi_tests/test_c.py 2024-02-12 13:18:08.732446053 +0000
40 +++ extra_tests/cffi_tests/test_c.py 2024-02-12 13:23:06.921031740 +0000
41
42 @@ -1,12 +1,5 @@
43 -from __future__ import annotations
44 -
45 -import contextlib
46 -import traceback
47 -import unittest.mock
48 -
49 import pytest
50 import sys
51 -import typing as t
52
53 is_musl = False
54 if sys.platform == 'linux':
55 @@ -30,36 +23,6 @@ except ImportError:
56 pytest.skip("_testunc() not available")
57 from _cffi_backend import __version__
58
59 -
60 [email protected]
61 -def _assert_unraisable(error_type: type[Exception] | None, message: str = '', traceback_tokens: list[str] | None = None):
62 - """Assert that a given sys.unraisablehook interaction occurred (or did not occur, if error_type is None) while this context was active"""
63 - raised_errors: list[Exception] = []
64 - raised_traceback: str = ''
65 -
66 - # sys.unraisablehook is called more than once for chained exceptions; accumulate the errors and tracebacks for inspection
67 - def _capture_unraisable_hook(ur_args):
68 - nonlocal raised_traceback
69 - raised_errors.append(ur_args.exc_value)
70 -
71 - # NB: need to use the old etype/value/tb form until 3.10 is the minimum
72 - raised_traceback += (ur_args.err_msg or '' + '\n') + ''.join(traceback.format_exception(None, ur_args.exc_value, ur_args.exc_traceback))
73 -
74 -
75 - with pytest.MonkeyPatch.context() as mp:
76 - mp.setattr(sys, 'unraisablehook', _capture_unraisable_hook)
77 - yield
78 -
79 - if error_type is None:
80 - assert not raised_errors
81 - assert not raised_traceback
82 - return
83 -
84 - assert any(type(raised_error) is error_type for raised_error in raised_errors)
85 - assert any(message in str(raised_error) for raised_error in raised_errors)
86 - for t in traceback_tokens or []:
87 - assert t in raised_traceback
88 -
89 # ____________________________________________________________
90
91 import sys
92 @@ -1377,6 +1340,7 @@ def test_callback():
93
94
95 def test_callback_exception():
96 + pytest.skip("XXX not written for Python 2")
97 def check_value(x):
98 if x == 10000:
99 raise ValueError(42)
100 diff --git a/extra_tests/cffi_tests/cffi0/test_version.py b/extra_tests/cffi_tests/cffi0/test_version.py
101 index 5aec6f91e27..f08731e1d14 100644
102 --- extra_tests/cffi_tests/cffi0/test_version.py
103 +++ extra_tests/cffi_tests/cffi0/test_version.py
104 @@ -41,11 +41,11 @@ def test_doc_version():
105
106 def test_pyproject_version():
107 cffi_root = Path(os.path.dirname(__file__)).parent.parent
108 - p = cffi_root / 'pyproject.toml'
109 + p = cffi_root / 'setup.py'
110 content = _read(p)
111 #
112 v = cffi.__version__.replace('+', '')
113 - assert f'version = "{v}"' in content
114 + assert ("version='%s'" % v) in content
115
116 def test_c_version():
117 cffi_root = Path(os.path.dirname(__file__)).parent.parent
118 --