# HG changeset patch # User Augie Fackler # Date 2011-07-25 19:59:31 # Node ID 5a0fdc7157694726dbc797350720fc1671bf47f6 # Parent 1dbd42a02153b9a6c757673d16eff373ff5bf32d check-code: disallow use of hasattr() The hasattr() builtin from Python < 3.2 [1] has slightly surprising behavior: it catches all exceptions, even KeyboardInterrupt. This causes it to have several surprising side effects, such as hiding warnings that occur during attribute load and causing mysterious failure modes when ^Cing an application. In later versions of Python 2.x [0], exception classes which do not inherit from Exception (such as SystemExit and KeyboardInterrupt) are not caught, but other types of exceptions may still silently cause returning False instead of getting a reasonable exception. [0] http://bugs.python.org/issue2196 [1] http://docs.python.org/dev/whatsnew/3.2.html diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -148,7 +148,7 @@ pypats = [ (r'(?