mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
*Always* check for exceptions in C++ methods, otherwise we miss important exceptions thrown in Python code called by C++ methods (like SystemExit!)
This commit is contained in:
parent
e468b293d1
commit
a044561be5
@ -2985,7 +2985,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
|
|||||||
|
|
||||||
int num_params = 0;
|
int num_params = 0;
|
||||||
bool only_pyobjects = true;
|
bool only_pyobjects = true;
|
||||||
bool check_exceptions = false;
|
//bool check_exceptions = false;
|
||||||
|
|
||||||
int pn;
|
int pn;
|
||||||
for (pn = 0; pn < (int)remap->_parameters.size(); ++pn) {
|
for (pn = 0; pn < (int)remap->_parameters.size(); ++pn) {
|
||||||
@ -3232,7 +3232,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
|
|||||||
|
|
||||||
// It's reasonable to assume that a function taking a PyObject
|
// It's reasonable to assume that a function taking a PyObject
|
||||||
// might also throw a TypeError if the type is incorrect.
|
// might also throw a TypeError if the type is incorrect.
|
||||||
check_exceptions = true;
|
//check_exceptions = true;
|
||||||
|
|
||||||
} else if (TypeManager::is_pointer_to_Py_buffer(type)) {
|
} else if (TypeManager::is_pointer_to_Py_buffer(type)) {
|
||||||
if (args_type == AT_single_arg) {
|
if (args_type == AT_single_arg) {
|
||||||
@ -3248,7 +3248,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
|
|||||||
extra_cleanup += "Py_XDECREF(" + param_name + "_buffer);";
|
extra_cleanup += "Py_XDECREF(" + param_name + "_buffer);";
|
||||||
expected_params += "memoryview";
|
expected_params += "memoryview";
|
||||||
++num_params;
|
++num_params;
|
||||||
check_exceptions = true;
|
//check_exceptions = true;
|
||||||
|
|
||||||
} else if (TypeManager::is_pointer(type)) {
|
} else if (TypeManager::is_pointer(type)) {
|
||||||
CPPType *obj_type = TypeManager::unwrap(TypeManager::resolve_type(type));
|
CPPType *obj_type = TypeManager::unwrap(TypeManager::resolve_type(type));
|
||||||
@ -3351,9 +3351,9 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
|
|||||||
|
|
||||||
// If this is the only overload, don't bother checking for type errors.
|
// If this is the only overload, don't bother checking for type errors.
|
||||||
// Any type error that is raised will simply pass through to below.
|
// Any type error that is raised will simply pass through to below.
|
||||||
if (func->_remaps.size() == 1) {
|
//if (func->_remaps.size() == 1) {
|
||||||
check_exceptions = false;
|
// check_exceptions = false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Track how many curly braces we've opened.
|
// Track how many curly braces we've opened.
|
||||||
short open_scopes = 0;
|
short open_scopes = 0;
|
||||||
@ -3541,7 +3541,8 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a method raises TypeError, continue.
|
// If a method raises TypeError, continue.
|
||||||
if (check_exceptions) {
|
//if (check_exceptions) {
|
||||||
|
if (true) {
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "if (PyErr_Occurred()) {\n";
|
<< "if (PyErr_Occurred()) {\n";
|
||||||
delete_return_value(out, indent_level, remap, return_expr);
|
delete_return_value(out, indent_level, remap, return_expr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user