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 /Doc/c-api | |
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 'Doc/c-api')
-rw-r--r-- | Doc/c-api/apiabiversion.rst | 9 | ||||
-rw-r--r-- | Doc/c-api/init.rst | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Doc/c-api/apiabiversion.rst b/Doc/c-api/apiabiversion.rst index 04050f7..53a42e7 100644 --- a/Doc/c-api/apiabiversion.rst +++ b/Doc/c-api/apiabiversion.rst @@ -58,5 +58,14 @@ See :ref:`stable` for a discussion of API and ABI stability across versions. Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is hexversion ``0x030a00f0``. + This version is also available via the symbol :data:`Py_Version`. + +.. c:var:: const unsigned long Py_Version + + The Python runtime version number encoded in a single constant integer, with + the same format as the c:macro:`PY_VERSION_HEX` macro. + This contains the Python version used at run time. + + .. versionadded:: 3.11 All the given macros are defined in :source:`Include/patchlevel.h`. diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 09dfc68..322b9e4 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -553,6 +553,8 @@ Process-wide parameters period. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as :data:`sys.version`. + See also the :data:`Py_Version` constant. + .. c:function:: const char* Py_GetPlatform() |