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: Allow inspecting buffering attribute of IO objects
Type: enhancement Stage: needs patch
Components: IO Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, pitrou, serhiy.storchaka, stutzbach
Priority: normal Keywords:

Created on 2017-05-29 08:59 by pitrou, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg294683 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-29 08:59
It would be useful to be able to inspect the buffering attribute of buffered and text I/O objects, especially for debugging.

I would expect e.g.:

>>> sys.stdout.buffering
1   # line-buffered
>>> sys.stdout.buffer.buffering
8192
msg294685 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-29 09:13
>>> sys.stdout.line_buffering
True

For buffered streams I would expect the attribute named "buffer_size", conforming to the name of the parameter of the constructor.
msg294849 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-05-31 16:13
Ah, I had forgotten about the `line_buffering` attribute. Thank you.
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74689
2017-05-31 16:13:25pitrousetmessages: + msg294849
2017-05-29 09:13:14serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg294685
2017-05-29 08:59:06pitroucreate