[IMP] odoo shell: set expected __name__ for scripts read from stdin

Name of scripts piped to `odoo shell` were `__builtin__` (`builtins` in
python3), which is not really obvious (and awful if your script must
handle python2 and python3).

Change it to `__main__`, allowing to use to common pattern
`if __name__ == '__main__':`
This commit is contained in:
Christophe Simonis
2018-02-02 13:36:32 +01:00
parent dccdff2539
commit dc8698132a
+1
View File
@@ -34,6 +34,7 @@ class Shell(Command):
def console(self, local_vars):
if not os.isatty(sys.stdin.fileno()):
local_vars['__name__'] = '__main__'
exec sys.stdin in local_vars
else:
if 'env' not in local_vars: