On 1/10/07, Josiah Carlson <[EMAIL PROTECTED]> wrote:
> According to the translation rules Colin has previously provided...
Phillip came up the translation, I just implemented it.
> re = get_resource()
> ...
> try:
> something()
> except RareException as re:
> ...
> ...
> re.use_resource()
>
> is translated into...
>
> re = get_resource()
> ...
> try:
> try:
> something()
> except RareException:
> re = <current exception>
> ...
> finally:
> re = None
> del re
> ...
> re.use_resource()
>
> That is, the 're = None; del re' stuff is executed regardless of whether
> the except body is executed. The user would be notified right away.
The correct translation is
re = get_resource()
...
try:
something()
except RareException as re:
try:
...
finally:
re = None
del re
...
re.use_resource()
So 're = None; del re;' is *only* executed if the except body is executed.
Collin Winter
_______________________________________________
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