V
V
Vadim Ushakov2021-10-25 13:25:50
Python
Vadim Ushakov, 2021-10-25 13:25:50

Why is the exception not shown?

There is a wrapper class in the code for the page control object. When working with an object through with statement, no exceptions are thrown. Those .. if there is an error somewhere in the method, then the program simply exits the block. Why is that?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Ushakov, 2021-10-25
@Nightmare1

In general, I solved the problem by realizing that exceptions inside the block are passed to the magic __exit__ method , approx.

def __exit__(self, exc_type, exc_value, exc_traceback):
where you can then either handle the exception or pass it above.

S
Sergey Gornostaev, 2021-10-25
@sergey-gornostaev

Apparently the context manager, located in the statement, swallows exceptions. It is impossible to say anything more precisely on the current formulation of the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question