Skip to content

Commit ad20b24

Browse files
committed
gh-129354: Fix grammar in PyErr_FormatUnraisable()
Replace "on verb+ing" with "when verb+ing".
1 parent 49f2465 commit ad20b24

File tree

11 files changed

+42
-42
lines changed

11 files changed

+42
-42
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
183183
DictRemoverObject *self = _DictRemoverObject_CAST(myself);
184184
if (self->key && self->dict) {
185185
if (-1 == PyDict_DelItem(self->dict, self->key)) {
186-
PyErr_FormatUnraisable("Exception ignored on calling _ctypes.DictRemover");
186+
PyErr_FormatUnraisable("Exception ignored when calling _ctypes.DictRemover");
187187
}
188188
Py_CLEAR(self->key);
189189
Py_CLEAR(self->dict);

Modules/_ctypes/callbacks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static void _CallPythonObject(ctypes_state *st,
226226
result = PyObject_Vectorcall(callable, args, nargs, NULL);
227227
if (result == NULL) {
228228
PyErr_FormatUnraisable(
229-
"Exception ignored on calling ctypes callback function %R",
229+
"Exception ignored when calling ctypes callback function %R",
230230
callable);
231231
}
232232

@@ -269,7 +269,7 @@ static void _CallPythonObject(ctypes_state *st,
269269
if (keep == NULL) {
270270
/* Could not convert callback result. */
271271
PyErr_FormatUnraisable(
272-
"Exception ignored on converting result "
272+
"Exception ignored when converting result "
273273
"of ctypes callback function %R",
274274
callable);
275275
}
@@ -282,7 +282,7 @@ static void _CallPythonObject(ctypes_state *st,
282282
"memory leak in callback function.",
283283
1) == -1) {
284284
PyErr_FormatUnraisable(
285-
"Exception ignored on converting result "
285+
"Exception ignored when converting result "
286286
"of ctypes callback function %R",
287287
callable);
288288
}

Modules/getpath.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
955955
) {
956956
Py_DECREF(co);
957957
Py_DECREF(dict);
958-
PyErr_FormatUnraisable("Exception ignored in preparing getpath");
958+
PyErr_FormatUnraisable("Exception ignored when preparing getpath");
959959
return PyStatus_Error("error evaluating initial values");
960960
}
961961

@@ -964,13 +964,13 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
964964

965965
if (!r) {
966966
Py_DECREF(dict);
967-
PyErr_FormatUnraisable("Exception ignored in running getpath");
967+
PyErr_FormatUnraisable("Exception ignored when running getpath");
968968
return PyStatus_Error("error evaluating path");
969969
}
970970
Py_DECREF(r);
971971

972972
if (_PyConfig_FromDict(config, configDict) < 0) {
973-
PyErr_FormatUnraisable("Exception ignored in reading getpath results");
973+
PyErr_FormatUnraisable("Exception ignored when reading getpath results");
974974
Py_DECREF(dict);
975975
return PyStatus_Error("error getting getpath results");
976976
}

Objects/moduleobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ _PyModule_ClearDict(PyObject *d)
703703
PyErr_Clear();
704704
}
705705
if (PyDict_SetItem(d, key, Py_None) != 0) {
706-
PyErr_FormatUnraisable("Exception ignored on clearing module dict");
706+
PyErr_FormatUnraisable("Exception ignored when clearing module dict");
707707
}
708708
}
709709
}
@@ -724,7 +724,7 @@ _PyModule_ClearDict(PyObject *d)
724724
PyErr_Clear();
725725
}
726726
if (PyDict_SetItem(d, key, Py_None) != 0) {
727-
PyErr_FormatUnraisable("Exception ignored on clearing module dict");
727+
PyErr_FormatUnraisable("Exception ignored when clearing module dict");
728728
}
729729
}
730730
}

