File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -1678,25 +1678,25 @@ _Unpickler_SetInputStream(UnpicklerObject *self, PyObject *file)
16781678{
16791679 /* Optional file methods */
16801680 if (_PyObject_LookupAttr (file , & _Py_ID (peek ), & self -> peek ) < 0 ) {
1681- return -1 ;
1681+ goto error ;
16821682 }
16831683 if (_PyObject_LookupAttr (file , & _Py_ID (readinto ), & self -> readinto ) < 0 ) {
1684- return -1 ;
1684+ goto error ;
16851685 }
1686- (void )_PyObject_LookupAttr (file , & _Py_ID (read ), & self -> read );
1687- (void )_PyObject_LookupAttr (file , & _Py_ID (readline ), & self -> readline );
1688- if (!self -> readline || !self -> read ) {
1689- if (!PyErr_Occurred ()) {
1690- PyErr_SetString (PyExc_TypeError ,
1691- "file must have 'read' and 'readline' attributes" );
1692- }
1693- Py_CLEAR (self -> read );
1694- Py_CLEAR (self -> readinto );
1695- Py_CLEAR (self -> readline );
1696- Py_CLEAR (self -> peek );
1697- return -1 ;
1686+ if (_PyObject_LookupAttr (file , & _Py_ID (read ), & self -> read ) < 0 ) {
1687+ goto error ;
1688+ }
1689+ if (_PyObject_LookupAttr (file , & _Py_ID (readline ), & self -> readline ) < 0 ) {
1690+ goto error ;
16981691 }
16991692 return 0 ;
1693+
1694+ error :
1695+ Py_CLEAR (self -> read );
1696+ Py_CLEAR (self -> readinto );
1697+ Py_CLEAR (self -> readline );
1698+ Py_CLEAR (self -> peek );
1699+ return -1 ;
17001700}
17011701
17021702/* Returns -1 (with an exception set) on failure, 0 on success. This may
You can’t perform that action at this time.
0 commit comments