diff options
author | Campbell Barton <campbell@blender.org> | 2022-07-05 06:41:55 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-07-05 06:41:55 +0300 |
commit | 780c0ea097444c3be60314dffd203c099720badb (patch) | |
tree | 0e6a288b19070a2c5d8e4983b96c7a7142a18fae /source/blender/python/generic | |
parent | dfa52017638abdf59791e5588c439d3a558a191d (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/generic')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index d2e3c44c1b6..8230801e184 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -641,6 +641,7 @@ void PyC_StackSpit(void) void PyC_FileAndNum(const char **r_filename, int *r_lineno) { PyFrameObject *frame; + PyCodeObject *code; if (r_filename) { *r_filename = NULL; @@ -649,13 +650,16 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno) *r_lineno = -1; } - if (!(frame = PyThreadState_GET()->frame)) { + if (!(frame = PyEval_GetFrame())) { + return; + } + if (!(code = PyFrame_GetCode(frame))) { return; } /* when executing a script */ if (r_filename) { - *r_filename = PyUnicode_AsUTF8(frame->f_code->co_filename); + *r_filename = PyUnicode_AsUTF8(code->co_filename); } /* when executing a module */ |