Skip to content

Commit 438b7c3

Browse files
gh-73231: Update documentation for PyErr_SetFromWindowsErr() (GH-117226)
1 parent aec1dac commit 438b7c3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/c-api/exceptions.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ For convenience, some of these functions will always return a
221221
222222
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
223223
224-
This is a convenience function to raise :exc:`WindowsError`. If called with
224+
This is a convenience function to raise :exc:`OSError`. If called with
225225
*ierr* of ``0``, the error code returned by a call to :c:func:`!GetLastError`
226226
is used instead. It calls the Win32 function :c:func:`!FormatMessage` to retrieve
227227
the Windows description of error code given by *ierr* or :c:func:`!GetLastError`,
228-
then it constructs a tuple object whose first item is the *ierr* value and whose
229-
second item is the corresponding error message (gotten from
230-
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
228+
then it constructs a :exc:`OSError` object with the :attr:`~OSError.winerror`
229+
attribute set to the error code, the :attr:`~OSError.strerror` attribute
230+
set to the corresponding error message (gotten from
231+
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_OSError,
231232
object)``. This function always returns ``NULL``.
232233
233234
.. availability:: Windows.

0 commit comments

Comments
 (0)