SyntaxError: (IndexError) list index out of range
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start with the failing expression at line 80 of invoice.tex and trace Mako's path through template.py, lexer.py match_expression, parsetree.py PythonCode, and pyparser.py parse. Reproduce the intermittent failure with the reported Mako versions and determine whether caching affects it; done means the cause is isolated and the behavior is consistently explained.
Written by the indexing model from the issue text.
Description
Hello,
we are using mako as template engine for generating latex-reports in tryton.
After an update of the source system from python 3.3 to python 3.5 migration, we get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/trytond/worker.py", line 108, in run_task
Queue(task_id).run()
File "/usr/local/lib/python3.7/dist-packages/trytond/ir/queue.py", line 169, in run
instances, *self.data['args'], **self.data['kwargs'])
File "/usr/local/lib/python3.7/dist-packages/trytond/model/modelview.py", line 672, in wrapper
return func(cls, records, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/sale/sale.py", line 885, in process
sale.create_invoice()
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/ebb_sale/sale.py", line 287, in create_invoice
Invoice.post([invoice])
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/sale/invoice.py", line 20, in wrapper
func(cls, invoices)
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/sale/invoice.py", line 87, in post
super(Invoice, cls).post(invoices)
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/purchase/invoice.py", line 21, in wrapper
func(cls, invoices)
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/purchase/invoice.py", line 98, in post
super(Invoice, cls).post(invoices)
File "/usr/local/lib/python3.7/dist-packages/trytond/model/modelview.py", line 672, in wrapper
return func(cls, records, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/trytond/model/workflow.py", line 36, in wrapper
result = func(cls, filtered, *args, **kwargs)
nvoice.py", line 1383, in post.7/dist-packages/trytond/modules/account_invoice/i--More--
invoice.print_invoice()
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/account_invoice/invoice.py", line 1292, in print_invoice
InvoiceReport.execute([self.id], {})
File "/usr/local/lib/python3.7/dist-packages/trytond/modules/latex_reports/latex.py", line 282, in execute
mytemplate = Template(filename=report_path.replace('.odt','.tex'), cache_enabled=False, input_encoding='utf-8', output_encoding='utf-8')
File "/usr/local/lib/python3.7/dist-packages/mako/template.py", line 338, in __init__
module = self._compile_from_file(path, filename)
File "/usr/local/lib/python3.7/dist-packages/mako/template.py", line 416, in _compile_from_file
filename)
File "/usr/local/lib/python3.7/dist-packages/mako/template.py", line 705, in _compile_text
generate_magic_comment=template.disable_unicode)
File "/usr/local/lib/python3.7/dist-packages/mako/template.py", line 685, in _compile
node = lexer.parse()
File "/usr/local/lib/python3.7/dist-packages/mako/lexer.py", line 241, in parse
if self.match_expression():
File "/usr/local/lib/python3.7/dist-packages/mako/lexer.py", line 402, in match_expression
lineno=line, pos=pos)
File "/usr/local/lib/python3.7/dist-packages/mako/lexer.py", line 140, in append_node
node = nodecls(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/mako/parsetree.py", line 194, in __init__
self.code = ast.PythonCode(text, **self.exception_kwargs)
File "/usr/local/lib/python3.7/dist-packages/mako/ast.py", line 40, in __init__
expr = pyparser.parse(code.lstrip(), "exec", **exception_kwargs)
File "/usr/local/lib/python3.7/dist-packages/mako/pyparser.py", line 48, in parse
), **exception_kwargs)
mako.exceptions.SyntaxException: (IndexError) list index out of range ("sale.invoice_address.party_name.replace('&','\\&')") in file '/tmp/trytond-latex-aevzw0qf/invoice.tex' at line: 80 char: 1
What we are wondering about: This does not occurs with the first time. It took some generations, e.g. is it possible, that somehow a caching is used and we should remove it?
We did test this with mako 1.1.3 and 1.0.7.
Thank you and best regards,
Hendrik
- Dominant language
- Python
- Stars
- 459
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sqlalchemy/mako
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
sqlalchemy/mako#432 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/mako#417 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
sqlalchemy/mako#392 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
sqlalchemy/mako#382 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
sqlalchemy/mako#376 · 9 comments ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100