mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
Check for NULL in raw_str on Python3 (#2290)
This commit is contained in:
parent
b2f52225fa
commit
8b9eb964d9
@ -933,8 +933,8 @@ private:
|
|||||||
/// Return string representation -- always returns a new reference, even if already a str
|
/// Return string representation -- always returns a new reference, even if already a str
|
||||||
static PyObject *raw_str(PyObject *op) {
|
static PyObject *raw_str(PyObject *op) {
|
||||||
PyObject *str_value = PyObject_Str(op);
|
PyObject *str_value = PyObject_Str(op);
|
||||||
#if PY_MAJOR_VERSION < 3
|
|
||||||
if (!str_value) throw error_already_set();
|
if (!str_value) throw error_already_set();
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
PyObject *unicode = PyUnicode_FromEncodedObject(str_value, "utf-8", nullptr);
|
PyObject *unicode = PyUnicode_FromEncodedObject(str_value, "utf-8", nullptr);
|
||||||
Py_XDECREF(str_value); str_value = unicode;
|
Py_XDECREF(str_value); str_value = unicode;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user