Support compilation for Python 3.7

This commit is contained in:
rdb 2017-10-13 12:40:29 +02:00
parent 5758fdf8f5
commit 51d948a7fa
4 changed files with 8 additions and 6 deletions

View File

@ -708,7 +708,7 @@ pack_object(PyObject *object) {
pack_int64(PyLong_AsLongLong(object));
#if PY_MAJOR_VERSION >= 3
} else if (PyUnicode_Check(object)) {
char *buffer;
const char *buffer;
Py_ssize_t length;
buffer = PyUnicode_AsUTF8AndSize(object, &length);
if (buffer) {

View File

@ -4819,7 +4819,7 @@ write_function_instance(ostream &out, FunctionRemap *remap,
<< default_value->_str.size() << ";\n";
}
} else {
indent(out, indent_level) << "char *" << param_name << "_str = NULL;\n";
indent(out, indent_level) << "const char *" << param_name << "_str = NULL;\n";
indent(out, indent_level) << "Py_ssize_t " << param_name << "_len;\n";
}
@ -4828,7 +4828,7 @@ write_function_instance(ostream &out, FunctionRemap *remap,
// As a special hack to fix pickling in Python 3, if the method name
// starts with py_decode_, we take a bytes object instead of a str.
if (remap->_cppfunc->get_local_name().substr(0, 10) == "py_decode_") {
indent(out, indent_level) << "if (PyBytes_AsStringAndSize(arg, &"
indent(out, indent_level) << "if (PyBytes_AsStringAndSize(arg, (char **)&"
<< param_name << "_str, &" << param_name << "_len) == -1) {\n";
indent(out, indent_level + 2) << param_name << "_str = NULL;\n";
indent(out, indent_level) << "}\n";
@ -4838,7 +4838,7 @@ write_function_instance(ostream &out, FunctionRemap *remap,
<< param_name << "_len);\n";
}
out << "#else\n"; // NB. PyString_AsStringAndSize also accepts a PyUnicode.
indent(out, indent_level) << "if (PyString_AsStringAndSize(arg, &"
indent(out, indent_level) << "if (PyString_AsStringAndSize(arg, (char **)&"
<< param_name << "_str, &" << param_name << "_len) == -1) {\n";
indent(out, indent_level + 2) << param_name << "_str = NULL;\n";
indent(out, indent_level) << "}\n";

View File

@ -2620,6 +2620,8 @@ def SetupBuildEnvironment(compiler):
if os.path.isdir(pcbsd_inc):
SYS_INC_DIRS.append(pcbsd_inc)
null.close()
# Print out the search paths
if GetVerbose():
print("System library search path:")

View File

@ -26,7 +26,7 @@ make(PyUnicodeObject *str) {
if (!PyUnicode_CHECK_INTERNED(str)) {
// Not an interned string; don't bother.
Py_ssize_t len = 0;
char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len);
const char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len);
if (c_str == NULL) {
return NULL;
}
@ -43,7 +43,7 @@ make(PyUnicodeObject *str) {
} else {
Py_ssize_t len = 0;
char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len);
const char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len);
string name(c_str, len);
#else