Skip to content

Commit 8bbd7c4

Browse files
committed
Updated deprecation logic per reviewer recommendations.
1 parent 92bc6fa commit 8bbd7c4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandas/io/xml.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
file_exists,
3333
get_handle,
3434
infer_compression,
35+
is_file_like,
3536
is_fsspec_url,
3637
is_url,
3738
stringify_path,
@@ -898,6 +899,7 @@ def read_xml(
898899
899900
.. deprecated:: 2.1.0
900901
Passing html literal strings is deprecated.
902+
Wrap literal xml input in ``io.StringIO`` or ``io.BytesIO`` instead.
901903
902904
xpath : str, optional, default './\*'
903905
The XPath to parse required set of nodes for migration to DataFrame.
@@ -1125,7 +1127,13 @@ def read_xml(
11251127
"""
11261128
check_dtype_backend(dtype_backend)
11271129

1128-
if isinstance(path_or_buffer, str) and "\n" in path_or_buffer:
1130+
if (
1131+
isinstance(path_or_buffer, str)
1132+
and not is_file_like(path_or_buffer)
1133+
and "\n" in path_or_buffer
1134+
):
1135+
with open("/home/richard/Desktop/file.txt", "a+") as fil:
1136+
fil.write(f"{path_or_buffer}\n\n\n")
11291137
warnings.warn(
11301138
"Passing literal xml to 'read_xml' is deprecated and "
11311139
"will be removed in a future version. To read from a "

0 commit comments

Comments
 (0)