aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-03-30 11:40:59 -0700
committerDavid Lord <davidism@gmail.com>2020-03-30 11:40:59 -0700
commit0a370316c6a4f0d034da5f90df5a671a32a8e376 (patch)
treea291ea51000c3d9aa7d32776d96ce609b68473aa /src
parentc074fd5ecb7af70b2f864c9ef545fffd38dc203b (diff)
parent786867a47cdff625ebdab9fa1dbfe65a0c7e1924 (diff)
downloadjinja-0a370316c6a4f0d034da5f90df5a671a32a8e376.tar.gz
Merge branch '2.11.x'
Diffstat (limited to 'src')
-rw-r--r--src/jinja2/lexer.py8
-rw-r--r--src/jinja2/utils.py3
2 files changed, 8 insertions, 3 deletions
diff --git a/src/jinja2/lexer.py b/src/jinja2/lexer.py
index e0b7a2e9..fc44dbeb 100644
--- a/src/jinja2/lexer.py
+++ b/src/jinja2/lexer.py
@@ -636,6 +636,7 @@ class Lexer:
source_length = len(source)
balancing_stack = []
lstrip_unless_re = self.lstrip_unless_re
+ newlines_stripped = 0
while 1:
# tokenizer loop
@@ -672,7 +673,9 @@ class Lexer:
if strip_sign == "-":
# Strip all whitespace between the text and the tag.
- groups = (text.rstrip(),) + groups[1:]
+ stripped = text.rstrip()
+ newlines_stripped = text[len(stripped) :].count("\n")
+ groups = (stripped,) + groups[1:]
elif (
# Not marked for preserving whitespace.
strip_sign != "+"
@@ -712,7 +715,8 @@ class Lexer:
data = groups[idx]
if data or token not in ignore_if_empty:
yield lineno, token, data
- lineno += data.count("\n")
+ lineno += data.count("\n") + newlines_stripped
+ newlines_stripped = 0
# strings as token just are yielded as it.
else:
diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py
index b373950e..8ee02958 100644
--- a/src/jinja2/utils.py
+++ b/src/jinja2/utils.py
@@ -643,7 +643,8 @@ class Namespace:
self.__attrs = dict(*args, **kwargs)
def __getattribute__(self, name):
- if name == "_Namespace__attrs":
+ # __class__ is needed for the awaitable check in async mode
+ if name in {"_Namespace__attrs", "__class__"}:
return object.__getattribute__(self, name)
try:
return self.__attrs[name]