Skip to content

Commit 8b9eb96

Browse files
authored
Check for NULL in raw_str on Python3 (#2290)
1 parent b2f5222 commit 8b9eb96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/pybind11/pytypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,8 @@ class str : public object {
933933
/// Return string representation -- always returns a new reference, even if already a str
934934
static PyObject *raw_str(PyObject *op) {
935935
PyObject *str_value = PyObject_Str(op);
936-
#if PY_MAJOR_VERSION < 3
937936
if (!str_value) throw error_already_set();
937+
#if PY_MAJOR_VERSION < 3
938938
PyObject *unicode = PyUnicode_FromEncodedObject(str_value, "utf-8", nullptr);
939939
Py_XDECREF(str_value); str_value = unicode;
940940
#endif

0 commit comments

Comments
 (0)