diff options
| author | ?ric Araujo <merwok@netwok.org> | 2011-10-19 03:08:54 +0200 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2011-10-19 03:08:54 +0200 |
| commit | 388b499a2b99bcd6e409bd0d593144faa0d52f40 (patch) | |
| tree | d22aeff001ac3ee03d06bbafc31c740075b5bcb0 /distutils2/command/config.py | |
| parent | 31f4c07c589c068242cada4bda617fa6bd51e5d5 (diff) | |
| parent | 2fd0570dc0f3e5498fc26066a322168ea9d8d0db (diff) | |
| download | disutils2-388b499a2b99bcd6e409bd0d593144faa0d52f40.tar.gz | |
Null merge default
Diffstat (limited to 'distutils2/command/config.py')
| -rw-r--r-- | distutils2/command/config.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/distutils2/command/config.py b/distutils2/command/config.py index e3af2e5..437cde9 100644 --- a/distutils2/command/config.py +++ b/distutils2/command/config.py @@ -67,17 +67,17 @@ class config(Command): def finalize_options(self): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - elif isinstance(self.include_dirs, basestring): + elif isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) if self.libraries is None: self.libraries = [] - elif isinstance(self.libraries, basestring): + elif isinstance(self.libraries, str): self.libraries = [self.libraries] if self.library_dirs is None: self.library_dirs = [] - elif isinstance(self.library_dirs, basestring): + elif isinstance(self.library_dirs, str): self.library_dirs = self.library_dirs.split(os.pathsep) def run(self): @@ -110,8 +110,7 @@ class config(Command): def _gen_temp_sourcefile(self, body, headers, lang): filename = "_configtest" + LANG_EXT[lang] - file = open(filename, "w") - try: + with open(filename, "w") as file: if headers: for header in headers: file.write("#include <%s>\n" % header) @@ -119,8 +118,6 @@ class config(Command): file.write(body) if body[-1] != "\n": file.write("\n") - finally: - file.close() return filename def _preprocess(self, body, headers, include_dirs, lang): @@ -206,11 +203,10 @@ class config(Command): self._check_compiler() src, out = self._preprocess(body, headers, include_dirs, lang) - if isinstance(pattern, basestring): + if isinstance(pattern, str): pattern = re.compile(pattern) - file = open(out) - try: + with open(out) as file: match = False while True: line = file.readline() @@ -219,8 +215,6 @@ class config(Command): if pattern.search(line): match = True break - finally: - file.close() self._clean() return match @@ -351,8 +345,5 @@ def dump_file(filename, head=None): logger.info(filename) else: logger.info(head) - file = open(filename) - try: + with open(filename) as file: logger.info(file.read()) - finally: - file.close() |
