Commit ef9ff07
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 8aee490 commit ef9ff07
1 file changed
+25
-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 | | |
| |||
1217 | 1218 | | |
1218 | 1219 | | |
1219 | 1220 | | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1220 | 1240 | | |
1221 | 1241 | | |
1222 | 1242 | | |
| |||
1263 | 1283 | | |
1264 | 1284 | | |
1265 | 1285 | | |
| 1286 | + | |
| 1287 | + | |
1266 | 1288 | | |
1267 | 1289 | | |
1268 | 1290 | | |
1269 | 1291 | | |
1270 | 1292 | | |
1271 | 1293 | | |
1272 | 1294 | | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
1273 | 1298 | | |
1274 | 1299 | | |
1275 | 1300 | | |
| |||
0 commit comments