Ronald Oussoren avatar Ronald Oussoren committed f9f1fbd

- Slightly strengthen the test for instance methods in
PyObjCTools.KeyValueCoding.getKey
- Fix bug #789193, this turned out to be a bug in the PyObjC core
(also added a unittest for this)

Comments (0)

Files changed (3)

pyobjc/Lib/PyObjCTools/KeyValueCoding.py

 
     try:
         m = getattr(obj, key)
-        if isinstance(m, (types.MethodType, types.BuiltinMethodType)):
+
+        if isinstance(m, types.MethodType):
+            if m.im_self is obj:
+                return m()
+            else:
+                return m
+
+        elif isinstance(m, types.BuiltinMethodType):
+            # Can't access the bound self of methods of builtin classes :-(
             return m()
+
+        elif isinstance(m, objc.selector):
+            if m.self is obj:
+                return m()
+            else:
+                return m
         else:
             return m
+
     except AttributeError:
         pass
 

pyobjc/Lib/objc/test/test_regr.py

             sig,
             'v@:@@@@@:i')
 
+    def testFSRepr(self):
+        import Foundation
+        fm = Foundation.NSFileManager.defaultManager()
+        self.assertRaises(TypeError, fm.stringWithFileSystemRepresentation_length_, "/var")
+        self.assertEquals(u"/var", fm.stringWithFileSystemRepresentation_length_("/var/boo", 4))
+
 if __name__ == '__main__':
     unittest.main()

pyobjc/Modules/objc/libffi_support.m

 					return NULL;
 				}
 			} else {
+				plain_count ++;
 				itemSize = objc_sizeof_type(argtype+1);
 				itemAlign = objc_alignof_type(argtype+1);
 				if (itemSize == -1) {
 					return NULL;
 				}
 			} else {
+				plain_count++;
 				itemSize = objc_sizeof_type(argtype+1);
 				itemAlign = objc_alignof_type(argtype+1);
 				if (itemSize == -1) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.