Commit 4cbc995
committed
Flatten handlers
pyflakes has traditionally recursed with a handler for every
level of the ast. The ast depth can become very large, especially
for an expression containing many binary operators.
Python has a maximum recursion limit, defaulting to a low number
like 1000, which resulted in a RuntimeError for the ast of:
x = 1 + 2 + 3 + ... + 1001
This change avoids recursing for nodes that do not have a specific
handler.
Checker.nodeDepth and node.depth changes from always being the
ast depth, which varied between Python version due to ast differences,
to being the number of nested handlers within pyflakes.1 parent 434bbb0 commit 4cbc995
2 files changed
+136
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
| 815 | + | |
815 | 816 | | |
816 | 817 | | |
817 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
818 | 851 | | |
819 | 852 | | |
820 | 853 | | |
| |||
844 | 877 | | |
845 | 878 | | |
846 | 879 | | |
847 | | - | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
848 | 886 | | |
849 | 887 | | |
850 | 888 | | |
| |||
855 | 893 | | |
856 | 894 | | |
857 | 895 | | |
858 | | - | |
859 | | - | |
| 896 | + | |
| 897 | + | |
860 | 898 | | |
861 | | - | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
862 | 904 | | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
863 | 908 | | |
864 | 909 | | |
865 | 910 | | |
| |||
911 | 956 | | |
912 | 957 | | |
913 | 958 | | |
914 | | - | |
915 | | - | |
916 | | - | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
917 | 963 | | |
918 | 964 | | |
919 | 965 | | |
920 | 966 | | |
921 | 967 | | |
922 | 968 | | |
923 | | - | |
| 969 | + | |
924 | 970 | | |
925 | 971 | | |
926 | 972 | | |
927 | 973 | | |
928 | | - | |
| 974 | + | |
929 | 975 | | |
930 | 976 | | |
931 | 977 | | |
| |||
937 | 983 | | |
938 | 984 | | |
939 | 985 | | |
940 | | - | |
| 986 | + | |
| 987 | + | |
941 | 988 | | |
942 | 989 | | |
943 | 990 | | |
| |||
1017 | 1064 | | |
1018 | 1065 | | |
1019 | 1066 | | |
1020 | | - | |
| 1067 | + | |
1021 | 1068 | | |
1022 | 1069 | | |
1023 | 1070 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
1084 | 1086 | | |
1085 | 1087 | | |
1086 | 1088 | | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
1087 | 1133 | | |
1088 | 1134 | | |
1089 | 1135 | | |
| |||
1168 | 1214 | | |
1169 | 1215 | | |
1170 | 1216 | | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1171 | 1222 | | |
1172 | 1223 | | |
1173 | 1224 | | |
| |||
1374 | 1425 | | |
1375 | 1426 | | |
1376 | 1427 | | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1377 | 1435 | | |
1378 | 1436 | | |
1379 | 1437 | | |
| |||
1715 | 1773 | | |
1716 | 1774 | | |
1717 | 1775 | | |
| 1776 | + | |
1718 | 1777 | | |
| 1778 | + | |
1719 | 1779 | | |
1720 | 1780 | | |
1721 | 1781 | | |
| |||
1782 | 1842 | | |
1783 | 1843 | | |
1784 | 1844 | | |
| 1845 | + | |
| 1846 | + | |
1785 | 1847 | | |
1786 | 1848 | | |
1787 | 1849 | | |
| |||
1790 | 1852 | | |
1791 | 1853 | | |
1792 | 1854 | | |
| 1855 | + | |
1793 | 1856 | | |
| 1857 | + | |
1794 | 1858 | | |
1795 | 1859 | | |
1796 | 1860 | | |
| |||
1808 | 1872 | | |
1809 | 1873 | | |
1810 | 1874 | | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
0 commit comments