Fix raw_building.object_build for pypy implementation. Closes #99583

authorFELD Boris <lothiraldan@gmail.com>
changeset80c265e655cf
branchdefault
phasepublic
hiddenno
parent revision#0272006bdfbe use open rather than file as 2to3 miss it (probably because of the file class attribute)
child revision#e907d421c802 include basic stdlib description from the pylint-brain project (https://bitbucket.org/sthenault/pylint-brain). Closes #100013, #b261077ba24c default is stable
files modified by this revision
ChangeLog
inference.py
raw_building.py
# HG changeset patch
# User FELD Boris <lothiraldan@gmail.com>
# Date 1342433356 -7200
# Mon Jul 16 12:09:16 2012 +0200
# Node ID 80c265e655cfbe09fe302e87f74bddd1ac97e0be
# Parent 0272006bdfbee3a0a1447315633bbfeb2f5920e8
Fix raw_building.object_build for pypy implementation. Closes #99583

diff --git a/ChangeLog b/ChangeLog
@@ -1,8 +1,12 @@
1  Change log for the astng package
2  ================================
3 
4 +--
5 +    * #99583: fix raw_building.object_build for pypy implementation
6 +    * use `open` rather than `file` in scoped_nodes as 2to3 miss it
7 +
8  2011-12-08  --  0.23.1
9      * #62295: avoid "OSError: Too many open files" by moving
10        .file_stream as a Module property opening the file only when needed
11 
12      * Lambda nodes should have a `name` attribute
diff --git a/inference.py b/inference.py
@@ -243,10 +243,11 @@
13          if index is YES:
14              yield YES
15              return
16          try:
17              # suppose it's a Tuple/List node (attribute error else)
18 +            # XXX infer self.value?
19              assigned = self.value.getitem(index.value, context)
20          except AttributeError:
21              raise InferenceError()
22          except (IndexError, TypeError):
23              yield YES
diff --git a/raw_building.py b/raw_building.py
@@ -238,14 +238,18 @@
24                  continue
25              if ismethod(member):
26                  member = member.im_func
27              if isfunction(member):
28                  # verify this is not an imported function
29 -                if member.func_code.co_filename != getattr(self._module, '__file__', None):
30 +                filename = getattr(member.func_code, 'co_filename', None)
31 +                if filename is None:
32 +                    assert isinstance(member, object)
33 +                    object_build_methoddescriptor(node, member, name)
34 +                elif filename != getattr(self._module, '__file__', None):
35                      attach_dummy_node(node, name, member)
36 -                    continue
37 -                object_build_function(node, member, name)
38 +                else:
39 +                    object_build_function(node, member, name)
40              elif isbuiltin(member):
41                  if self.imported_member(node, member, name):
42                      #if obj is object:
43                      #    print 'skippp', obj, name, member
44                      continue