Skip to content

Commit 396a7be

Browse files
committed
Only process comments when needed
1 parent d496031 commit 396a7be

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Tools/i18n/pygettext.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ def visit_file(self, source, filename):
348348
return
349349

350350
self.filename = filename
351-
self.comments = get_source_comments(source)
351+
if self.options.comment_tags:
352+
self.comments = get_source_comments(source)
352353
self.visit(module_tree)
353354

354355
def visit_Module(self, node):
@@ -436,7 +437,7 @@ def _extract_comments(self, node):
436437
return comments[first_index:]
437438

438439
def _is_translator_comment(self, comment):
439-
return comment.startswith(tuple(self.options.comment_tags))
440+
return comment.startswith(self.options.comment_tags)
440441

441442
def _add_message(
442443
self, lineno, msgid, msgid_plural=None, msgctxt=None, *,
@@ -634,6 +635,8 @@ class Options:
634635
finally:
635636
fp.close()
636637

638+
options.comment_tags = tuple(options.comment_tags)
639+
637640
# calculate escapes
638641
make_escapes(not options.escape)
639642

0 commit comments

Comments
 (0)