MatthieuDartiailh/bytecode

Errors in compute stacksize on 3.10

Closed this issue · 7 comments

People have been seeing a few errors on python 3.10 with inkcut

  File "/home/himbeere/.local/lib/python3.10/site-packages/inkcut/core/plugin.py", line 80, in start_default_workspace
    ui.select_workspace('inkcut.workspace')
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/workbench/ui/ui_plugin.py", line 157, in select_workspace
    new_workspace.start()
  File "/home/himbeere/.local/lib/python3.10/site-packages/inkcut/ui/workspace.py", line 46, in start
    self.workbench.get_plugin('inkcut.ui')
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/workbench/workbench.py", line 151, in get_plugin
    plugin.start()
  File "/home/himbeere/.local/lib/python3.10/site-packages/inkcut/ui/plugin.py", line 91, in start
    self._refresh_dock_items()
  File "/home/himbeere/.local/lib/python3.10/site-packages/inkcut/ui/plugin.py", line 194, in _refresh_dock_items
    DockItem = declaration.factory()
  File "/home/himbeere/.local/lib/python3.10/site-packages/inkcut/preview/manifest.enaml", line 30, in preview_factory
    from .view import PreviewDockItem
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/import_hooks.py", line 140, in exec_module
    code, _ = self.get_code()
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/import_hooks.py", line 401, in get_code
    return self.compile_code()
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/import_hooks.py", line 366, in compile_code
    code = EnamlCompiler.compile(ast, file_info.src_path)
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/enaml_compiler.py", line 178, in compile
    return compiler.visit(node)
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/enaml_ast.py", line 359, in visit
    result = visitor(node, *args, **kwargs)
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/enaml_compiler.py", line 206, in visit_Module
    return cg.to_code()
  File "/home/himbeere/.local/lib/python3.10/site-packages/enaml/core/code_generator.py", line 119, in to_code
    return bc_code.to_code()
  File "/home/himbeere/.local/lib/python3.10/site-packages/bytecode/bytecode.py", line 204, in to_code
    stacksize = self.compute_stacksize(check_pre_and_post=check_pre_and_post)
  File "/home/himbeere/.local/lib/python3.10/site-packages/bytecode/bytecode.py", line 195, in compute_stacksize
    cfg = _bytecode.ControlFlowGraph.from_bytecode(self)
  File "/home/himbeere/.local/lib/python3.10/site-packages/bytecode/cfg.py", line 391, in from_bytecode
    if not block[-1].is_final():
  File "/home/himbeere/.local/lib/python3.10/site-packages/bytecode/cfg.py", line 44, in __getitem__
    value = super().__getitem__(index)
IndexError: list index out of range

See inkcut/inkcut#320

Thanks for the report. Could you provide me with an example of the offending bytecode ?

Actually following the import causing the issue I got to the offending part.

The issue is not in bytecode but in enaml which is generating nonsense code. I have a fix at nucleic/enaml#476 which needs a test and a changelog entry.

Tested and it works. Thank you!

I will try to cut a 0.14.1 ASAP.

Enaml 0.14.1 is online

Thank you!