1. Ronald Oussoren
  2. pyobjc

Commits

Ronald Oussoren  committed 5ecb756

Partial fix for the bug mentioned by David Eppstein: pychecker causes crashes
when the checked module uses PyObjC.

This is not a complete fix: I now get warnings about using a deallocated
object when running pychecker on this script:

# Start of file
import Foundation
# End of file

  • Participants
  • Parent commits 6eb927d
  • Branches default

Comments (0)

Files changed (1)

File pyobjc/Modules/objc/method-accessor.m

View file
  • Ignore whitespace
 
 	if (PyObjCClass_Check(self)) {
 		objc_object = (id)PyObjCClass_GetClass(self);
-	
+
 		if (!class_method) {
 			unbound_instance_method = 1;
 		}
 		return NULL;
 	}
 
+	if (objc_object == nil) {
+		ObjCErr_Set(PyExc_AttributeError,
+			"<nil> doesn't have attribute %s", name);
+		return NULL;
+	}
+
 	if (class_method && strcmp(((Class)objc_object)->name, "NSProxy") == 0){
 		if (sel == @selector(methodSignatureForSelector:)) {
 			ObjCErr_Set(PyExc_AttributeError,
 		}
 	}
 
-	if (unbound_instance_method) {
-		methsig = [objc_object instanceMethodSignatureForSelector:sel];
-	} else {
-		methsig = [objc_object methodSignatureForSelector:sel];
-	}
+	NS_DURING
+		if (unbound_instance_method) {
+			methsig = [objc_object instanceMethodSignatureForSelector:sel];
+		} else {
+			methsig = [objc_object methodSignatureForSelector:sel];
+		}
+	NS_HANDLER
+		methsig = nil;
+	NS_ENDHANDLER
 
 	if (methsig == NULL) {
 		ObjCErr_Set(PyExc_AttributeError,