Before making the initial post I did some research on the signature of the exceptions in the builtins module. More exactly, I use attributes as revealed by dir, omitting those that begin with __ as a proxy for the signature. These investigation as now added to the previous github URL Python's StopIteration exception puzzled me. Here's why. What's going on here? BTW, I've solved the puzzle. · GitHub .
Here’s what I found. The following exceptions have a unique signature (or more exactly the proxy I described above). One of them is StopIteration. All of the signatures have args. But StopIteration is the only one that has value. Should it have both values? And if so, what are their respective functions?
---
1 ('add_note', 'args', 'derive', 'exceptions', 'message', 'split', 'subgroup', 'with_traceback')
val[:4]=['ExceptionGroup']
---
1 ('add_note', 'args', 'name', 'obj', 'with_traceback')
val[:4]=['AttributeError']
---
1 ('add_note', 'args', 'value', 'with_traceback')
val[:4]=['StopIteration']
Here are the two most common signatures. Notice that StopIteration has the most common (34 exception classes) signature, except for the unique addition of a value attribute.
34 ('add_note', 'args', 'with_traceback')
val[:4]=['Exception', 'ArithmeticError', 'AssertionError', 'BufferError']
---
18 ('add_note', 'args', 'characters_written', 'errno', 'filename', 'filename2', 'strerror', 'with_traceback')
val[:4]=['OSError', 'BlockingIOError', 'ChildProcessError', 'ConnectionError']
Here are the remaining signatures.
---
4 ('add_note', 'args', 'end_lineno', 'end_offset', 'filename', 'lineno', 'msg', 'offset', 'print_file_and_line', 'text', 'with_traceback')
val[:4]=['SyntaxError', 'IndentationError', '_IncompleteInputError', 'TabError']
---
3 ('add_note', 'args', 'encoding', 'end', 'object', 'reason', 'start', 'with_traceback')
val[:4]=['UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeTranslateError']
---
2 ('add_note', 'args', 'msg', 'name', 'name_from', 'path', 'with_traceback')
val[:4]=['ImportError', 'ModuleNotFoundError']
---
2 ('add_note', 'args', 'name', 'with_traceback')
val[:4]=['NameError', 'UnboundLocalError']