Skip to content

Commit ad20b24

Browse files
committed
pythongh-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

Python/pylifecycle.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,13 +1475,13 @@ finalize_modules_delete_special(PyThreadState *tstate, int verbose)
14751475
PySys_WriteStderr("# clear builtins._\n");
14761476
}
14771477
if (PyDict_SetItemString(interp->builtins, "_", Py_None) < 0) {
1478-
PyErr_FormatUnraisable("Exception ignored on setting builtin variable _");
1478+
PyErr_FormatUnraisable("Exception ignored when setting builtin variable _");
14791479
}
14801480

14811481
const char * const *p;
14821482
for (p = sys_deletes; *p != NULL; p++) {
14831483
if (_PySys_ClearAttrString(interp, *p, verbose) < 0) {
1484-
PyErr_FormatUnraisable("Exception ignored on clearing sys.%s", *p);
1484+
PyErr_FormatUnraisable("Exception ignored when clearing sys.%s", *p);
14851485
}
14861486
}
14871487
for (p = sys_files; *p != NULL; p+=2) {
@@ -1492,13 +1492,13 @@ finalize_modules_delete_special(PyThreadState *tstate, int verbose)
14921492
}
14931493
PyObject *value;
14941494
if (PyDict_GetItemStringRef(interp->sysdict, orig_name, &value) < 0) {
1495-
PyErr_FormatUnraisable("Exception ignored on restoring sys.%s", name);
1495+
PyErr_FormatUnraisable("Exception ignored when restoring sys.%s", name);
14961496
}
14971497
if (value == NULL) {
14981498
value = Py_NewRef(Py_None);
14991499
}
15001500
if (PyDict_SetItemString(interp->sysdict, name, value) < 0) {
1501-
PyErr_FormatUnraisable("Exception ignored on restoring sys.%s", name);
1501+
PyErr_FormatUnraisable("Exception ignored when restoring sys.%s", name);
15021502
}
15031503
Py_DECREF(value);
15041504
}
@@ -1510,7 +1510,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
15101510
{
15111511
PyObject *weaklist = PyList_New(0);
15121512
if (weaklist == NULL) {
1513-
PyErr_FormatUnraisable("Exception ignored on removing modules");
1513+
PyErr_FormatUnraisable("Exception ignored when removing modules");
15141514
}
15151515

15161516
#define STORE_MODULE_WEAKREF(name, mod) \
@@ -1519,13 +1519,13 @@ finalize_remove_modules(PyObject *modules, int verbose)
15191519
if (wr) { \
15201520
PyObject *tup = PyTuple_Pack(2, name, wr); \
15211521
if (!tup || PyList_Append(weaklist, tup) < 0) { \
1522-
PyErr_FormatUnraisable("Exception ignored on removing modules"); \
1522+
PyErr_FormatUnraisable("Exception ignored when removing modules"); \
15231523
} \
15241524
Py_XDECREF(tup); \
15251525
Py_DECREF(wr); \
15261526
} \
15271527
else { \
1528-
PyErr_FormatUnraisable("Exception ignored on removing modules"); \
1528+
PyErr_FormatUnraisable("Exception ignored when removing modules"); \
15291529
} \
15301530
}
15311531

@@ -1536,7 +1536,7 @@ finalize_remove_modules(PyObject *modules, int verbose)
15361536
} \
15371537
STORE_MODULE_WEAKREF(name, mod); \
15381538
if (PyObject_SetItem(modules, name, Py_None) < 0) { \
1539-
PyErr_FormatUnraisable("Exception ignored on removing modules"); \
1539+
PyErr_FormatUnraisable("Exception ignored when removing modules"); \
15401540
} \
15411541
}
15421542

@@ -1550,22 +1550,22 @@ finalize_remove_modules(PyObject *modules, int verbose)
15501550
else {
15511551
PyObject *iterator = PyObject_GetIter(modules);
15521552
if (iterator == NULL) {
1553-
PyErr_FormatUnraisable("Exception ignored on removing modules");
1553+
PyErr_FormatUnraisable("Exception ignored when removing modules");
15541554
}
15551555
else {
15561556
PyObject *key;
15571557
while ((key = PyIter_Next(iterator))) {
15581558
PyObject *value = PyObject_GetItem(modules, key);
15591559
if (value == NULL) {
1560-
PyErr_FormatUnraisable("Exception ignored on removing modules");
1560+
PyErr_FormatUnraisable("Exception ignored when removing modules");
15611561
continue;
15621562
}
15631563
CLEAR_MODULE(key, value);
15641564
Py_DECREF(value);
15651565
Py_DECREF(key);
15661566
}
15671567
if (PyErr_Occurred()) {
1568-
PyErr_FormatUnraisable("Exception ignored on removing modules");
1568+
PyErr_FormatUnraisable("Exception ignored when removing modules");
15691569
}
15701570
Py_DECREF(iterator);
15711571
}
@@ -1585,7 +1585,7 @@ finalize_clear_modules_dict(PyObject *modules)
15851585
}
15861586
else {
15871587
if (PyObject_CallMethodNoArgs(modules, &_Py_ID(clear)) == NULL) {
1588-
PyErr_FormatUnraisable("Exception ignored on clearing sys.modules");
1588+
PyErr_FormatUnraisable("Exception ignored when clearing sys.modules");
15891589
}
15901590
}
15911591
}
@@ -1597,11 +1597,11 @@ finalize_restore_builtins(PyThreadState *tstate)
15971597
PyInterpreterState *interp = tstate->interp;
15981598
PyObject *dict = PyDict_Copy(interp->builtins);
15991599
if (dict == NULL) {
1600-
PyErr_FormatUnraisable("Exception ignored on restoring builtins");
1600+
PyErr_FormatUnraisable("Exception ignored when restoring builtins");
16011601
}
16021602
PyDict_Clear(interp->builtins);
16031603
if (PyDict_Update(interp->builtins, interp->builtins_copy)) {
1604-
PyErr_FormatUnraisable("Exception ignored on restoring builtins");
1604+
PyErr_FormatUnraisable("Exception ignored when restoring builtins");
16051605
}
16061606
Py_XDECREF(dict);
16071607
}
@@ -1773,7 +1773,7 @@ flush_std_files(void)
17731773

17741774
if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
17751775
if (_PyFile_Flush(fout) < 0) {
1776-
PyErr_FormatUnraisable("Exception ignored on flushing sys.stdout");
1776+
PyErr_FormatUnraisable("Exception ignored when flushing sys.stdout");
17771777
status = -1;
17781778
}
17791779
}

0 commit comments

Comments
 (0)