Skip to content

Commit

Permalink
ini: do not treat rem as a comment start
Browse files Browse the repository at this point in the history
These are typically valid INI keys, this iniparse behavior seems weird.

Other iniparse consumers seem to do this as well (for example crudini).

Fixes WeblateOrg/weblate#10561
  • Loading branch information
nijel committed Dec 8, 2023
1 parent 0c69499 commit 192bbcf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/translate/storage/test_ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ def test_serialize(self):
store.serialize(out)

assert out.getvalue() == content

def test_rem(self):
content = b"[default]\nremaining=None"
store = self.StoreClass()
store.parse(content)
assert len(store.units) == 1
out = BytesIO()
store.serialize(out)

assert out.getvalue() == content
6 changes: 5 additions & 1 deletion translate/storage/ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
from translate.storage import base

try:
from iniparse import INIConfig
from iniparse import INIConfig, change_comment_syntax
except ImportError:
raise ImportError("Missing iniparse library.")


# Disable treating anything starting with rem as a comment, this changes
# global iniparse state
change_comment_syntax(allow_rem=False)

dialects = {}


Expand Down

0 comments on commit 192bbcf

Please sign in to comment.