summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorEmmanuel Ferdman <emmanuelferdman@gmail.com>2026-03-13 01:57:41 +0200
committerGitHub <noreply@github.com>2026-03-12 19:57:41 -0400
commit7cb2221e9267dec3f1cf7c88b8686d38fd956639 (patch)
tree91c3327cbcea6d46df485aad5a2c2321563c4ee6 /django/template
parent3180ddb3f532ef246d318d64225886b7c0593676 (diff)
Encapsulated loop logic to avoid leaking module-level variables.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/smartif.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/django/template/smartif.py b/django/template/smartif.py
index c0682f3b1e..ad4d01f898 100644
--- a/django/template/smartif.py
+++ b/django/template/smartif.py
@@ -111,10 +111,14 @@ OPERATORS = {
"<=": infix(10, lambda context, x, y: x.eval(context) <= y.eval(context)),
}
+
# Assign 'id' to each:
-for key, op in OPERATORS.items():
- op.id = key
-del key, op
+def _init_operators():
+ for key, op in OPERATORS.items():
+ op.id = key
+
+
+_init_operators()
class Literal(TokenBase):