pybars3 icon indicating copy to clipboard operation
pybars3 copied to clipboard

TypeError: list indices must be integers, not str

Open dobesv opened this issue 8 years ago • 2 comments

Sometimes I get this error while compiling a template, but not always. I wonder if this library is not thread-safe?

Traceback (most recent call last):
  File "/home/dobes/env/lib/python2.7/site-packages/pybars/_compiler.py", line 827, in compile
    container = self._generate_code(source)
  File "/home/dobes/env/lib/python2.7/site-packages/pybars/_compiler.py", line 801, in _generate_code
    output = self._compiler(tree).apply('compile')[0]
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 299, in apply
    val, err = self._apply(r, ruleName, args)
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 329, in _apply
    [rule(), self.input])
  File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 11, in rule_compile
    self.considerError(lastError)
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 396, in many
    v, _ = fn()
  File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 8, in _G_many_2
    _G_exactly_1, lastError = self.exactly('-')
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 329, in _apply
    [rule(), self.input])
  File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 59, in rule_rule
    return (_G_apply_1, self.currentError)
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 414, in _or
    ret, err = f()
  File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 48, in _G_or_5
    return (_G_apply_1, self.currentError)
  File "/home/dobes/env/lib/python2.7/site-packages/pymeta/runtime.py", line 329, in _apply
    [rule(), self.input])
  File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 107, in rule_block
    _locals['x'] = _G_apply_1
  File "<string>", line 1, in <module>
  File "/home/dobes/env/lib/python2.7/site-packages/pybars/_compiler.py", line 554, in add_block
    self._locals[name] = nested
TypeError: list indices must be integers, not str

dobesv avatar Jan 25 '17 21:01 dobesv

@dobesv do you have an example template where this happens sometimes?

isaacdd avatar Oct 07 '18 20:10 isaacdd

I get the same error occasionally. Have not had time to look into it further as it is not that often.

pg1671 avatar Mar 21 '22 22:03 pg1671