[PyObjC-svn] r2411 - trunk/pyobjc/pyobjc-core/Modules/objc

[email protected] Wed, 10 Mar 2010 16:56:56 -0600
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Wed Mar 10 16:56:56 2010
New Revision: 2411

Log:
Make conversion of python exception to objc not crash
when the Python stack overflows.


Modified:
   trunk/pyobjc/pyobjc-core/Modules/objc/objc_util.m

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/objc_util.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/objc_util.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/objc_util.m	Wed Mar 10 16:56:56 2010
@@ -227,7 +227,13 @@
 	if (args == NULL) {
 		PyErr_Clear();
 	} else {
-		return PyObjC_PythonToId(args);
+		id result;
+
+		if (depythonify_c_value(@encode(id), args, &result) == -1) {
+			abort();
+		}
+		NSLog(@"exception: %@", result);
+		return result;
 	}
 
 	args = PyObject_GetAttrString(exc_value, "_pyobjc_info_");
@@ -293,11 +299,11 @@
 
 	val = [NSException 
 		exceptionWithName:@"OC_PythonException"
-		reason:[NSString stringWithFormat:@"%@: %@", PyObjC_PythonToId(typerepr), PyObjC_PythonToId(repr)]
+			   reason:[NSString stringWithFormat:@"%@: %@", typerepr?PyObjC_PythonToId(typerepr):NULL, repr?PyObjC_PythonToId(repr):NULL]
 		userInfo:userInfo];
 
-	Py_DECREF(typerepr);
-	Py_DECREF(repr);
+	Py_XDECREF(typerepr);
+	Py_XDECREF(repr);
 
 	if (PyObjC_VerboseLevel) {
 		PyErr_Restore(exc_type, exc_value , exc_traceback);

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev