Skip to content

Commit 11c1add

Browse files
author
Roberto De Ioris
committed
another round of unsupported gotos removal
1 parent 89571c5 commit 11c1add

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,35 +1743,45 @@ void unreal_engine_py_log_error() {
17431743
PyErr_Fetch(&type, &value, &traceback);
17441744
PyErr_NormalizeException(&type, &value, &traceback);
17451745

1746-
if (!value)
1747-
goto end;
1746+
if (!value) {
1747+
PyErr_Clear();
1748+
return;
1749+
}
17481750

17491751
char *msg = NULL;
17501752
PyObject *zero = PyUnicode_AsUTF8String(PyObject_Str(value));
17511753
if (zero) {
17521754
msg = PyBytes_AsString(zero);
17531755
}
17541756

1755-
if (!msg)
1756-
goto end;
1757+
if (!msg) {
1758+
PyErr_Clear();
1759+
return;
1760+
}
17571761

17581762
UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(msg));
17591763

17601764
// taken from uWSGI ;)
1761-
if (!traceback) goto end;
1765+
if (!traceback) {
1766+
PyErr_Clear();
1767+
return;
1768+
}
17621769

17631770
PyObject *traceback_module = PyImport_ImportModule("traceback");
17641771
if (!traceback_module) {
1765-
goto end;
1772+
PyErr_Clear();
1773+
return;
17661774
}
17671775

17681776
PyObject *traceback_dict = PyModule_GetDict(traceback_module);
17691777
PyObject *format_exception = PyDict_GetItemString(traceback_dict, "format_exception");
17701778

17711779
if (format_exception) {
17721780
PyObject *ret = PyObject_CallFunctionObjArgs(format_exception, type, value, traceback, NULL);
1773-
if (!ret)
1774-
goto end;
1781+
if (!ret) {
1782+
PyErr_Clear();
1783+
return;
1784+
}
17751785
if (PyList_Check(ret)) {
17761786
for (int i = 0; i < PyList_Size(ret); i++) {
17771787
PyObject *item = PyList_GetItem(ret, i);
@@ -1785,7 +1795,6 @@ void unreal_engine_py_log_error() {
17851795
}
17861796
}
17871797

1788-
end:
17891798
PyErr_Clear();
17901799
}
17911800

0 commit comments

Comments
 (0)