This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implement named exception cleanup
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: collinwinter
Priority: normal Keywords: patch

Created on 2007-01-08 03:02 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stdlib_fixes.patch collinwinter, 2007-01-08 16:49 Repair stdlib
exc_cleanup.patch collinwinter, 2007-01-08 16:50 Implement exception cleanup
Messages (7)
msg51700 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 03:02
This patch implements the solution outlined in http://mail.python.org/pipermail/python-3000/2007-January/005395.html for avoiding exception-related refcount cycles.

Specifically,

try:
  ...
except ExcType, e:
  #body

is translated to

try:
  ...
except ExcType, e:
  try:
    # body
  finally:
    e = None
    del e


The attached patches are against r53289. exc_cleanup.patch is the implementation and testcases, while stdlib_fixes.patch repairs all places in the stdlib that depended on the old behaviour.
msg51701 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 03:02
File Added: stdlib_fixes.patch
msg51702 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 03:34
This is the first time I've done this kind of surgery on the compiler, so any tips/tricks/advice would be greatly appreciated.
msg51703 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 16:49
File Added: stdlib_fixes.patch
msg51704 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 16:50
File Added: exc_cleanup.patch
msg51705 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-08 16:51
Patches updated in reponse to PJE's comment
(http://mail.python.org/pipermail/python-3000/2007-January/005430.html):

"""In the tuple or list case, there's no need to reset the variables, because 
then the traceback won't be present any more; the exception object will 
have been discarded after unpacking."""
msg51706 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-01-10 02:14
This patched has been superseded by patch #1631942.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44425
2008-01-06 22:29:46adminsetkeywords: - py3k
versions: + Python 3.0
2007-01-08 03:02:03collinwintercreate