@@ -501,7 +501,13 @@ future_init(FutureObj *fut, PyObject *loop)
|
501 | 501 | if (is_true < 0) { |
502 | 502 | return -1; |
503 | 503 | } |
504 | | -if (is_true) { |
| 504 | +if (is_true && !_Py_IsFinalizing()) { |
| 505 | +/* Only try to capture the traceback if the interpreter is not being |
| 506 | + finalized. The original motivation to add a `_Py_IsFinalizing()` |
| 507 | + call was to prevent SIGSEGV when a Future is created in a __del__ |
| 508 | + method, which is called during the interpreter shutdown and the |
| 509 | + traceback module is already unloaded. |
| 510 | + */ |
505 | 511 | fut->fut_source_tb = _PyObject_CallNoArg(traceback_extract_stack); |
506 | 512 | if (fut->fut_source_tb == NULL) { |
507 | 513 | return -1; |
|