Merge pull request #4270 from ThomasWaldmann/fix-configparser-diaper-1.1

avoid diaper pattern in configparser by opening files, fixes #4263
This commit is contained in:
TW 2019-01-27 03:25:40 +01:00 committed by GitHub
commit 8a8c447e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -263,7 +263,8 @@ class CacheConfig:
def load(self):
self._config = configparser.ConfigParser(interpolation=None)
self._config.read(self.config_path)
with open(self.config_path) as fd:
self._config.read_file(fd)
self._check_upgrade(self.config_path)
self.id = self._config.get('cache', 'repository')
self.manifest_id = unhexlify(self._config.get('cache', 'manifest'))

View file

@ -382,7 +382,8 @@ class Repository:
else:
self.lock = None
self.config = ConfigParser(interpolation=None)
self.config.read(os.path.join(self.path, 'config'))
with open(os.path.join(self.path, 'config')) as fd:
self.config.read_file(fd)
if 'repository' not in self.config.sections() or self.config.getint('repository', 'version') != 1:
self.close()
raise self.InvalidRepository(path)