Skip to content

Commit 538e2f8

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 255f9ad commit 538e2f8

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
@@ -168,7 +168,9 @@
168168
// If DEFINED, pybind11::str can only hold PyUnicodeObject, and
169169
// pybind11::isinstance<str>() is true only for pybind11::str.
170170

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

0 commit comments

Comments
 (0)