Commits

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)

  • Participants
  • Parent commits b90dea6

Comments (0)

Files changed (3)

File 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
 

File 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()

File 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) {