Skip to content

Commit 73f7290

Browse files
committed
sapling: demandimport: Fix unknown python exception, module threading has no attribute Rlock
Summary: When using a recent version of python (3.12), running a sapling command returns the error `unknown python exception`: AttributeError: partially initialized module 'threading' has no attribute 'RLock' (most likely due to a circular import). This is caused by cpython breaking demandimport by `importing` threading locally in `importlib.util.LazyLoader.exec_module`. Adding `threading` along with `warnings`, and `_weakrefset` (which are imported by threading) to demandimport's ignore list resolves the issue. Refs: python/cpython#117983 https://repo.mercurial-scm.org/hg/file/63ede7a43a37/hgdemandimport/__init__.py https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076449 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076747
1 parent c78a196 commit 73f7290

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

eden/scm/sapling/hgdemandimport/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
"__builtin__",
5858
"builtins",
5959
"urwid.command_map", # for pudb
60-
"_thread", # For RLock
60+
# threading is locally imported by importlib.util.LazyLoader.exec_module
61+
"_weakrefset",
62+
"warnings",
63+
"threading", # For RLock
6164
"_scandir", # for IPython
6265
"collections.abc", # for IPython - pickleshare
6366
"sqlite3", # for IPython to detect missing sqlite

0 commit comments

Comments
 (0)