summaryrefslogtreecommitdiff
path: root/setuptools/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/config.py')
-rw-r--r--setuptools/config.py20
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)