Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: (IndexError) list index out of range #321

Open
artcon-de-com opened this issue Jul 6, 2020 · 3 comments
Open

SyntaxError: (IndexError) list index out of range #321

artcon-de-com opened this issue Jul 6, 2020 · 3 comments

Comments

@artcon-de-com
Copy link

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

@zzzeek
Copy link
Member

zzzeek commented Jul 6, 2020

hi there -

that would not be caching within Mako because that's parsing a .py file. I don't know what the issue is but something is not syntactically working out in a file called "invoice.tex" on your side.

a python 3.3 -> 3.5 migration can potentially impact things because there may be subtle changes in the ast module. but would need to see the failing portion of your invoice.tex file to further diagnose what the problem is.

@artcon-de-com
Copy link
Author

artcon-de-com commented Jul 6, 2020 via email

@zzzeek
Copy link
Member

zzzeek commented Jul 6, 2020

yeah something is obviously going very wrong , that error is coming from calling Python compile() directly. if this program runs from the console in the main thread, I'd use pdb to take a closer look at the Python string it is trying to compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants