UI: improve errors when evaluating a number button fails

Showing the Python error without any explanation is often
not enough information and doesn't hint that the error was in the
user input.

The error report from a invalid expression such as '..1' used to be:
   ('invalid syntax', ('<string>', 1, 1, '..1'))

Now reads:
   Error evaluating number, see Info editor for details: invalid syntax

Address issue raised by T78913.
This commit is contained in:
2020-07-27 13:46:58 +10:00
parent 7beef1fd33
commit 565d7f75cc
9 changed files with 80 additions and 39 deletions

View File

@@ -82,23 +82,23 @@ bool BPY_execute_text(struct bContext *C,
bool BPY_execute_string_as_number(struct bContext *C,
const char *imports[],
const char *expr,
const bool verbose,
const char *report_prefix,
double *r_value);
bool BPY_execute_string_as_intptr(struct bContext *C,
const char *imports[],
const char *expr,
const bool verbose,
const char *report_prefix,
intptr_t *r_value);
bool BPY_execute_string_as_string_and_size(struct bContext *C,
const char *imports[],
const char *expr,
const bool verbose,
const char *report_prefix,
char **r_value,
size_t *r_value_size);
bool BPY_execute_string_as_string(struct bContext *C,
const char *imports[],
const char *expr,
const bool verbose,
const char *report_prefix,
char **r_value);
bool BPY_execute_string_ex(struct bContext *C,