diff --git a/Lib/io.py b/Lib/io.py index b24a21cf1d4..2f2d3c5997f 100644 --- a/Lib/io.py +++ b/Lib/io.py @@ -34,6 +34,7 @@ import sys import codecs import _fileio +import io import warnings # XXX Shouldn't we use st_blksize whenever we can? @@ -973,7 +974,7 @@ def __init__(self, buffer, encoding=None, newline=None): if encoding is None: try: encoding = os.device_encoding(buffer.fileno()) - except AttributeError: + except (AttributeError, io.UnsupportedOperation): pass if encoding is None: try: