Commit 0db3d59
Allow multiphase modules to be re-imported (#5782)
* Failing unit test
* Potential fix for the issue of re-importing a multi-phase module
- When a module is successfully imported and exec'd, save its handle in a dict in the interpreter state
- Use a special Py_mod_create slot to look in the cache and return the cached handle if it is in the cache
- Don't re-run the user exec function if the module is in the interpreter's cache (implying it was already successfully imported)
* Oops, need to inline these.
* Clang-Tidy fixes
* Oops, debug code
* Add xfail for this GraalPy bug
* Remove static from these function defs, it was a cut-and-paste error in the first place.
* Fix test comment
* Proper error handling
* Oops
* Split up this line, but still just ignore failure .. if the module doesn't have the right properties to check the cache then just allow exec to run.
* Clean up - already looked up the name, just use that.
* Some compilers complain if the pointer isn't taken here, weird.
* Allow attribute errors to be thrown here, will be converted to import errors by the exception handler.
* Remove bogus incref, unconditionally expect a __spec__.name on the module
* Add PR to test comment
* style: pre-commit fixes
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 780ec11 commit 0db3d59
File tree
3 files changed
+76
-3
lines changed- include/pybind11
- detail
- tests
3 files changed
+76
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
459 | 462 | | |
460 | 463 | | |
461 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1329 | 1329 | | |
1330 | 1330 | | |
1331 | 1331 | | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1332 | 1383 | | |
1333 | 1384 | | |
1334 | | - | |
| 1385 | + | |
1335 | 1386 | | |
1336 | 1387 | | |
1337 | 1388 | | |
1338 | | - | |
| 1389 | + | |
1339 | 1390 | | |
1340 | 1391 | | |
1341 | 1392 | | |
1342 | 1393 | | |
1343 | 1394 | | |
| 1395 | + | |
| 1396 | + | |
1344 | 1397 | | |
1345 | 1398 | | |
1346 | 1399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
| |||
0 commit comments