Commit 40af9d6
pythongh-132835: Add defensive NULL checks to MRO resolution (pythonGH-134763)
Currently, there are a few places where tp_mro could theoretically
become NULL, but do not in practice. This commit adds defensive checks for
NULL values to ensure that any changes do not introduce a crash and that
state invariants are upheld.
The assertions added in this commit are all instances where a NULL value would get passed to something not expecting a NULL, so it is better to catch an assertion failure than crash later on.
There are a few cases where it is OK for the return of lookup_tp_mro to be NULL, such as when passed to is_subtype_with_mro, which handles this explicitly.
(cherry picked from commit a8edca6)
Co-authored-by: Emma Smith <[email protected]>1 parent a490d67 commit 40af9d6
1 file changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1658 | 1658 | | |
1659 | 1659 | | |
1660 | 1660 | | |
1661 | | - | |
| 1661 | + | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | 1664 | | |
| |||
1669 | 1669 | | |
1670 | 1670 | | |
1671 | 1671 | | |
| 1672 | + | |
1672 | 1673 | | |
1673 | 1674 | | |
1674 | 1675 | | |
| |||
1713 | 1714 | | |
1714 | 1715 | | |
1715 | 1716 | | |
1716 | | - | |
| 1717 | + | |
1717 | 1718 | | |
1718 | 1719 | | |
1719 | 1720 | | |
| |||
1795 | 1796 | | |
1796 | 1797 | | |
1797 | 1798 | | |
1798 | | - | |
| 1799 | + | |
1799 | 1800 | | |
1800 | 1801 | | |
1801 | 1802 | | |
| |||
3291 | 3292 | | |
3292 | 3293 | | |
3293 | 3294 | | |
| 3295 | + | |
3294 | 3296 | | |
3295 | 3297 | | |
3296 | 3298 | | |
| |||
3325 | 3327 | | |
3326 | 3328 | | |
3327 | 3329 | | |
| 3330 | + | |
3328 | 3331 | | |
3329 | 3332 | | |
3330 | | - | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
3331 | 3336 | | |
3332 | 3337 | | |
3333 | 3338 | | |
| |||
8623 | 8628 | | |
8624 | 8629 | | |
8625 | 8630 | | |
| 8631 | + | |
8626 | 8632 | | |
8627 | 8633 | | |
8628 | 8634 | | |
| |||
0 commit comments