Commit d1cccc3
Make embed tests compatible with Python 3.12+ behavior changes
Three CPython behavior changes surfaced as failures/crashes once the
overload-resolution crash was fixed, all on 3.12+:
- ClassManagerTests.BindsCorrectOverloadForClassName crashed the host with
"Python memory allocator called without holding the GIL". TestClass2's
Get(PyObject o) re-enters Python via ToPython() while MethodBinder has
released the GIL (allow_threads) around the managed call. A managed
callback that re-enters Python must re-acquire the GIL; tolerated on
<=3.11, fatal on 3.12+. Wrap the body in using (Py.GIL()).
- TestGetsPythonCodeInfoInStackTrace[ForNestedInterop]: 3.12+ adds caret
indicator lines (e.g. "~~~^^^") under source lines in tracebacks, shifting
the positional assertions. Drop caret-only lines before asserting
(no-op on <=3.11).
- Codecs.ExceptionDecodedNoInstance: 3.12 eagerly normalizes exceptions, so
the error indicator always carries an instance ("value"); the instanceless
scenario this decoder targets can no longer be produced. Guard the test to
<3.12.
Verified: full embed suite green on 3.11 (910/910) with these changes; the
three previously-failing tests pass on 3.14.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent bfdfebb commit d1cccc3
3 files changed
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
965 | 965 | | |
966 | 966 | | |
967 | 967 | | |
968 | | - | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
969 | 976 | | |
970 | 977 | | |
971 | 978 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
364 | 372 | | |
365 | 373 | | |
366 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
239 | 244 | | |
240 | 245 | | |
241 | 246 | | |
| |||
298 | 303 | | |
299 | 304 | | |
300 | 305 | | |
301 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
302 | 312 | | |
303 | 313 | | |
304 | 314 | | |
| |||
0 commit comments