mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
44afe2b35a
commit
6ced7c4333
6 changed files with 36 additions and 65 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue