@@ -197,35 +197,51 @@ void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::T
197197 PyErr_Fetch (&type, &value, &traceback);
198198 PyErr_NormalizeException (&type, &value, &traceback);
199199
200- if (!value)
201- goto end;
200+ if (!value) {
201+ PyErr_Clear ();
202+ OnConsoleCommandExecuted.ExecuteIfBound ();
203+ return ;
204+ }
202205
203206 char *msg = NULL ;
204207 PyObject *zero = PyUnicode_AsUTF8String (PyObject_Str (value));
205208 if (zero) {
206209 msg = PyBytes_AsString (zero);
207210 }
208211
209- if (!msg)
210- goto end;
212+ if (!msg) {
213+ PyErr_Clear ();
214+ OnConsoleCommandExecuted.ExecuteIfBound ();
215+ return ;
216+ }
211217
212218 UE_LOG (LogTemp, Error, TEXT (" %s" ), UTF8_TO_TCHAR (msg));
213219
214220 // taken from uWSGI ;)
215- if (!traceback) goto end;
221+ if (!traceback) {
222+ PyErr_Clear ();
223+ OnConsoleCommandExecuted.ExecuteIfBound ();
224+ return ;
225+ }
216226
217227 PyObject *traceback_module = PyImport_ImportModule (" traceback" );
218228 if (!traceback_module) {
219- goto end;
229+ PyErr_Clear ();
230+ OnConsoleCommandExecuted.ExecuteIfBound ();
231+ return ;
220232 }
221233
222234 PyObject *traceback_dict = PyModule_GetDict (traceback_module);
223235 PyObject *format_exception = PyDict_GetItemString (traceback_dict, " format_exception" );
224236
225237 if (format_exception) {
226238 PyObject *ret = PyObject_CallFunctionObjArgs (format_exception, type, value, traceback, NULL );
227- if (!ret)
228- goto end;
239+ if (!ret) {
240+ PyErr_Clear ();
241+ OnConsoleCommandExecuted.ExecuteIfBound ();
242+ return ;
243+ }
244+
229245 if (PyList_Check (ret)) {
230246 for (int i = 0 ; i < PyList_Size (ret); i++) {
231247 PyObject *item = PyList_GetItem (ret, i);
@@ -238,8 +254,6 @@ void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::T
238254 UE_LOG (LogTemp, Error, TEXT (" %s" ), UTF8_TO_TCHAR (PyUnicode_AsUTF8 (PyObject_Str (ret))));
239255 }
240256 }
241-
242- end:
243257 PyErr_Clear ();
244258 }
245259 }
0 commit comments