When using raise x from None, Python sets x.__suppress_context__ to True. This is intended to tell anyone traversing the exception chain to ignore the __context__ property, but we were ignoring this
This PR will stop traversing the exception chain when an exception has __suppress_context__ set
This was added in PEP 415, with some background in PEP 409
In this small refactor, I noticed we'd broken the case where notify is passed a string. This isn't really intended to be supported, but I've fixed it and added a test as it could be a BC break and was trivial to solve
Goal
When using
raise x from None
, Python setsx.__suppress_context__
toTrue
. This is intended to tell anyone traversing the exception chain to ignore the__context__
property, but we were ignoring thisThis PR will stop traversing the exception chain when an exception has
__suppress_context__
setThis was added in PEP 415, with some background in PEP 409
In this small refactor, I noticed we'd broken the case where
notify
is passed a string. This isn't really intended to be supported, but I've fixed it and added a test as it could be a BC break and was trivial to solve