Mercurial > hg
comparison mercurial/extensions.py @ 36178:646002338365
py3: introduce and use pycompat.getargspec
This is getfullargspec on py3, which means we can't use namedtuple
named accessors for all fields (eg keywords from getargspec is varkw
from getfullargspec, with the same meaning). Solves some warning
issues on Python 3.
I didn't clean up httpclient because that's vendored code I think we
should probably discard, and I didn't touch the manpage generator for
now either.
Differential Revision: https://phab.mercurial-scm.org/D2251
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 13 Feb 2018 23:00:01 -0700 |
parents | 78d9a7b7cdb6 |
children | 4088e568a411 |
comparison
equal
deleted
inserted
replaced
36177:187f2474bc11 | 36178:646002338365 |
---|---|
193 if extsetup: | 193 if extsetup: |
194 try: | 194 try: |
195 try: | 195 try: |
196 extsetup(ui) | 196 extsetup(ui) |
197 except TypeError: | 197 except TypeError: |
198 # Try to use getfullargspec (Python 3) first, and fall | 198 if pycompat.getargspec(extsetup).args: |
199 # back to getargspec only if it doesn't exist so as to | |
200 # avoid warnings. | |
201 if getattr(inspect, 'getfullargspec', | |
202 getattr(inspect, 'getargspec'))(extsetup).args: | |
203 raise | 199 raise |
204 extsetup() # old extsetup with no ui argument | 200 extsetup() # old extsetup with no ui argument |
205 except Exception as inst: | 201 except Exception as inst: |
206 ui.traceback(force=True) | 202 ui.traceback(force=True) |
207 msg = util.forcebytestr(inst) | 203 msg = util.forcebytestr(inst) |