Run this example on a 32-bit machine with more than 2GB of addressable RAM (e.g. by default, more or less anything but Windows). On Python 2.7 it raises "SystemError: Negative size passed to PyString_FromStringAndSize". On a debug version, it causes an assert in _Py_Mangle() to trigger.
Modified the example to run in only 1+GB of RAM, so that it crashes also on 32-bit versions of the Python 2.7 interpreter in Windows (the most common around, I suppose).
You may want to add a test. This might help notice that comparing an integer of type Py_ssize_t to check if it's greater than PY_SSIZE_T_MAX is bogus in C :-(
The crash is very obscure, I don't think we want to bother with a unit test for that (it took 14 seconds to crash or pass here). > This might help notice that comparing an integer of type Py_ssize_t to > check if it's greater than PY_SSIZE_T_MAX is bogus in C The variables are of type size_t, not Py_ssize_t (which explains why the comparison works).
History
Date
User
Action
Args
2022-04-11 14:57:43
admin
set
github: 61845
2013-04-07 10:30:49
pitrou
set
resolution: fixedmessages: +
2013-04-07 08:24:16
arigo
set
resolution: fixed -> (no value)messages: + stage: resolved -> test needed