A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-September/149591.html below:

[Python-Dev] Evil reference cycles caused Exception.__traceback__

[Python-Dev] Evil reference cycles caused Exception.__traceback__Nick Coghlan ncoghlan at gmail.com
Mon Sep 18 06:35:02 EDT 2017
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:

1. If the exception ref count == 1, just drop the reference and let
the traceback die with it
2. If the exception ref count > 1, check for a new "__keep_locals__" attribute
3. If it's true, just drop the reference and otherwise leave the exception alone
4. If it's false, recursively clear all the already terminated frames
in __traceback__, __context__, and __cause__

For now, we'd default to "__keep_locals__ = True", but we'd attempt to
figure out some way to migrate to the default being "__keep_locals__ =
False".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4