You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
requests 2.26.0 switched to using charset_normalizer by default under Python 3 (see: googleapis/python-cloud-core#117). After this change, a response constructed with an empty JSON body (b"{}) can no longer unmarshall to the empty dict in its json method.
To Reproduce
>>>importcharset_normalizer>>>empty_json_response=b"{}">>>detected=charset_normalizer.detect(empty_json_response)
....nox/unit-3-6/lib/python3.6/site-packages/charset_normalizer/api.py:95: UserWarning: Tryingtodetectencodingfromatinyportionof (2) byte(s).
warn('Trying to detect encoding from a tiny portion of ({}) byte(s).'.format(length))
>>>detected
{'encoding': 'utf_16_be', 'language': '', 'confidence': 1.0}
>>>decoded=empty_json_response.decode(detected["encoding"])
>>>decoded'筽'>>>importjson>>>json.loads(decoded)
/opt/Python-3.6.10/lib/python3.6/json/__init__.py:354: inloadsreturn_default_decoder.decode(s)
/opt/Python-3.6.10/lib/python3.6/json/decoder.py:339: indecodeobj, end=self.raw_decode(s, idx=_w(s, 0).end())
__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self=<json.decoder.JSONDecoderobjectat0x7fd0b5810860>, s='筽', idx=0defraw_decode(self, s, idx=0):
"""Decode a JSON document from ``s`` (a ``str`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. This can be used to decode a JSON document from a string that may have extraneous data at the end. """try:
obj, end=self.scan_once(s, idx)
exceptStopIterationaserr:
>raiseJSONDecodeError("Expecting value", s, err.value) fromNoneEjson.decoder.JSONDecodeError: Expectingvalue: line1column1 (char0)
Expected behavior
I expect to be able unmarshall b"{}" into an empty dict, {}.
Desktop (please complete the following information):
OS: Linux
Python version: 3.6, 3.7, 3.8, 3.9
Package version: 2.0.1
The text was updated successfully, but these errors were encountered:
Thanks for the report,
I was able to reproduce this easily. The miss-detect fault happen in the plugin TooManySymbolOrPunctuationPlugin(MessDetectorPlugin).
Adjustments are to be done in this plugin.
Describe the bug
requests 2.26.0
switched to usingcharset_normalizer
by default under Python 3 (see: googleapis/python-cloud-core#117). After this change, a response constructed with an empty JSON body (b"{}
) can no longer unmarshall to the empty dict in itsjson
method.To Reproduce
Expected behavior
I expect to be able unmarshall
b"{}"
into an empty dict,{}
.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: