Skip to content
Snippets Groups Projects
Commit 847f703a4d13 authored by kiilerix's avatar kiilerix
Browse files

utils: imp module is removed in Python 3.12 - get is_frozen() from _imp

imp has been deprecated for a long time, and has finally been removed in Python
3.12 .

The successor importlib is using the same internal _imp module as imp, but
doesn't expose it's is_frozen. Using the internal function directly seems like
the cleanest solution.

Another alternative to
  imp.is_frozen("__main__")
is
  sys.modules['__main__'].__spec__.origin == 'frozen'
but that seems even more internal and fragile.
parent b9eb65a1ec14
No related branches found
No related tags found
2 merge requests!647branching: merge stable into default,!627A bunch of 3.12 compat stuff
......@@ -8,7 +8,7 @@
# GNU General Public License version 2 or any later version.
import imp
import _imp
import os
import sys
......@@ -24,7 +24,7 @@
return (
pycompat.safehasattr(sys, "frozen") # new py2exe
or pycompat.safehasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__") # tools/freeze
or _imp.is_frozen("__main__") # tools/freeze
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment