mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Since PyUnicode_AsString is a public API, don't just assert, but do
a regular check and return an error if not unicode.
This commit is contained in:
parent
b0d26335f2
commit
e0a0a6e937
1 changed files with 4 additions and 1 deletions
|
@ -1204,7 +1204,10 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
|
||||||
char*
|
char*
|
||||||
PyUnicode_AsString(PyObject *unicode)
|
PyUnicode_AsString(PyObject *unicode)
|
||||||
{
|
{
|
||||||
assert(PyUnicode_Check(unicode));
|
if (!PyUnicode_Check(unicode)) {
|
||||||
|
PyErr_BadArgument();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
unicode = _PyUnicode_AsDefaultEncodedString(unicode, NULL);
|
unicode = _PyUnicode_AsDefaultEncodedString(unicode, NULL);
|
||||||
if (!unicode)
|
if (!unicode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue