Fix checkers.utils for other implementations (use of __builtins__). Closes #99139. Closes #89838. Theses fixes need fixes on logilab-astng and logilab-common

authorFELD Boris <lothiraldan@gmail.com>
changeset0fc805bbfbe3
branchdefault
phasepublic
hiddenno
parent revision#014e44bbebb6 Refactor test_func in order to extract common part for reutilization in pylint-brain
child revision#7c1c822957fd fix indentation
files modified by this revision
checkers/utils.py
# HG changeset patch
# User FELD Boris <lothiraldan@gmail.com>
# Date 1341847426 -7200
# Mon Jul 09 17:23:46 2012 +0200
# Node ID 0fc805bbfbe303741c4a87e6f721486e82cd50b6
# Parent 014e44bbebb6ac1887cd9de09ca044c993c0ff4b
Fix checkers.utils for other implementations (use of __builtins__). Closes #99139. Closes #89838. Theses fixes need fixes on logilab-astng and logilab-common

diff --git a/checkers/utils.py b/checkers/utils.py
@@ -31,11 +31,11 @@
1  def is_inside_except(node):
2      """Returns true if node is inside the name of an except handler."""
3      current = node
4      while current and not isinstance(current.parent, astng.ExceptHandler):
5          current = current.parent
6 -    
7 +
8      return current and current is current.parent.name
9 
10 
11  def get_all_elements(node):
12      """Recursively returns all atoms in nested lists and tuples."""
@@ -111,11 +111,11 @@
13 
14  def is_empty(body):
15      """return true if the given node does nothing but 'pass'"""
16      return len(body) == 1 and isinstance(body[0], astng.Pass)
17 
18 -builtins =  __builtins__.copy()
19 +builtins = builtins.__dict__.copy()
20  SPECIAL_BUILTINS = ('__builtins__',) # '__path__', '__file__')
21 
22  def is_builtin(name): # was is_native_builtin
23      """return true if <name> could be considered as a builtin defined by python
24      """
@@ -368,6 +368,6 @@
25  def is_attr_private(attrname):
26      """Check that attribute name is private (at least two leading underscores,
27      at most one trailing underscore)
28      """
29      regex = re.compile('^_{2,}.*[^_]+_?$')
30 -    return regex.match(attrname)
31 \ No newline at end of file
32 +    return regex.match(attrname)