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 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:29doerwaltersetrecipients: + doerwalter
2015-06-19 16:16:29doerwaltersetmessageid: <1434730589.67.0.681224722356.issue24474@psf.upfronthosting.co.za>
2015-06-19 16:16:29doerwalterlinkissue24474 messages
2015-06-19 16:16:29doerwaltercreate