New submission from Dwight Guth:

Consider the following program:

import io 
class A(io.IOBase): 
  def __init__(self): 
    self.x = 5 
  def read(self, limit=-1): 
    self.x -= 1 
    if self.x > 0: 
      return b"5" 
    return b"" 
  def seek(self, offset, whence=0): 
    return 0 
  def write(self, b): 
    pass 
 
a = A() 
a.close() 
assert a.__next__() == b"5555" 
assert a.readline() == b"" 
assert a.tell() == 0

These three operations succeed, even though the file is closed. However, these 
two operations fail:

a.readlines()
a.writelines([])

Why do some of the mixin methods on IOBase call _checkClosed and others don't?

----------
components: IO
messages: 190224
nosy: dwight.guth
priority: normal
severity: normal
status: open
title: Inconsistent behavior of IOBase methods on closed files
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18082>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to