##// END OF EJS Templates
py3: a second argument to open can't be bytes...
Martijn Pieters -
r30118:c19266ed default
parent child Browse files
Show More
@@ -305,6 +305,24 b' if sys.version_info[0] >= 3:'
305 except IndexError:
305 except IndexError:
306 pass
306 pass
307
307
308 # Bare open call (not an attribute on something else)
309 if (fn == 'open' and not (prevtoken.type == token.OP and
310 prevtoken.string == '.')):
311 try:
312 # (NAME, 'open')
313 # (OP, '(')
314 # (NAME|STRING, 'filename')
315 # (OP, ',')
316 # (NAME|STRING, mode)
317 st = tokens[i + 4]
318 if (st.type == token.STRING and
319 st.string[0] in ("'", '"')):
320 rt = tokenize.TokenInfo(st.type, 'u%s' % st.string,
321 st.start, st.end, st.line)
322 tokens[i + 4] = rt
323 except IndexError:
324 pass
325
308 # It changes iteritems to items as iteritems is not
326 # It changes iteritems to items as iteritems is not
309 # present in Python 3 world.
327 # present in Python 3 world.
310 if fn == 'iteritems':
328 if fn == 'iteritems':
@@ -319,7 +337,7 b' if sys.version_info[0] >= 3:'
319 # ``replacetoken`` or any mechanism that changes semantics of module
337 # ``replacetoken`` or any mechanism that changes semantics of module
320 # loading is changed. Otherwise cached bytecode may get loaded without
338 # loading is changed. Otherwise cached bytecode may get loaded without
321 # the new transformation mechanisms applied.
339 # the new transformation mechanisms applied.
322 BYTECODEHEADER = b'HG\x00\x04'
340 BYTECODEHEADER = b'HG\x00\x05'
323
341
324 class hgloader(importlib.machinery.SourceFileLoader):
342 class hgloader(importlib.machinery.SourceFileLoader):
325 """Custom module loader that transforms source code.
343 """Custom module loader that transforms source code.
General Comments 0
You need to be logged in to leave comments. Login now