Commit 37f35db
authored
[mypyc] Enable assertions in tests and fix failures (#20553)
For some reason assertions are disabled when running mypyc tests.
Explicitly undefining `NDEBUG` when compiling enables them again so I
have added compiler options to undefine it when requested optimization
level is 0.
Found two issues after enabling them:
- When interning strings there is an assertion that makes calling the
function multiple times crash. It might be called multiple times when
multiple modules are initialized within one compilation unit so I have
added an early return when the strings are already interned.
- `Py_SIZE` has an
[assertion](https://github.com/python/cpython/blob/2750f3c9b5c5e3787ebf4637125c9d746ad4694b/Include/object.h#L231)
to disallow calling it with `PyLong` arguments starting from python
3.12. Compiled code would call it when converting `PyLong` to `int64`.
Instead we can use `PyUnstable_Long_CompactValue`.1 parent 4912d77 commit 37f35db
3 files changed
+13
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
| 683 | + | |
| 684 | + | |
683 | 685 | | |
684 | 686 | | |
685 | 687 | | |
686 | 688 | | |
| 689 | + | |
687 | 690 | | |
688 | 691 | | |
689 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
339 | 344 | | |
340 | 345 | | |
| 346 | + | |
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
0 commit comments