File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -251,18 +251,14 @@ def __call__(self, *args):
251251 return ValueError ("boom" )
252252
253253 hook = Trigger ()
254- try :
255- json . JSONDecodeError = hook
256- json .decoder . JSONDecodeError = hook
257-
254+ with (
255+ support . swap_attr ( json , " JSONDecodeError" , hook ),
256+ support . swap_attr ( json .decoder , " JSONDecodeError" , hook )
257+ ):
258258 # The exact exception type is not important here;
259259 # this test only ensures we don't crash.
260260 with self .assertRaises (Exception ):
261261 json .loads ('"\\ uZZZZ"' )
262262
263- finally :
264- json .JSONDecodeError = orig_json_error
265- json .decoder .JSONDecodeError = orig_decoder_error
266-
267263class TestPyFail (TestFail , PyTest ): pass
268264class TestCFail (TestFail , CTest ): pass
You can’t perform that action at this time.
0 commit comments