Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion babel/messages/pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _extract_locations(line: str) -> list[str]:
)
in_filename = False
continue
elif c == " ":
elif c in " \t":
if in_filename:
location += c
elif location:
Expand Down
20 changes: 20 additions & 0 deletions tests/messages/test_pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ def test_enclosed_filenames_in_location_comment():
assert True is catalog.is_identical(catalog2)


@pytest.mark.parametrize("separator", ["\t", " \t "])
def test_read_po_with_tab_separated_locations(separator):
locations = separator.join(
[
"plain.py:1",
"\u2068with space.py\u2069:2",
"\u2068with\ttab.py\u2069:3",
"last.py:4",
],
)
catalog = pofile.read_po(StringIO(f'#: {locations}\nmsgid "foo"\nmsgstr "bar"\n'))

assert catalog["foo"].locations == [
("plain.py", 1),
("with space.py", 2),
("with\ttab.py", 3),
("last.py", 4),
]


def test_unescape():
escaped = '"Say:\\n \\"hello, world!\\"\\n"'
unescaped = 'Say:\n "hello, world!"\n'
Expand Down