Opened 2 months ago
Last modified 2 months ago
#35756 closed Bug
Auto reload raises TypeError: unhashable type: 'types.SimpleNamespace' — at Initial Version
Reported by: | Paul Petersik | Owned by: | |
---|---|---|---|
Component: | Utilities | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The iter_modules_and_files
function from django.utils.autoreload
raises TypeError: unhashable type: 'types.SimpleNamespace'
when a types.SimpleNamespace
is put into sys.modules
.
This is for instance the case when the zipp>=3.18.2
package is used (see https://github.com/jaraco/zipp/blob/d66007a66b7dbd88e69eaf59faae8b614cba256d/zipp/compat/overlay.py#L23) which is used by importlib_meta>=8.5.0
(see https://github.com/python/importlib_metadata/blob/90073b1aa7a49cc5fdbdc0e6e871f39e461b9422/pyproject.toml#L21)
The error can be reproduced by putting from zipp.compat.overlay import zipfile
somewhere in your django project.
This problem was already discussed and analyzed on stackoverflow:
https://stackoverflow.com/questions/78977665/django-autoreload-raises-typeerror-unhashable-type-types-simplenamespace/78977785#78977785