Commits

Ronald Oussoren committed 7c91299

Fix a bug with "magic cookie" objects: you'd get a crash when trying to
get the repr of them.

Comments (0)

Files changed (2)

pyobjc-core/Modules/objc/corefoundation.m

 static PyObject*
 cf_repr(PyObject* self)
 {
+	if (PyObjCObject_GetFlags(self) & PyObjCObject_kMAGIC_COOKIE) {
+		return PyString_FromFormat(
+			"<%s CoreFoundation magic instance %p>",
+			self->ob_type->tp_name, PyObjCObject_GetObject(self));
+	}
+
+
+
 	CFStringRef repr = CFCopyDescription(PyObjCObject_GetObject(self));
 	if (repr) {
 		PyObject* result = pythonify_c_value(@encode(id), &repr);

pyobjc-core/Modules/objc/objc-object.m

 	PyObjCObject* self = (PyObjCObject*)_self;
 	PyObject* res;
 
+	if (self->flags & PyObjCObject_kMAGIC_COOKIE) {
+		return PyString_FromFormat(
+			"<%s objective-c magic instance %p>",
+			self->ob_type->tp_name, self->objc_object);
+	}
+
 	if ((self->flags & PyObjCObject_kUNINITIALIZED) == 0 && !PyObjCObject_IsClassic(self)) {
 		/* Try to call the method 'description', which is the ObjC
 		 * equivalent of __repr__. If that fails we'll fall back to