Message57002
Verified on 2.5.0. The problem stems from contextmanager.__exit__:
def __exit__(self, type, value, traceback):
if type is None:
try:
self.gen.next()
except StopIteration:
return
else:
raise RuntimeError("generator didn't stop")
else:
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw
()")
except StopIteration, exc:
# Suppress the exception *unless* it's the same
exception that
# was passed to throw(). This prevents a StopIteration
# raised inside the "with" statement from being
suppressed
return exc is not value
except:
# only re-raise if it's *not* the exception that was
# passed to throw(), because __exit__() must not raise
# an exception unless __exit__() itself failed. But
throw()
# has to raise the exception to signal propagation, so
this
# fixes the impedance mismatch between the throw()
protocol
# and the __exit__() protocol.
#
if sys.exc_info()[1] is not value:
raise
Conjecture: internal StopIteration exceptions are always the same
instance (PyExc_StopIteration) when propagated to python, invalidating
the return exc is not value
check. |
|
| Date |
User |
Action |
Args |
| 2007-10-31 20:26:22 | klaas | set | spambayes_score: 0.192658 -> 0.192658 recipients:
+ klaas, Rhamphoryncus |
| 2007-10-31 20:26:22 | klaas | set | spambayes_score: 0.192658 -> 0.192658 messageid: <1193862382.17.0.585425136201.issue1705170@psf.upfronthosting.co.za> |
| 2007-10-31 20:26:22 | klaas | link | issue1705170 messages |
| 2007-10-31 20:26:21 | klaas | create | |
|