Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ For convenience, some of these functions will always return a
.. versionadded:: 3.4


.. c:function:: void PyErr_RangedSyntaxLocationObject(PyObject *filename, int lineno, int col_offset, int end_lineno, int end_col_offset)

Similar to :c:func:`PyErr_SyntaxLocationObject`, but also sets the
*end_lineno* and *end_col_offset* information for the current exception.
Comment on lines +314 to +315
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure that this is correct. Unless I'm going crazy, this is exactly the same as PyErr_SyntaxLocationObjectEx:

cpython/Python/errors.c

Lines 1910 to 1914 in 209eaff

void
PyErr_RangedSyntaxLocationObject(PyObject *filename, int lineno, int col_offset,
int end_lineno, int end_col_offset) {
PyErr_SyntaxLocationObjectEx(filename, lineno, col_offset, end_lineno, end_col_offset);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is, see the PyErr_SyntaxLocationObject invocation of PyErr_SyntaxLocationObjectEx.

void
PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset) {
    PyErr_SyntaxLocationObjectEx(filename, lineno, col_offset, lineno, -1);
}

We are essentially just exposing the full functionality of PyErr_SyntaxLocationObjectEx.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like PyErr_SyntaxLocationObjectEx is undocumented. Let's document that and document PyErr_RangedSyntaxLocationObject as a soft-deprecated alias to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to expose it first:

static void

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so we named something like a public API without exposing it -- yuck! I think we're all good here then.


.. versionadded:: 3.10


.. c:function:: void PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)

Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string
Expand Down
Loading