Selaa lähdekoodia

Support compilation for Python 3.7

rdb 8 vuotta sitten
vanhempi
sitoutus
51d948a7fa

+ 1 - 1
direct/src/dcparser/dcPacker.cxx

@@ -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) {

+ 3 - 3
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -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";

+ 2 - 0
makepanda/makepandacore.py

@@ -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:")

+ 2 - 2
panda/src/gobj/internalName_ext.cxx

@@ -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