File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -159,15 +159,21 @@ def _check_not_closed(self):
159
159
raise ValueError ("I/O operation on closed file" )
160
160
161
161
def _check_can_read (self ):
162
- if not self .readable ():
162
+ if self .closed :
163
+ raise ValueError ("I/O operation on closed file" )
164
+ if self ._mode not in (_MODE_READ , _MODE_READ_EOF ):
163
165
raise io .UnsupportedOperation ("File not open for reading" )
164
166
165
167
def _check_can_write (self ):
166
- if not self .writable ():
168
+ if self .closed :
169
+ raise ValueError ("I/O operation on closed file" )
170
+ if self ._mode != _MODE_WRITE :
167
171
raise io .UnsupportedOperation ("File not open for writing" )
168
172
169
173
def _check_can_seek (self ):
170
- if not self .readable ():
174
+ if self .closed :
175
+ raise ValueError ("I/O operation on closed file" )
176
+ if self ._mode not in (_MODE_READ , _MODE_READ_EOF ):
171
177
raise io .UnsupportedOperation ("Seeking is only supported "
172
178
"on files open for reading" )
173
179
if not self ._fp .seekable ():
You can’t perform that action at this time.
0 commit comments