[Python-checkins] bpo-43321: Fix SystemError in getargs.c (GH-24656)
methane
webhook-mailer at python.org
Sat Feb 27 06:31:32 EST 2021
https://github.com/python/cpython/commit/c71d24f55828e7f0f2c8750d2e1b04d04539beff
commit: c71d24f55828e7f0f2c8750d2e1b04d04539beff
branch: master
author: Inada Naoki <songofacandy at gmail.com>
committer: methane <songofacandy at gmail.com>
date: 2021-02-27T20:31:03+09:00
summary:
bpo-43321: Fix SystemError in getargs.c (GH-24656)
files:
A Misc/NEWS.d/next/Core and Builtins/2021-02-26-13-17-52.bpo-43321.TCS3ph.rst
M Python/getargs.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-02-26-13-17-52.bpo-43321.TCS3ph.rst b/Misc/NEWS.d/next/Core and Builtins/2021-02-26-13-17-52.bpo-43321.TCS3ph.rst
new file mode 100644
index 0000000000000..32c5ce14de51c
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-02-26-13-17-52.bpo-43321.TCS3ph.rst
@@ -0,0 +1,2 @@
+Fix ``SystemError`` raised when ``PyArg_Parse*()`` is used with ``#`` but
+without ``PY_SSIZE_T_CLEAN`` defined.
diff --git a/Python/getargs.c b/Python/getargs.c
index 936eb6a89a392..b85b575a147fe 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -655,14 +655,14 @@ static const char *
convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
char *msgbuf, size_t bufsize, freelist_t *freelist)
{
+#define RETURN_ERR_OCCURRED return msgbuf
/* For # codes */
#define REQUIRE_PY_SSIZE_T_CLEAN \
if (!(flags & FLAG_SIZE_T)) { \
PyErr_SetString(PyExc_SystemError, \
"PY_SSIZE_T_CLEAN macro must be defined for '#' formats"); \
- return NULL; \
+ RETURN_ERR_OCCURRED; \
}
-#define RETURN_ERR_OCCURRED return msgbuf
const char *format = *p_format;
char c = *format++;
More information about the Python-checkins
mailing list