MCPcopy Create free account
hub / github.com/numpy/numpy / _check_mode

Function _check_mode

numpy/lib/_datasource.py:46–66  ·  view source on GitHub ↗

Check mode and that encoding and newline are compatible. Parameters ---------- mode : str File open mode. encoding : str File encoding. newline : str Newline for text files.

(mode, encoding, newline)

Source from the content-addressed store, hash-verified

44
45
46def _check_mode(mode, encoding, newline):
47 """Check mode and that encoding and newline are compatible.
48
49 Parameters
50 ----------
51 mode : str
52 File open mode.
53 encoding : str
54 File encoding.
55 newline : str
56 Newline for text files.
57
58 """
59 if "t" in mode:
60 if "b" in mode:
61 raise ValueError("Invalid mode: %r" % (mode,))
62 else:
63 if encoding is not None:
64 raise ValueError("Argument 'encoding' not supported in binary mode")
65 if newline is not None:
66 raise ValueError("Argument 'newline' not supported in binary mode")
67
68
69# Using a class instead of a module-level dictionary

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected