[Python-projects] astng crash on list indices
Osmo Salomaa
otsaloma at cc.hut.fi
Mon Mar 12 03:04:53 CET 2007
Hello list,
I've been experiencing the following "TypeError: list indices must be
integers" astng bug for already a while now. Only recently I narrowed it
down to a minimal piece of test code. The bug appears at least when the
default value of a list index is defined to None in __init__. See below
for the bug-causing class and a valid use case.
class Example(object):
def __init__(self):
self.index = None
def choose(self):
cls = (list, tuple)[self.index]
return cls()
example = Example()
example.index = 1
print example.choose()
The output I get is:
$ pylint -rn test_pylint.py
No config file found, using default configuration
************* Module test_pylint
C: 1: Missing docstring
C: 1:Example: Missing docstring
C: 4:Example.choose: Missing docstring
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 4, in <module>
lint.Run(sys.argv[1:])
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
890, in __init__
linter.check(args)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
496, in check
self.check_file(filepath, modname, checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
513, in check_file
astng = self._check_file(filepath, modname, checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
537, in _check_file
if not self.check_astng_module(astng, checkers):
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
599, in check_astng_module
if implements(checker, IASTNGChecker)])
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
616, in astng_events
self.astng_events(child, checkers, _reversed_checkers)
File "/usr/local/lib/python2.5/site-packages/pylint/lint.py", line
613, in astng_events
checker.visit(astng)
File "/usr/local/lib/python2.5/site-packages/logilab/astng/utils.py",
line 84, in visit
method(node)
File
"/usr/local/lib/python2.5/site-packages/pylint/checkers/typecheck.py",
line 181, in visit_callfunc
called = safe_infer(node.node)
File
"/usr/local/lib/python2.5/site-packages/pylint/checkers/utils.py", line
40, in safe_infer
value = inferit.next()
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/inference.py",
line 45, in wrapped
for res in _func(node, context, **kwargs):
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/__init__.py", line
122, in _infer_stmts
for infered in stmt.infer(context):
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/inference.py",
line 45, in wrapped
for res in _func(node, context, **kwargs):
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/__init__.py", line
122, in _infer_stmts
for infered in stmt.infer(context):
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/inference.py",
line 45, in wrapped
for res in _func(node, context, **kwargs):
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/inference.py",
line 376, in infer_subscript
assigned = self.expr.getitem(index.value)
File
"/usr/local/lib/python2.5/site-packages/logilab/astng/inference.py",
line 661, in tl_getitem
return self.nodes[index]
TypeError: list indices must be integers
Version I'm using:
$ pylint --version
No config file found, using default configuration
pylint 0.13.0,
astng 0.17.0, common 0.21.1
Python 2.5 (release25-maint, Dec 9 2006, 14:35:53)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)]
--
Osmo Salomaa <otsaloma at cc.hut.fi>
More information about the Python-Projects
mailing list