[PyObjC-svn] r1995 - in trunk/pyobjc/pyobjc-core: Lib/objc/test Modules/objc

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Mon Apr 14 11:24:35 2008
New Revision: 1995

Log:
Allow "def m(self, *args, **kwds)" as well, used in some
decorator definitions.


Modified:
   trunk/pyobjc/pyobjc-core/Lib/objc/test/test_method_prototypes.py
   trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/test/test_method_prototypes.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/test/test_method_prototypes.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/test/test_method_prototypes.py	Mon Apr 14 11:24:35 2008
@@ -163,6 +163,17 @@
             def replacementObjectForArchiver_(*args, **kwds):
                 pass
 
+
+        # Also allow versions with an explicit self argument, those
+        # are commonly used as well.
+        class OC_InPro_AllOpt3 (NSObject):
+            def init(self, *args, **kwds):
+                pass
+
+        class OC_InPro_AllOpt4 (NSObject):
+            def replacementObjectForArchiver_(self, *args, **kwds):
+                pass
+
     def testOptionalArgs(self):
         # BAD: optional arguments, which don't exist in Objective-C
         try:

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m	Mon Apr 14 11:24:35 2008
@@ -1765,8 +1765,11 @@
 
 		if (stubUserdata->argCount == methinfo->ob_size - 1 && !haveVarArgs && !haveVarKwds) {
 			/* OK */
-		} else if (stubUserdata->argCount == 0 && haveVarArgs && haveVarKwds) {
-			/* OK */
+		} else if (stubUserdata->argCount <= 1 && haveVarArgs && haveVarKwds) {
+			/* OK: 
+			 *    def m(self, *args, **kwds), or 
+			 *    def m(*args, **kwds)  
+			 */
 		} else {
 			/* Wrong number of arguments, raise an error */
 			PyObject* repr = PyObject_Repr(callable);
@@ -3320,7 +3323,7 @@
 	} else if (PyTuple_Size(args) != methinfo->ob_size - 2) {
 
 		PyErr_Format(PyExc_TypeError, "Need %"PY_FORMAT_SIZE_T"d arguments, got %"PY_FORMAT_SIZE_T"d",
-			plain_count + byref_in_count, PyTuple_Size(args));
+			methinfo->ob_size - 2, PyTuple_Size(args));
 		goto error_cleanup;
 	}
 

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.