Skip to content

io.BufferedRWPair doc warning may need clarification #82776

Open

Description

@rgov
mannequin
BPO 38595
Nosy @pitrou, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-10-26.05:19:33.715>
labels = ['type-bug', '3.7', 'docs']
title = 'io.BufferedRWPair doc warning may need clarification'
updated_at = <Date 2019-10-26.05:30:22.117>
user = 'https://bugs.python.org/rgov'

bugs.python.org fields:

activity = <Date 2019-10-26.05:30:22.117>
actor = 'rgov'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2019-10-26.05:19:33.715>
creator = 'rgov'
dependencies = []
files = []
hgrepos = []
issue_num = 38595
keywords = []
message_count = 2.0
messages = ['355404', '355405']
nosy_count = 5.0
nosy_names = ['pitrou', 'benjamin.peterson', 'stutzbach', 'docs@python', 'rgov']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue38595'
versions = ['Python 3.7']

Activity

  1. rgov commented on Oct 26, 2019

    rgovmannequin
    MannequinAuthor

    The documentation for the io.BufferedRWPair class gives this warning:

    BufferedRWPair does not attempt to synchronize accesses to its underlying raw streams. You should not pass it the same object as reader and writer; use BufferedRandom instead.

    I have a hard time understanding what this warning is trying to tell me.

    1. What does it mean to "synchronize accesses"?

    2. Why can't I pass the same object as reader and writer? The docstring in _pyio.py says, "This is typically used with a socket or two-way pipe."

    3. How does BufferedRandom, which adds the seek() and tell() interfaces, address the issue of "synchroniz[ing] accesses"? Is synchronization automatic? What does this do for sockets or pipes which cannot seek?

  2. added
    docs
    type-bug
    on Oct 26, 2019
  3. rgov commented on Oct 26, 2019

    rgovmannequin
    MannequinAuthor

    The origin of this warning involves interleaving read and write operations, and was added here: https://bugs.python.org/issue12213

    I'm not sure if it applies to sockets, pipes, etc. though.

    The pySerial documentation advises using io.BufferedRWPair(x, x) where x is a serial device. But this StackOverflow post reports that it is problematic, in line with the warning. (The author appears to be talking about Windows.)

    https://stackoverflow.com/questions/24498048/python-io-modules-textiowrapper-or-buffererwpair-functions-are-not-playing-nice

  4. transferred this issue fromon Apr 10, 2022
  5. cmaloney commented on Nov 19, 2026

    @cmaloney
    Contributor

    Socket uses this same pattern. Should make it as safe as possible in the current code and should remove the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)docstopic-IOtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions