summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-10 01:19:51 (GMT)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-10 01:19:51 (GMT)
commit3b822d6c89ac6dffe5304adf0ce77c2d42406338 (patch)
tree9611fd543334e146032283448ecff2610ebd985a /Lib/lib2to3/fixes
parent50a903de4cc050d0d4d3a02ab13036421909e4cf (diff)
parent28325749c01815097aa2bc06508004a1f894c279 (diff)
downloadcpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.zip
cpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.tar.gz
cpython-3b822d6c89ac6dffe5304adf0ce77c2d42406338.tar.bz2
Issue #25969: Update the lib2to3 grammar to handle the unpacking
generalizations added in 3.5.
Diffstat (limited to 'Lib/lib2to3/fixes')
-rw-r--r--Lib/lib2to3/fixes/fix_apply.py11
-rw-r--r--Lib/lib2to3/fixes/fix_intern.py10
-rw-r--r--Lib/lib2to3/fixes/fix_reload.py11
3 files changed, 32 insertions, 0 deletions
diff --git a/Lib/lib2to3/fixes/fix_apply.py b/Lib/lib2to3/fixes/fix_apply.py
index 81a46dc..826ec8c 100644
--- a/Lib/lib2to3/fixes/fix_apply.py
+++ b/Lib/lib2to3/fixes/fix_apply.py
@@ -34,6 +34,17 @@ class FixApply(fixer_base.BaseFix):
func = results["func"]
args = results["args"]
kwds = results.get("kwds")
+ # I feel like we should be able to express this logic in the
+ # PATTERN above but I don't know how to do it so...
+ if args:
+ if args.type == self.syms.star_expr:
+ return # Make no change.
+ if (args.type == self.syms.argument and
+ args.children[0].value == '**'):
+ return # Make no change.
+ if kwds and (kwds.type == self.syms.argument and
+ kwds.children[0].value == '**'):
+ return # Make no change.
prefix = node.prefix
func = func.clone()
if (func.type not in (token.NAME, syms.atom) and
diff --git a/Lib/lib2to3/fixes/fix_intern.py b/Lib/lib2to3/fixes/fix_intern.py
index fb2973c..a852330 100644
--- a/Lib/lib2to3/fixes/fix_intern.py
+++ b/Lib/lib2to3/fixes/fix_intern.py
@@ -25,6 +25,16 @@ class FixIntern(fixer_base.BaseFix):
"""
def transform(self, node, results):
+ if results:
+ # I feel like we should be able to express this logic in the
+ # PATTERN above but I don't know how to do it so...
+ obj = results['obj']
+ if obj:
+ if obj.type == self.syms.star_expr:
+ return # Make no change.
+ if (obj.type == self.syms.argument and
+ obj.children[0].value == '**'):
+ return # Make no change.
names = ('sys', 'intern')
new = ImportAndCall(node, results, names)
touch_import(None, 'sys', node)
diff --git a/Lib/lib2to3/fixes/fix_reload.py b/Lib/lib2to3/fixes/fix_reload.py
index 1855357..b717273 100644
--- a/Lib/lib2to3/fixes/fix_reload.py
+++ b/Lib/lib2to3/fixes/fix_reload.py
@@ -22,6 +22,17 @@ class FixReload(fixer_base.BaseFix):
"""
def transform(self, node, results):
+ if results:
+ # I feel like we should be able to express this logic in the
+ # PATTERN above but I don't know how to do it so...
+ obj = results['obj']
+ print('obj:', repr(obj))
+ if obj:
+ if obj.type == self.syms.star_expr:
+ return # Make no change.
+ if (obj.type == self.syms.argument and
+ obj.children[0].value == '**'):
+ return # Make no change.
names = ('imp', 'reload')
new = ImportAndCall(node, results, names)
touch_import(None, 'imp', node)