python fixes

now, one can do "script run mything.py" multiple times without
crashing, and exit codes are correct.

Pm3PyRun_SimpleFileNoExit:
* use XDECREF instead of DECREF (handles possible nullptr).
* don't double-free "er".
* print exit status correctly.

CmdScriptRun:
* allow invoking scripts multiple times.
* fix memleak of argtable contents if help path not triggered.
* configure_c_stdio should be 0 or 1, not < 0.
* py_conf: don't explicitly set options to their default values, it's confusing.
* Call Py_Finalize only when exiting pm3.

main_loop:
* cleanup cmdscript from main_loop. Important to call
  Py_Finalize from here in case Qt is used (in which case
  main_loop is on Qt thread).

ProxGuiQT::MainLoop:
* reduce timer delay to 0 - there isn't a need to wait here.
This commit is contained in:
Shawn Hoffman committed 2026-05-22 16:38:59 -07:00
1 parent 65de25c67e
commit 148e5ed2d1
4 files changed
+173 -72

No files matched your search

+4
View File
@@ -36,6 +36,7 @@
#include "flash.h"
#include "preferences.h"
#include "commonutil.h"
#include "cmdscript.h"
#ifndef _WIN32
#include <locale.h>
@@ -512,6 +513,7 @@ check_script:
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
g_pendingPrompt = true;
// TODO this should be free'd via pm3line_free
script_cmd = pm3line_read(prompt_filtered);
#if defined(_WIN32)
//Check if color support needs to be enabled again in case the window buffer did change
@@ -614,6 +616,8 @@ check_script:
free(cmd);
cmd = NULL;
}
CmdScriptCleanup();
}
#ifndef LIBPM3