Skip to content

Commit 7689133

Browse files
sarinaThomas Grainger
authored andcommitted
Lexer's __init__ only takes template_string as arg (django 1.9)
1 parent 4c03571 commit 7689133

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

django_babel/extract.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ def extract_django(fileobj, keywords, comment_tags, options):
3333
encoding = options.get('encoding', 'utf8')
3434
text = fileobj.read().decode(encoding)
3535

36-
for t in Lexer(text, None).tokenize():
36+
try:
37+
text_lexer = Lexer(text)
38+
except TypeError:
39+
# Django 1.9 changed the way we invoke Lexer; older versions
40+
# require two parameters.
41+
text_lexer = Lexer(text, None)
42+
43+
for t in text_lexer.tokenize():
3744
lineno += t.contents.count('\n')
3845
if intrans:
3946
if t.token_type == TOKEN_BLOCK:

0 commit comments

Comments
 (0)