Commit 30c2cf8
committed
Fix warn mode to work when warnings are configured as errors
Remove catch_warnings() workaround from production code and instead
fix the root cause: tests were allowing sys.warnoptions to leak into
the forkserver subprocess via _args_from_interpreter_flags().
When CI runs with -W error, the forkserver subprocess was inheriting
this flag and converting our ImportWarning calls into exceptions,
causing it to crash.
Solution: Save and clear sys.warnoptions in test setUp, restore in
tearDown. This gives the forkserver subprocess a clean warning state
where warnings.warn() works as intended.
Also remove unnecessary set_forkserver_preload([]) call from tearDown.1 parent 6d4c521 commit 30c2cf8
File tree
2 files changed
+14
-15
lines changed- Lib
- multiprocessing
- test/test_multiprocessing_forkserver
2 files changed
+14
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
254 | 252 | | |
255 | 253 | | |
256 | 254 | | |
| |||
265 | 263 | | |
266 | 264 | | |
267 | 265 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
275 | 271 | | |
276 | 272 | | |
277 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| 20 | + | |
17 | 21 | | |
18 | | - | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
0 commit comments