File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -237,30 +237,28 @@ def test_linecol(self):
237237 (line , col , idx ))
238238
239239 def test_reentrant_jsondecodeerror_does_not_crash (self ):
240+ # gh-143544
240241 import json
241242
242243 orig_json_error = json .JSONDecodeError
243244 orig_decoder_error = json .decoder .JSONDecodeError
244245
245246 class Trigger :
246247 def __call__ (self , * args ):
247- import json as mod
248248 # Remove JSONDecodeError during construction to trigger re-entrancy
249- if hasattr (mod , "JSONDecodeError" ):
250- del mod .JSONDecodeError
251- if hasattr (mod .decoder , "JSONDecodeError" ):
252- del mod .decoder .JSONDecodeError
249+ del json .JSONDecodeError
250+ del json .decoder .JSONDecodeError
253251 return ValueError ("boom" )
254252
255253 hook = Trigger ()
256254 try :
257255 json .JSONDecodeError = hook
258256 json .decoder .JSONDecodeError = hook
259257
260- # The exact exception type is not important here; the test
261- # only verifies that we do not crash or trigger a SystemError .
258+ # The exact exception type is not important here;
259+ # this test only ensures we don't crash.
262260 with self .assertRaises (Exception ):
263- self .loads ('"\\ uZZZZ"' )
261+ json .loads ('"\\ uZZZZ"' )
264262
265263 finally :
266264 json .JSONDecodeError = orig_json_error
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments