1010--------------
1111
1212These functions provide access to some useful capabilities on Windows platforms.
13- Some higher-level modules use these functions to build the Windows
14- implementations of their services. For example, the :mod: `getpass ` module uses
13+ Some higher-level modules use these functions to build the Windows
14+ implementations of their services. For example, the :mod: `getpass ` module uses
1515this in the implementation of the :func: `getpass ` function.
1616
1717Further documentation on these functions can be found in the Platform API
@@ -35,11 +35,11 @@ File Operations
3535
3636.. function :: locking(fd, mode, nbytes)
3737
38- Lock part of a file based on file descriptor *fd * from the C runtime. Raises
39- :exc: `OSError ` on failure. The locked region of the file extends from the
38+ Lock part of a file based on file descriptor *fd * from the C runtime. Raises
39+ :exc: `OSError ` on failure. The locked region of the file extends from the
4040 current file position for *nbytes * bytes, and may continue beyond the end of the
41- file. *mode * must be one of the :const: `!LK_\* ` constants listed below. Multiple
42- regions in a file may be locked at the same time, but may not overlap. Adjacent
41+ file. *mode * must be one of the :const: `!LK_\* ` constants listed below. Multiple
42+ regions in a file may be locked at the same time, but may not overlap. Adjacent
4343 regions are not merged; they must be unlocked individually.
4444
4545 .. audit-event :: msvcrt.locking fd,mode,nbytes msvcrt.locking
@@ -49,7 +49,7 @@ File Operations
4949 LK_RLCK
5050
5151 Locks the specified bytes. If the bytes cannot be locked, the program
52- immediately tries again after 1 second. If, after 10 attempts, the bytes cannot
52+ immediately tries again after 1 second. If, after 10 attempts, the bytes cannot
5353 be locked, :exc: `OSError ` is raised.
5454
5555
@@ -74,17 +74,17 @@ File Operations
7474
7575.. function :: open_osfhandle(handle, flags)
7676
77- Create a C runtime file descriptor from the file handle *handle *. The *flags *
77+ Create a C runtime file descriptor from the file handle *handle *. The *flags *
7878 parameter should be a bitwise OR of :const: `os.O_APPEND `, :const: `os.O_RDONLY `,
79- and :const: `os.O_TEXT `. The returned file descriptor may be used as a parameter
79+ and :const: `os.O_TEXT `. The returned file descriptor may be used as a parameter
8080 to :func: `os.fdopen ` to create a file object.
8181
8282 .. audit-event :: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle
8383
8484
8585.. function :: get_osfhandle(fd)
8686
87- Return the file handle for the file descriptor *fd *. Raises :exc: `OSError ` if
87+ Return the file handle for the file descriptor *fd *. Raises :exc: `OSError ` if
8888 *fd * is not recognized.
8989
9090 .. audit-event :: msvcrt.get_osfhandle fd msvcrt.get_osfhandle
@@ -105,7 +105,7 @@ Console I/O
105105.. function :: getch()
106106
107107 Read a keypress and return the resulting character as a byte string.
108- Nothing is echoed to the console. This call will block if a keypress
108+ Nothing is echoed to the console. This call will block if a keypress
109109 is not already available, but will not wait for :kbd: `Enter ` to be
110110 pressed. If the pressed key was a special function key, this will
111111 return ``'\000' `` or ``'\xe0' ``; the next call will return the keycode.
@@ -119,7 +119,7 @@ Console I/O
119119
120120.. function :: getche()
121121
122- Similar to :func: `getch `, but the keypress will be echoed if it represents a
122+ Similar to :func: `getch `, but the keypress will be echoed if it represents a
123123 printable character.
124124
125125
@@ -158,4 +158,93 @@ Other Functions
158158.. function :: heapmin()
159159
160160 Force the :c:func: `malloc ` heap to clean itself up and return unused blocks to
161- the operating system. On failure, this raises :exc: `OSError `.
161+ the operating system. On failure, this raises :exc: `OSError `.
162+
163+
164+ .. function :: set_error_mode(mode)
165+
166+ Changes the location where the C runtime writes an error message for an error
167+ that might end the program. *mode * must be one of the :const: `!OUT_\* `
168+ constants listed below or :const: `REPORT_ERRMODE `. Returns the old setting
169+ or -1 if an error occurs. Only available in
170+ :ref: `debug build of Python <debug-build >`.
171+
172+
173+ .. data :: OUT_TO_DEFAULT
174+
175+ Error sink is determined by the app's type. Only available in
176+ :ref: `debug build of Python <debug-build >`.
177+
178+
179+ .. data :: OUT_TO_STDERR
180+
181+ Error sink is a standard error. Only available in
182+ :ref: `debug build of Python <debug-build >`.
183+
184+
185+ .. data :: OUT_TO_MSGBOX
186+
187+ Error sink is a message box. Only available in
188+ :ref: `debug build of Python <debug-build >`.
189+
190+
191+ .. data :: REPORT_ERRMODE
192+
193+ Report the current error mode value. Only available in
194+ :ref: `debug build of Python <debug-build >`.
195+
196+
197+ .. function :: CrtSetReportMode(type, mode)
198+
199+ Specifies the destination or destinations for a specific report type
200+ generated by :c:func: `!_CrtDbgReport ` in the MS VC++ runtime. *type * must be
201+ one of the :const: `!CRT_\* ` constants listed below. *mode * must be one of the
202+ :const: `!CRTDBG_\* ` constants listed below. Only available in
203+ :ref: `debug build of Python <debug-build >`.
204+
205+
206+ .. function :: CrtSetReportFile(type, file)
207+
208+ After you use :func: `CrtSetReportMode ` to specify :const: `CRTDBG_MODE_FILE `,
209+ you can specify the file handle to receive the message text. *type * must be
210+ one of the :const: `!CRT_\* ` constants listed below. *file * shuld be the file
211+ handle your want specified. Only available in
212+ :ref: `debug build of Python <debug-build >`.
213+
214+
215+ .. data :: CRT_WARN
216+
217+ Warnings, messages, and information that doesn't need immediate attention.
218+
219+
220+ .. data :: CRT_ERROR
221+
222+ Errors, unrecoverable problems, and issues that require immediate attention.
223+
224+
225+ .. data :: CRT_ASSERT
226+
227+ Assertion failures.
228+
229+
230+ .. data :: CRTDBG_MODE_DEBUG
231+
232+ Writes the message to the debugger's output window.
233+
234+
235+ .. data :: CRTDBG_MODE_FILE
236+
237+ Writes the message to a user-supplied file handle. :func: `CrtSetReportFile `
238+ should be called to define the specific file or stream to use as
239+ the destination.
240+
241+
242+ .. data :: CRTDBG_MODE_WNDW
243+
244+ Creates a message box to display the message along with the ``Abort ``,
245+ ``Retry ``, and ``Ignore `` buttons.
246+
247+
248+ .. data :: CRTDBG_REPORT_MODE
249+
250+ Returns current *mode * for the specified *type *.
0 commit comments