mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-18 04:52:06 +02:00
Fix _NamespacePath concatenation error in file_path function
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
This commit is contained in:
parent
8c653da57a
commit
dd3f495ba4
2 changed files with 49 additions and 1 deletions
48
docs/PATCH_ADDONS_PATH.md
Normal file
48
docs/PATCH_ADDONS_PATH.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# 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:
|
||||
```python
|
||||
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:
|
||||
|
||||
```python
|
||||
addons_paths = list(odoo.addons.__path__) + [root_path]
|
||||
```
|
||||
|
||||
## File Modified
|
||||
|
||||
- `odoo-bringout-oca-ocb-base/odoo/tools/misc.py` line 169
|
||||
|
||||
## Related Code
|
||||
|
||||
The `file_path()` function is used throughout Odoo to:
|
||||
- Verify file paths under known `addons_path` directories
|
||||
- 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](https://www.python.org/dev/peps/pep-0420/)
|
||||
- Working commit reference: 3f19943cec2680164696765266fc0cdb4e9220c5
|
||||
Loading…
Add table
Add a link
Reference in a new issue