Commit 25baa75
ref: Remove residual Python 2 compatibility code
Python 2 support was dropped in SDK 2.0.0, but several Python 2 shims,
dead branches, and stale comments remained. Clean them up:
- Delete `with_metaclass()` from `_compat.py` and rewrite
`class Hub(with_metaclass(HubMeta))` to use the native `metaclass=`
keyword (also drops a `type: ignore`).
- Remove the `im_class`/`im_func` try/except in `qualname_from_function`
(unreachable on Python 3) and collapse the `__qualname__` vs
`__name__` elif in both `utils.qualname_from_function` and the Django
`signals_handlers._get_receiver_name` (Py3 always has `__qualname__`).
- Drop the `try: ModuleNotFoundError except Exception: ImportError`
shim in `client.py` — `ModuleNotFoundError` has existed since Py3.6 —
and use `ModuleNotFoundError` directly at the call site.
- Replace `super(_Client, self).__init__(...)` with `super().__init__(...)`.
- Remove the `bdist_wheel universal=1` option from `setup.py`; universal
wheels are for Py2/Py3-compatible packages and do not apply here.
- Strip misleading Py2 references from comments in the Django middleware
integration and in `tests/conftest.py`.
No behavior change. Minimum supported Python stays at 3.6 — Python 3.6-vs-later
compat code (e.g. `aiocontextvars`, `nullcontext`, `re.Pattern` fallback) is
intentionally left alone.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent e476bf5 commit 25baa75
8 files changed
Lines changed: 5 additions & 50 deletions
File tree
- sentry_sdk
- integrations/django
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | 3 | | |
12 | 4 | | |
13 | 5 | | |
14 | 6 | | |
15 | 7 | | |
16 | 8 | | |
17 | 9 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 10 | | |
27 | 11 | | |
28 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 170 | | |
179 | 171 | | |
180 | 172 | | |
| |||
289 | 281 | | |
290 | 282 | | |
291 | 283 | | |
292 | | - | |
| 284 | + | |
293 | 285 | | |
294 | 286 | | |
295 | 287 | | |
| |||
318 | 310 | | |
319 | 311 | | |
320 | 312 | | |
321 | | - | |
| 313 | + | |
322 | 314 | | |
323 | 315 | | |
324 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | | - | |
| 111 | + | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1472 | 1472 | | |
1473 | 1473 | | |
1474 | 1474 | | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | 1475 | | |
1486 | 1476 | | |
1487 | 1477 | | |
| |||
1499 | 1489 | | |
1500 | 1490 | | |
1501 | 1491 | | |
1502 | | - | |
1503 | | - | |
1504 | 1492 | | |
1505 | | - | |
1506 | 1493 | | |
1507 | 1494 | | |
1508 | 1495 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | 116 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
531 | | - | |
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
| |||
548 | 546 | | |
549 | 547 | | |
550 | 548 | | |
551 | | - | |
552 | | - | |
553 | | - | |
| 549 | + | |
| 550 | + | |
554 | 551 | | |
555 | 552 | | |
556 | 553 | | |
| |||
0 commit comments