Browse Source

python: Remove usage of private _PyUnicode C API calls

Disyer 2 years ago
parent
commit
596ff9ddb8
2 changed files with 3 additions and 5 deletions
  1. 2 4
      dtool/src/interrogatedb/py_panda.cxx
  2. 1 1
      panda/src/pgraph/renderState_ext.cxx

+ 2 - 4
dtool/src/interrogatedb/py_panda.cxx

@@ -623,7 +623,7 @@ PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulen
       if (main_module == NULL) {
       if (main_module == NULL) {
         interrogatedb_cat.warning() << "Unable to import __main__\n";
         interrogatedb_cat.warning() << "Unable to import __main__\n";
       }
       }
-      
+
       // Extract the __file__ attribute, if present.
       // Extract the __file__ attribute, if present.
       Filename main_dir;
       Filename main_dir;
       PyObject *file_attr = nullptr;
       PyObject *file_attr = nullptr;
@@ -784,9 +784,7 @@ bool Dtool_ExtractArg(PyObject **result, PyObject *args, PyObject *kwds,
     if (kwds != nullptr && PyDict_GET_SIZE(kwds) == 1 &&
     if (kwds != nullptr && PyDict_GET_SIZE(kwds) == 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 >= 0x03060000
-      return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
-#elif PY_MAJOR_VERSION >= 3
+#if PY_MAJOR_VERSION >= 3
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
       return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
 #else
 #else
       return PyString_CheckExact(key) && strcmp(PyString_AS_STRING(key), keyword) == 0;
       return PyString_CheckExact(key) && strcmp(PyString_AS_STRING(key), keyword) == 0;

+ 1 - 1
panda/src/pgraph/renderState_ext.cxx

@@ -39,7 +39,7 @@ make(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 (!PyUnicode_CheckExact(key) || !_PyUnicode_EqualToASCIIString(key, "override")) {
+    if (!PyUnicode_CheckExact(key) || PyUnicode_CompareWithASCIIString(key, "override") != 0) {
       Dtool_Raise_TypeError("RenderState.make() received an unexpected keyword argument");
       Dtool_Raise_TypeError("RenderState.make() received an unexpected keyword argument");
       return nullptr;
       return nullptr;
     }
     }