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
This commit is contained in:
Gabriele N. Tornetta
2021-12-10 01:52:05 +00:00
committed by GitHub
parent da3cf4304f
commit 50669083fe
12 changed files with 34 additions and 0 deletions

View File

@@ -62,6 +62,10 @@ typedef void (*PyOS_sighandler_t)(int);
PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000
PyAPI_DATA(const unsigned long) Py_Version;
#endif
#ifndef Py_LIMITED_API
# define Py_CPYTHON_PYLIFECYCLE_H
# include "cpython/pylifecycle.h"