diff options
author | Gabriele N. Tornetta <P403n1x87@users.noreply.github.com> | 2021-12-10 01:52:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 01:52:05 (GMT) |
commit | 50669083fe16a42cba90b5dd8c1a017751f69fd8 (patch) | |
tree | fc2a1c7425e20d7df0b4fa44b23fdf47b5bbf35c /Lib | |
parent | da3cf4304f6dd530533bbd2c0913b674cd803744 (diff) | |
download | cpython-50669083fe16a42cba90b5dd8c1a017751f69fd8.zip cpython-50669083fe16a42cba90b5dd8c1a017751f69fd8.tar.gz cpython-50669083fe16a42cba90b5dd8c1a017751f69fd8.tar.bz2 |
bpo-43931: Export Python version as API data (GH-25577)
When Python is embedded in other applications, it is not easy to determine which version of Python is being used. This change exposes the Python version as part of the API data. Tools like Austin (https://github.com/P403n1x87/austin) can benefit from this data when targeting applications like uWSGI, as the Python version can then be inferred systematically by looking at the exported symbols rather than relying on unreliable pattern matching or other hacks (like remote code execution etc...).
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_capi.py | 3 | ||||
-rw-r--r-- | Lib/test/test_stable_abi_ctypes.py | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index d512470..ecf3aa3 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -840,6 +840,9 @@ class Test_testcapi(unittest.TestCase): def test_widechar(self): _testcapi.test_widechar() + def test_version_api_data(self): + self.assertEqual(_testcapi.Py_Version, sys.hexversion) + class Test_testinternalcapi(unittest.TestCase): locals().update((name, getattr(_testinternalcapi, name)) diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py index d0cd5c2..9fd6b14 100644 --- a/Lib/test/test_stable_abi_ctypes.py +++ b/Lib/test/test_stable_abi_ctypes.py @@ -808,6 +808,7 @@ SYMBOL_NAMES = ( "Py_SetRecursionLimit", "Py_UTF8Mode", "Py_VaBuildValue", + "Py_Version", "Py_XNewRef", "_PyArg_ParseTupleAndKeywords_SizeT", "_PyArg_ParseTuple_SizeT", |