summaryrefslogtreecommitdiff
path: root/odoo/tools/safe_eval.py
AgeCommit message (Collapse)Author
2018-11-29[REF] *: replace deprecated pycompat helpers for builtinsAdrian Torres
This commit replaces calls to pycompat helpers that were intended for python 2 <-> python 3 interoperability for python 3 builtins, as python 2 is no longer officially supported by Odoo. This includes: * calls to imap/izip/ifilter replaced by map/zip/filter * uses of text_type replaced by str * uses of unichr replaced by chr * calls to implements_to_string, implements_iterator removed * string_types and integer_types replaced by str, int respectively * calls to to_native replaced by calls to to_text This is done in preparation to the removal of these deprecated helpers in the following commit.
2018-07-30[FIX] P3: add missing opcodeOlivier Laurent
In Python 3, SETUP_FINALLY is used if the exception object is bound in the except block — even if there is no finally block — in order to unbind and cleanup the exception's binding as part of PEP 3110: https://www.python.org/dev/peps/pep-3110/#semantic-changes This allows both using exception objects in Python 3 and using finally blocks in both version. opw 1824211
2018-07-17[ADD] tools: add new 3.7 opcodesMartin Trigaux
Python 3.7 introduced two new opcodes LOAD_METHOD and CALL_METHOD. https://docs.python.org/3/whatsnew/3.7.html#cpython-bytecode-changes https://bugs.python.org/issue26110 Basic QWeb rendering was failing on operations like request.csrf_token() ValueError: forbidden opcode(s) in 'request.csrf_token()': LOAD_METHOD, CALL_METHOD Closes #25783
2017-10-17[FIX]: safe_eval’ing some large scripts yield illegal opcodesjaredkipe
Following the 3.6 wordcode change, EXTENDED_ARGS gets used for jumps offset by more than 256 bytes (128 opcodes), most commonly absolute (so many script of more than 128 opcodes with conditionals arer going to trigger the issue). In bytecoded Python versions, EXTENDED_ARGS was only necessary above 65k opcodes: the opcode would get a separate 16-bits argument, while wordcode opcodes get 8-bit intrinsic.
2017-08-20[FIX] P3: text model typesXavier Morel
* remove references to basestring & unicode (use relevant pycompat helpers) * remove some str calls (either entirely or replaced by relevant helper, either text or native) * use better API to avoid unnecessary conversions * remove some XML declarations in views
2017-06-26[IMP] reorganise opcodes in categoriesXavier Morel
2017-06-26[FIX] P3: bytecode changesXavier Morel
* Python 3.4 adds new convenient bytecode-inspection API to dis which is nice, however Python 3.6 also switches from the old bytecode to a new wordcode which breaks _get_opcodes and *requires* that we use the new API * add various opcodes which either were added in Python 3 (CALL_FUNCTION_EX) or were only used for some small corners of Python 2 but have been expanded or despecialised in Python 3 (BUILD_SLICE)
2017-05-12[FIX] P3: raise exception with existing tracebackXavier Morel
In Python 2, to raise a new exception but reuse a traceback requires a special form of ``raise`` (``raise etype, evalue, tb``). In Python 3, this is now done via a ``with_traceback`` method on exception objects. However this requires a bit of trickery as the former is invalid syntax in Python 3, hence pycompat bridge created via an exec for Python 2.
2017-05-10[FIX] P3: list -> iterable builtins (#16811)xmo-odoo
In Python 3: * various builtins and dict methods were changed to return view/iterable objects rather than lists * and the separate Python 2 view/iterable builtins and methods were removed altogether This is problematic when using these items as list (which the happens repeatedly in Odoo), but more viciously when iterating *multiple times* over them (which also happens, which I've messed up multiple times while writing this, and which is a pain to debug even when you've just created the issue). Convert all code using these to semantics-matching cross-version helper functions to get the LCD behaviour between P2 and P3, and forbid the builtins via lint. issue #8530
2017-04-27[FIX] builtins removed from Python 3xmo-odoo
* Reverse wrapper courtesy of @rco-odoo's original P3 branch * thin compat module stripped down from werkzeug (to augment as needed) issue 8530
2017-04-11[#8530] convert exception handlers to except..as syntaxXavier Morel
Futurize fixers: * lib2to3.fixes.fix_except
2016-09-02[FIX] odoo: rename imports and adapt import hooksRaphael Collet
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet