QUERY · ISSUE
json lib module, syntax error
needs-info
The json lib module seems to have an issue. That was not observed in 2018.
To reproduce the error take:
r = requests.get('https://aa.usno.navy.mil/api/rstt/oneday?date=2023-11-21 &coords=48.441832,9.890139 &tz=2').json()
Generated error message:
File "requests/init.py", line 33, in json
ValueError: syntax error in JSON
CANDIDATE · ISSUE
Syntax errors on module imports are confusing
Compare uPy:
Traceback (most recent call last):
File "a.py", line 1, in <module>
File "/home/pfalcon/projects-3rdparty/micropython-lib/json/json/__init__.py", line 110, in <module>
File "/home/pfalcon/projects-3rdparty/micropython-lib/json/json/decoder.py", line 9, in <module>
SyntaxError: invalid syntax
and CPy:
Traceback (most recent call last):
File "a.py", line 1, in <module>
import json
File "/home/pfalcon/projects-3rdparty/micropython-lib/json/json/__init__.py", line 110, in <module>
from json.decoder import JSONDecoder
File "/home/pfalcon/projects-3rdparty/micropython-lib/json/json/decoder.py", line 9, in <module>
import json.scanner
File "/home/pfalcon/projects-3rdparty/micropython-lib/json/json/scanner.py", line 50
print m.groups()
^
SyntaxError: invalid syntax
This returns status_code==400 on my ESP32C3 , here is REPL :
The request works fine on my Linux box - using ipython- and returns a good
jsonstring. Thetextis not JSON. Maybe the difficulty is inrequestsmodule?On the ESP32C3 micropython:
On my linux box:
If I remove the space between date and
&coordsand remove the space abetween coordinates and&tzit works:It works ... sometimes, means it is not stable.
I often get this error:
...
File "requests/init.py", line 180, in get
File "requests/init.py", line 76, in request
OSError: -202
In order to be able to debug the issue, you need to provide examples of valid JSON that the library does not parse.