diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index d06d84cbdfc..d29afffebf8 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -29,6 +29,9 @@ __all__ = [ import _collections_abc import sys as _sys +_sys.modules['collections.abc'] = _collections_abc +abc = _collections_abc + from itertools import chain as _chain from itertools import repeat as _repeat from itertools import starmap as _starmap diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py deleted file mode 100644 index 034ba377a0d..00000000000 --- a/Lib/collections/abc.py +++ /dev/null @@ -1,3 +0,0 @@ -import _collections_abc -import sys -sys.modules[__name__] = _collections_abc diff --git a/Misc/NEWS.d/next/Library/2024-10-11-00-40-13.gh-issue-125245.8vReM-.rst b/Misc/NEWS.d/next/Library/2024-10-11-00-40-13.gh-issue-125245.8vReM-.rst new file mode 100644 index 00000000000..c880efe73d0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-11-00-40-13.gh-issue-125245.8vReM-.rst @@ -0,0 +1,2 @@ +Fix race condition when importing :mod:`collections.abc`, which could +incorrectly return an empty module.