def rawstream(fp):
# type: (IO[Any]) -> IO[bytes]
if PY3:
try:
return fp.buffer # type: ignore
except AttributeError:
# There might be a BytesIO behind fp.
pass
return fp # type: Optional[IO[bytes]]