Nick Coghlan added the comment: The sentinel form of next() is nice when there's a natural sentinel value, but needing to *create* a sentinel is generally a sign that the out-of-band exception is a better fit. The function could likely do with some refactoring (e.g. breaking out some helper
Yury Selivanov added the comment: This isn't a bug, as raise exc from None only hides *display* of the context, it doesn't lose the record of the context entirely. Agree. My patch, though, is still valid. I think removing try..except blocks actually simplifies the code, and removes the
Nick Coghlan added the comment: This isn't a bug, as raise exc from None only hides *display* of the context, it doesn't lose the record of the context entirely. This means Walter's display code is incorrect, as it isn't checking for __suppress_context__: import inspect try: ...
New submission from Walter Dörwald: 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))
Changes by Yury Selivanov yseliva...@gmail.com: -- assignee: - yselivanov components: +Library (Lib) nosy: +yselivanov versions: +Python 3.5, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24474
Yury Selivanov added the comment: Hi Walter, Thanks for reporting this. A patch is attached. -- keywords: +needs review, patch nosy: +larry, ncoghlan stage: - patch review Added file: http://bugs.python.org/file39743/sig.patch ___ Python tracker