Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-04-12 14:39:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-13 08:28:43 +0300
commitf5060bc90118c88593fd213728bf58894fa6394c (patch)
treed58797c31faea554ee2075fcfc21d734d541083a /source/blender/python/BPY_extern_run.h
parent8d9fd0427dd6cf9556f2bb4415ead82c73300d32 (diff)
PyAPI: support retrieving the exception when running a string
- Optionally get the error as a single line. - Support access the error as an allocated string. - PyC_ExceptionBuffer_Simple was always printing to the `stdout` while PyC_ExceptionBuffer didn't, now either print to the output. Without this, callers are unable to do anything with the error string.
Diffstat (limited to 'source/blender/python/BPY_extern_run.h')
-rw-r--r--source/blender/python/BPY_extern_run.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/python/BPY_extern_run.h b/source/blender/python/BPY_extern_run.h
index 5f12ada4ff2..b65b5d61b9d 100644
--- a/source/blender/python/BPY_extern_run.h
+++ b/source/blender/python/BPY_extern_run.h
@@ -42,27 +42,43 @@ bool BPY_run_text(struct bContext *C,
bool BPY_run_string_exec(struct bContext *C, const char *imports[], const char *expr);
bool BPY_run_string_eval(struct bContext *C, const char *imports[], const char *expr);
+/**
+ * \note When this struct is passed in as NULL,
+ * print errors to the `stdout` and clear.
+ */
+struct BPy_RunErrInfo {
+ /** Brief text, single line (can show this in status bar for e.g.). */
+ bool use_single_line_error;
+
+ /** Report with optional prefix (when non-NULL). */
+ struct ReportList *reports;
+ const char *report_prefix;
+
+ /** Allocated exception text (assign when non-NULL). */
+ char **r_string;
+};
+
/* Run, evaluating to fixed type result. */
bool BPY_run_string_as_number(struct bContext *C,
const char *imports[],
const char *expr,
- const char *report_prefix,
+ struct BPy_RunErrInfo *err_info,
double *r_value);
bool BPY_run_string_as_intptr(struct bContext *C,
const char *imports[],
const char *expr,
- const char *report_prefix,
+ struct BPy_RunErrInfo *err_info,
intptr_t *r_value);
bool BPY_run_string_as_string_and_size(struct bContext *C,
const char *imports[],
const char *expr,
- const char *report_prefix,
+ struct BPy_RunErrInfo *err_info,
char **r_value,
size_t *r_value_size);
bool BPY_run_string_as_string(struct bContext *C,
const char *imports[],
const char *expr,
- const char *report_prefix,
+ struct BPy_RunErrInfo *err_info,
char **r_value);
#ifdef __cplusplus