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 ncoghlan
Recipients Jim.Jewett, Trundle, Yury.Selivanov, barry, benjamin.peterson, cvrebert, daniel.urban, eric.araujo, ethan.furman, gcbirzan, gvanrossum, jamesh, ncoghlan, pitrou, yorik.sar
Date 2013-10-26.08:28:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1382776089.88.0.450499762507.issue12029@psf.upfronthosting.co.za>
In-reply-to
Content
Because context managers are closer to try/finally blocks than they are to exception handling, the class-based implementation for the contextlib.suppress API uses issubclass rather than emulating the CPython exception handling semantics: http://hg.python.org/cpython/file/09153a9a3bb9/Lib/contextlib.py#l202

The exception checking in the unittest module is similarly based on issubclass: http://hg.python.org/cpython/file/09153a9a3bb9/Lib/unittest/case.py#l129

I'm planning to add the catch() and ExitLabel() context managers to contextlib2 this evening, and those too will be based on issubclass().

Perhaps as a near term thing, we should put an "implementation detail" notice somewhere in the language reference, pointing that it's the code using issubclass that is considered correct here, and CPython's exception handling that is considered out of line?
History
Date User Action Args
2013-10-26 08:28:10ncoghlansetrecipients: + ncoghlan, gvanrossum, barry, jamesh, pitrou, benjamin.peterson, eric.araujo, Trundle, cvrebert, daniel.urban, yorik.sar, ethan.furman, Yury.Selivanov, Jim.Jewett, gcbirzan
2013-10-26 08:28:09ncoghlansetmessageid: <1382776089.88.0.450499762507.issue12029@psf.upfronthosting.co.za>
2013-10-26 08:28:09ncoghlanlinkissue12029 messages
2013-10-26 08:28:09ncoghlancreate