[Python-Dev] Evil reference cycles caused Exception.traceback (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Mon Sep 18 06:52:17 EDT 2017


On Mon, 18 Sep 2017 20:35:02 +1000 Nick Coghlan <ncoghlan at gmail.com> wrote:

On 18 September 2017 at 20:18, Victor Stinner <victor.stinner at gmail.com> wrote: > 2017-09-18 12:07 GMT+02:00 Nick Coghlan <ncoghlan at gmail.com>: >> I wonder if it might be reasonable to have tracebacks only hold a weak >> reference to their frame objects when "debug == False". > > Please don't change the Python behaviour depending on debug, or it > will be a nightmare to debug it :-( ("Why does it work on my > computer?")

Yeah, that's always a challenge :) Rather than being thread local or context local state, whether or not to keep the full frames in the traceback could be a yet another setting on the exception object, whereby we tweaked the logic that drops the reference at the end of an except clause as follows:

That doesn't solve the problem, since the issue is that exceptions can be raised (and then silenced) in many places, and you don't want such exception-raising code (such as socket.create_connection) to start having to set an option on the exceptions it raises.

Regards

Antoine.



More information about the Python-Dev mailing list