mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 11:28:14 +00:00
utils: fix unimporting partially-imported modules
Previously, delattr from the parent package might throw KeyError.
This commit is contained in:
parent
75e65bbb2d
commit
2c2930c663
@ -28,8 +28,12 @@ def unimport_end(mods):
|
||||
continue
|
||||
path = mod[:i]
|
||||
name = mod[i + 1 :]
|
||||
if path in sys.modules:
|
||||
try:
|
||||
delattr(sys.modules[path], name)
|
||||
except KeyError:
|
||||
# either path is not present in sys.modules, or module is not
|
||||
# referenced from the parent package. both is fine.
|
||||
pass
|
||||
# collect removed modules
|
||||
gc.collect()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user