So, I interact with a third-party library that raises someti0mes exceptions, but raises the same exception for everything (in particular suds.WebFault. However, it is possible to determine the exact type of the exception from the data on Exclusion. I am looking for an abstract exception in the exceptions that are subclasses of this type, those.
from suds import WebFault
class MoreSpecificError(WebFault):
pass
I like the subclass because it will not break the existing implementations that are expected WebFault. The problem that I have encountered, is transferring data already WebFaultin MoreSpecificError. What I would like to do is take an existing exception object and simply βturn it intoβ a subclass without any change or re-launch __init__. What I have done so far to accomplish this looks something like this:
from suds import WebFault
class MoreSpecificError(WebFault):
def __new__(cls, internal_fault):
return internal_fault
def __init__(self, internal_fault):
pass
Edit: now I know that this does not work, the new object will not have a subclass type
"", __init__, pass . , __new__ (: deepcopy, , () , .)
, ? , , . , Python - . .