mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-40943: PY_SSIZE_T_CLEAN required for '#' formats (GH-20784)
The PY_SSIZE_T_CLEAN macro must now be defined to use PyArg_ParseTuple() and Py_BuildValue() "#" formats: "es#", "et#", "s#", "u#", "y#", "z#", "U#" and "Z#". See the PEP 353. Update _testcapi.test_buildvalue_issue38913().
This commit is contained in:
parent
01ece63d42
commit
37bb289556
6 changed files with 86 additions and 101 deletions
|
@ -6868,29 +6868,36 @@ test_buildvalue_issue38913(PyObject *self, PyObject *Py_UNUSED(ignored))
|
|||
PyObject *res;
|
||||
const char str[] = "string";
|
||||
const Py_UNICODE unicode[] = L"unicode";
|
||||
PyErr_SetNone(PyExc_ZeroDivisionError);
|
||||
assert(!PyErr_Occurred());
|
||||
|
||||
res = Py_BuildValue("(s#O)", str, 1, Py_None);
|
||||
assert(res == NULL);
|
||||
if (!PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_SystemError)) {
|
||||
return NULL;
|
||||
}
|
||||
PyErr_Clear();
|
||||
|
||||
res = Py_BuildValue("(z#O)", str, 1, Py_None);
|
||||
assert(res == NULL);
|
||||
if (!PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_SystemError)) {
|
||||
return NULL;
|
||||
}
|
||||
PyErr_Clear();
|
||||
|
||||
res = Py_BuildValue("(y#O)", str, 1, Py_None);
|
||||
assert(res == NULL);
|
||||
if (!PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_SystemError)) {
|
||||
return NULL;
|
||||
}
|
||||
PyErr_Clear();
|
||||
|
||||
res = Py_BuildValue("(u#O)", unicode, 1, Py_None);
|
||||
assert(res == NULL);
|
||||
if (!PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_SystemError)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue