diff options
author | idle sign <idlesign@yandex.ru> | 2016-12-10 22:24:01 +0700 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-10 11:23:00 -0500 |
commit | c471788dbccf4fcf669d141e6f1325c1b43b8b94 (patch) | |
tree | 0c2e1ce63904504c4efc45e12ce085f93cdd4466 | |
parent | 35f3d1f37fdb137d5f5316058d49c96b9f28ca2d (diff) | |
download | external_python_setuptools-c471788dbccf4fcf669d141e6f1325c1b43b8b94.tar.gz external_python_setuptools-c471788dbccf4fcf669d141e6f1325c1b43b8b94.tar.bz2 external_python_setuptools-c471788dbccf4fcf669d141e6f1325c1b43b8b94.zip |
Proper finalization for `read_configuration()`.
-rw-r--r-- | setuptools/config.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/setuptools/config.py b/setuptools/config.py index 743575f0..d71ff028 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -38,19 +38,21 @@ def read_configuration( current_directory = os.getcwd() os.chdir(os.path.dirname(filepath)) - dist = Distribution() + try: + dist = Distribution() - filenames = dist.find_config_files() if find_others else [] - if filepath not in filenames: - filenames.append(filepath) + filenames = dist.find_config_files() if find_others else [] + if filepath not in filenames: + filenames.append(filepath) - _Distribution.parse_config_files(dist, filenames=filenames) + _Distribution.parse_config_files(dist, filenames=filenames) - handlers = parse_configuration( - dist, dist.command_options, - ignore_option_errors=ignore_option_errors) + handlers = parse_configuration( + dist, dist.command_options, + ignore_option_errors=ignore_option_errors) - os.chdir(current_directory) + finally: + os.chdir(current_directory) return configuration_to_dict(handlers) |