8000 gh-105375: Improve error handling in _Unpickler_SetInputStream() by erlend-aasland · Pull Request #105667 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-105375: Improve error handling in _Unpickler_SetInputStream() #105667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address Serhiy's review
Don't clear arbitrary exceptions
  • Loading branch information
erlend-aasland committed Jun 12, 2023
commit ab8606ab782d7ca3e10834322c164ff023dcf021
12 changes: 7 additions & 5 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,15 +1684,17 @@ _Unpickler_SetInputStream(UnpicklerObject *self, PyObject *file)
goto error;
}
if (_PyObject_LookupAttr(file, &_Py_ID(read), &self->read) < 0) {
PyErr_Clear();
goto error;
}
if (_PyObject_LookupAttr(file, &_Py_ID(readline), &self->readline) < 0) {
PyErr_Clear();
goto error;
}
if (!self->readline || !self->read) {
PyErr_SetString(PyExc_TypeError,
"file must have 'read' and 'readline' attributes");
goto error;
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"file must have 'read' and 'readline' attributes");
goto error;
}
}
return 0;

Expand Down
0