Issue 30877: possibe typo in json/scanner.py (original) (raw)

Created on 2017-07-08 06:48 by c-fos, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2632 closed python-dev,2017-07-08 06:48
PR 7048 merged serhiy.storchaka,2018-05-22 10:08
PR 7053 merged miss-islington,2018-05-22 11:56
PR 7054 merged miss-islington,2018-05-22 11:57
Messages (7)
msg297945 - (view) Author: c-fos (c-fos) * Date: 2017-07-08 06:48
Should "py_make_scanner" return "scan_once" function rather than "_scan_once"?
msg297949 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-07-08 07:39
Good catch c-fos! The scan_once() wrapper was introduced in , but py_make_scanner() still returns unwrapped _scan_once(). Is it possible to write a test that catches this bug?
msg297951 - (view) Author: c-fos (c-fos) * Date: 2017-07-08 08:40
The possible test: import unittest from json.decoder import JSONDecoder class Memo_Test(unittest.TestCase): def test_for_empty_memo(self): json_str = '{"a": 1}' decoder = JSONDecoder() decoder.decode(json_str) self.assertEqual(decoder.memo, {}) suite = unittest.TestSuite() suite.addTest(Memo_Test("test_for_empty_memo")) runner = unittest.TextTestRunner() runner.run(suite) But it works only when _json import fails
msg297952 - (view) Author: c-fos (c-fos) * Date: 2017-07-08 09:20
Test independent from _json library: import unittest from json.decoder import JSONDecoder from json.scanner import py_make_scanner class Memo_Test(unittest.TestCase): def test_for_empty_memo(self): json_str = '{"a": 1}' decoder = JSONDecoder() decoder.scan_once = py_make_scanner(decoder) result = decoder.decode(json_str) self.assertEqual(result, {"a":1}) self.assertEqual(decoder.memo, {}) suite = unittest.TestSuite() suite.addTest(Memo_Test("test_for_empty_memo")) runner = unittest.TextTestRunner() runner.run(suite)
msg317267 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-22 10:11
Sorry for not fixing this issue earlier. The fix is trivial, but it needed tests. PR 7048 adds a simpler test.
msg317274 - (view) Author: miss-islington (miss-islington) Date: 2018-05-22 13:03
New changeset 25fd6cc5b0ad311bb771ae47ae8173417730bb6a by Miss Islington (bot) in branch '3.7': bpo-30877: Fix clearing a cache in the the JSON decoder. (GH-7048) https://github.com/python/cpython/commit/25fd6cc5b0ad311bb771ae47ae8173417730bb6a
msg317277 - (view) Author: miss-islington (miss-islington) Date: 2018-05-22 13:26
New changeset 2baee0aa77055755ac50e92e64bbccfea4108621 by Miss Islington (bot) in branch '3.6': bpo-30877: Fix clearing a cache in the the JSON decoder. (GH-7048) https://github.com/python/cpython/commit/2baee0aa77055755ac50e92e64bbccfea4108621
History
Date User Action Args
2022-04-11 14:58:48 admin set github: 75060
2018-05-22 15:45:19 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-05-22 13:26:52 miss-islington set messages: +
2018-05-22 13:03:20 miss-islington set nosy: + miss-islingtonmessages: +
2018-05-22 11:57:17 miss-islington set pull_requests: + <pull%5Frequest6688>
2018-05-22 11:56:25 miss-islington set pull_requests: + <pull%5Frequest6687>
2018-05-22 10:14:12 serhiy.storchaka link issue33596 superseder
2018-05-22 10:11:22 serhiy.storchaka set messages: + versions: + Python 3.8, - Python 3.5
2018-05-22 10:08:53 serhiy.storchaka set keywords: + patchpull_requests: + <pull%5Frequest6685>
2017-07-08 09:20:14 c-fos set messages: +
2017-07-08 08:40:42 c-fos set messages: +
2017-07-08 07:39:09 serhiy.storchaka set versions: + Python 3.5, Python 3.6nosy: + serhiy.storchaka, pitroumessages: + stage: patch review
2017-07-08 06:48:37 python-dev set pull_requests: + <pull%5Frequest2697>
2017-07-08 06:48:08 c-fos create