Commit cba06ba
committed
gh-130472: Fix pyrepl fancycompleter edge cases
Keep pyrepl completion logic working on the uncolored completion text.
The reader now strips ANSI escapes before comparing the typed stem,
inserting a sole completion, computing the shared prefix, and filtering
an open completion menu. This fixes colored completions that would stop
refining correctly once more characters were typed.
Restore readline's callable postfix behavior for attribute completions by
routing single attribute matches through rlcompleter's callable postfix
logic while keeping the full expr.attr stem for menu refinement. Global
completion also treats soft keywords as keywords instead of trying to
evaluate them.
Avoid side effects while probing attribute values for coloring by not
forcing property access and by preserving lazy module imports. Also make
the fake color-sorting escape prefix round-trip cleanly once the match
index grows past three digits.
Only honor PYTHON_BASIC_COMPLETER when the environment is enabled, so
pyrepl setup now respects -E / sys.flags.ignore_environment. Add
regression tests for the reader behavior, callable attribute completion,
property and lazy-import safety, large color-sort prefixes, and the -E
setup path.1 parent 9b9b37d commit cba06ba
File tree
5 files changed
+255
-57
lines changed- Lib
- _pyrepl
- test/test_pyrepl
5 files changed
+255
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| 182 | + | |
182 | 183 | | |
183 | 184 | | |
184 | | - | |
| 185 | + | |
185 | 186 | | |
186 | | - | |
| 187 | + | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
218 | | - | |
| 220 | + | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
| |||
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
68 | | - | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
73 | | - | |
| 80 | + | |
74 | 81 | | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
79 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
80 | 114 | | |
81 | 115 | | |
82 | | - | |
| 116 | + | |
83 | 117 | | |
84 | 118 | | |
85 | 119 | | |
86 | | - | |
| 120 | + | |
87 | 121 | | |
88 | 122 | | |
89 | 123 | | |
| |||
112 | 146 | | |
113 | 147 | | |
114 | 148 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
119 | 163 | | |
120 | 164 | | |
121 | | - | |
| 165 | + | |
122 | 166 | | |
123 | 167 | | |
124 | 168 | | |
125 | 169 | | |
126 | 170 | | |
127 | 171 | | |
128 | 172 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 173 | + | |
145 | 174 | | |
146 | 175 | | |
147 | | - | |
| 176 | + | |
148 | 177 | | |
149 | 178 | | |
150 | 179 | | |
151 | 180 | | |
152 | 181 | | |
153 | 182 | | |
154 | 183 | | |
155 | | - | |
| 184 | + | |
156 | 185 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
161 | 190 | | |
162 | 191 | | |
163 | | - | |
| 192 | + | |
164 | 193 | | |
165 | 194 | | |
166 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
614 | 618 | | |
615 | 619 | | |
616 | 620 | | |
| |||
0 commit comments