Python 3 issue
See original GitHub issueUnder Python 3.4.2 I get an error:
XML input:
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Python snippet:
with open(xml_file) as f:
d = xmltodict.parse(f, xml_attribs=True)
Error message:
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/xmltodict.py", line 246, in parse
parser.ParseFile(xml_input)
TypeError: read() did not return a bytes object (type=str)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./xml2json.py", line 27, in <module>
print(convert(sys.argv[1]))
File "./xml2json.py", line 17, in convert
d = xmltodict.parse(f, xml_attribs=xml_attribs)
File "/usr/lib/python3.4/site-packages/xmltodict.py", line 248, in parse
parser.Parse(xml_input, True)
TypeError: '_io.TextIOWrapper' does not support the buffer interface
Under Python 2.7 this example works fine.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Python tracker: List of issues
ID GH Activity Status Creator Assigned To Type Msgs
2771 47020 7 months ago open gvanrossum ezio.melotti behavior 145
24778 68966 8 months ago open...
Read more >Common migration problems — Supporting Python 3
The biggest problem you may encounter relates to one of the most important changes in Python 3; strings are now always Unicode. This...
Read more >Why is the Migration to Python 3 Taking So Long?
The idea behind developing Python 3 was to implement a single big change that got rid of a legacy problem in Python: rendering...
Read more >Python 3 Issues - Gradescope Autograder Documentation
If you're having issues with your Python 3 autograder not starting and you're overriding the system version of python3 , it may be...
Read more >How to install the latest Python 3 on Mac with no issues
I tried several approaches to installing Python 3 on Mac, and this is what worked as the best solution for these three goals:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found the solution: you need to open the XML input as binary:
Notice the “rb” mode instead of “r”.
I didn’t make the parser, can’t say. Try asking in stackoverflow.com, someone out there might know.