Use try-else-finally in Python >= 2.5

This commit is contained in:
Thomas Nagy 2016-05-18 22:01:37 +02:00
parent 3f38b9d2b8
commit 74e54322c5
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
2 changed files with 22 additions and 24 deletions

View File

@ -245,18 +245,17 @@ echo LIB=%%LIB%%;%%LIBPATH%%
del(env['CL']) del(env['CL'])
try: try:
try: conf.cmd_and_log(fc + ['/help'], env=env)
conf.cmd_and_log(fc + ['/help'], env=env) except UnicodeError:
except UnicodeError: st = Utils.ex_stack()
st = Utils.ex_stack() if conf.logger:
if conf.logger: conf.logger.error(st)
conf.logger.error(st) conf.fatal('msvc: Unicode error - check the code page?')
conf.fatal('msvc: Unicode error - check the code page?') except Exception as e:
except Exception as e: debug('msvc: get_ifort_version: %r %r %r -> failure %s', compiler, version, target, str(e))
debug('msvc: get_ifort_version: %r %r %r -> failure %s', compiler, version, target, str(e)) conf.fatal('msvc: cannot run the compiler in get_ifort_version (run with -v to display errors)')
conf.fatal('msvc: cannot run the compiler in get_ifort_version (run with -v to display errors)') else:
else: debug('msvc: get_ifort_version: %r %r %r -> OK', compiler, version, target)
debug('msvc: get_ifort_version: %r %r %r -> OK', compiler, version, target)
finally: finally:
conf.env[compiler_name] = '' conf.env[compiler_name] = ''

View File

@ -192,18 +192,17 @@ echo LIB=%%LIB%%;%%LIBPATH%%
del(env['CL']) del(env['CL'])
try: try:
try: conf.cmd_and_log(cxx + ['/help'], env=env)
conf.cmd_and_log(cxx + ['/help'], env=env) except UnicodeError:
except UnicodeError: st = Utils.ex_stack()
st = Utils.ex_stack() if conf.logger:
if conf.logger: conf.logger.error(st)
conf.logger.error(st) conf.fatal('msvc: Unicode error - check the code page?')
conf.fatal('msvc: Unicode error - check the code page?') except Exception as e:
except Exception as e: debug('msvc: get_msvc_version: %r %r %r -> failure %s', compiler, version, target, str(e))
debug('msvc: get_msvc_version: %r %r %r -> failure %s', compiler, version, target, str(e)) conf.fatal('msvc: cannot run the compiler in get_msvc_version (run with -v to display errors)')
conf.fatal('msvc: cannot run the compiler in get_msvc_version (run with -v to display errors)') else:
else: debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
finally: finally:
conf.env[compiler_name] = '' conf.env[compiler_name] = ''