[Patches] [ python-Patches-1631942 ] New exception syntax
SourceForge.net
noreply at sourceforge.net
Wed Jan 10 17:23:41 CET 2007
Patches item #1631942, was opened at 2007-01-09 21:12
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1631942&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: None
Group: Python 3000
Status: Open
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Collin Winter (collinwinter)
Assigned to: Nobody/Anonymous (nobody)
Summary: New exception syntax
Initial Comment:
The attached patches implement the new "except V as N:" syntax and the solution outlined in http://mail.python.org/pipermail/python-3000/2007-January/005395.html for avoiding exception-related refcount cycles.
new_exceptions.patch is the implementation and tests.
fixup.patch adjusts the stdlib to use the new syntax.
doc_fixes.patch fixes documentation and some docs-related utilities missed by Guido's 2to3 code.
All patches are against r53289.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2007-01-10 11:23
Message:
Logged In: YES
user_id=6380
Originator: NO
Thanks!!
Submitted, with tarfile.py and test_exceptions.py corrected (kept the 'del
e' in the latter).
Committed revision 53342.
Note: there is now a new test_hotshot failure, probably due to the
different code generated for except clauses; I'm keeping this patch open
for that.
Is it time to drop the unpacking (sequence) behavior from exceptions
altogether, per Brett's PEP? (That would be a new SF patch.)
----------------------------------------------------------------------
Comment By: Collin Winter (collinwinter)
Date: 2007-01-10 09:40
Message:
Logged In: YES
user_id=1344176
Originator: YES
I think there were only four files I had to patch manually after running
2to3; each used automatic exception unpacking.
2to3 successfully fixes Lib/tarfile.py (as of tarfile.py r53336, 2to3
r53339).
The 'del e' in testExceptionCleanup() was indeed needed; it was there to
verify that the transformation was
except V as N:
try:
...
finally:
N = None
del N
and not
except V as N:
try:
...
finally:
del N
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2007-01-10 00:39
Message:
Logged In: YES
user_id=6380
Originator: NO
For some strange reason, test_exceptions was wrong. I'm guessing that the
newly added test should be this:
def testExceptionCleanup(self):
# Make sure "except V as N" exceptions are cleaned up properly
try:
raise Exception()
except Exception as e:
self.failUnless(e)
self.failIf('e' in locals())
(it had ', e' instead of 'as e', and there was an unneeded 'del e' after
self.failUnless(e).)
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2007-01-09 22:41
Message:
Logged In: YES
user_id=6380
Originator: NO
Reviewing... Seems the merge tfrom the 2.6 trunk that Thomas did made
some changes to tarfile.py.
Did you have to manually patch anything up after running 2to3/refactor.py
-f except on the entire stdlib?
patching file Lib/tarfile.py
Hunk #1 succeeded at 1540 (offset 38 lines).
Hunk #3 succeeded at 1573 (offset 38 lines).
Hunk #5 succeeded at 1745 (offset 38 lines).
Hunk #7 succeeded at 1786 (offset 38 lines).
Hunk #9 FAILED at 1795.
1 out of 9 hunks FAILED -- saving rejects to file Lib/tarfile.py.rej
----------------------------------------------------------------------
Comment By: Collin Winter (collinwinter)
Date: 2007-01-09 21:13
Message:
Logged In: YES
user_id=1344176
Originator: YES
File Added: fixup.patch
----------------------------------------------------------------------
Comment By: Collin Winter (collinwinter)
Date: 2007-01-09 21:13
Message:
Logged In: YES
user_id=1344176
Originator: YES
File Added: doc_fixes.patch
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1631942&group_id=5470
More information about the Patches
mailing list