make FileIO.mode always include 'b'

#4386 Reviewed by Amaury
This commit is contained in:
Benjamin Peterson 2008-11-22 00:41:45 +00:00
parent 656aa28cd5
commit 44309e6b37
8 changed files with 24 additions and 16 deletions

View file

@ -198,10 +198,12 @@ class SocketIO(io.RawIOBase):
# XXX More docs
def __init__(self, sock, mode):
if mode not in ("r", "w", "rw"):
if mode not in ("r", "w", "rw", "rb", "wb", "rwb"):
raise ValueError("invalid mode: %r" % mode)
io.RawIOBase.__init__(self)
self._sock = sock
if "b" not in mode:
mode += "b"
self._mode = mode
self._reading = "r" in mode
self._writing = "w" in mode