diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 17:15:42 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 17:15:42 (GMT) |
commit | 6ced7c433353208e5b9d4dc25018937f1c9ae87d (patch) | |
tree | 61efdd2c527ab2eeeff1dd306218b91efbe1b91d /Modules/_testcapimodule.c | |
parent | 44afe2b35a3f82f26d35a2cec507ec6d59e6d6d3 (diff) | |
download | cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.zip cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.tar.gz cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.tar.bz2 |
Issue #10833: Use PyErr_Format() and PyUnicode_FromFormat() instead of
PyOS_snprintf() to avoid temporary buffer allocated on the stack and a
conversion from bytes to Unicode.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 75dbe57..35d25e6 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -22,14 +22,7 @@ static PyObject *TestError; /* set to exception object in init */ static PyObject * raiseTestError(const char* test_name, const char* msg) { - char buf[2048]; - - if (strlen(test_name) + strlen(msg) > sizeof(buf) - 50) - PyErr_SetString(TestError, "internal error msg too large"); - else { - PyOS_snprintf(buf, sizeof(buf), "%s: %s", test_name, msg); - PyErr_SetString(TestError, buf); - } + PyErr_Format(TestError, "%s: %s", test_name, msg); return NULL; } |