Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialize by using __new__ whenever possible
Using of the class constructor and passing it the args values is not always correct, the custom parameters could be different to the args actually recorded by the built-in Exception class. Try to use the __new__ to create class instance and initialize the args attribute afterwards to prevent calling constructor with wrong arguments. Other instance attributes are initialized in a standard way by pickle module, so this way the reconstruction of the exception is complete. Subclasses of OSError are known exceptions to this, because they initialize read-only attributes from the constructor argument values, so usage of the __new__ factory method leads to lost values of those read-only attributes. Fixes: ionelmc#65 Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
- Loading branch information