Mercurial > hg > mercurial-source
comparison contrib/setup3k.py @ 14973:bcba68e81a81
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.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 16:07:52 -0500 (2011-07-25) |
parents | 4c50552fc9bc |
children | 0d4f6e843b05 |
comparison
equal
deleted
inserted
replaced
14972:0b21ae0a2366 | 14973:bcba68e81a81 |
---|---|
6 | 6 |
7 from distutils.command.build_py import build_py_2to3 | 7 from distutils.command.build_py import build_py_2to3 |
8 from lib2to3.refactor import get_fixers_from_package as getfixers | 8 from lib2to3.refactor import get_fixers_from_package as getfixers |
9 | 9 |
10 import sys | 10 import sys |
11 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'): | 11 if getattr(sys, 'version_info', (0, 0, 0)) < (2, 4, 0, 'final'): |
12 raise SystemExit("Mercurial requires Python 2.4 or later.") | 12 raise SystemExit("Mercurial requires Python 2.4 or later.") |
13 | 13 |
14 if sys.version_info[0] >= 3: | 14 if sys.version_info[0] >= 3: |
15 def b(s): | 15 def b(s): |
16 '''A helper function to emulate 2.6+ bytes literals using string | 16 '''A helper function to emulate 2.6+ bytes literals using string |
234 | 234 |
235 def build_extension(self, ext): | 235 def build_extension(self, ext): |
236 try: | 236 try: |
237 build_ext.build_extension(self, ext) | 237 build_ext.build_extension(self, ext) |
238 except CCompilerError: | 238 except CCompilerError: |
239 if not hasattr(ext, 'optional') or not ext.optional: | 239 if getattr(ext, 'optional', False): |
240 raise | 240 raise |
241 log.warn("Failed to build optional extension '%s' (skipping)", | 241 log.warn("Failed to build optional extension '%s' (skipping)", |
242 ext.name) | 242 ext.name) |
243 | 243 |
244 class hgbuildpy(build_py_2to3): | 244 class hgbuildpy(build_py_2to3): |