Skip to content

fix(JinjaSetup, TemplateDir): bind root from os.walk to fix NameError in recursive search - #175

Open
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:fix/jinjasetup-templatedir-root-nameerror
Open

fix(JinjaSetup, TemplateDir): bind root from os.walk to fix NameError in recursive search#175
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:fix/jinjasetup-templatedir-root-nameerror

Conversation

@SoundMatt

Copy link
Copy Markdown
Contributor

Both find_matching_template_files implementations unpacked os.walk as for _, _, filenames, discarding the root directory string. The body then built file paths using os.path.join(root, ff), referencing an undefined variable. Calling either function with recurse=True raises a NameError.

Fix by binding the first value to root instead of discarding it with _.

…ecursive template search

Both `find_matching_template_files` functions discarded the first value
from `os.walk` using `_`, then constructed file paths with `root` — a
variable that was therefore never defined, causing a `NameError` when
the recursive code path was taken.  Capture it as `root`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@gunnar-mb

Copy link
Copy Markdown
Collaborator

Some of the oldest template handling might have left obsolete code, but this TemplateDir.py is referenced from JinjaTemplateEnvk, so I think the code is used. But how does it then work despite the described problem?

Test / review and possibly remove now obsolete implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants