commit: e69ec2d046626fa2079d460aab469d04256182cd
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 24 19:52:10 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Oct 24 19:53:57 2019 +0000
URL: https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=e69ec2d0
write_make_conf: fix infinite loop (bug 698470)
Fixes: 42238f4ff13a ("write_make_conf: support multi-line GENTOO_MIRRORS (bug
543814)")
Bug: https://bugs.gentoo.org/698470
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
mirrorselect/configs.py | 2 ++
tests/test_write_make_conf.py | 1 +
2 files changed, 3 insertions(+)
diff --git a/mirrorselect/configs.py b/mirrorselect/configs.py
index df718f6..4cba14f 100644
--- a/mirrorselect/configs.py
+++ b/mirrorselect/configs.py
@@ -81,6 +81,8 @@ def write_make_conf(output, config_path, var, mirror_string):
lex.quotes = "\"'"
while True:
key = lex.get_token()
+ if key is None:
+ break
if key == var:
begin_line = lex.lineno
diff --git a/tests/test_write_make_conf.py b/tests/test_write_make_conf.py
index 3dedd93..fb84978 100644
--- a/tests/test_write_make_conf.py
+++ b/tests/test_write_make_conf.py
@@ -23,6 +23,7 @@ class WriteMakeConfTestCase(unittest.TestCase):
('\n{}="foo \\\nbar"\n'.format(var),
'\n{}\n'.format(mirror_string)),
('\n\n{}="foo \\\nbar"\n'.format(var),
'\n\n{}\n'.format(mirror_string)),
('\n\n{}="foo \\\nbar"\na="b"\n'.format(var),
'\n\na="b"\n{}\n'.format(mirror_string)),
+ ('', '{}\n'.format(mirror_string)),
)
for make_conf, expected_result in cases: