← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 664207] Re: safe_eval is not compatible with python 2.7

 

*** This bug is a duplicate of bug 644267 ***
    https://bugs.launchpad.net/bugs/644267

** This bug has been marked a duplicate of bug 644267
   safe_eval() incompatible with python2.7's bytecode
 * You can subscribe to bug 644267 by following this link: https://bugs.launchpad.net/openobject-server/+bug/644267/+subscribe

-- 
safe_eval is not compatible with python 2.7
https://bugs.launchpad.net/bugs/664207
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP OpenObject.

Status in OpenObject Server: New

Bug description:
I got errors then validating workflow transactions with python 2.7.


[2010-10-21 00:29:43,550][shudas] ERROR:web-services:[46]:   File "/home/giedrius/sandbox/openerp/openserver/bin/workflow/wkf_expr.py", line 59, in _eval_expr
[2010-10-21 00:29:43,550][shudas] ERROR:web-services:[47]:     ret = eval(line, env, nocopy=True)
[2010-10-21 00:29:43,550][shudas] ERROR:web-services:[48]:   File "/home/giedrius/sandbox/openerp/openserver/bin/tools/safe_eval.py", line 271, in safe_eval
[2010-10-21 00:29:43,550][shudas] ERROR:web-services:[49]:     return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
[2010-10-21 00:29:43,550][shudas] ERROR:web-services:[50]:   File "/home/giedrius/sandbox/openerp/openserver/bin/tools/safe_eval.py", line 105, in test_expr
[2010-10-21 00:29:43,558][shudas] ERROR:web-services:[51]:     raise ValueError("opcode %s not allowed (%r)" % (opname[code], expr))
[2010-10-21 00:29:43,558][shudas] ERROR:web-services:[52]: ValueError: opcode JUMP_IF_TRUE_OR_POP not allowed (u"(order_policy=='prepaid') or ((order_policy=='postpaid') and shipped)")


It seems that OPCODES has changed in the newest python version. I've added patch to fix this incompatibilities.

In this patch, JUMP_IF_TRUE, JUMP_IF_FALSE opcodes are changed to POP_JUMP_IF_TRUE, POP_JUMP_IF_FALSE, JUMP_IF_TRUE_OR_POP, JUMP_IF_FALSE_OR_POP.





References