Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2016-05-13.16:59:09.479>labels= ['type-bug', 'library', '3.9', '3.10', '3.11']
title='pickling and repr of exceptions with kwargs'updated_at=<Date2022-01-06.13:25:55.215>user='https://github.com/Taywee'
This is a problem not only with CalledProcessError, but with all custom exceptions with overridden __init__. BaseException.__new__ saves positional arguments as the "args" attribute, but ignores keyword arguments. repr() and pickle use "args".
remilapeyre commented on Jan 16, 2019
remilapeyremannequin
Mannequin
More actions
I tried to fix the issue, the attached PR solves the issue of saving the kwargs and unpickling the exception but I was not able to fix a regression I caused in test_memory_error_in_PyErr_PrintEx.
Reviewing Rémi's page made me realise that a big part of the root cause here is pickle support in exceptions predating the introduction of __getnewargs__ and __getnewargs_ex__.
changed the title [-]subprocess.CalledProcessError's repr changes based on kwargs, and doesn't unpickle[/-][+]pickling and repr of exceptions with kwargs[/+]on Jan 6, 2022
Activity
Taywee commented on May 13, 2016
When using kwargs to construct a CalledProcessError, the repr doesn't show those args, and using kwargs also breaks pickling:
serhiy-storchaka commented on May 13, 2016
This is a problem not only with CalledProcessError, but with all custom exceptions with overridden __init__. BaseException.__new__ saves positional arguments as the "args" attribute, but ignores keyword arguments. repr() and pickle use "args".
remilapeyre commented on Jan 16, 2019
I tried to fix the issue, the attached PR solves the issue of saving the kwargs and unpickling the exception but I was not able to fix a regression I caused in test_memory_error_in_PyErr_PrintEx.
ncoghlan commented on Jan 31, 2019
Reviewing Rémi's page made me realise that a big part of the root cause here is pickle support in exceptions predating the introduction of __getnewargs__ and __getnewargs_ex__.