mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
50669083fe
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
19 lines
406 B
C
19 lines
406 B
C
|
|
/* Return the full version string. */
|
|
|
|
#include "Python.h"
|
|
|
|
#include "patchlevel.h"
|
|
|
|
const char *
|
|
Py_GetVersion(void)
|
|
{
|
|
static char version[250];
|
|
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
|
|
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
|
|
return version;
|
|
}
|
|
|
|
// Export the Python hex version as a constant.
|
|
const unsigned long Py_Version = PY_VERSION_HEX;
|