@@ -1208,26 +1208,30 @@ buffered_tell(buffered *self, PyObject *Py_UNUSED(ignored))
12081208static PyObject *
12091209_buffered_seek_unlocked (buffered * self , Py_off_t target , int whence )
12101210{
1211- Py_off_t n ;
12121211 PyObject * res = NULL ;
12131212
12141213 if (self -> writable ) {
12151214 res = _bufferedwriter_flush_unlocked (self );
1216- if (res == NULL )
1215+ if (res == NULL ) {
12171216 return res ;
1217+ }
12181218 Py_CLEAR (res );
12191219 }
12201220
12211221 /* TODO: align on block boundary and read buffer if needed? */
1222- if (whence == 1 )
1222+ if (whence == 1 ) {
12231223 target -= RAW_OFFSET (self );
1224- n = _buffered_raw_seek (self , target , whence );
1225- if (n == -1 )
1224+ }
1225+
1226+ Py_off_t n = _buffered_raw_seek (self , target , whence );
1227+ if (n == -1 ) {
12261228 return res ;
1229+ }
12271230 self -> raw_pos = -1 ;
12281231 res = PyLong_FromOff_t (n );
1229- if (res != NULL && self -> readable )
1232+ if (res != NULL && self -> readable ) {
12301233 _bufferedreader_reset_buf (self );
1234+ }
12311235
12321236 return res ;
12331237}
@@ -1781,20 +1785,20 @@ _bufferedwriter_reset_buf(buffered *self)
17811785static void
17821786_bufferedwriter_set_append (buffered * self )
17831787{
1784- PyObject * mode ;
1785-
1786- mode = _PyObject_GetAttrId (self -> raw , & PyId_mode );
1788+ PyObject * mode = _PyObject_GetAttrId (self -> raw , & PyId_mode );
17871789 if (mode != NULL ) {
1788- /* Raw fileobj has no mode string so as far as we can know it has
1789- normal write behavior */
1790- if (PyUnicode_FindChar (mode , 'a' , 0 , PyUnicode_GET_LENGTH (mode ), 1 ) != -1 ) {
1790+ if (PyUnicode_FindChar (mode , 'a' , 0 ,
1791+ PyUnicode_GET_LENGTH (mode ), 1 ) != -1 ) {
17911792 self -> appending = 1 ;
1792- } else {
1793+ }
1794+ else {
17931795 self -> appending = 0 ;
17941796 }
17951797 Py_DECREF (mode );
1796- } else {
1797- PyErr_Clear ();
1798+ }
1799+ else {
1800+ /* Raw fileobj has no mode string so as far as we can know it has
1801+ normal write behavior */
17981802 self -> appending = 0 ;
17991803 }
18001804}
@@ -1981,8 +1985,9 @@ _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer)
19811985
19821986 if (self -> appending ) {
19831987 res = _buffered_seek_unlocked (self , 0 , SEEK_END );
1984- if (res == NULL )
1988+ if (res == NULL ) {
19851989 goto error ;
1990+ }
19861991 Py_DECREF (res );
19871992 }
19881993
0 commit comments