Ease the debugging of internal pickle errors.#22438
Conversation
iritkatriel
left a comment
There was a problem hiding this comment.
I think a change like this should come with changes to tests.
| PyErr_Format(PyExc_TypeError, | ||
| "cannot pickle '%.200s' object", | ||
| "cannot pickle '%.200s' object: expected " \ | ||
| "fixed-length instance (tp_itemsize != 0)", |
There was a problem hiding this comment.
An alternative message here could be "missing getstate on variable-length object".
@iritkatriel Do you mean I should change everything that comes from |
It's important to make sure that the lines you are changing are even covered by tests. If not, then you should add whatever tests are missing. If they exist, then you can change the expected message so that your change is verified, and the PR reviewer can see that there is test coverage and that the message fits the test case. You also need to create a ticket on bugs.python.org and link it to this PR. |
Not sure how to reproduce all these exceptions. I probably have to create buggy |
|
Some exceptions never make it to users (and sometimes they are sanity checks that can't even happen). In both cases they are not worth changing. Just change the ones you know how to produce. |
OK, I have only to remember how I got one of these errors... Sorry for the confusion. |
|
Serhiy made a good point, but I don't quite see how the asserts are going to help. "Internal debugging" sounds like debugging python itself. But the problem you are trying to solve is that a user type is unpicklable and the user is not getting an indication why. |
Well, no, I reproduced this bug trying to add a builltin, CPython type. The error messages was useful to me to identify the problem. I think it was I wrong the size in the |
|
It seems it fails the tests... probably for the I think it's better to close it. |


All pickle error messages was a generic "cannot pickle 'type' object". Added
some explaining for every individual error.asserts to individuate in debug mode the error.