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: pyperformance html5lib cannot import Mapping (and fails)
Type: crash Stage: resolved
Components: Tests Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Travis Lazar, vstinner, xtreak
Priority: normal Keywords:

Created on 2019-11-08 01:30 by Travis Lazar, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (8)
msg356219 - (view) Author: Travis Lazar (Travis Lazar) Date: 2019-11-08 01:30
When running pyperformance html5lib test, the application crashes with "ImportError: cannot import name 'Mapping' from 'collections' (/py3buildpath/lib/python3.9/collections/__init__.py)"

To reproduce:

1 - Build Python from source. I produced with git commit befa032d8869e0fab4732d910f3887642879d644 from cpython GitHub.

2 - Run pyperformance with: /py3buildpath/bin/pyperformance run --python=/py3buildpath/bin/python3 --venv venvpath -b html5lib -o output.json

3 - Immediate crash is seen with message:

#!/bin/sh
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_tokenizer.py", line 16, in <module>
    from ._trie import Trie
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/__init__.py", line 3, in <module>
    from .py import Trie as PyTrie
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/py.py", line 6, in <module>
    from ._base import Trie as ABCTrie
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/_base.py", line 3, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/root/py3-tot-no/lib/python3.9/collections/__init__.py)
ERROR: Benchmark html5lib failed: Benchmark died
Traceback (most recent call last):
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py", line 132, in run_benchmarks
    bench = func(cmd_prefix, options)
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/benchmarks/__init__.py", line 244, in BM_html5lib
    return run_perf_script(python, options, "html5lib")
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py", line 98, in run_perf_script
    run_command(cmd, hide_stderr=not options.verbose)
  File "/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py", line 66, in run_command
    raise RuntimeError("Benchmark died")
RuntimeError: Benchmark died
msg356220 - (view) Author: Travis Lazar (Travis Lazar) Date: 2019-11-08 01:31
Forgot to include that this was built on an aarch64 (Ampere eMAG) system.
msg356221 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-11-08 02:18
collections removed ABC access in 3.9. It seems you are using an older version of pip. Please update to the latest version which has the vendored html5lib package fixed.
msg356227 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-11-08 06:34
Sorry, I misread the traceback itself as if it's from pip. It's from html5lib being incompatible with 3.9 as per the latest release on 1.0.1 (Dec 7, 2017) . There is an issue to request new release with the fix at https://github.com/html5lib/html5lib-python/issues/419 . Maybe you can try building html5lib from their master branch to be used in pyperformance. I would propose closing it as third party.
msg356228 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-08 08:05
I fixed the issue by disabling temporarily the benchmark, until html5lib is fixed:
https://github.com/python/pyperformance/commit/8043c159215836fa733ee0815feecdd359e8852a

--

That's Python bug tracker. The pyperformance bug tracker is at:
https://github.com/python/pyperformance/issues

Your issue is that "import html5lib" fails on Python 3.9 because there is no html5lib release including the fix:
https://github.com/html5lib/html5lib-python/issues/419

The bug has already been fixed in html5lib.

One workaround would be to disable htmllib benchmark on Python 3.9 until https://github.com/html5lib/html5lib-python/issues/419 is fixed.

--

> collections removed ABC access in 3.9.

That's bpo-25988 with commit ef092fe9905f61ca27889092ca1248a11aa74498.

--

pip backported the html5lib patch:
https://github.com/pypa/pip/commit/ef7ca1472c1fdd085cffb8183b7ce8abbe9e2800#diff-2496ad1eedee846e323ed2916d6c2d24

The fix is included in pip since pip 19.3.1.

Note: The ensurepip module of the master branch of Python uses a bundled copy of pip 19.2.3.
msg356252 - (view) Author: Travis Lazar (Travis Lazar) Date: 2019-11-08 17:54
Really appreciate all the commentary and references here. Thanks for that.

The resolution of disabling html5lib in pyperformance is good. I'll assume no html5lib benchmarking in pyperformance (master) until a version of html5lib is released compatible with 3.9.

Thanks again.
msg356402 - (view) Author: Travis Lazar (Travis Lazar) Date: 2019-11-11 23:22
FYI: this affects tornado_http and django_template as well.
msg356487 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-12 21:17
> FYI: this affects tornado_http and django_template as well.

Please report pyperformance issues at:
https://github.com/python/pyperformance/issues
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82920
2019-11-12 21:17:32vstinnersetmessages: + msg356487
2019-11-11 23:22:48Travis Lazarsetmessages: + msg356402
2019-11-08 17:54:30Travis Lazarsetmessages: + msg356252
2019-11-08 08:05:19vstinnersetstatus: open -> closed
resolution: fixed
stage: resolved
2019-11-08 08:05:07vstinnersetnosy: + vstinner
messages: + msg356228
2019-11-08 06:34:55xtreaksetmessages: + msg356227
2019-11-08 02:18:28xtreaksetnosy: + xtreak
messages: + msg356221
2019-11-08 01:31:41Travis Lazarsetmessages: + msg356220
2019-11-08 01:30:55Travis Lazarcreate