forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Add abi_features to sys #1
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
Open
zklaus
wants to merge
12
commits into
main
Choose a base branch
from
abi-features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2cad401
Add abi_features to sys
zklaus e24cc36
Add docs
zklaus cf7dd25
Add gil-enabled threading feature
zklaus 7c4a399
Apply suggestions from code review
zklaus 28013cd
Remove superfluous availability flag in docs
zklaus 1e70c5d
Remove superfluous list
zklaus 4ddb002
Improve bitness detection
zklaus f69a8f8
Simplify debug check
zklaus 123e810
Fix typo
zklaus 29f1ea0
Remove obsolete code
zklaus d92e16c
Apply suggestions from code review
zklaus 22fbaa6
Update Doc/library/sys.rst
zklaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3479,6 +3479,71 @@ make_impl_info(PyObject *version_info) | |||||||||||||||||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| static PyObject* | ||||||||||||||||||||||||||||||||||||||||||||||
| make_abi_features(void) | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| int res; | ||||||||||||||||||||||||||||||||||||||||||||||
| PyObject *features = PyFrozenSet_New(NULL); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (features == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef Py_GIL_DISABLED | ||||||||||||||||||||||||||||||||||||||||||||||
| PyObject *threading_feature = PyUnicode_FromString("free-threading"); | ||||||||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||||||||
| PyObject *threading_feature = PyUnicode_FromString("gil-enabled"); | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
| if (threading_feature == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| res = PySet_Add(features, threading_feature); | ||||||||||||||||||||||||||||||||||||||||||||||
| Py_DECREF(threading_feature); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (res < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef Py_DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||
| PyObject *debug = PyUnicode_FromString("debug"); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (debug == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| res = PySet_Add(features, debug); | ||||||||||||||||||||||||||||||||||||||||||||||
| Py_DECREF(debug); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (res < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PyObject *bitness; | ||||||||||||||||||||||||||||||||||||||||||||||
| switch (PY_SSIZE_T_MAX) { | ||||||||||||||||||||||||||||||||||||||||||||||
| case 0x7FFFFFFFL: | ||||||||||||||||||||||||||||||||||||||||||||||
| bitness = PyUnicode_FromString("32-bit"); | ||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||
| case 0x7FFFFFFFFFFFFFFFL: | ||||||||||||||||||||||||||||||||||||||||||||||
| bitness = PyUnicode_FromString("64-bit"); | ||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||
| bitness = Py_NewRef(Py_None); | ||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3518
to
+3528
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (bitness == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| if (bitness != Py_None) { | ||||||||||||||||||||||||||||||||||||||||||||||
| res = PySet_Add(features, bitness); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| Py_DECREF(bitness); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (res < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| goto error; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return features; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| error: | ||||||||||||||||||||||||||||||||||||||||||||||
| Py_XDECREF(features); | ||||||||||||||||||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef __EMSCRIPTEN__ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| PyDoc_STRVAR(emscripten_info__doc__, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -3665,6 +3730,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) | |||||||||||||||||||||||||||||||||||||||||||||
| #ifdef ABIFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||
| SET_SYS_FROM_STRING("abiflags", ABIFLAGS); | ||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||
| SET_SYS("abi_features", make_abi_features()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #define ENSURE_INFO_TYPE(TYPE, DESC) \ | ||||||||||||||||||||||||||||||||||||||||||||||
| do { \ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right place. This information is part of the target architecture, where this API is meant to expose features of the Python ABI — see PEP 3149.