简体   繁体   中英

Debugging in a context manager in python

I have quite a complex context manager integrated into my software and I am making some changes to them. How can I get a full error log that occurs within the with the block. All I can do so far is:

print exc_type
print exc_val
print exc_tb

But this does not reveal the full traceback of the error. How can I get the classic error log à la Traceback (most recent call last):

Thank you for any help

You can

import traceback

and then

traceback.print_exc()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM