Mercurial > hg
comparison mercurial/__init__.py @ 31445:83e080144faf
py3: rewrite itervalues() as values() by importer
I'm not a great fan of these importer magics, but this should be okay since
"itervalues" seems as unique name as "iteritems".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 13 Mar 2017 08:44:57 -0700 |
parents | 8a17c541177f |
children | 526e4597cca5 |
comparison
equal
deleted
inserted
replaced
31444:55390e97fdd2 | 31445:83e080144faf |
---|---|
308 for argn in range(2): | 308 for argn in range(2): |
309 argidx = _findargnofcall(argn) | 309 argidx = _findargnofcall(argn) |
310 if argidx is not None: | 310 if argidx is not None: |
311 _ensureunicode(argidx) | 311 _ensureunicode(argidx) |
312 | 312 |
313 # It changes iteritems to items as iteritems is not | 313 # It changes iteritems/values to items/values as they are not |
314 # present in Python 3 world. | 314 # present in Python 3 world. |
315 elif fn == 'iteritems': | 315 elif fn in ('iteritems', 'itervalues'): |
316 yield t._replace(string='items') | 316 yield t._replace(string=fn[4:]) |
317 continue | 317 continue |
318 | 318 |
319 # Emit unmodified token. | 319 # Emit unmodified token. |
320 yield t | 320 yield t |
321 | 321 |
322 # Header to add to bytecode files. This MUST be changed when | 322 # Header to add to bytecode files. This MUST be changed when |
323 # ``replacetoken`` or any mechanism that changes semantics of module | 323 # ``replacetoken`` or any mechanism that changes semantics of module |
324 # loading is changed. Otherwise cached bytecode may get loaded without | 324 # loading is changed. Otherwise cached bytecode may get loaded without |
325 # the new transformation mechanisms applied. | 325 # the new transformation mechanisms applied. |
326 BYTECODEHEADER = b'HG\x00\x08' | 326 BYTECODEHEADER = b'HG\x00\x09' |
327 | 327 |
328 class hgloader(importlib.machinery.SourceFileLoader): | 328 class hgloader(importlib.machinery.SourceFileLoader): |
329 """Custom module loader that transforms source code. | 329 """Custom module loader that transforms source code. |
330 | 330 |
331 When the source code is converted to a code object, we transform | 331 When the source code is converted to a code object, we transform |