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

AttributeError: module 'collections' has no attribute 'MutableMapping' in Python 3.12 #3090

Closed
dev-msln opened this issue May 19, 2024 · 4 comments

Comments

@dev-msln
Copy link

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

1- install a Django project with Python3.12 docker image.
2- install the sentry-sdk latest version (pip install sentry-sdk==2.2.0)
3- add sentry to django setting
4- run the django project and you face the error

Expected Result

Django should start without any issues. On Python 3.9 it was fine. recently I upgraded Python version to 3.12 in my project and after that, it won't work.

Python 3.12
Django 4.2

Actual Result

import sentry_sdk
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/init.py", line 1, in
from sentry_sdk.hub import Hub, init
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/hub.py", line 5, in
from sentry_sdk.scope import Scope, _ScopeManager
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/scope.py", line 11, in
from sentry_sdk.attachments import Attachment
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/attachments.py", line 5, in
from sentry_sdk.envelope import Item, PayloadRef
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/envelope.py", line 6, in
from sentry_sdk.session import Session
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/session.py", line 5, in
from sentry_sdk.utils import format_timestamp
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1302, in
HAS_REAL_CONTEXTVARS, ContextVar = _get_contextvars()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1272, in _get_contextvars
if not _is_contextvars_broken():
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1213, in _is_contextvars_broken
from eventlet.patcher import is_monkey_patched # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/eventlet/init.py", line 6, in
from eventlet import convenience
File "/usr/local/lib/python3.12/site-packages/eventlet/convenience.py", line 7, in
from eventlet.green import socket
File "/usr/local/lib/python3.12/site-packages/eventlet/green/socket.py", line 21, in
from eventlet.support import greendns
File "/usr/local/lib/python3.12/site-packages/eventlet/support/greendns.py", line 78, in
setattr(dns, pkg, import_patched('dns.' + pkg))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/eventlet/support/greendns.py", line 60, in import_patched
return patcher.import_patched(module_name, **modules)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/eventlet/patcher.py", line 132, in import_patched
return inject(
^^^^^^^
File "/usr/local/lib/python3.12/site-packages/eventlet/patcher.py", line 109, in inject
module = import(module_name, {}, {}, module_name.split('.')[:-1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/dns/namedict.py", line 35, in
class NameDict(collections.MutableMapping):
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'

Product Area

Unknown

Link

No response

DSN

https://lk-xo.sentry.io/projects/backend-lk/

Version

No response

@getsantry
Copy link

getsantry bot commented May 19, 2024

Assigning to @getsentry/support for routing ⏲️

@JLuse JLuse transferred this issue from getsentry/sentry May 20, 2024
@sentrivana
Copy link
Contributor

Hey @dev-msln, thanks for reporting. It looks like a dependency of yours isn't Python 3.12 compatible since it tries to import MutableMapping from collections instead of collections.abc, where it was moved in 3.10.

What version of eventlet are you running?

@dev-msln
Copy link
Author

@sentrivana Hi. Thank you for your response.
The issue was related to dnspython lib. After upgrading it to the latest version, the issue has been fixed.

@sentrivana
Copy link
Contributor

Thanks for the follow up @dev-msln!

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

No branches or pull requests

2 participants