diff options
Diffstat (limited to 'Lib/lib2to3/fixer_util.py')
-rw-r--r-- | Lib/lib2to3/fixer_util.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py index 0c485f0..f93df00 100644 --- a/Lib/lib2to3/fixer_util.py +++ b/Lib/lib2to3/fixer_util.py @@ -222,6 +222,29 @@ def in_special_context(node): return True return False +def is_probably_builtin(node): + """ + Check that something isn't an attribute or function name etc. + """ + prev = node.get_prev_sibling() + if prev is not None and prev.type == token.DOT: + # Attribute lookup. + return False + parent = node.parent + if parent.type in (syms.funcdef, syms.classdef): + return False + if parent.type == syms.expr_stmt and parent.children[0] is node: + # Assignment. + return False + if parent.type == syms.parameters or \ + (parent.type == syms.typedargslist and ( + (prev is not None and prev.type == token.COMMA) or + parent.children[0] is node + )): + # The name of an argument. + return False + return True + ########################################################### ### The following functions are to find bindings in a suite ########################################################### |