Skip to content

Commit

Permalink
check python version before import imp
Browse files Browse the repository at this point in the history
  • Loading branch information
wsyxbcl authored Aug 13, 2024
1 parent 1488566 commit b7812d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utool/util_inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,15 @@ def rrr(verbose=True):
if not __RELOAD_OK__:
raise Exception('Reloading has been forced off')
try:
import imp
v = sys.version_info
if v.major >= 3 and v.minor >= 4:
import importlib
importlib.reload(module)
else:
import imp
imp.reload(module)
if verbose and not QUIET:
builtins.print('RELOAD: ' + str(module_prefix) + ' __name__=' + module_name)
imp.reload(module)
except Exception as ex:
print(ex)
print('%s Failed to reload' % module_prefix)
Expand Down

0 comments on commit b7812d2

Please sign in to comment.