mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-18 07:52:04 +02:00
Convert odoo.addons.__path__ to list before concatenation with [root_path]
to fix TypeError when using Python 3.7+ namespace packages.
Error: unsupported operand type(s) for +: '_NamespacePath' and 'list'
Location: odoo/tools/misc.py:169
Added documentation explaining the fix in docs/PATCH_ADDONS_PATH.md
🤖 assisted by claude
1.4 KiB
1.4 KiB
Fix for _NamespacePath Concatenation Error
Issue
After upgrading, Odoo failed to start with the following error:
TypeError: unsupported operand type(s) for +: '_NamespacePath' and 'list'
This occurred in odoo/tools/misc.py:169 in the file_path() function.
Root Cause
In Python 3.7+, namespace packages use _NamespacePath objects for the __path__ attribute. This special type cannot be directly concatenated with a Python list using the + operator.
The problematic code was:
addons_paths = odoo.addons.__path__ + [root_path]
When odoo.addons.__path__ is a _NamespacePath object, attempting to add it to a list [root_path] raises a TypeError.
Solution
Convert the _NamespacePath to a list before concatenation:
addons_paths = list(odoo.addons.__path__) + [root_path]
File Modified
odoo-bringout-oca-ocb-base/odoo/tools/misc.pyline 169
Related Code
The file_path() function is used throughout Odoo to:
- Verify file paths under known
addons_pathdirectories - Locate module resources (icons, static files, etc.)
- Validate file access for security purposes
This fix ensures the function can properly construct the list of addon paths to search.
References
- Python namespace packages: PEP 420
- Working commit reference:
3f19943cec