This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author klaas
Recipients Rhamphoryncus, klaas
Date 2007-10-31.20:26:21
SpamBayes Score 0.19265841
Marked as misclassified No
Message-id <1193862382.17.0.585425136201.issue1705170@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2007-10-31 20:26:22klaassetspambayes_score: 0.192658 -> 0.19265841
recipients: + klaas, Rhamphoryncus
2007-10-31 20:26:22klaassetspambayes_score: 0.192658 -> 0.192658
messageid: <1193862382.17.0.585425136201.issue1705170@psf.upfronthosting.co.za>
2007-10-31 20:26:22klaaslinkissue1705170 messages
2007-10-31 20:26:21klaascreate