| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
There was a problem hiding this comment.
Two small comments, but overall looks good.
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
Updated the code to make the matching function an argument and removed the extra call. |
Sorry, something went wrong.
|
@crazymerlyn Thanks for the updates. Your pr still requires a news entry. The easiest way to add this is to use click on the Details button next to the failing bedevere/news in the list of CI checks. Also see https://devguide.python.org/core-developers/committing/#how-to-add-a-news-entry |
Sorry, something went wrong.
|
added a news entry |
Sorry, something went wrong.
|
@eendebakpt Updated with the suggested change. |
Sorry, something went wrong.
|
@crazymerlyn I read the corresponding issue and opinions on whether we should make this change or not (at least back in 2016!) are not unanimous. A core developer should decide whether to accept this or not. The code in the PR looks good to me. Since this PR is not backwards compatible and there has been some discussion it is good to update the documentation (e.g. here https://docs.python.org/3/library/json.html#json.JSONDecoder.raw_decode) and add a Changed in version x.xx section (for an example see https://docs.python.org/3/library/bisect.html#bisect.bisect) |
Sorry, something went wrong.
Whitespace is allowed before JSON objects according to RFC 4627.
| .. versionchanged:: 3.14 | ||
| Now ignores any leading whitespace instead of returning an error |
There was a problem hiding this comment.
| .. versionchanged:: 3.14 | |
| Now ignores any leading whitespace instead of returning an error | |
| .. versionchanged:: next | |
| Leading whitespaces are now ignored instead of raising an exception. |
Sorry, something went wrong.
There was a problem hiding this comment.
whitespace is an uncountable noun, so it shouldn’t be pluralized.
Sorry, something went wrong.
| class TestRawDecode: | ||
| def test_whitespace(self): | ||
| decoder = self.json.JSONDecoder() | ||
| self.assertEqual(decoder.raw_decode(' {}'), ({}, 3)) | ||
| self.assertEqual(decoder.raw_decode(' []'), ([], 4)) | ||
| self.assertEqual(decoder.raw_decode(' ""'), ('', 5)) | ||
| s = ' { "key" : "value" , "k":"v" } \n' \ | ||
| ' { "key": "value", "k" :"v"} ' | ||
| val1, n1 = decoder.raw_decode(s) | ||
| val2, n2 = decoder.raw_decode(s[n1:]) | ||
| self.assertEqual(val1, {"key":"value", "k":"v"}) | ||
| self.assertEqual(val2, {"key":"value", "k":"v"}) |
There was a problem hiding this comment.
| class TestRawDecode: | |
| def test_whitespace(self): | |
| decoder = self.json.JSONDecoder() | |
| self.assertEqual(decoder.raw_decode(' {}'), ({}, 3)) | |
| self.assertEqual(decoder.raw_decode(' []'), ([], 4)) | |
| self.assertEqual(decoder.raw_decode(' ""'), ('', 5)) | |
| s = ' { "key" : "value" , "k":"v" } \n' \ | |
| ' { "key": "value", "k" :"v"} ' | |
| val1, n1 = decoder.raw_decode(s) | |
| val2, n2 = decoder.raw_decode(s[n1:]) | |
| self.assertEqual(val1, {"key":"value", "k":"v"}) | |
| self.assertEqual(val2, {"key":"value", "k":"v"}) | |
| class TestRawDecode: | |
| def test_whitespace(self): | |
| decoder = self.json.JSONDecoder() | |
| self.assertEqual(decoder.raw_decode(' {}'), ({}, 3)) | |
| self.assertEqual(decoder.raw_decode(' []'), ([], 4)) | |
| self.assertEqual(decoder.raw_decode(' ""'), ('', 5)) | |
| s = ' { "key" : "value" , "k":"v" } \n' \ | |
| ' { "key": "value", "k" :"v"} ' | |
| val1, n1 = decoder.raw_decode(s) | |
| val2, n2 = decoder.raw_decode(s[n1:]) | |
| self.assertEqual(val1, {"key":"value", "k":"v"}) | |
| self.assertEqual(val2, {"key":"value", "k":"v"}) | |
In addition, let's test n1 and n2. And test when there are whitespaces inside the values or keys.
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
Keep only the encoder floatstr deferral here; the decoder whitespace skip is contentious (depends on pythongh-117397 and shows mixed results on large documents) and moves to its own PR.
| Back | FazBrowse Home | New Git URL |
Based on Bayard's patch in https://bugs.python.org/issue15393
Fixes #59598