Message245506
| Author |
doerwalter |
| Recipients |
doerwalter |
| Date |
2015年06月19日.16:16:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1434730589.67.0.681224722356.issue24474@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
When an exception is raised by inspect.Signature.bind() in some cases the exception has a StopIteration as its __context__:
import inspect
try:
inspect.signature(lambda x:None).bind()
except Exception as exc:
print(repr(exc))
print(repr(exc.__context__))
This prints:
TypeError("missing a required argument: 'x'",)
StopIteration()
I would have expected it to print:
TypeError("missing a required argument: 'x'",)
None
This reason for this is that the code in bind() has nested exception handlers. The innermost handler does
raise TypeError(...) from None
to drop the exception context, but another context exception gets added by the outermost exception handler. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年06月19日 16:16:29 | doerwalter | set | recipients:
+ doerwalter |
| 2015年06月19日 16:16:29 | doerwalter | set | messageid: <1434730589.67.0.681224722356.issue24474@psf.upfronthosting.co.za> |
| 2015年06月19日 16:16:29 | doerwalter | link | issue24474 messages |
| 2015年06月19日 16:16:29 | doerwalter | create |
|