mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-122888: Fix crash on certain calls to str() (GH-122889) (#122947)
Fixes GH-122888
(cherry picked from commit 53ebb6232a
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
8b64ce4eb4
commit
55aede7342
3 changed files with 44 additions and 12 deletions
|
@ -14817,7 +14817,16 @@ unicode_vectorcall(PyObject *type, PyObject *const *args,
|
|||
return PyObject_Str(object);
|
||||
}
|
||||
const char *encoding = arg_as_utf8(args[1], "encoding");
|
||||
const char *errors = (nargs == 3) ? arg_as_utf8(args[2], "errors") : NULL;
|
||||
if (encoding == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
const char *errors = NULL;
|
||||
if (nargs == 3) {
|
||||
errors = arg_as_utf8(args[2], "errors");
|
||||
if (errors == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return PyUnicode_FromEncodedObject(object, encoding, errors);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue