From dc8698132af9b5735d9729a3068951f287d2fc2e Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 2 Feb 2018 13:36:32 +0100 Subject: [PATCH] [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__':` --- openerp/cli/shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openerp/cli/shell.py b/openerp/cli/shell.py index 2e11645032d..76e715135cd 100644 --- a/openerp/cli/shell.py +++ b/openerp/cli/shell.py @@ -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: