Skip to content

Commit 3780cbe

Browse files
committed
BUG: Restore duck typing
Restore duck typing for fname
1 parent 8043174 commit 3780cbe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/io/stata.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1881,12 +1881,12 @@ def _open_file_binary_write(fname: FilePathOrBuffer) -> Tuple[BinaryIO, bool]:
18811881
own : bool
18821882
True if the file was created, otherwise False
18831883
"""
1884-
if isinstance(fname, IOBase):
1885-
return fname, False
1884+
if hasattr(fname, "write"):
1885+
return fname, False # type: ignore
18861886
elif isinstance(fname, (str, Path)):
18871887
return open(fname, "wb"), True
18881888
else:
1889-
raise ValueError("fname must be a binary file, buffer or path-like.")
1889+
raise TypeError("fname must be a binary file, buffer or path-like.")
18901890

18911891

18921892
def _set_endianness(endianness: str) -> str:

0 commit comments

Comments
 (0)