bpo-16965: 2to3 now rewrites execfile() to open with 'rb'. (GH-8569)

This commit is contained in:
Zackery Spytz 2018-10-13 03:27:30 -06:00 committed by Serhiy Storchaka
parent 0461704060
commit d4d60134b2
3 changed files with 12 additions and 9 deletions

View file

@ -31,7 +31,8 @@ class FixExecfile(fixer_base.BaseFix):
# call.
execfile_paren = node.children[-1].children[-1].clone()
# Construct open().read().
open_args = ArgList([filename.clone()], rparen=execfile_paren)
open_args = ArgList([filename.clone(), Comma(), String('"rb"', ' ')],
rparen=execfile_paren)
open_call = Node(syms.power, [Name("open"), open_args])
read = [Node(syms.trailer, [Dot(), Name('read')]),
Node(syms.trailer, [LParen(), RParen()])]