[Python-projects] Crash detected in ASTNG 0.13.1- Proposed patch included.

Pierre_Rouleau at ImpathNetworks.com Pierre_Rouleau at ImpathNetworks.com
Wed May 2 22:38:16 CEST 2007


Bonjour Sylvain,

I ran into a ASTNG problem when pylinting a module that imports a SWIGged
module.

I am using:
     pylintw.py 0.13.1,
     astng 0.17.0, common 0.21.2
     Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]

The traceback is:

Traceback (most recent call last):
  File "c:\python24\lib\site-packages\logilab\astng\manager.py", line 104, in
astng_from_file
    astng = ASTNGBuilder(self).file_build(filepath, modname)
  File "c:\python24\Lib\site-packages\logilab\astng\builder.py", line 220, in
file_build
    node = self.string_build(data, modname, path)
  File "c:\python24\Lib\site-packages\logilab\astng\builder.py", line 230, in
string_build
    return self.ast_build(parse(data + '\n'), modname, path)
  File "c:\python24\Lib\site-packages\logilab\astng\builder.py", line 253, in
ast_build
    getattr(self, 'delayed_visit_%s' % dnode.__class__.__name__.lower())(dnode)
  File "c:\python24\Lib\site-packages\logilab\astng\builder.py", line 470, in
delayed_visit_assattr
    for infered in node.expr.infer():
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 45, in
wrapped
    for res in _func(node, context, **kwargs):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 300, in
infer_getattr
    for obj in owner.igetattr(self.attrname, context):
  File "c:\python24\Lib\site-packages\logilab\astng\__init__.py", line 122, in
_infer_stmts
    for infered in stmt.infer(context):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 45, in
wrapped
    for res in _func(node, context, **kwargs):
  File "c:\python24\Lib\site-packages\logilab\astng\__init__.py", line 122, in
_infer_stmts
    for infered in stmt.infer(context):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 45, in
wrapped
    for res in _func(node, context, **kwargs):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 300, in
infer_getattr
    for obj in owner.igetattr(self.attrname, context):
  File "c:\python24\Lib\site-packages\logilab\astng\__init__.py", line 122, in
_infer_stmts
    for infered in stmt.infer(context):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 45, in
wrapped
    for res in _func(node, context, **kwargs):
  File "c:\python24\Lib\site-packages\logilab\astng\inference.py", line 88, in
infer_empty_node
    yield MANAGER.astng_from_something(self.object)
  File "c:\python24\lib\site-packages\logilab\astng\manager.py", line 197, in
astng_from_something
    modname = klass.__module__
NameError: Unknown C global variable
imcapserver.py:1: [F0002] logilab.astng._exceptions.ASTNGBuildingException: 1-
Unable to load module imcapserver (Unknown C global variable)

I used the following patch to fix the problem:

--- manager.py  2007-05-02 16:24:28.146250000 -0400
+++ manager.1.py        2007-05-02 16:23:26.505625000 -0400
@@ -197,7 +197,11 @@
                 modname = klass.__module__
             except AttributeError:
                 raise ASTNGBuildingException(
-                    'Unable to get module for object %r' % obj)
+                    'Unable to get module for object %r' % obj)
+            except NameError:
+                raise ASTNGBuildingException(
+                    'Unable to get module for object ??')
+
         try:
             name = klass.__name__
         except AttributeError:
@@ -366,3 +370,4 @@
     def __repr__(self):
         return '<Project %r at %s (%s modules)>' % (self.name, id(self),
                                                     len(self.modules))
+
----------------------

I did not really investigate why repr(obj) fails, but the patch appears to fix
the problem

What I did, though is to print obj, and that caused Python itself to crash,
something I don't see very often!


Anyway, hope this helps.


--

Pierre Rouleau




More information about the Python-Projects mailing list