Skip to content

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

Open

Description

@DarthABAP

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

Activity

  1. zzzeek commented on Jul 6, 2020

    @zzzeek
    Member

    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.

  2. DarthABAP commented on Jul 6, 2020

    @DarthABAP
    Author
  3. zzzeek commented on Jul 6, 2020

    @zzzeek
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions