Commit f64d739
committed
BUG: Preserve sys.path during Slicer module discovery
This fixes a regression introduced in fa915a0 ("BUG: Fix improper Python
initialization causing inconsistent interpreter state", 2025-07-17) in which
calling `_PyInterpreterState_SetConfig` allowed to update the the argv values
associated with the Python config but with the unintended side effect of resetting
the `config.module_search_paths`. This commit ensures the `sys.path` updated
during module discovery and prior calling `qSlicerCoreApplication::handleCommandLineArguments`
where the config is "reinitialized" is restored.
Here are the steps:
- Captures the initial `sys.path` before applying configuration.
- Restores the exact `sys.path` after configuration is applied.
- Ensures modifications to `sys.path` by modules are preserved.
Notes:
- Setting `config.module_search_paths_set=1` alone is insufficient because
the copied config may not include runtime additions to `sys.path`.1 parent a125c00 commit f64d739
1 file changed
+26
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
1263 | 1264 | | |
1264 | 1265 | | |
1265 | 1266 | | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1266 | 1289 | | |
1267 | 1290 | | |
1268 | 1291 | | |
1269 | 1292 | | |
1270 | 1293 | | |
1271 | 1294 | | |
1272 | 1295 | | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1273 | 1299 | | |
1274 | 1300 | | |
1275 | 1301 | | |
| |||
0 commit comments