Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43931: Export Python version as API data #25577

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

@P403n1x87
Copy link
Contributor

@P403n1x87 P403n1x87 commented Apr 24, 2021

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...).

https://bugs.python.org/issue43931

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 with the
API data
@P403n1x87 P403n1x87 changed the title bpo-43931: export Python version as API data bpo-43931: Export Python version as API data Apr 24, 2021
@markshannon
Copy link
Contributor

@markshannon markshannon commented May 14, 2021

Wouldn't it make more sense to export the hex version number?
The format is fixed and won't need parsing.

@P403n1x87
Copy link
Contributor Author

@P403n1x87 P403n1x87 commented May 14, 2021

Wouldn't it make more sense to export the hex version number?
The format is fixed and won't need parsing.

Yes it makes a lot of sense. Indeed I have thought about exporting something like

(PY_MAJOR << 16) | (PY_MINOR << 8) | PY_PATCH

as an alternative, which would certainly be more efficient to read and parse, but then I realised that I could do

(gdb) print Py_Version
$1 = 0x2d788d "3.10.0a7+"

which is neat 🙂. Personally, as far as my use-cases go, I'm fine either way, so if you prefer that I make the change that's totally cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants