Commit 270082e
committed
stubgen: don't recurse forever on a class that refers back to itself
generate_class_stub() recurses into every attribute whose value is a class
defined in the same module, so a class that exposes itself (C.C = C), or a
pair of classes that expose each other, makes it recurse until Python raises
RecursionError.
Skip an attribute whose value is the class currently being generated or any
class enclosing it: such an attribute is a back reference, not a nested class.
Fixes #119891 parent 5bb72b7 commit 270082e
2 files changed
Lines changed: 53 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
864 | 868 | | |
865 | 869 | | |
866 | 870 | | |
| |||
920 | 924 | | |
921 | 925 | | |
922 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
923 | 940 | | |
924 | 941 | | |
925 | 942 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
953 | 953 | | |
954 | 954 | | |
955 | 955 | | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
956 | 975 | | |
957 | 976 | | |
958 | 977 | | |
| |||
1004 | 1023 | | |
1005 | 1024 | | |
1006 | 1025 | | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1007 | 1042 | | |
1008 | 1043 | | |
1009 | 1044 | | |
| |||
0 commit comments