Skip to content

with fails with traceback error on failure __exit__ #714

@ikappaki

Description

@ikappaki

Hi,

the with macro fails when an exception is thrown in its body and the __exit__ magic method is hit:

TypeError: 'traceback' object is not callable
  1. To reproduce, open up a REPL.
  2. Manage a socket connection with and throw anything, it throws an exception about traceback rather than the actual exception
basilisp.user=> (with [sock (socket/socket socket/AF_INET socket/SOCK_STREAM)]
                            (throw (python/ValueError)))
Traceback (most recent call last):
  File "<REPL Input>", line 1, in <module>
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\src\basilisp\src\basilisp\cli.py", line 306, in repl
    result = eval_str(lsrc, ctx, ns, eof)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\src\basilisp\src\basilisp\cli.py", line 52, in eval_str
    last = compiler.compile_and_exec_form(form, ctx, ns)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\src\basilisp\src\basilisp\lang\compiler\__init__.py", line 163, in compile_and_exec_form
    exec(bytecode, ns.module.__dict__)
  File "<REPL Input>", line 2, in <module>
TypeError: 'traceback' object is not callable
basilisp.user=>

PR to follow.

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