This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: StreamReaderProtocol docs recommend using private API
Type: Stage:
Components: asyncio Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: aymeric.augustin, gvanrossum, python-dev, vstinner, yselivanov
Priority: normal Keywords:

Created on 2015-08-18 09:48 by aymeric.augustin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg248767 - (view) Author: Aymeric Augustin (aymeric.augustin) * Date: 2015-08-18 09:48
https://docs.python.org/3/library/asyncio-stream.html?highlight=streamreaderprotocol#stream-functions says:

> (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code – there’s really nothing special here except some convenience.)

StreamReaderProtocol inherits from streams.FlowControlMixin which isn't documented. Applying this advice means, instead of inheriting from StreamReaderProtocol, inheriting from streams.FlowControlMixin -- in order to obtain the _drain_helper method, which StreamWriter.drain must wait for.

At this point inheriting StreamReaderProtocol appears to be the lesser evil.

I suggest to remove this paragraph from the documentation.
msg253190 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-10-19 20:12
I just re-read the docs here (which came straight from the open_connection() docstring). The parenthetical remark is confusing -- I meant something more like

"""
If you want to use different classes than StreamReader, StreamReaderProtocol and StreamWriter, just copy the code of open_connection() and substitute your own classes.
"""

That is, the customization it is trying to refer to is open_connection(), not the classes.

FWIW I think subclassing implementation classes is a dangerous practice and shouldn't be encouraged.

Because the same reasoning applies to all the top-level functions here (but not to the classes), I think I'll delete the offending paragraph and replace it with something like the following at the top of the docs for this module:

"""
The top-level functions in this module are meant convenience wrappers only; there's really nothing special there, and if they don't do what you want feel free to copy their code.
"""
msg253191 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-19 20:20
New changeset d91208957e4e by Guido van Rossum in branch '3.4':
Issue #24885: Update note in docs about stream convenience functions.
https://hg.python.org/cpython/rev/d91208957e4e

New changeset 43c63dd2f383 by Guido van Rossum in branch '3.5':
Issue #24885: Update note in docs about stream convenience functions. (Merge 3.4->3.5)
https://hg.python.org/cpython/rev/43c63dd2f383

New changeset 7947f43a1a87 by Guido van Rossum in branch 'default':
Issue #24885: Update note in docs about stream convenience functions. (Merge 3.5->3.6)
https://hg.python.org/cpython/rev/7947f43a1a87
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 69073
2015-10-19 20:54:03gvanrossumsetstatus: open -> closed
assignee: gvanrossum
resolution: fixed
2015-10-19 20:20:05python-devsetnosy: + python-dev
messages: + msg253191
2015-10-19 20:12:06gvanrossumsetmessages: + msg253190
2015-08-18 09:48:30aymeric.augustincreate