# HG changeset patch # User Mads Kiilerich <m...@kiilerich.com> # Date 1687863903 -7200 # Tue Jun 27 13:05:03 2023 +0200 # Branch stable # Node ID f45267a4d61f7687727efa7fe571d4f2522a3bb6 # Parent 85a1bdb7d945c647670761676c97ce716fe3796d 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. diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py --- a/mercurial/utils/resourceutil.py +++ b/mercurial/utils/resourceutil.py @@ -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 @@ def mainfrozen(): 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 ) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@lists.mercurial-scm.org https://lists.mercurial-scm.org/mailman/listinfo/mercurial-devel