From 325727ef2f648d84ee13b310fb0da7760354f909 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 9 Nov 2025 23:21:49 +0100 Subject: [PATCH] deploy-stub: Add flag for enabling verbose mode in Python --- pandatool/src/deploy-stub/android_main.cxx | 12 ++++++++++++ pandatool/src/deploy-stub/deploy-stub.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/pandatool/src/deploy-stub/android_main.cxx b/pandatool/src/deploy-stub/android_main.cxx index 685062c5ef..dc6a3c2317 100644 --- a/pandatool/src/deploy-stub/android_main.cxx +++ b/pandatool/src/deploy-stub/android_main.cxx @@ -32,6 +32,14 @@ // Leave room for future expansion. #define MAX_NUM_POINTERS 24 +/* Stored in the flags field of the blobinfo structure below. */ +enum Flags { + F_log_append = 1, + F_log_filename_strftime = 2, + F_keep_docstrings = 4, + F_python_verbose = 8, +}; + // Define an exposed symbol where we store the offset to the module data. extern "C" { __attribute__((__visibility__("default"), used)) @@ -283,6 +291,10 @@ void android_main(struct android_app *app) { PyConfig_SetBytesString(&config, &config.platlibdir, libdir); env->ReleaseStringUTFChars(libdir_jstr, libdir); + if (blobinfo.flags & F_python_verbose) { + config.verbose = 1; + } + status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); if (PyStatus_Exception(status)) { diff --git a/pandatool/src/deploy-stub/deploy-stub.c b/pandatool/src/deploy-stub/deploy-stub.c index 6cd2c2803c..b47615a6b7 100644 --- a/pandatool/src/deploy-stub/deploy-stub.c +++ b/pandatool/src/deploy-stub/deploy-stub.c @@ -35,6 +35,7 @@ enum Flags { F_log_append = 1, F_log_filename_strftime = 2, F_keep_docstrings = 4, + F_python_verbose = 8, }; /* Define an exposed symbol where we store the offset to the module data. */ @@ -416,6 +417,10 @@ int Py_FrozenMain(int argc, char **argv) } #endif + if (blobinfo.flags & F_python_verbose) { + Py_VerboseFlag = 1; + } + #ifndef NDEBUG if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') inspect = 1;