MCPcopy
hub / github.com/pandas-dev/pandas / _is_binary_mode

Function _is_binary_mode

pandas/io/common.py:1228–1246  ·  view source on GitHub ↗

Whether the handle is opened in binary mode

(handle: FilePath | BaseBuffer, mode: str)

Source from the content-addressed store, hash-verified

1226
1227
1228def _is_binary_mode(handle: FilePath | BaseBuffer, mode: str) -> bool:
1229 """Whether the handle is opened in binary mode"""
1230 # specified by user
1231 if "t" in mode or "b" in mode:
1232 return "b" in mode
1233
1234 # exceptions
1235 text_classes = (
1236 # classes that expect string but have 'b' in mode
1237 codecs.StreamWriter,
1238 codecs.StreamReader,
1239 codecs.StreamReaderWriter,
1240 )
1241 if issubclass(type(handle), text_classes):
1242 return False
1243
1244 return isinstance(handle, _get_binary_io_classes()) or "b" in getattr(
1245 handle, "mode", mode
1246 )
1247
1248
1249@functools.lru_cache

Callers 1

get_handleFunction · 0.85

Calls 1

_get_binary_io_classesFunction · 0.85

Tested by

no test coverage detected