classification
Title: PY_SSIZE_T_CLEAN conflicts with Py_LIMITED_API
Type: Stage:
Components: Extension Modules Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dholth, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2016-07-12 15:59 by dholth, last changed 2020-06-10 16:48 by vstinner.

Messages (6)
msg270252 - (view) Author: Daniel Holth (dholth) Date: 2016-07-12 15:59
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?
msg270255 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-07-12 16:32
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).
msg270256 - (view) Author: Daniel Holth (dholth) Date: 2016-07-12 17:16
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:
>
> On Nov 22, 2008, at 4:05 AM, Martin v. Löwis wrote:
>
>> I just noticed that the Python 3 C API still contains PY_SSIZE_T_CLEAN.
>>
>> This macro was a transition mechanism, to allow extensions to use
>> Py_ssize_t in PyArg_ParseTuple, while allowing other module continue
>> to use int.
>>
>> In Python 3, I would like the mechanism, making Py_ssize_t the only
>> valid data type for size in, say, s# parsers.
>>
>> Is it ok to still change that?
>
> Given that we just released the last planned candidate, I'd say it was too
> late to change this for Python 3.0.
>

But we can at least document that the macro is a gone as soon as 3.0
final is out the door.

-Brett
msg270260 - (view) Author: Daniel Holth (dholth) Date: 2016-07-12 18:00
Oh, I can avoid this problem by setting Py_LIMITED_API to 0x30300000 or greater.
msg371221 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-10 16:48
> 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
msg371222 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-10 16:48
See also bpo-40943: PEP 353: Drop support for PyArg_ParseTuple() format when PY_SSIZE_T_CLEAN is not defined.
History
Date User Action Args
2020-06-10 16:48:48vstinnersetmessages: + msg371222
2020-06-10 16:48:28vstinnersetnosy: + vstinner
messages: + msg371221
2016-07-12 18:00:43dholthsetmessages: + msg270260
2016-07-12 17:16:50dholthsetmessages: + msg270256
2016-07-12 16:32:35serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg270255
2016-07-12 15:59:47dholthcreate