summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-19 09:45:31 (GMT)
committerGitHub <noreply@github.com>2020-06-19 09:45:31 (GMT)
commit37bb2895561d3e63a631f10875567b4e33b30c07 (patch)
tree25afc8f4882caeaef5f14e09499a5e949f218b0c /Modules
parent01ece63d42b830df106948db0aefa6c1ba24416a (diff)
downloadcpython-37bb2895561d3e63a631f10875567b4e33b30c07.zip
cpython-37bb2895561d3e63a631f10875567b4e33b30c07.tar.gz
cpython-37bb2895561d3e63a631f10875567b4e33b30c07.tar.bz2
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().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 5302641..808483e 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -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;
}