File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,15 +159,21 @@ def _check_not_closed(self):
159159 raise ValueError ("I/O operation on closed file" )
160160
161161 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 ):
163165 raise io .UnsupportedOperation ("File not open for reading" )
164166
165167 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 :
167171 raise io .UnsupportedOperation ("File not open for writing" )
168172
169173 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 ):
171177 raise io .UnsupportedOperation ("Seeking is only supported "
172178 "on files open for reading" )
173179 if not self ._fp .seekable ():
You can’t perform that action at this time.
0 commit comments