setup3k: use getattr instead of hasattr
authorAugie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 16:07:52 -0500
changeset 14972 bcba68e81a81
parent 14971 0b21ae0a2366
child 14973 5656cb5b9028
setup3k: use getattr instead of hasattr Note that hasattr is fixed on Python 3, so this is more about being concise and keeping check-code happy than actual correctness of code.
contrib/setup3k.py
--- a/contrib/setup3k.py	Mon Jul 25 16:37:18 2011 -0500
+++ b/contrib/setup3k.py	Mon Jul 25 16:07:52 2011 -0500
@@ -8,7 +8,7 @@
 from lib2to3.refactor import get_fixers_from_package as getfixers
 
 import sys
-if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
+if getattr(sys, 'version_info', (0, 0, 0)) < (2, 4, 0, 'final'):
     raise SystemExit("Mercurial requires Python 2.4 or later.")
 
 if sys.version_info[0] >= 3:
@@ -236,7 +236,7 @@
         try:
             build_ext.build_extension(self, ext)
         except CCompilerError:
-            if not hasattr(ext, 'optional') or not ext.optional:
+            if getattr(ext, 'optional', False):
                 raise
             log.warn("Failed to build optional extension '%s' (skipping)",
                      ext.name)