"Collin Winter" <[EMAIL PROTECTED]> wrote:
> On 1/9/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> > On 1/8/07, Collin Winter <[EMAIL PROTECTED]> wrote:
> > > FWIW, I wasn't aware that things like "except T, (a, b, c):" were
> > > possible until I started work on this patch; I thought <name> was all
> > > you _could_ use.
> >
> > And, given the secial semantics for this position, I would support
> > changing the syntax to *only* allow a single simple name there -- not
> > even x.y.z. Thsh should handle 99.9% of existing code anyway.
> >
> > (And yes, if someone wants to add the 'as' keyword at the same time
> > that would be great!
>
> Ask and you shall receive: patch #1631942 implements both the 'as'
> keyword for exceptions and the new exception cleanup semantics.
I know that one of the points of all of this is so that the name that
the exc_info() stuff gets in the local scope doesn't propagate past the
except clause, but I can't help feeling as if removing the name isn't a
little overenthusiastic.
Here's an alternate semantic...
try:
...
except <exceptions> as <name>:
<body>
... would become ...
try:
try:
...
except <exceptions>:
<name> = sys.exc_info()
<body>
finally:
if '<name>' in locals():
<name> = None
The benefit to the above is that the name only disappears from the
namespace if the user deletes it, otherwise the name is bound to None.
We could do some trickery to see if the name is bound to the exception,
but that may be a bit of overkill.
- Josiah
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com