diff --git a/pandas/io/parquet.py b/pandas/io/parquet.py index c5bfbd2b6b35d..1b8526275c155 100644 --- a/pandas/io/parquet.py +++ b/pandas/io/parquet.py @@ -180,8 +180,12 @@ def write( mode="wb", is_dir=partition_cols is not None, ) - if isinstance(path_or_handle, io.BufferedWriter): - path_or_handle = path_or_handle.raw.name + if ( + isinstance(path_or_handle, io.BufferedWriter) + and hasattr(path_or_handle, "name") + and isinstance(path_or_handle.name, (str, bytes)) + ): + path_or_handle = path_or_handle.name try: if partition_cols is not None: diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 93cc2fd5100c8..2eb8738d88b41 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -13,6 +13,7 @@ from pandas._config import get_option +from pandas.compat import is_platform_windows from pandas.compat.pyarrow import ( pa_version_under2p0, pa_version_under5p0, @@ -728,6 +729,13 @@ def test_unsupported_float16(self, pa): df = pd.DataFrame(data=data, columns=["fp16"]) self.check_external_error_on_write(df, pa, pyarrow.ArrowException) + @pytest.mark.xfail( + is_platform_windows(), + reason=( + "PyArrow does not cleanup of partial files dumps when unsupported " + "dtypes are passed to_parquet function in windows" + ), + ) @pytest.mark.parametrize("path_type", [str, pathlib.Path]) def test_unsupported_float16_cleanup(self, pa, path_type): # #44847, #44914