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)
| 44 | |
| 45 | |
| 46 | def _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 |
nothing calls this directly
no outgoing calls
no test coverage detected