Skip to content

Commit 60c72d6

Browse files
committed
use _PyException_AddNote instead of calling add_note explicitly
1 parent 284f66e commit 60c72d6

6 files changed

Lines changed: 5 additions & 12 deletions

File tree

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ struct _Py_global_strings {
299299
STRUCT_FOR_ID(aclose)
300300
STRUCT_FOR_ID(add)
301301
STRUCT_FOR_ID(add_done_callback)
302-
STRUCT_FOR_ID(add_note)
303302
STRUCT_FOR_ID(adobe)
304303
STRUCT_FOR_ID(after_in_child)
305304
STRUCT_FOR_ID(after_in_parent)

Include/internal/pycore_pyerrors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ PyAPI_FUNC(PyObject*) _PyErr_FormatFromCause(
2929
...
3030
);
3131

32-
extern int _PyException_AddNote(
32+
// Export for 'pyexpat' shared extension.
33+
PyAPI_FUNC(int) _PyException_AddNote(
3334
PyObject *exc,
3435
PyObject *note);
3536

Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/pyexpat.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,11 @@ invalid_expat_handler_rv(const char *name)
512512
if (note == NULL) {
513513
goto error;
514514
}
515-
PyObject *res = PyObject_CallMethodOneArg(exc, &_Py_ID(add_note), note);
515+
int rc = _PyException_AddNote(exc, note);
516516
Py_DECREF(note);
517-
if (res == NULL) {
517+
if (rc < 0) {
518518
goto error;
519-
}
520-
Py_DECREF(res);
519+
};
521520
goto done;
522521

523522
error:

0 commit comments

Comments
 (0)