Commit 3599dc7
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 df35beb commit 3599dc7
1 file changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1499 | 1499 | | |
1500 | 1500 | | |
1501 | 1501 | | |
1502 | | - | |
| 1502 | + | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | 1505 | | |
| |||
1510 | 1510 | | |
1511 | 1511 | | |
1512 | 1512 | | |
| 1513 | + | |
1513 | 1514 | | |
1514 | 1515 | | |
1515 | 1516 | | |
| |||
1554 | 1555 | | |
1555 | 1556 | | |
1556 | 1557 | | |
1557 | | - | |
| 1558 | + | |
1558 | 1559 | | |
1559 | 1560 | | |
1560 | 1561 | | |
| |||
1636 | 1637 | | |
1637 | 1638 | | |
1638 | 1639 | | |
1639 | | - | |
| 1640 | + | |
1640 | 1641 | | |
1641 | 1642 | | |
1642 | 1643 | | |
| |||
2865 | 2866 | | |
2866 | 2867 | | |
2867 | 2868 | | |
| 2869 | + | |
2868 | 2870 | | |
2869 | 2871 | | |
2870 | 2872 | | |
| |||
2899 | 2901 | | |
2900 | 2902 | | |
2901 | 2903 | | |
| 2904 | + | |
2902 | 2905 | | |
2903 | 2906 | | |
2904 | | - | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
2905 | 2910 | | |
2906 | 2911 | | |
2907 | 2912 | | |
| |||
8014 | 8019 | | |
8015 | 8020 | | |
8016 | 8021 | | |
| 8022 | + | |
8017 | 8023 | | |
8018 | 8024 | | |
8019 | 8025 | | |
| |||
0 commit comments