On Wed, Jul 14, 2021 at 11:22 AM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Tue, Jul 13, 2021 at 10:27:55PM +0300, Serhiy Storchaka wrote:
>
> > The writelines method is the part of interface. Adding new parameter or
> > new method to interface is a major breaking change. It will make invalid
> > all existing user code which implements this interface.
>
> I think that statement is a bit strong. How will it break existing code?
> The code will still work exactly the same as before.
>
> We added the BufferedIOBase.readinto1 method in Python 3.5, before that
> we added 'x' mode and `opener=None` parameter to FileIO in 3.3.
>
> https://docs.python.org/3/library/io.html#io.BufferedIOBase.readinto1
>
> https://docs.python.org/3/library/io.html#io.FileIO
>
> In 3.7 we allowed the BytesIO.read1 size parameter to be optional:
>
> https://docs.python.org/3/library/io.html#io.BytesIO.read1
>
> There are other changes to the IO interfaces through to Python 3.7. If
> that didn't break code, I don't see why this change would.
>
> I think that adding a new method or a keyword-only arg to writelines in
> 3.11 would be fine.
>

Breakage has to be justified. The value of readinto1 is more
significant than a change to writelines(), which - I'll be honest - is
an API that I've never bothered with. It's usually easiest to just
write().

But OTOH, the breakage here wouldn't be very significant. In theory,
it means adding the functionality to every file-like object. In
practice, nobody knows what "file-like object" really means, other
than "has that one method of file objects that I'm going to be
calling", so if other objects don't have this method or arg, it won't
hurt.

I'm -0 on this.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EUUNVMEH2Y4OCM4GDKEOYCSWE63JUCBP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to