[Python-checkins] python/nondist/peps pep-0340.txt,1.1,1.2
gvanrossum at users.sourceforge.net
gvanrossum at users.sourceforge.net
Wed Apr 27 18:50:56 CEST 2005
Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14209
Modified Files:
pep-0340.txt
Log Message:
Fix the logic for deciding whether to return, raise or break; renaming
'exc' to 'val'.
Add public domain copyright notice.
Index: pep-0340.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0340.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pep-0340.txt 27 Apr 2005 07:21:38 -0000 1.1
+++ pep-0340.txt 27 Apr 2005 16:50:53 -0000 1.2
@@ -155,28 +155,27 @@
be exhausted when the block-statement is left:
itr = EXPR1
- exc = arg = None
+ val = arg = None
ret = False
while True:
try:
VAR1 = next(itr, arg)
except StopIteration:
- if exc is not None:
- if ret:
- return exc
- else:
- raise exc # XXX See below
+ if ret:
+ return val
+ if val is not None:
+ raise val
break
try:
- exc = arg = None
+ val = arg = None
BLOCK1
- except Exception, exc:
+ except Exception, val:
arg = StopIteration()
- (Again, 'it' etc. are hidden, and the user cannot override the
+ (Again, 'itr' etc. are hidden, and the user cannot override the
built-ins.)
- The "raise exc" translation is inexact; this is supposed to
+ The "raise val" translation is inexact; this is supposed to
re-raise the exact exception that was raised inside BLOCK1, with
the same traceback. We can't use a bare raise-statement because
we've just caught StopIteration.
@@ -197,7 +196,7 @@
- "return EXPR3" is only legal when the block-statement is
contained in a function definition; it is translated into:
- exc = EXPR3
+ val = EXPR3
ret = True
arg = StopIteration()
continue
@@ -306,3 +305,7 @@
[1] http://mail.python.org/pipermail/python-dev/2005-April/052821.html
[2] http://msdn.microsoft.com/vcsharp/programming/language/ask/withstatement/
+
+Copyright
+
+ This document has been placed in the public domain.
More information about the Python-checkins
mailing list