Check for NULL in raw_str on Python3 (#2290)

This commit is contained in:
Boris Staletic 2020-07-11 17:20:22 +02:00 committed by GitHub
parent b2f52225fa
commit 8b9eb964d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -933,8 +933,8 @@ private:
/// Return string representation -- always returns a new reference, even if already a str
static PyObject *raw_str(PyObject *op) {
PyObject *str_value = PyObject_Str(op);
#if PY_MAJOR_VERSION < 3
if (!str_value) throw error_already_set();
#if PY_MAJOR_VERSION < 3
PyObject *unicode = PyUnicode_FromEncodedObject(str_value, "utf-8", nullptr);
Py_XDECREF(str_value); str_value = unicode;
#endif