Merge with 2.5 -r 21515:21619.
This commit is contained in:
@@ -353,8 +353,8 @@ PyObject *BPY_exception_buffer(void)
|
||||
PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */
|
||||
PyObject *string_io = NULL;
|
||||
PyObject *string_io_buf = NULL;
|
||||
PyObject *string_io_mod;
|
||||
PyObject *string_io_getvalue;
|
||||
PyObject *string_io_mod= NULL;
|
||||
PyObject *string_io_getvalue= NULL;
|
||||
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
|
||||
@@ -374,14 +374,11 @@ PyObject *BPY_exception_buffer(void)
|
||||
#else
|
||||
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
|
||||
#endif
|
||||
return NULL;
|
||||
goto error_cleanup;
|
||||
} else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) {
|
||||
Py_DECREF(string_io_mod);
|
||||
return NULL;
|
||||
goto error_cleanup;
|
||||
} else if (! (string_io_getvalue= PyObject_GetAttrString(string_io, "getvalue"))) {
|
||||
Py_DECREF(string_io_mod);
|
||||
Py_DECREF(string_io);
|
||||
return NULL;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
Py_INCREF(stdout_backup); // since these were borrowed we dont want them freed when replaced.
|
||||
@@ -408,6 +405,18 @@ PyObject *BPY_exception_buffer(void)
|
||||
|
||||
PyErr_Clear();
|
||||
return string_io_buf;
|
||||
|
||||
|
||||
error_cleanup:
|
||||
/* could not import the module so print the error and close */
|
||||
Py_XDECREF(string_io_mod);
|
||||
Py_XDECREF(string_io);
|
||||
|
||||
PyErr_Restore(error_type, error_value, error_traceback);
|
||||
PyErr_Print(); /* print the error */
|
||||
PyErr_Clear();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *BPy_enum_as_string(EnumPropertyItem *item)
|
||||
|
||||
Reference in New Issue
Block a user