From 2824efee4be08e01d553c0af296ba836ee486823 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Thu, 8 Nov 2018 11:11:07 +0000 Subject: [PATCH] [FIX] base: ensure python version >= 3.5 Odoo 12.0 does *not* officially support any python version below 3.5, but no effort had been made to gracefully announce this to the end user if they were to run Odoo in an unsupported python version. This is done because Odoo 12.0 uses py3-only constructs which can and will raise different errors if ran in python 2. With this patch, Odoo will display an appropriate error message and won't launch at all unless it is being run with python 3.5 or greater. closes odoo/odoo#28502 --- odoo/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/odoo/__init__.py b/odoo/__init__.py index f9e2db590f6..6bfe00b8499 100644 --- a/odoo/__init__.py +++ b/odoo/__init__.py @@ -3,17 +3,21 @@ """ OpenERP core library.""" + #---------------------------------------------------------- # odoo must be a namespace package for odoo.addons to become one too # https://packaging.python.org/guides/packaging-namespace-packages/ #---------------------------------------------------------- __path__ = __import__('pkgutil').extend_path(__path__, __name__) +# As of version 12.0, python 2 is no longer supported, ensure py version is >= 3.5 +import sys +assert sys.version_info > (3, 5), "Python 2 detected, Odoo requires Python >= 3.5 to run." + #---------------------------------------------------------- # Running mode flags (gevent, prefork) #---------------------------------------------------------- # Is the server running with gevent. -import sys evented = False if len(sys.argv) > 1 and sys.argv[1] == 'gevent': sys.argv.remove('gevent')