Commits

Ronald Oussoren committed be8707c

Calling methods on 'plain' python objects works again (bit-rot in action?)

Comments (0)

Files changed (1)

pyobjc/Modules/objc/OC_PythonObject.m

 		return NULL;
 	}
 	if (PyFunction_Check(pymethod)) {
+        	func_code = (PyCodeObject *)PyFunction_GetCode(pymethod);
+		if (argcount == func_code->co_argcount) {
+			return pymethod;
+		}
+	} else if (PyMethod_Check(pymethod)) {
 		func_code = (PyCodeObject *)PyFunction_GetCode(
 			PyMethod_Function (pymethod));
 		if (argcount == func_code->co_argcount - 1) {
 			return pymethod;
 		}
-	} else if (PyMethod_Check(pymethod)) {
-        	func_code = (PyCodeObject *)PyFunction_GetCode(pymethod);
-		if (argcount == func_code->co_argcount) {
-			return pymethod;
-		}
 	} 
 	return NULL;
 }
 	} else {
 		func_code = (PyCodeObject *) PyFunction_GetCode(
 			pymethod);
-		  argcount = func_code->co_argcount;
+		argcount = func_code->co_argcount;
 	}
 
-	encoding = alloca(argcount+3);
-	memset(encoding, '@', argcount+2);
-	encoding[argcount+2] = '\0';
+	encoding = alloca(argcount+4);
+	memset(encoding, '@', argcount+3);
+	encoding[argcount+3] = '\0';
 	encoding[2] = ':';
 	return [NSMethodSignature signatureWithObjCTypes:encoding];
 }
 
-/*
- * XXX: Should make sure that this is consistant with forwardInvocation for
- *      ObjCObject_Type
- * XXX: There is no testsuite for this code!
- */
 - (void) forwardInvocation:(NSInvocation *) invocation
 {
 	/* XXX: Needs cleanup */
 	}
  
 	argcount = [msign numberOfArguments];
-	args = PyTuple_New(argcount);
+	args = PyTuple_New(argcount-2);
 	if (args == NULL) {
 		ObjCErr_ToObjC();
 	}