From 7ef68e4b0e9c4ba3efed2b7625af8e379b4f1683 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Tue, 22 Oct 2019 09:39:24 +0000 Subject: [PATCH] [FIX] core: using absolute paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Start odoo-bin using a tier module (like `python3 -m pdb odoo-bin`), the odoo/addons __path__ contains the relative link to the modules instead of the absolute link like when directly started (`python3 odoo-bin`). This cause trouble importing modules because it reuses the relative path from within other directories. closes odoo/odoo#39182 X-original-commit: 941e051fc6b33e7a90400c77d63d589049b027a6 Signed-off-by: Xavier Dollé (xdo) --- odoo/__init__.py | 7 ++++++- odoo/addons/__init__.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/odoo/__init__.py b/odoo/__init__.py index 30da3608237..8eb764a712d 100644 --- a/odoo/__init__.py +++ b/odoo/__init__.py @@ -8,7 +8,12 @@ # 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__) +import pkgutil +import os.path +__path__ = [ + os.path.abspath(path) + for path in pkgutil.extend_path(__path__, __name__) +] import sys assert sys.version_info > (3, 6), "Outdated python version detected, Odoo requires Python >= 3.6 to run." diff --git a/odoo/addons/__init__.py b/odoo/addons/__init__.py index c0058937588..56e3bd2d875 100644 --- a/odoo/addons/__init__.py +++ b/odoo/addons/__init__.py @@ -17,4 +17,9 @@ Importing them from here is deprecated. # make odoo.addons a namespace package, while keeping this __init__.py # present, for python 2 compatibility # https://packaging.python.org/guides/packaging-namespace-packages/ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) +import pkgutil +import os.path +__path__ = [ + os.path.abspath(path) + for path in pkgutil.extend_path(__path__, __name__) +]