See https://github.com/getsentry/sentry-python/commit/c1cf0fef79db0d7ebe5c640ab0fe0f7ae06c9d21 - ported in https://github.com/getsentry/sentry-python/pull/4090 - missing part added in https://github.com/getsentry/sentry-python/pull/4104