Jelajahi Sumber

fix __rsub__ nonsense

David Rose 20 tahun lalu
induk
melakukan
968ad486b8
1 mengubah file dengan 5 tambahan dan 15 penghapusan
  1. 5 15
      dtool/src/interrogate/interfaceMakerPythonNative.cxx

+ 5 - 15
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -638,21 +638,11 @@ void InterfaceMakerPythonNative::write_ClasseDetails(ostream &out, Object * obj)
             ostringstream GetThis;
             GetThis << "    "<<cClassName  << " * local_this = NULL;\n";
             GetThis << "    DTOOL_Call_ExtractThisPointerForType(self,&Dtool_"<<  ClassName<<",(void **)&local_this);\n";
-            GetThis << "    if(local_this == NULL)\n";
-            GetThis << "    {\n";
-            GetThis << "      if(!PyTuple_Check(args))\n";
-            GetThis << "      {\n";
-            GetThis << "        PyObject * temp = args;\n";
-            GetThis << "        args = self;\n";
-            GetThis << "        self = temp;\n";    
-            GetThis << "        DTOOL_Call_ExtractThisPointerForType(self,&Dtool_"<<  ClassName<<",(void **)&local_this);\n";
-            GetThis << "      }\n";
-            GetThis << "      if(local_this == NULL)\n";
-            GetThis << "      {\n";
-            GetThis << "        PyErr_SetString(PyExc_TypeError, \"Error extracting 'this' pointer.  Self is not a " << cClassName << "\");\n";
-            GetThis << "        return (PyObject *) NULL;\n" ;
-            GetThis << "      }\n";
-            GetThis << "    };\n";
+            GetThis << "    if(local_this == NULL) {\n";
+            GetThis << "      // This might happen if Python called a reverse operator like __rsub__().\n";
+	    GetThis << "      Py_INCREF(Py_NotImplemented);\n";
+	    GetThis << "      return Py_NotImplemented;\n";
+            GetThis << "    }\n";
 
             write_function_for_top(out, func,GetThis.str());
         }