Python/compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,12 @@ _PyCompile_ExitScope(compiler *c)
704704
assert(c->u);
705705
/* we are deleting from a list so this really shouldn't fail */
706706
if (PySequence_DelItem(c->c_stack, n) < 0) {
707-
PyErr_FormatUnraisable("Exception ignored on removing "
707+
PyErr_FormatUnraisable("Exception ignored when removing "
708708
"the last compiler stack item");
709709
}
710710
if (nested_seq != NULL) {
711711
if (_PyInstructionSequence_AddNested(c->u->u_instr_sequence, nested_seq) < 0) {
712-
PyErr_FormatUnraisable("Exception ignored on appending "
712+
PyErr_FormatUnraisable("Exception ignored when appending "
713713
"nested instruction sequence");
714714
}
715715
}

Python/crossinterp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,28 +670,28 @@ _PyXI_excinfo_InitFromException(_PyXI_excinfo *info, PyObject *exc)
670670
const char *failure = NULL;
671671

672672
if (_excinfo_init_type_from_exception(&info->type, exc) < 0) {
673-
failure = "error while initializing exception type snapshot";
673+
failure = "error when initializing exception type snapshot";
674674
goto error;
675675
}
676676

677677
// Extract the exception message.
678678
PyObject *msgobj = PyObject_Str(exc);
679679
if (msgobj == NULL) {
680-
failure = "error while formatting exception";
680+
failure = "error when formatting exception";
681681
goto error;
682682
}
683683
info->msg = _copy_string_obj_raw(msgobj, NULL);
684684
Py_DECREF(msgobj);
685685
if (info->msg == NULL) {
686-
failure = "error while copying exception message";
686+
failure = "error when copying exception message";
687687
goto error;
688688
}
689689

690690
// Pickle a traceback.TracebackException.
691691
PyObject *tbexc = NULL;
692692
if (_convert_exc_to_TracebackException(exc, &tbexc) < 0) {
693693
#ifdef Py_DEBUG
694-
PyErr_FormatUnraisable("Exception ignored while creating TracebackException");
694+
PyErr_FormatUnraisable("Exception ignored when creating TracebackException");
695695
#endif
696696
PyErr_Clear();
697697
}
@@ -700,7 +700,7 @@ _PyXI_excinfo_InitFromException(_PyXI_excinfo *info, PyObject *exc)
700700
Py_DECREF(tbexc);
701701
if (info->errdisplay == NULL) {
702702
#ifdef Py_DEBUG
703-
PyErr_FormatUnraisable("Exception ignored while formatting TracebackException");
703+
PyErr_FormatUnraisable("Exception ignored when formatting TracebackException");
704704
#endif
705705
PyErr_Clear();
706706
}
@@ -1621,7 +1621,7 @@ _propagate_not_shareable_error(_PyXI_session *session)
16211621
dlcontext_t ctx;
16221622
if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
16231623
PyErr_FormatUnraisable(
1624-
"Exception ignored while propagating not shareable error");
1624+
"Exception ignored when propagating not shareable error");
16251625
return;
16261626
}
16271627
if (PyErr_ExceptionMatches(ctx.PyExc_NotShareableError)) {

Python/errors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
16331633
PyObject *hook_args = make_unraisable_hook_args(
16341634
tstate, exc_type, exc_value, exc_tb, err_msg, obj);
16351635
if (hook_args == NULL) {
1636-
err_msg_str = ("Exception ignored on building "
1636+
err_msg_str = ("Exception ignored when building "
16371637
"sys.unraisablehook arguments");
16381638
goto error;
16391639
}

Python/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,15 +1779,15 @@ do_gc_callback(GCState *gcstate, const char *phase,
17791779
"collected", stats->collected,
17801780
"uncollectable", stats->uncollectable);
17811781
if (info == NULL) {
1782-
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
1782+
PyErr_FormatUnraisable("Exception ignored when invoking gc callbacks");
17831783
return;
17841784
}
17851785
}
17861786

17871787
PyObject *phase_obj = PyUnicode_FromString(phase);
17881788
if (phase_obj == NULL) {
17891789
Py_XDECREF(info);
1790-
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
1790+
PyErr_FormatUnraisable("Exception ignored when invoking gc callbacks");
17911791
return;
17921792
}
17931793

Python/gc_free_threading.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,15 +1427,15 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
14271427
"collected", collected,
14281428
"uncollectable", uncollectable);
14291429
if (info == NULL) {
1430-
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
1430+
PyErr_FormatUnraisable("Exception ignored when invoking gc callbacks");
14311431
return;
14321432
}
14331433
}
14341434

14351435
PyObject *phase_obj = PyUnicode_FromString(phase);
14361436
if (phase_obj == NULL) {
14371437
Py_XDECREF(info);
1438-
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
1438+
PyErr_FormatUnraisable("Exception ignored when invoking gc callbacks");
14391439
return;
14401440
}
14411441

Python/import.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
594594
if (PyList_SetSlice(MODULES_BY_INDEX(interp),
595595
0, PyList_GET_SIZE(MODULES_BY_INDEX(interp)),
596596
NULL)) {
597-
PyErr_FormatUnraisable("Exception ignored on clearing interpreters module list");
597+
PyErr_FormatUnraisable("Exception ignored when clearing interpreters module list");
598598
}
599599
}
600600

@@ -4080,13 +4080,13 @@ _PyImport_FiniCore(PyInterpreterState *interp)
40804080
int verbose = _PyInterpreterState_GetConfig(interp)->verbose;
40814081

40824082
if (_PySys_ClearAttrString(interp, "meta_path", verbose) < 0) {
4083-
PyErr_FormatUnraisable("Exception ignored on clearing sys.meta_path");
4083+
PyErr_FormatUnraisable("Exception ignored when clearing sys.meta_path");
40844084
}
40854085

40864086
// XXX Pull in most of finalize_modules() in pylifecycle.c.
40874087

40884088
if (_PySys_ClearAttrString(interp, "modules", verbose) < 0) {
4089-
PyErr_FormatUnraisable("Exception ignored on clearing sys.modules");
4089+
PyErr_FormatUnraisable("Exception ignored when clearing sys.modules");
40904090
}
40914091

40924092
_PyImport_ClearCore(interp);
@@ -4161,10 +4161,10 @@ _PyImport_FiniExternal(PyInterpreterState *interp)
41614161
// XXX Uninstall importlib metapath importers here?
41624162

41634163
if (_PySys_ClearAttrString(interp, "path_importer_cache", verbose) < 0) {
4164-
PyErr_FormatUnraisable("Exception ignored on clearing sys.path_importer_cache");
4164+
PyErr_FormatUnraisable("Exception ignored when clearing sys.path_importer_cache");
41654165
}
41664166
if (_PySys_ClearAttrString(interp, "path_hooks", verbose) < 0) {
4167-
PyErr_FormatUnraisable("Exception ignored on clearing sys.path_hooks");
4167+
PyErr_FormatUnraisable("Exception ignored when clearing sys.path_hooks");
41684168
}
41694169
}
41704170

0 commit comments

Comments
 (0)