This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: collections: remove deprecated aliases to ABC classes
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: duplicate
Dependencies: Superseder: collections.abc.Indexable
View: 25988
Assigned To: Nosy List: hugovk, serhiy.storchaka, vstinner, xtreak, yan12125
Priority: normal Keywords: patch

Created on 2019-06-17 20:38 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14171 closed vstinner, 2019-06-17 20:44
PR 23754 merged hugovk, 2020-12-13 18:43
Messages (8)
msg345905 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-17 20:38
Extract of collections documentation:
https://docs.python.org/dev/library/collections.html

"Deprecated since version 3.3, will be removed in version 3.9: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.8."

Attached PR removes these aliases.
msg345906 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-17 20:47
pip is broken by this change, causing test_venv to fail: html5lib still uses collections to get ABC.

FAIL: test_with_pip (test.test_venv.EnsurePipTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/prog/python/master/Lib/test/test_venv.py", line 407, in do_test_with_pip
    self.run_with_capture(venv.create, self.env_dir,
  File "/home/vstinner/prog/python/master/Lib/test/test_venv.py", line 69, in run_with_capture
    func(*args, **kwargs)
subprocess.CalledProcessError: Command '['/tmp/tmpkxga42lx/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vstinner/prog/python/master/Lib/test/test_venv.py", line 466, in test_with_pip
    self.do_test_with_pip(False)
  File "/home/vstinner/prog/python/master/Lib/test/test_venv.py", line 415, in do_test_with_pip
    self.fail(msg.format(exc, details))
AssertionError: Command '['/tmp/tmpkxga42lx/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

**Subprocess Output**
/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/pyparsing.py:3068: SyntaxWarning: invalid escape sequence \w
/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/pyparsing.py:3068: SyntaxWarning: invalid escape sequence \w
Traceback (most recent call last):
  File "/home/vstinner/prog/python/master/Lib/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/vstinner/prog/python/master/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/vstinner/prog/python/master/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/home/vstinner/prog/python/master/Lib/ensurepip/__init__.py", line 198, in _main
    return _bootstrap(
  File "/home/vstinner/prog/python/master/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/home/vstinner/prog/python/master/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/__init__.py", line 40, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 8, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 12, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/__init__.py", line 6, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/completion.py", line 6, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 25, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/index.py", line 14, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/__init__.py", line 25, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/html5parser.py", line 8, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/_tokenizer.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/_trie/__init__.py", line 3, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/_trie/py.py", line 6, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpwhk_ss_e/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/html5lib/_trie/_base.py", line 3, in <module>
ImportError: cannot import name 'Mapping' from 'collections' (/home/vstinner/prog/python/master/Lib/collections/__init__.py)
msg345908 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-17 20:54
html5lib has already been fixed:
https://github.com/vstinner/html5lib-python/commit/4f9235752cea29c5a31721440578b430823a1e69

But latest html5lib release was version 1.0.1 at... Dec 7, 2017 :-(

Paul Ganssle requested a new html5lib release... to fix the collections warning :-)
https://github.com/html5lib/html5lib-python/issues/419
msg345923 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-17 21:58
Oh. I wasn't aware of the previous attempt: https://github.com/python/cpython/pull/10596 there is a long discussion there. The blocker issue was also html5lib.
msg348011 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-07-16 10:09
Right now (pip 19.1.1?), "./python -m venv env" still fails because of html5lib/_trie/py.py. There is still no activitiy on the request to get a new release:
https://github.com/html5lib/html5lib-python/issues/419
msg348424 - (view) Author: (yan12125) * Date: 2019-07-25 02:39
In CPython commit 5380def8269b24a8a3bc46396373a1dc91b1dd1a, bundled pip is updated to 19.2.1, and since pip 19.2 an html5lib patch is backported [1] to "prefer importing from collections.abc instead of collections" [2]. I believe https://github.com/python/cpython/pull/10596 can be revisited now.

[1] https://github.com/pypa/pip/commit/ef7ca1472c1fdd085cffb8183b7ce8abbe9e2800
[2] https://github.com/pypa/pip/commit/3d6bb3a29676f880e84014d98afcb5ac74a9844e
msg354092 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-10-07 13:12
I think this can be closed since https://bugs.python.org/issue25988 has the PR merged.
msg384981 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-12 23:16
New changeset c47c78b878ff617164b2b94ff711a6103e781753 by Hugo van Kemenade in branch 'master':
bpo-37324: Remove ABC aliases from collections (GH-23754)
https://github.com/python/cpython/commit/c47c78b878ff617164b2b94ff711a6103e781753
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81505
2021-01-12 23:16:45vstinnersetmessages: + msg384981
2020-12-13 18:43:36hugovksetnosy: + hugovk

pull_requests: + pull_request22611
2019-10-07 13:20:44serhiy.storchakasetstatus: open -> closed
superseder: collections.abc.Indexable
resolution: duplicate
stage: patch review -> resolved
2019-10-07 13:12:36xtreaksetnosy: + serhiy.storchaka, xtreak
messages: + msg354092
2019-08-22 15:54:25vstinnerlinkissue37917 superseder
2019-07-25 02:39:51yan12125setnosy: + yan12125
messages: + msg348424
2019-07-16 10:09:27vstinnersetmessages: + msg348011
2019-06-17 21:58:35vstinnersetmessages: + msg345923
2019-06-17 20:54:20vstinnersetmessages: + msg345908
2019-06-17 20:47:06vstinnersetmessages: + msg345906
2019-06-17 20:44:53vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request14013
2019-06-17 20:38:32vstinnercreate