Skip to content

Commit

Permalink
Always cook templates in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
malthe committed Jan 17, 2024
1 parent 27dd468 commit 731c413
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changes

In next release ...

- Always cook templates in debug mode, even when using
`CHAMELEON_CACHE` option to persist generated code on disk.

- Parsing the AST back to Python code now uses the built-in
`ast.unparse` function. This change is not directly surfaced but
means that the unparsing code is now more correctly tracking changes
Expand Down
4 changes: 0 additions & 4 deletions src/chameleon/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ def get(self, filename: str) -> dict[str, Any] | None:
def build(self, source: str, filename: str) -> dict[str, Any]:
acquire_lock()
try:
d = self.get(filename)
if d is not None:
return d

base, ext = os.path.splitext(filename)
name = os.path.join(self.path, base + ".py")

Expand Down
2 changes: 1 addition & 1 deletion src/chameleon/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _cook(

filename = self._get_module_name(name)
cooked = self.loader.get(filename)
if cooked is None:
if cooked is None or DEBUG_MODE:
try:
source = self._compile(body, builtins)
if self.debug:
Expand Down

0 comments on commit 731c413

Please sign in to comment.