• Kirill Smelkov's avatar
    errors: Take .__cause__ into account · 03f88c0b
    Kirill Smelkov authored
    A Python error can have links to other errors by means of both .Unwrap()
    and .__cause__ . These ways are both explicit and so should be treated
    by e.g. errors.Is as present in error's error chain.
    It is a bit unclear, at least initially, how to linearise and order
    error chain traversal in divergence points - for exception objects where
    both .Unwrap() and .__cause__ are !None. However more closer look
    suggests linearisation rule to traverse into .__cause__ after going
    through .Unwrap() part - please see details in documentation added into
    -> Teach errors.Is to do this traversal, and this way now e.g. exception
    raised as
    	raise X from Y
    will be treated by errors.Is as being both X and Y, even if any of X or Y
    also has its own error chain via .Unwrap().
    Top-level documentation is TODO.
_errors.pyx 6.88 KB