Skip to content

Commit

Permalink
sapling: demandimport: Fix unknown python exception, module `threadin… (
Browse files Browse the repository at this point in the history
#977)

Summary:
…g` has no attribute `Rlock`

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

Pull Request resolved: #977

Reviewed By: ahornby

Differential Revision: D65039760

fbshipit-source-id: 134258735005cb6710cb3f33e3c23eb3a000bcb6
  • Loading branch information
markbhasawut authored and facebook-github-bot committed Oct 29, 2024
1 parent 969162e commit 65a7e90
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 65a7e90

Please sign in to comment.