Browse Source

Compile fixes for older Python 3 versions

rdb 8 years ago
parent
commit
65a705217e
2 changed files with 15 additions and 11 deletions
  1. 3 3
      dtool/src/interrogatedb/py_panda.cxx
  2. 12 8
      dtool/src/pystub/pystub.cxx

+ 3 - 3
dtool/src/interrogatedb/py_panda.cxx

@@ -48,7 +48,7 @@ size_t PyLongOrInt_AsSize_t(PyObject *vv) {
   }
   }
 
 
   if (!PyLong_Check(vv)) {
   if (!PyLong_Check(vv)) {
-    PyErr_BadInternalCall();
+    Dtool_Raise_TypeError("a long or int was expected");
     return (size_t)-1;
     return (size_t)-1;
   }
   }
 
 
@@ -950,7 +950,7 @@ bool Dtool_ExtractArg(PyObject **result, PyObject *args, PyObject *kwds,
     if (kwds != NULL && ((PyDictObject *)kwds)->ma_used == 1 &&
     if (kwds != NULL && ((PyDictObject *)kwds)->ma_used == 1 &&
         PyDict_Next(kwds, &ppos, &key, result)) {
         PyDict_Next(kwds, &ppos, &key, result)) {
       // We got the item, we just need to make sure that it had the right key.
       // We got the item, we just need to make sure that it had the right key.
-#if PY_VERSION_HEX >= 0x03050000
+#if PY_VERSION_HEX >= 0x03060000
       return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
       return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
 #elif PY_MAJOR_VERSION >= 3
 #elif PY_MAJOR_VERSION >= 3
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
@@ -999,7 +999,7 @@ bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, PyObject *kwds,
       }
       }
 
 
       // We got the item, we just need to make sure that it had the right key.
       // We got the item, we just need to make sure that it had the right key.
-#if PY_VERSION_HEX >= 0x03050000
+#if PY_VERSION_HEX >= 0x03060000
       return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
       return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
 #elif PY_MAJOR_VERSION >= 3
 #elif PY_MAJOR_VERSION >= 3
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;

+ 12 - 8
dtool/src/pystub/pystub.cxx

@@ -145,19 +145,21 @@ extern "C" {
   EXPCL_PYSTUB int PyType_GenericAlloc(...);
   EXPCL_PYSTUB int PyType_GenericAlloc(...);
   EXPCL_PYSTUB int PyType_IsSubtype(...);
   EXPCL_PYSTUB int PyType_IsSubtype(...);
   EXPCL_PYSTUB int PyType_Ready(...);
   EXPCL_PYSTUB int PyType_Ready(...);
+  EXPCL_PYSTUB int PyUnicodeUCS2_AsWideChar(...);
+  EXPCL_PYSTUB int PyUnicodeUCS2_AsWideCharString(...);
+  EXPCL_PYSTUB int PyUnicodeUCS2_CompareWithASCIIString(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromFormat(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromFormat(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromString(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromString(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromStringAndSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromStringAndSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromWideChar(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_FromWideChar(...);
-  EXPCL_PYSTUB int PyUnicodeUCS2_AsWideChar(...);
-  EXPCL_PYSTUB int PyUnicodeUCS2_AsWideCharString(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_GetSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS2_GetSize(...);
+  EXPCL_PYSTUB int PyUnicodeUCS4_AsWideChar(...);
+  EXPCL_PYSTUB int PyUnicodeUCS4_AsWideCharString(...);
+  EXPCL_PYSTUB int PyUnicodeUCS4_CompareWithASCIIString(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromFormat(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromFormat(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromString(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromString(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromStringAndSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromStringAndSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromWideChar(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_FromWideChar(...);
-  EXPCL_PYSTUB int PyUnicodeUCS4_AsWideChar(...);
-  EXPCL_PYSTUB int PyUnicodeUCS4_AsWideCharString(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_GetSize(...);
   EXPCL_PYSTUB int PyUnicodeUCS4_GetSize(...);
   EXPCL_PYSTUB int PyUnicode_AsUTF8(...);
   EXPCL_PYSTUB int PyUnicode_AsUTF8(...);
   EXPCL_PYSTUB int PyUnicode_AsUTF8AndSize(...);
   EXPCL_PYSTUB int PyUnicode_AsUTF8AndSize(...);
@@ -362,19 +364,21 @@ int PyTuple_Type(...) { return 0; };
 int PyType_GenericAlloc(...) { return 0; };
 int PyType_GenericAlloc(...) { return 0; };
 int PyType_IsSubtype(...) { return 0; }
 int PyType_IsSubtype(...) { return 0; }
 int PyType_Ready(...) { return 0; };
 int PyType_Ready(...) { return 0; };
+int PyUnicodeUCS2_AsWideChar(...) { return 0; }
+int PyUnicodeUCS2_AsWideCharString(...) { return 0; }
+int PyUnicodeUCS2_CompareWithASCIIString(...) { return 0; }
 int PyUnicodeUCS2_FromFormat(...) { return 0; }
 int PyUnicodeUCS2_FromFormat(...) { return 0; }
 int PyUnicodeUCS2_FromString(...) { return 0; }
 int PyUnicodeUCS2_FromString(...) { return 0; }
 int PyUnicodeUCS2_FromStringAndSize(...) { return 0; }
 int PyUnicodeUCS2_FromStringAndSize(...) { return 0; }
 int PyUnicodeUCS2_FromWideChar(...) { return 0; }
 int PyUnicodeUCS2_FromWideChar(...) { return 0; }
-int PyUnicodeUCS2_AsWideChar(...) { return 0; }
-int PyUnicodeUCS2_AsWideCharString(...) { return 0; }
 int PyUnicodeUCS2_GetSize(...) { return 0; }
 int PyUnicodeUCS2_GetSize(...) { return 0; }
+int PyUnicodeUCS4_AsWideChar(...) { return 0; }
+int PyUnicodeUCS4_AsWideCharString(...) { return 0; }
+int PyUnicodeUCS4_CompareWithASCIIString(...) { return 0; }
 int PyUnicodeUCS4_FromFormat(...) { return 0; }
 int PyUnicodeUCS4_FromFormat(...) { return 0; }
 int PyUnicodeUCS4_FromString(...) { return 0; }
 int PyUnicodeUCS4_FromString(...) { return 0; }
 int PyUnicodeUCS4_FromStringAndSize(...) { return 0; }
 int PyUnicodeUCS4_FromStringAndSize(...) { return 0; }
 int PyUnicodeUCS4_FromWideChar(...) { return 0; }
 int PyUnicodeUCS4_FromWideChar(...) { return 0; }
-int PyUnicodeUCS4_AsWideChar(...) { return 0; }
-int PyUnicodeUCS4_AsWideCharString(...) { return 0; }
 int PyUnicodeUCS4_GetSize(...) { return 0; }
 int PyUnicodeUCS4_GetSize(...) { return 0; }
 int PyUnicode_AsUTF8(...) { return 0; }
 int PyUnicode_AsUTF8(...) { return 0; }
 int PyUnicode_AsUTF8AndSize(...) { return 0; }
 int PyUnicode_AsUTF8AndSize(...) { return 0; }