Skip to content

Commit 322c49c

Browse files
committed
TST: Replace ensure_clean utility function (fixing CI error)
1 parent b0725ff commit 322c49c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/_testing/_io.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ def round_trip_pickle(
5858
# keeping an open file handle (important on Windows) while still
5959
# ensuring automatic cleanup.
6060
with tempfile.TemporaryDirectory() as tmpdir:
61-
temp_path = pathlib.Path(tmpdir) / _path
61+
# Only join tmpdir with _path when _path is a string or Path-like.
62+
# _path may be a ReadPickleBuffer (file-like) in which case it
63+
# should be used directly for pickle operations.
64+
if isinstance(_path, (str, pathlib.Path)):
65+
temp_path = pathlib.Path(tmpdir) / _path
66+
else:
67+
temp_path = _path
6268
pd.to_pickle(obj, temp_path)
6369
return pd.read_pickle(temp_path)
6470

0 commit comments

Comments
 (0)