Skip to content

Commit

Permalink
Remove use of isinstance
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Aug 1, 2021
1 parent 1759a41 commit a103b07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ with open("path_to_file/conf.toml", "rb") as f:
toml_dict = tomli.load(f)
```

Opening the file in binary mode (with the `"rb"` flag) is highly encouraged.
The file must be opened in binary mode (with the `"rb"` flag).
Binary mode will enforce decoding the file as UTF-8 with universal newlines disabled,
both of which are required to correctly parse TOML.
Support for text file objects is deprecated for removal in the next major release.
Expand Down
6 changes: 3 additions & 3 deletions tomli/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class TOMLDecodeError(ValueError):


def load(fp: IO, *, parse_float: ParseFloat = float) -> Dict[str, Any]:
"""Parse TOML from a file object."""
"""Parse TOML from a binary file object."""
s = fp.read()
if isinstance(s, bytes):
try:
s = s.decode()
else:
except AttributeError:
warnings.warn(
"Text file object support is deprecated in favor of binary file objects."
' Use `open("foo.toml", "rb")` to open the file in binary mode.',
Expand Down

0 comments on commit a103b07

Please sign in to comment.