Skip to content
Snippets Groups Projects
Commit 2d41b4b7 authored by Christophe Monniez's avatar Christophe Monniez
Browse files

[ADD] core: add python 3.9 opcodes in safe_eval

Partial backport of 3cced11e.

Part-of: odoo/odoo#138754
parent a039c058
Branches
Tags
No related merge requests found
......@@ -67,6 +67,7 @@ _CONST_OPCODES = set(opmap[x] for x in [
'BUILD_LIST', 'BUILD_MAP', 'BUILD_TUPLE', 'BUILD_SET',
# 3.6: literal map with constant keys https://bugs.python.org/issue27140
'BUILD_CONST_KEY_MAP',
'LIST_EXTEND',
# until Python 3.5, literal maps are compiled to creating an empty map
# (pre-sized) then filling it key by key
'STORE_MAP',
......@@ -88,6 +89,9 @@ _EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
# comprehensions
'LIST_APPEND', 'MAP_ADD', 'SET_ADD',
'COMPARE_OP',
# specialised comparisons
'CONTAINS_OP',
'DICT_MERGE',
] if x in opmap))
_SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
......@@ -109,6 +113,7 @@ _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
'RAISE_VARARGS', 'LOAD_NAME', 'STORE_NAME', 'DELETE_NAME', 'LOAD_ATTR',
'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST', 'UNPACK_SEQUENCE',
'LOAD_GLOBAL', # Only allows access to restricted globals
'RERAISE', 'JUMP_IF_NOT_EXC_MATCH',
] if x in opmap))
_logger = logging.getLogger(__name__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment