Skip to content

Commit ac48fde

Browse files
[3.12] gh-73231: Update documentation for PyErr_SetFromWindowsErr() (GH-117226) (GH-117973)
(cherry picked from commit 438b7c3) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 0a40580 commit ac48fde

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/c-api/exceptions.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,14 @@ For convenience, some of these functions will always return a
208208
209209
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
210210
211-
This is a convenience function to raise :exc:`WindowsError`. If called with
211+
This is a convenience function to raise :exc:`OSError`. If called with
212212
*ierr* of ``0``, the error code returned by a call to :c:func:`!GetLastError`
213213
is used instead. It calls the Win32 function :c:func:`!FormatMessage` to retrieve
214214
the Windows description of error code given by *ierr* or :c:func:`!GetLastError`,
215-
then it constructs a tuple object whose first item is the *ierr* value and whose
216-
second item is the corresponding error message (gotten from
217-
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
215+
then it constructs a :exc:`OSError` object with the :attr:`~OSError.winerror`
216+
attribute set to the error code, the :attr:`~OSError.strerror` attribute
217+
set to the corresponding error message (gotten from
218+
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_OSError,
218219
object)``. This function always returns ``NULL``.
219220
220221
.. availability:: Windows.

0 commit comments

Comments
 (0)