[Patches] [ python-Patches-1630248 ] Implement named exception cleanup

SourceForge.net noreply at sourceforge.net
Mon Jan 8 17:51:57 CET 2007


Patches item #1630248, was opened at 2007-01-07 22:02
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1630248&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Collin Winter (collinwinter)
Assigned to: Nobody/Anonymous (nobody)
Summary: Implement named exception cleanup

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Collin Winter (collinwinter)
Date: 2007-01-08 11:51

Message:
Logged In: YES 
user_id=1344176
Originator: YES

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."""

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-01-08 11:50

Message:
Logged In: YES 
user_id=1344176
Originator: YES

File Added: exc_cleanup.patch

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-01-08 11:49

Message:
Logged In: YES 
user_id=1344176
Originator: YES

File Added: stdlib_fixes.patch

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-01-07 22:34

Message:
Logged In: YES 
user_id=1344176
Originator: YES

This is the first time I've done this kind of surgery on the compiler, so
any tips/tricks/advice would be greatly appreciated.

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-01-07 22:02

Message:
Logged In: YES 
user_id=1344176
Originator: YES

File Added: stdlib_fixes.patch

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1630248&group_id=5470


More information about the Patches mailing list