From 754eb27f456c0aa3db31f0e99699d140cb45f9e9 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sat, 8 Nov 2025 09:44:30 -0500 Subject: [PATCH 1/3] Doucment PyErr_ProgramTextObject() and PyErr_ProgramText() --- Doc/c-api/exceptions.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 9c75f66f683195..652af85cd83e31 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -331,6 +331,22 @@ For convenience, some of these functions will always return a use. +.. c:function:: PyObject *PyErr_ProgramTextObject(PyObject *filename, int lineno) + + Get the source line in *filename* at line *lineno*. *filename* should be a + Python :class:`str` object. + + On success, this function returns a Python string object with the found line. + On failure, this function returns ``NULL`` without an exception set. + + +.. c:function:: PyObject *PyErr_ProgramText(const char *filename, int lineno) + + Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a + :c:expr:`const char *` UTF-8 encoded string instead of a Python object + reference. + + Issuing warnings ================ From dd94f5210e5e56ab762995cf9df96c27ac7975c8 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sat, 8 Nov 2025 10:07:31 -0500 Subject: [PATCH 2/3] Update Doc/c-api/exceptions.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/c-api/exceptions.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 652af85cd83e31..f44d0b25ba757d 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -343,8 +343,9 @@ For convenience, some of these functions will always return a .. c:function:: PyObject *PyErr_ProgramText(const char *filename, int lineno) Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a - :c:expr:`const char *` UTF-8 encoded string instead of a Python object - reference. + :c:expr:`const char *`, which is decoded with the + :term:`filesystem-encoding-and-error-handler`, instead of a + Python object reference. Issuing warnings From 7a6bd06b15b086960ed080c681067bef14f3157a Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sat, 8 Nov 2025 10:11:47 -0500 Subject: [PATCH 3/3] Fix warning. --- Doc/c-api/exceptions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index f44d0b25ba757d..4a0b6fd8eab245 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -344,7 +344,7 @@ For convenience, some of these functions will always return a Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a :c:expr:`const char *`, which is decoded with the - :term:`filesystem-encoding-and-error-handler`, instead of a + :term:`filesystem encoding and error handler`, instead of a Python object reference.