From e5e2fe5a6f084fb98c2c9b4adec0383fec4a5256 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 1 Jul 2019 22:52:17 +0200 Subject: Catch EnvironmentError instead of OSError/IOError menuconfig.py tended to crash on I/O errors on Python 2, due to forgetting to update some 'except OSError's. Catch EnvironmentError instead. EnvironmentError is a common base class of IOError and OSError on Python 2, and an alias for OSError on Python 3. Use it elsewhere too, as it might help catch obscure I/O errors on Python 2. --- menuconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'menuconfig.py') diff --git a/menuconfig.py b/menuconfig.py index 6afc1c4..799cc4a 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1829,7 +1829,7 @@ def _try_load(filename): try: _kconf.load_config(filename) return True - except OSError as e: + except EnvironmentError as e: _error("Error loading '{}'\n\n{} (errno: {})" .format(filename, e.strerror, errno.errorcode[e.errno])) return False @@ -1881,7 +1881,7 @@ def _try_save(save_fn, filename, description): try: # save_fn() returns a message to print return save_fn(filename) - except OSError as e: + except EnvironmentError as e: _error("Error saving {} to '{}'\n\n{} (errno: {})" .format(description, e.filename, e.strerror, errno.errorcode[e.errno])) -- cgit v1.2.3