fix python version check (#705)

Commit 11a337f1 added major and minor python version
checking to cast.h but does not use the macros defined
via the Python.h inclusion. This may be due to an
intention to use the variables defined by the cmake
module FindPythonInterpreter, but nothing in the
pybind11 repo does anything to convert the cmake
variables to preprocessor defines.
This commit is contained in:
eirrgang 2017-03-01 04:53:38 -05:00 committed by Wenzel Jakob
parent 5143989623
commit 11c9f32c0f

View File

@ -646,14 +646,14 @@ struct type_caster<std::basic_string<CharT, Traits, Allocator>, enable_if_t<is_s
using StringType = std::basic_string<CharT, Traits, Allocator>;
bool load(handle src, bool) {
#if PY_VERSION_MAJOR < 3
#if PY_MAJOR_VERSION < 3
object temp;
#endif
handle load_src = src;
if (!src) {
return false;
} else if (!PyUnicode_Check(load_src.ptr())) {
#if PY_VERSION_MAJOR >= 3
#if PY_MAJOR_VERSION >= 3
return false;
// The below is a guaranteed failure in Python 3 when PyUnicode_Check returns false
#else