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
Python 3.0 beta 2 : json and urllib not working together? #48013
Comments
Hi, Running the attached program in Python 3.0 beta 2 gives the following error: File "C:\Python30\lib\json\decoder.py", line 21, in linecol I can't figure out if there's an error in the program itself, but I Please let me know if there's anything I can do to help (if this is a Regards, |
Adding full traceback: $ python yahoo_search.py
Traceback (most recent call last):
File "yahoo_search.py", line 35, in <module>
for result in search(query)['Result']:
File "yahoo_search.py", line 28, in search
result = json.load(urllib.request.urlopen(url))
File "C:\Python30\lib\json\__init__.py", line 267, in load
parse_constant=parse_constant, **kw)
File "C:\Python30\lib\json\__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "C:\Python30\lib\json\decoder.py", line 322, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
File "C:\Python30\lib\json\decoder.py", line 30, in errmsg
lineno, colno = linecol(doc, pos)
File "C:\Python30\lib\json\decoder.py", line 21, in linecol
lineno = doc.count('\n', 0, pos) + 1
TypeError: expected an object with the buffer interface |
On the code against the trunk, I am getting the following error: Traceback (most recent call last):
File "python3k_json.py", line 38, in <module>
for result in search(query)['Result']:
File "python3k_json.py", line 31, in search
result = json.load(obj)
File "/usr/local/lib/python3.0/json/__init__.py", line 267, in load
parse_constant=parse_constant, **kw)
File "/usr/local/lib/python3.0/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.0/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: can't use a string pattern on a bytes-like object Swaroop: What encoding would be the JSON File content? You can try by Few more things to note:
|
Hi Senthil, I am not aware of what encoding is used. An example of the content is ( If the above link does not work properly, please use http://is.gd/2bbI ) When viewing this, Firefox says it is UTF-8. |
If you look at the headers of HTTP response, the encoding is utf-8. You |
This is superseded by bpo-4136. |
1 similar comment
This is superseded by bpo-4136. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: