Skip to content

Fallback signatures corrupt paths containing '.py' internally: replace('.py','') strips non-suffix occurrences (CLDK-005) #84

Description

@rahlk

From the external v0.3.0/Odoo quality audit, finding CLDK-005 (severity Medium). Plain bug, no schema change — fix applies to both main and the v2 stage chain.

Symptom

Eight Odoo symbols have corrupted path-derived signatures because .py is removed everywhere in the dotted path, not just as the file suffix:

pathstored signature prefixexpected
odoo/tools/babel/python_extractor.pyodoo.tools.babelthon_extractorodoo.tools.babel.python_extractor
odoo/_monkeypatches/pytz.pyodoo._monkeypatchestzodoo._monkeypatches.pytz
odoo/tools/pycompat.pyodoo.toolscompatodoo.tools.pycompat

Reproduced exactly:

>>>'odoo/tools/pycompat.py'.replace('/', '.').replace('.py', '')
'odoo.toolscompat'

Root cause

The fallback signature builder (used when Jedi goto yields nothing) does str(relative_path).replace('/', '.').replace('.py', '') — and str.replace removes every occurrence, so the .py inside .pycompat is deleted along with the suffix. Three sites in codeanalyzer/syntactic_analysis/symbol_table_builder.py: main @ 206, 209, 262; v2 chain @ 217, 220, 281.

Only 8 Odoo symbols are hit because this is the fallback path and few module paths contain an interior .py; corruption then propagates to every symbol keyed under the module prefix.

Fix

Strip the suffix before joining: relative_path.with_suffix('') (or removesuffix('.py') on the string) — never replace. Add a fixture with a .py-embedding name (e.g. pycompat.py, babel/python_extractor.py) asserting the signature prefix, per the audit gate: remove only a terminal extension; every signature begins with the exact path-derived module prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions