This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author João Eiras
Recipients João Eiras, serhiy.storchaka
Date 2020-03-01.17:55:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583085350.79.0.755473946684.issue39750@roundup.psfhosted.org>
In-reply-to
Content
On a related note, after inspecting the UnicodeEror C code, the exception object keeps explicit references to 'encoding', 'object', 'start', 'end' and 'reason'. That means that if those properties are set (the C code does have setters) then the properties stored in UnicodeError go out of sync with the args tuple in BaseException. And so pickling and unpickling will restore the original values, and not those that were set after the exception being created, unless args is too modified.

My suggestion would be to just fetch all 5 properties from the args tuple inside the getters and setters, and in the setters, recreate the tuple with a modified value. The constructor could do argument validation but would not set any properties, because that would be delegated to BaseException.
History
Date User Action Args
2020-03-01 17:55:50João Eirassetrecipients: + João Eiras, serhiy.storchaka
2020-03-01 17:55:50João Eirassetmessageid: <1583085350.79.0.755473946684.issue39750@roundup.psfhosted.org>
2020-03-01 17:55:50João Eiraslinkissue39750 messages
2020-03-01 17:55:50João Eirascreate