We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0725ff commit 322c49cCopy full SHA for 322c49c
pandas/_testing/_io.py
@@ -58,7 +58,13 @@ def round_trip_pickle(
58
# keeping an open file handle (important on Windows) while still
59
# ensuring automatic cleanup.
60
with tempfile.TemporaryDirectory() as tmpdir:
61
- temp_path = pathlib.Path(tmpdir) / _path
+ # 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
68
pd.to_pickle(obj, temp_path)
69
return pd.read_pickle(temp_path)
70
0 commit comments