diff --git a/waflib/Options.py b/waflib/Options.py index 19d83604..23949ca8 100644 --- a/waflib/Options.py +++ b/waflib/Options.py @@ -203,7 +203,7 @@ class OptionsContext(Context.Context): """ try: gr = self.option_groups[k[0]] - except: + except KeyError: gr = self.parser.add_option_group(*k, **kw) self.option_groups[k[0]] = gr return gr diff --git a/waflib/Utils.py b/waflib/Utils.py index ddce92c9..cf925639 100644 --- a/waflib/Utils.py +++ b/waflib/Utils.py @@ -21,31 +21,31 @@ except ImportError: return self.pop(0) try: import _winreg as winreg -except: +except ImportError: try: import winreg - except: + except ImportError: winreg = None from waflib import Errors try: from collections import UserDict -except: +except ImportError: from UserDict import UserDict try: from hashlib import md5 -except: +except ImportError: try: from md5 import md5 - except: + except ImportError: # never fail to enable fixes from another module pass try: import threading -except: +except ImportError: class threading(object): """ A fake threading class for platforms lacking the threading module. @@ -66,7 +66,7 @@ else: run_old(*args, **kwargs) except (KeyboardInterrupt, SystemExit): raise - except: + except Exception: sys.excepthook(*sys.exc_info()) threading.Thread.run = run @@ -167,7 +167,7 @@ def h_file(filename): try: x = ''.encode('hex') -except: +except LookupError: import binascii def to_hex(s): ret = binascii.hexlify(s) @@ -197,7 +197,7 @@ if is_win32: if not s: try: import ctypes - except: + except ImportError: # there is nothing much we can do return [x + ':\\' for x in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')] else: diff --git a/waflib/ansiterm.py b/waflib/ansiterm.py index a534e49a..f0c8dca5 100644 --- a/waflib/ansiterm.py +++ b/waflib/ansiterm.py @@ -32,7 +32,7 @@ else: try: _type = unicode - except: + except NameError: _type = str to_int = lambda number, default: number and int(number) or default