File tree Expand file tree Collapse file tree 3 files changed +10
-0
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 1717import time
1818import unittest
1919from unittest import mock
20+ import _imp
2021
2122from test .support import os_helper
2223from test .support import (
@@ -529,6 +530,13 @@ def test_dll_dependency_import(self):
529530 env = env ,
530531 cwd = os .path .dirname (pyexe ))
531532
533+ def test_issue105979 (self ):
534+ # this used to crash
535+ with self .assertRaises (ImportError ) as cm :
536+ _imp .get_frozen_object ("x" , b"6\' \xd5 Cu\x12 " )
537+ self .assertIn ("Frozen object named 'x' is invalid" ,
538+ str (cm .exception ))
539+
532540
533541@skip_if_dont_write_bytecode
534542class FilePermissionTests (unittest .TestCase ):
Original file line number Diff line number Diff line change 1+ Fix crash in :func: `!_imp.get_frozen_object ` due to improper exception handling.
Original file line number Diff line number Diff line change @@ -1327,6 +1327,7 @@ unmarshal_frozen_code(struct frozen_info *info)
13271327 PyObject * co = PyMarshal_ReadObjectFromString (info -> data , info -> size );
13281328 if (co == NULL ) {
13291329 /* Does not contain executable code. */
1330+ PyErr_Clear ();
13301331 set_frozen_error (FROZEN_INVALID , info -> nameobj );
13311332 return NULL ;
13321333 }
You can’t perform that action at this time.
0 commit comments