-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-99064: Added warnings for file objects with non-UTF8 content #123887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
851b179
c2c9aa7
65984a4
cd9eaa8
b84075c
bfdfc5b
eac7791
3cbd0ca
45b0e8f
121a6b1
604dc15
a88a0b4
32b35b5
be27e53
5b1a048
12d91b5
cd9e7a7
99aa9b5
78834a8
ca044ce
2d98fff
b753d31
cbd6dbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1200,6 +1200,15 @@ def parse(source, parser=None): | |
Return an ElementTree instance. | ||
|
||
""" | ||
import warnings | ||
|
||
if (hasattr(source, 'encoding') and | ||
source.encoding == 'ISO-8859-1' and | ||
source.mode == 'r'): | ||
warnings.warn( | ||
rruuaanng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"For file objects containing XML data" | ||
rruuaanng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"with non-ASCII and non-UTF-8 encoding (e.g. ISO 8859-1), " | ||
rruuaanng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"the file must have been opened in binary mode.", category=RuntimeWarning) | ||
|
||
tree = ElementTree() | ||
tree.parse(source, parser) | ||
return tree | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Added a warning in the :func:`xml.etree.ElementTree.parse` for | ||
``'ISO-8859-1'`` encoding files opened in ``r`` mode. Patch by RUANG. | ||
rruuaanng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.