Skip to content

Commit

Permalink
BUG: Restore duck typing
Browse files Browse the repository at this point in the history
Restore duck typing for fname
  • Loading branch information
bashtage committed Jan 16, 2020
1 parent 8043174 commit 3780cbe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1881,12 +1881,12 @@ def _open_file_binary_write(fname: FilePathOrBuffer) -> Tuple[BinaryIO, bool]:
own : bool
True if the file was created, otherwise False
"""
if isinstance(fname, IOBase):
return fname, False
if hasattr(fname, "write"):
return fname, False # type: ignore
elif isinstance(fname, (str, Path)):
return open(fname, "wb"), True
else:
raise ValueError("fname must be a binary file, buffer or path-like.")
raise TypeError("fname must be a binary file, buffer or path-like.")


def _set_endianness(endianness: str) -> str:
Expand Down

0 comments on commit 3780cbe

Please sign in to comment.