@@ -68,18 +68,16 @@ Handling Exceptions
6868-------------------
6969
7070At runtime, when an exception occurs, the interpreter calls
71- `` get_exception_handler() `` in
72- [ Python/ceval.c] ( https://github.com/python/cpython/blob/main/Python/ceval.c )
71+ ` get_exception_handler() ` in [ Python/ceval.c] ( ../Python/ceval.c )
7372to look up the offset of the current instruction in the exception
7473table. If it finds a handler, control flow transfers to it. Otherwise, the
7574exception bubbles up to the caller, and the caller's frame is
7675checked for a handler covering the ` CALL ` instruction. This
7776repeats until a handler is found or the topmost frame is reached.
7877If no handler is found, then the interpreter function
79- (`` _PyEval_EvalFrameDefault() ` ` ) returns NULL. During unwinding,
78+ (` _PyEval_EvalFrameDefault() ` ) returns NULL. During unwinding,
8079the traceback is constructed as each frame is added to it by
81- `` PyTraceBack_Here() `` , which is in
82- [ Python/traceback.c] ( https://github.com/python/cpython/blob/main/Python/traceback.c ) .
80+ ` PyTraceBack_Here() ` , which is in [ Python/traceback.c] ( ../Python/traceback.c ) .
8381
8482Along with the location of an exception handler, each entry of the
8583exception table also contains the stack depth of the ` try ` instruction
@@ -174,22 +172,20 @@ which is then encoded as:
174172
175173for a total of five bytes.
176174
177- The code to construct the exception table is in `` assemble_exception_table() ` `
178- in [ Python/assemble.c] ( https://github.com/python/cpython/blob/main /Python/assemble.c) .
175+ The code to construct the exception table is in ` assemble_exception_table() `
176+ in [ Python/assemble.c] ( .. /Python/assemble.c) .
179177
180178The interpreter's function to lookup the table by instruction offset is
181- `` get_exception_handler() `` in
182- [ Python/ceval.c] ( https://github.com/python/cpython/blob/main/Python/ceval.c ) .
183- The Python function `` _parse_exception_table() `` in
184- [ Lib/dis.py] ( https://github.com/python/cpython/blob/main/Lib/dis.py )
179+ ` get_exception_handler() ` in [ Python/ceval.c] ( ../Python/ceval.c ) .
180+ The Python function ` _parse_exception_table() ` in [ Lib/dis.py] ( ../Lib/dis.py )
185181returns the exception table content as a list of namedtuple instances.
186182
187183Exception Chaining Implementation
188184---------------------------------
189185
190186[ Exception chaining] ( https://docs.python.org/dev/tutorial/errors.html#exception-chaining )
191- refers to setting the `` __context__ `` and `` __cause__ ` ` fields of an exception as it is
192- being raised. The `` __context__ `` field is set by `` _PyErr_SetObject() ` ` in
193- [ Python/errors.c] ( https://github.com/python/cpython/blob/main/ Python/errors.c)
194- (which is ultimately called by all `` PyErr_Set*() `` functions).
195- The `` __cause__ `` field (explicit chaining) is set by the `` RAISE_VARARGS ` ` bytecode.
187+ refers to setting the ` __context__ ` and ` __cause__ ` fields of an exception as it is
188+ being raised. The ` __context__ ` field is set by ` _PyErr_SetObject() ` in
189+ [ Python/errors.c] ( ../ Python/errors.c) (which is ultimately called by all
190+ ` PyErr_Set*() ` functions). The ` __cause__ ` field (explicit chaining) is set by
191+ the ` RAISE_VARARGS ` bytecode.
0 commit comments