FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-105375: Improve _pickle error handling by erlend-aasland · Pull Request #105475 · python/cpython · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
Revert "Bail early from _Unpickler_SetInputStream() also"
This reverts commit a91713a.
  • Loading branch information
erlend-aasland committed Jun 8, 2023
commit 32ef4684fce889366709b308d95fca0f6c024366
28 changes: 14 additions & 14 deletions Modules/_pickle.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1678,25 +1678,25 @@ _Unpickler_SetInputStream(UnpicklerObject *self, PyObject *file)
{
/* Optional file methods */
if (_PyObject_LookupAttr(file, &_Py_ID(peek), &self->peek) < 0) {
goto error;
return -1;
}
if (_PyObject_LookupAttr(file, &_Py_ID(readinto), &self->readinto) < 0) {
goto error;
}
if (_PyObject_LookupAttr(file, &_Py_ID(read), &self->read) < 0) {
goto error;
return -1;
}
if (_PyObject_LookupAttr(file, &_Py_ID(readline), &self->readline) < 0) {
goto error;
(void)_PyObject_LookupAttr(file, &_Py_ID(read), &self->read);
(void)_PyObject_LookupAttr(file, &_Py_ID(readline), &self->readline);
if (!self->readline || !self->read) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"file must have 'read' and 'readline' attributes");
}
Py_CLEAR(self->read);
Py_CLEAR(self->readinto);
Py_CLEAR(self->readline);
Py_CLEAR(self->peek);
return -1;
}
return 0;

error:
Py_CLEAR(self->read);
Py_CLEAR(self->readinto);
Py_CLEAR(self->readline);
Py_CLEAR(self->peek);
return -1;
}

/* Returns -1 (with an exception set) on failure, 0 on success. This may
Expand Down

Back | FazBrowse Home | New Git URL