Skip to content

Commit

Permalink
sapling: demandimport: Fix unknown python exception, module `threadin…
Browse files Browse the repository at this point in the history
…g` 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
  • Loading branch information
markbhasawut committed Oct 27, 2024
1 parent c78a196 commit 0792e4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eden/scm/sapling/hgdemandimport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"__builtin__",
"builtins",
"urwid.command_map", # for pudb
"_thread", # For RLock
# threading is locally imported by importlib.util.LazyLoader.exec_module
"_weakrefset",
"warnings",
"threading", # For RLock
"_scandir", # for IPython
"collections.abc", # for IPython - pickleshare
"sqlite3", # for IPython to detect missing sqlite
Expand Down

0 comments on commit 0792e4f

Please sign in to comment.