Skip to content

Commit 2ac4dbb

Browse files
committed
Define PYBIND11_STR_CASTER_NO_IMPLICIT_DECODE, but only for Python 3.
Also defining this for Python 2 would require many insertions of six.ensure_text() in client code.
1 parent 0de68d4 commit 2ac4dbb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/pybind11/detail/common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@
167167
// If DEFINED, pybind11::str can only hold PyUnicodeObject, and
168168
// pybind11::isinstance<str>() is true only for pybind11::str.
169169

170-
//#define PYBIND11_STR_CASTER_NO_IMPLICIT_DECODE
170+
#if PY_MAJOR_VERSION >= 3
171+
#define PYBIND11_STR_CASTER_NO_IMPLICIT_DECODE
172+
#endif
171173
// This macro has an effect only if PYBIND11_STR_NON_PERMISSIVE is defined.
172174
// If UNDEFINED, the pybind11::str caster will implicitly decode bytes to PyUnicodeObject.
173175
// If DEFINED, the pybind11::str caster will only accept PyUnicodeObject.

0 commit comments

Comments
 (0)