Commits

Ronald Oussoren committed 8aea2e0

Fix test failure for the creation of formal protocols

Comments (0)

Files changed (3)

pyobjc-core/Modules/objc/formal-protocol.m

 	for (i = 0; i < len; i++) {
 		PyObject* sel = PySequence_Fast_GET_ITEM(selectors, i);
 		SEL theSel = PyObjCSelector_GetSelector(sel);
-		const char* theSignature = PyObjCSelector_Signature(sel);
-
-		protocol_addMethodDescription(theProtocol, theSel, theSignature, 
-				PyObjCSelector_Required(sel), !PyObjCSelector_IsClassMethod(sel));
+		const char* theSignature = strdup(PyObjCSelector_Signature(sel));
+		if (theSignature == NULL) {
+			goto error;
+		}
+		protocol_addMethodDescription(
+			theProtocol, 
+			theSel, 
+			theSignature, 
+			(BOOL)PyObjCSelector_Required(sel), 
+			(BOOL)!PyObjCSelector_IsClassMethod(sel));
 	}
 
 	objc_registerProtocol(theProtocol);

pyobjc-core/Modules/objc/objc-runtime-compat.m

 	SETUP(ivar_getOffset);
 #endif /* MIN_REQUIRED < 10.5 && !OBJC2 */
 
+#ifdef SETUP 
+#undef SETUP
+#endif
+
 
 #if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7)
 	/* Compat definitions for protocol creation
 	PyObjC_protocol_addProtocol = compat_protocol_addProtocol;
 #endif
 
-#ifdef SETUP 
-#undef SETUP
-#endif
 
 #elif defined(__LP64__)
 	PyObjC_objc_allocateProtocol = objc_allocateProtocol;

pyobjc-core/PyObjCTest/test3_protocol.py

     from PyObjCTest.protocol import OC_TestProtocol
 
 
-MyProto = objc.informal_protocol("MyProto", (
+MyProto3 = objc.informal_protocol("MyProto3", (
     objc.selector(None, selector=b"testMethod", signature=b"I@:", isRequired=1),
     objc.selector(None, selector=b"testMethod2:", signature=b"v@:i", isRequired=0)
 ))
 
 class Test3InformalProtocols(TestCase):
     def testOptional(self):
-        class ProtoClass3 (NSObject, protocols=[MyProto]):
+        class ProtoClass3 (NSObject, protocols=[MyProto3]):
             def testMethod(self):
                 pass
 
 
 
 if (sys.maxsize < 2 ** 32) or (platform.mac_ver()[0] >= '10.7'):
-    EmptyProtocol = objc.formal_protocol("EmptyProtocol", None, ())
+    EmptyProtocol3 = objc.formal_protocol("EmptyProtocol3", None, ())
 
-    MyProtocol = objc.formal_protocol("MyProtocol", None, (
+
+    MyProtocol3 = objc.formal_protocol("MyProtocol3", None, (
         objc.selector(None, selector=b"protoMethod", signature=b"I@:"),
         objc.selector(None, selector=b"anotherProto:with:", signature=b"v@:ii"),
     ))
 
-    MyOtherProtocol = objc.formal_protocol("MyOtherProtocol", 
-            (MyProtocol,), [
+    MyOtherProtocol3 = objc.formal_protocol("MyOtherProtocol3", 
+            (MyProtocol3,), [
                 objc.selector(None, selector=b"yetAnother:", signature=b"i@:I")
             ])
 
-    MyClassProtocol = objc.formal_protocol("MyClassProtocol", None, [
+    MyClassProtocol3 = objc.formal_protocol("MyClassProtocol3", None, [
         objc.selector(None, selector=b"anAnotherOne:", signature=b"i@:i"),
         objc.selector(None, selector=b"aClassOne:", signature=b"@@:i", isClassMethod=1),
     ])
 
         def testMethodInfo(self):
             self.assertEqual(
-                    MyProtocol.descriptionForInstanceMethod_("protoMethod"),
+                    MyProtocol3.descriptionForInstanceMethod_("protoMethod"),
                         ("protoMethod", "I@:"))
 
             self.assertEqual(
-                    MyProtocol.descriptionForInstanceMethod_("nosuchmethod"),
+                    MyProtocol3.descriptionForInstanceMethod_("nosuchmethod"),
                         None)
 
             self.assertEqual(
-                    MyClassProtocol.descriptionForClassMethod_("aClassOne:"),
+                    MyClassProtocol3.descriptionForClassMethod_("aClassOne:"),
                         ("aClassOne:", "@@:i"))
 
             self.assertEqual(
-                    MyClassProtocol.descriptionForClassMethod_("nosuchmethod"),
+                    MyClassProtocol3.descriptionForClassMethod_("nosuchmethod"),
                         None)
 
 
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.