Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sapling: demandimport: Fix unknown python exception, module threading has no attribute Rlock #977

Closed

Conversation

markbhasawut
Copy link
Contributor

@markbhasawut markbhasawut commented Oct 27, 2024

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

…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
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@markbhasawut markbhasawut changed the title sapling: demandimport: Fix unknown python exception, module `threadin… sapling: demandimport: Fix unknown python exception, module threading has no attribute Rlock Oct 27, 2024
@markbhasawut markbhasawut marked this pull request as ready for review October 27, 2024 21:03
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 65a7e90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants