Skip to content

Commit d85e7b2

Browse files
committed
Dropped a branch for Python < 2.7 compatibility.
1 parent 80da25d commit d85e7b2

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

debug_toolbar/middleware.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,8 @@ def process_response(self, request, response):
114114
# Insert the toolbar in the response.
115115
content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)
116116
insert_before = dt_settings.get_config()['INSERT_BEFORE']
117-
try: # Python >= 2.7
118-
pattern = re.escape(insert_before)
119-
bits = re.split(pattern, content, flags=re.IGNORECASE)
120-
except TypeError: # Python < 2.7
121-
pattern = '(.+?)(%s|$)' % re.escape(insert_before)
122-
matches = re.findall(pattern, content, flags=re.DOTALL | re.IGNORECASE)
123-
bits = [m[0] for m in matches if m[1] == insert_before]
124-
# When the body ends with a newline, there's two trailing groups.
125-
bits.append(''.join(m[0] for m in matches if m[1] == ''))
117+
pattern = re.escape(insert_before)
118+
bits = re.split(pattern, content, flags=re.IGNORECASE)
126119
if len(bits) > 1:
127120
# When the toolbar will be inserted for sure, generate the stats.
128121
for panel in reversed(toolbar.enabled_panels):

0 commit comments

Comments
 (0)