diff options
| author | Tarek Ziad? <tarek@ziade.org> | 2010-02-28 15:49:00 +0100 |
|---|---|---|
| committer | Tarek Ziad? <tarek@ziade.org> | 2010-02-28 15:49:00 +0100 |
| commit | 77c3828bcac984f46c42588002b7081af0ac45c5 (patch) | |
| tree | 0124d4dd9380f6b9b9ac3dadb82873c87f761d24 /src/distutils2 | |
| parent | d137a098ee94cb52072b4eed52d40e3aec88432d (diff) | |
| download | disutils2-77c3828bcac984f46c42588002b7081af0ac45c5.tar.gz | |
make sure we can have a cfg file without a global section
Diffstat (limited to 'src/distutils2')
| -rw-r--r-- | src/distutils2/_backport/sysconfig.py | 10 | ||||
| -rw-r--r-- | src/distutils2/_backport/tests/test_sysconfig.py | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/distutils2/_backport/sysconfig.py b/src/distutils2/_backport/sysconfig.py index 16a0fac..5d082b7 100644 --- a/src/distutils2/_backport/sysconfig.py +++ b/src/distutils2/_backport/sysconfig.py @@ -19,7 +19,11 @@ _SCHEMES.read(_CONFIG_FILE) _VAR_REPL = re.compile(r'\{([^{]*?)\}') def _expand_globals(config): - globals = config.items('globals') + if config.has_section('globals'): + globals = config.items('globals') + else: + globals = tuple() + sections = config.sections() for section in sections: if section == 'globals': @@ -76,9 +80,9 @@ if _PYTHON_BUILD: def _subst_vars(path, local_vars): """In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. - + If there is no corresponding value, leave the token unchanged. - + """ def _replacer(matchobj): name = matchobj.group(1) diff --git a/src/distutils2/_backport/tests/test_sysconfig.py b/src/distutils2/_backport/tests/test_sysconfig.py index b51bb10..e4db614 100644 --- a/src/distutils2/_backport/tests/test_sysconfig.py +++ b/src/distutils2/_backport/tests/test_sysconfig.py @@ -257,6 +257,10 @@ class TestSysConfig(unittest2.TestCase): self.assertEquals(config.get('posix', 'foo'), 'ok') self.assertEquals(config.get('posix', 'more'), '/etc/ok') + # we might not have globals after all + # extending again (==no more globals section) + _expand_globals(config) + def test_suite(): return unittest2.makeSuite(TestSysConfig) |
