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

chardet 5.0 KeyError with Python 3.10 on Windows #265

Open
cas-- opened this issue Jun 29, 2022 · 5 comments
Open

chardet 5.0 KeyError with Python 3.10 on Windows #265

cas-- opened this issue Jun 29, 2022 · 5 comments

Comments

@cas--
Copy link

cas-- commented Jun 29, 2022

Yesterday I encountered a strange CI failure for our Windows GitHub CI workflows which had been running fine until then. The Python 3.7 job passed fine but the Python 3.10 job failed.

https://github.com/deluge-torrent/deluge/actions/workflows/ci.yml?query=branch%3Adevelop

The only difference I could find from a diff of the logs was the new chardet 5.0.0 being pulled in. So I pinned chardet to 4.0.0 and CI is passing again.

GitHub Actions Environment:

Virtual Environment: windows-2022 (20220626.1)
Python 3.10.5

Just to note that I also tested same error occurs with windows-2019.

The traceback is rather cryptic since it comes from pytest but this is all there is from the job:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\_pytest\main.py", line 264, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\_pytest\config\__init__.py", line 995, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\pluggy\_hooks.py", line 277, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\_pytest\faulthandler.py", line 27, in pytest_configure
INTERNALERROR>     import faulthandler
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1024, in _find_and_load
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 171, in __enter__
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 123, in acquire
INTERNALERROR> KeyError: 1832
cas-- added a commit to deluge-torrent/deluge that referenced this issue Jun 29, 2022
A recent dependency change caused the tests running on GitHub Actions
under Python 3.10.5 on Windows to fail when starting pytest run:

    ...
    INTERNALERROR>   File "<frozen importlib._bootstrap>", line 123, in acquire
    INTERNALERROR> KeyError: xxxx

The cause seems to have been a newer version of chardet package released
recently.

* Fixed by pinning chardet to v4
* Also pin Windows version to 2019 to match packaging workflow

See-also: https://github.com/deluge-torrent/deluge/actions/runs/2578427588
Issue: chardet/chardet#265
@dan-blanchard
Copy link
Member

dan-blanchard commented Jun 29, 2022

Well, that's a baffling one. The traceback doesn't seem to be related to chardet at all

@cas--
Copy link
Author

cas-- commented Jun 30, 2022

It is rather confounding but I have narrowed it down to this commit: 3222295

And looks to be related to importing the module rather than usage, as suspected from pytest traceback, and I'll continue to investigate when I have a spare moment

Testing with 3.8 and 3.9 didn't show any issues, just 3.10 affected

As an aside the KeyError is a result of the pytest faulthandler calls rather than originating error, as mentioned here with pdb: https://bugs.python.org/issue34609#msg326674

@jayaddison
Copy link

(:wave: I landed here as part of reading the state of any bugs related to chardet v5.0.0)

Although I'm not 100% certain, it looks like this could be related to the issue described in python/cpython#/91351 -- the lock-acquisition methods named in the stacktrace are the same, and so is the exception class raised.

@dan-blanchard
Copy link
Member

I added Mac and Windows testing to our build matrix in #267 and I can't reproduce this issue.

@jayaddison
Copy link

The (likely intermittent) issue that appeared here has, I think, been resolved by gh-91351 in v3.12a5 of Python. It's still a while until the scheduled release of Py3.12 final -- to mention nothing of CI config for chardet -- so maybe it's a distraction to even mention - but I get the sense that this has been resolved.

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

No branches or pull requests

3 participants