[Python-projects] visit_import bug

Robert Kirkpatrick robertk at bcgsc.ca
Mon Feb 11 21:36:22 CET 2008


Hi Guys,

I run into this error:

robertk01> pylint process_single_lane.py
No config file found, using default configuration
************* Module process_single_lane
C: 36: Line too long (91/80)
C:163: Line too long (107/80)
C:167: Line too long (115/80)
W:308: Found indentation with tabs instead of spaces
C:337: Line too long (97/80)
C:556: Line too long (131/80)
C:558: Line too long (166/80)
C:  1: Missing docstring
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/pylint",
line 4, in <module>
    lint.Run(sys.argv[1:])
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 900, in __init__
    linter.check(args)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 492, in check
    self.check_astng_module(astng, checkers)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 601, in check_astng_module
    if implements(checker, IASTNGChecker)])
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 618, in astng_events
    self.astng_events(child, checkers, _reversed_checkers)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 618, in astng_events
    self.astng_events(child, checkers, _reversed_checkers)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/lint.py", line 615, in astng_events
    checker.visit(astng)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/logilab/astng/utils.py", line 84, in visit
    method(node)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
es/pylint/checkers/variables.py", line 359, in visit_import
    module = node.infer_name_module(parts[0]).next()
AttributeError: Import instance has no attribute 'infer_name_module'



But if I change the section of visit_import() in variables.py to comment out
the try/except, I can run pylint ok:

    def visit_import(self, node):
        """check modules attribute accesses"""
        for name, _ in node.names:
            parts = name.split('.')
            #try:
            #    import pdb; pdb.set_trace();
            #    module = node.infer_name_module(parts[0]).next()
            #except astng.ResolveError:
            #    continue
            continue
            self._check_module_attrs(node, module, parts[1:])


I noticed in the log that this was worked on in revision 144 but I have no
idea what this code actually does or how to address it other than what I
did.

I also don't know if there is something weird with the code on my end or if
my code is highlighting a bug.

Any advice?

Cheers,
Rob



More information about the Python-Projects mailing list