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 <campbell@blender.org>2022-07-05 06:41:55 +0300
committerCampbell Barton <campbell@blender.org>2022-07-05 06:41:55 +0300
commit780c0ea097444c3be60314dffd203c099720badb (patch)
tree0e6a288b19070a2c5d8e4983b96c7a7142a18fae /source/blender/python/intern/bpy_interface.c
parentdfa52017638abdf59791e5588c439d3a558a191d (diff)
Python: support v3.11 (beta) with changes to PyFrameObject & opcodes
- Use API calls to access frame-data as PyFrameObject is now opaque. - Update opcodes allowed for safe driver evaluation. **Details** Some opcodes have been added for safe-driver evaluation. Python 3.11 removes many opcodes - the number of accepted opcodes in Blender's listing dropped from 65 to 43) however some new opcodes also needed to be added. As this relates to security details about newly added opcodes have been noted below (see [0] for full documentation). Newly added opcodes: - CACHE: Used to control caching instructions. - RESUME: A no-op. Performs internal checks. - BINARY_OP: Implements the binary and in-place operators, replacing specific binary operations. - CALL, PRECALL, KW_NAMES: Used for calling functions, replacing some existing opcodes. - POP_JUMP_{FORWARD/BACKWARD}_IF_{TRUE/FALSE/NONE/NOT_NONE}. Manipulate the byte-code counter. - SWAP, PUSH_NULL. Stack manipulation. Resolves T99277. [0]: https://docs.python.org/3.11/library/dis.html
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 0ab8b4385e5..ea64fa6c098 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -582,16 +582,17 @@ void BPY_python_use_system_env(void)
void BPY_python_backtrace(FILE *fp)
{
fputs("\n# Python backtrace\n", fp);
- PyThreadState *tstate = PyGILState_GetThisThreadState();
- if (tstate != NULL && tstate->frame != NULL) {
- PyFrameObject *frame = tstate->frame;
- do {
- const int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
- const char *filepath = PyUnicode_AsUTF8(frame->f_code->co_filename);
- const char *funcname = PyUnicode_AsUTF8(frame->f_code->co_name);
- fprintf(fp, " File \"%s\", line %d in %s\n", filepath, line, funcname);
- } while ((frame = frame->f_back));
+ PyFrameObject *frame;
+ if (!(frame = PyEval_GetFrame())) {
+ return;
}
+ do {
+ PyCodeObject *code = PyFrame_GetCode(frame);
+ const int line = PyFrame_GetLineNumber(frame);
+ const char *filepath = PyUnicode_AsUTF8(code->co_filename);
+ const char *funcname = PyUnicode_AsUTF8(code->co_name);
+ fprintf(fp, " File \"%s\", line %d in %s\n", filepath, line, funcname);
+ } while ((frame = PyFrame_GetBack(frame)));
}
void BPY_DECREF(void *pyob_ptr)