forked from isagalaev/ijson
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Error with 2.5 #12
Labels
invalid
This doesn't seem right
Comments
You need to open the file in binary mode e.g. |
Or simply with |
Don't work if opens with encoding. Only works with binary and without encoding. |
rtobar
added a commit
that referenced
this issue
Oct 1, 2019
All ijson backends, except for the python backend, need a bytes reader in order to work. With the change of default backends in ijson 2.5 it became clear that many people relied on the ability of the python backend to accept string readers, and thus ijson's public API broke. This commit adds a new function to turn a utf8-encoded string reader into a bytes reader. It is mostly intended for use within ijson, but users might find some of it useful. Related issues: #12, #13 Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
rtobar
added a commit
that referenced
this issue
Oct 1, 2019
All backends, except for the python backend, require a bytes reader, but users didn't expect this and some were give us a utf8-encoded string reader instead. With this commit we check and automatically translate the given reader so users don't have to bother (yet) doing it. Together with the translation a DeprecationWarning is issued to make it clear that this automatic translation won't be there for long. Related issues: #12, #13 Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Example:
test_ijson.py
test.json
Result:
<_yajl2.items object at 0x7fb21010f650>
<generator object at 0x7fb2100e0c00>
Traceback (most recent call last):
File "test_ijson.py", line 11, in
for objects in forms:
File "test_ijson.py", line 9, in
forms = (o for o in form)
TypeError: expected bytes, str found
If I import the python backend as ijson everthing went fine.
The text was updated successfully, but these errors were encountered: