← Back to Pull requests

[18.0][FIX] cetmix_tower_server: drop re.template, removed in Python 3.13 #492

Closed
unknown closed this pull request without merging on Aug 30, 2026 16:45 UTC
View on GitHub
unknown unknown commented on Aug 30, 2026 00:35 UTC
Author

Problem

cx_tower_variable.py and cx_tower_command.py both wrap the re module for safe_eval and whitelist re.template. That function was deprecated in Python 3.11 and removed in 3.13, so on 3.13+ neither module can be imported:

File ".../cetmix_tower_server/models/cx_tower_variable.py", line 16, in <module>
    re = wrap_module(
File ".../odoo/tools/safe_eval.py", line 471, in __init__
    target = getattr(module, attrib)
AttributeError: module 're' has no attribute 'template'. Did you mean: 'replace'?

The failure is at import time, so -i cetmix_tower aborts part-way through loading the module graph and leaves the database half-initialised. There is no partial degradation — the module simply cannot install.

Reproduce

Install cetmix_tower on Odoo 18.0 running on Python 3.13 or newer. Encountered on Ubuntu 26.04 / Python 3.14 while setting up a control plane.

This affects any host on Python 3.13+ — Ubuntu 25.10 onward, Debian trixie onward — so it becomes more common over time, not less.

Fix

Remove "template" from both wrap_module() whitelists. Two lines.

re.template was undocumented and deprecated for two releases, so this takes away nothing anyone can be relying on: on 3.13+ it cannot be called at all, and Odoo's own safe_eval does not expose it either.

If you would rather keep it available on older interpreters, the alternative is to build the list conditionally:

_RE_ATTRS = ["match", "fullmatch", ..., "escape", "error"]
if hasattr(_re, "template"):
    _RE_ATTRS.append("template")

Happy to switch to that if you prefer it.

Scope

I checked every wrap_module() call in the repo against Python 3.14, resolving each wrapped module and asserting each whitelisted attribute exists. re.template in these two files is the only one affected — requests, json, hashlib, hmac, urllib.parse, tldextract and the dns. wrappers all resolve cleanly.

No version bump included, since the post-merge bot appears to handle that.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

Bug Fixes
Improved compatibility with newer Python versions by handling the unavailable re.template feature safely.
Preserved supported regular-expression functionality, including re.template where available.
* Fixed command evaluation and variable validation imports that could fail on Python versions without re.template.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 319 lines (+239 / -80) across 3 files Reviewer: ivs-cetmix Review duration: 969m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 319 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.345
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #492"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 40.4% (MEDIUM) · Higher = larger blast radius
40.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.5% · Safe to merge
17.5%