|
28 | 28 | Tracer,
|
29 | 29 | )
|
30 | 30 |
|
| 31 | + |
| 32 | +# I don't understand why, but if we use `cast(set[TLineNo], ...)` inside |
| 33 | +# the _trace() function, we get some strange behavior on PyPy 3.10. |
| 34 | +# Assigning these names here and using them below fixes the problem. |
| 35 | +# See https://github.com/nedbat/coveragepy/issues/1902 |
| 36 | +set_TLineNo = set[TLineNo] |
| 37 | +set_TArc = set[TArc] |
| 38 | + |
| 39 | + |
31 | 40 | # We need the YIELD_VALUE opcode below, in a comparison-friendly form.
|
32 | 41 | # PYVERSIONS: RESUME is new in Python3.11
|
33 | 42 | RESUME = dis.opmap.get("RESUME")
|
@@ -253,9 +262,9 @@ def _trace(
|
253 | 262 | flineno: TLineNo = frame.f_lineno
|
254 | 263 |
|
255 | 264 | if self.trace_arcs:
|
256 |
| - cast(set[TArc], self.cur_file_data).add((self.last_line, flineno)) |
| 265 | + cast(set_TArc, self.cur_file_data).add((self.last_line, flineno)) |
257 | 266 | else:
|
258 |
| - cast(set[TLineNo], self.cur_file_data).add(flineno) |
| 267 | + cast(set_TLineNo, self.cur_file_data).add(flineno) |
259 | 268 | self.last_line = flineno
|
260 | 269 |
|
261 | 270 | elif event == "return":
|
@@ -286,7 +295,7 @@ def _trace(
|
286 | 295 | real_return = True
|
287 | 296 | if real_return:
|
288 | 297 | first = frame.f_code.co_firstlineno
|
289 |
| - cast(set[TArc], self.cur_file_data).add((self.last_line, -first)) |
| 298 | + cast(set_TArc, self.cur_file_data).add((self.last_line, -first)) |
290 | 299 |
|
291 | 300 | # Leaving this function, pop the filename stack.
|
292 | 301 | self.cur_file_data, self.cur_file_name, self.last_line, self.started_context = (
|
|
0 commit comments