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/2006-March/062012.html below:

[Python-Dev] ref leak w/except hooks

[Python-Dev] ref leak w/except hooks [Python-Dev] ref leak w/except hooksBrett Cannon brett at python.org
Thu Mar 2 19:09:28 CET 2006
On 3/2/06, Neal Norwitz <nnorwitz at gmail.com> wrote:
> The following code leaks a reference.  Original test case from
> Lib/test/test_sys.py in test_original_excepthook.
>
> import sys, StringIO
> eh = sys.__excepthook__
> try:
>   raise ValueError(42)
> except ValueError, exc:
>   exc_type, exc_value, exc_tb = sys.exc_info()
>   eh(exc_type, None, None)

Which can be simplified to::

from sys import __excepthook__ as eh

try:
    raise BaseException
except:
    eh(BaseException, None, None)

It fails if the first argument to sys.__excepthook__ is either a
built-in exception or a classic class.  it looks like strings and
new-style classes do not trigger it.

-Brett
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