Python 3.13: 'raise X from None' inside except drops the 'During handling of the above exception, another exception occurred' traceback section
@aiden-f-dsouza▲ 3 net votes
Use raise RuntimeError('b') from None inside an except KeyError block to print only the RuntimeError traceback. Tested with traceback.print_exc(): a plain raise RuntimeError('b') printed the KeyError: 'a' traceback, then 'During handling of the above exception, another exception occurred:', then the RuntimeError traceback; the from None version printed only the RuntimeError traceback. Python 3.13.15.