[issue35848] readinto is not a method on io.TextIOBase

Steve Palmer report at bugs.python.org
Tue Jan 29 11:50:34 EST 2019


Steve Palmer <steve at srpalmer.me.uk> added the comment:

I agree with Karthikeyan that the method does not apply in the io.TextIOBase class context.  I'm sorry that I didn't spot the note in the description of io.TextIOBase - though I think that it is easy to miss.

I'd suggest that there are two ways to clear this up:

1. change only the documentation to read "Even though IOBase does not declare read() or write() because their signatures will vary, implementations and clients should consider those methods part of the interface."  (deleting reference to readinto())

2. change the standard library for io.TextIOBase to add a method readinto which will raise an UnsupportedOperation.

With option 1, the descriptions for io.RawIOBase and io.BufferedIOBase both include description of the readinto method, so nothing is lost by removing mention of it at the io.IOBase level of the hierarchy.  In any case, readinto() is not defined on the io.IOBase class.

>>> 'readinto' not in dir(io.IOBase)
True

With option 2, it feels like this is closer to the design intent of a common interface over similar but distinguished classes.  It also avoids removing things from the documentation in case someone already has some expectations of the behaviour.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35848>
_______________________________________


More information about the Python-bugs-list mailing list