-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
PY_SSIZE_T_CLEAN conflicts with Py_LIMITED_API #71686
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
Comments
When compiling my cryptacular extension https://bitbucket.org/dholth/cryptacular I noticed -DPy_LIMITED_API -DPY_SSIZE_T_CLEAN creates a binary that does not actually use the limited api. This causes segfaults on Linux but does not appear to cause problems on Windows. I found some emails suggestid PY_SSIZE_T_CLEAN was supposed to go away entirely? |
First we should make PY_SSIZE_T_CLEAN mandatory for the term of at least two releases (or to the end of 2.7 support). |
Here it is. https://mail.python.org/pipermail/python-3000/2008-November/015344.html On Sat, Nov 22, 2008 at 06:29, Barry Warsaw <barry at python.org> wrote:
But we can at least document that the macro is a gone as soon as 3.0 -Brett |
Oh, I can avoid this problem by setting Py_LIMITED_API to 0x30300000 or greater. |
Hum, maybe the behavior is different because of the following code in Include/modsupport.h: /* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
#if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats This change hurt me too. A python c module I depend on just started doing this when I upgraded to Fedora36. This broke the ABI in a minor release and ? |
Modify the extension to use Py_ssize_t and define PY_SSIZE_T_CLEAN macro. |
Python 3.10 change (issue #85115):
|
@encukou: You may be interested by this tricky issue :-) I don't know its status in Python 3.12. |
With The situation is unfortunate for non-C languages (which don't see macros). Of course, removing the functionality was disruptive, like any removal of functionality. It wouldn't go away if I'd been in charge. |
If recent versions of Python are fine, can we just close the issue? |
How non-C languages work with variable-argument C functions? How they work with pointers to ssize_t? |
With difficulty.
Same as any other pointer to a C integral type. It's not trivial, but if you can't do it, Python's C API won't be too useful. |
Defining |
Is this issue still relevant after #106315? AFAICS, we can close this as outdated, no? |
I close the issue. While the history is complicated, the root stable ABI issue has been fixed in Python 3.13 by commit adccff3 of gh-104922. History:
At the ABI level, Python <= 3.12 calls different functions if PY_SSIZE_T_CLEAN is defined. Example: #ifdef PY_SSIZE_T_CLEAN
#define PyArg_Parse _PyArg_Parse_SizeT
... Python >= 3.13 calls the same function if PY_SSIZE_T_CLEAN macro is defined or not. The macro PY_SSIZE_T_CLEAN is ignored by Python 3.13 and newer. If you consider Python >= 3.13, the stable ABI is fixed. Python 3.11 and 3.12 still have the ABI issue. From what I understood, PY_SSIZE_T_CLEAN was never compatible with the stable ABI. Python 3.10 and newer always use |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: