Template.render_context(context) (re)sets context['self']
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 459
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Migrated issue, originally created by Anonymous
I'm not quite positive that this is a bug, but I’m pretty sure it is.
When Template.render_context() is called, it sets context['self'].
So, if one renders another template like this:
subtemplate.render_context(context)
After the call to render_context(), context['self'] no longer contains the correct namespace. This (at least) causes problems for any <%block>s in the calling template.
I've attached a short test script which demonstrates the problem.
Attachments: test_render_context_bug.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the attached test script, imported_issue_attachments/184/test_render_context_bug.py, to reproduce the changed context['self']. Then locate the Template.render_context() entry point, trace how nested rendering affects the caller's context, and use the script's expected behavior as the completion check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100