10
10
--------------
11
11
12
12
These 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
15
15
this in the implementation of the :func: `getpass ` function.
16
16
17
17
Further documentation on these functions can be found in the Platform API
@@ -35,11 +35,11 @@ File Operations
35
35
36
36
.. function :: locking(fd, mode, nbytes)
37
37
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
40
40
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
43
43
regions are not merged; they must be unlocked individually.
44
44
45
45
.. audit-event :: msvcrt.locking fd,mode,nbytes msvcrt.locking
@@ -49,7 +49,7 @@ File Operations
49
49
LK_RLCK
50
50
51
51
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
53
53
be locked, :exc: `OSError ` is raised.
54
54
55
55
@@ -74,17 +74,17 @@ File Operations
74
74
75
75
.. function :: open_osfhandle(handle, flags)
76
76
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 *
78
78
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
80
80
to :func: `os.fdopen ` to create a file object.
81
81
82
82
.. audit-event :: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle
83
83
84
84
85
85
.. function :: get_osfhandle(fd)
86
86
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
88
88
*fd * is not recognized.
89
89
90
90
.. audit-event :: msvcrt.get_osfhandle fd msvcrt.get_osfhandle
@@ -105,7 +105,7 @@ Console I/O
105
105
.. function :: getch()
106
106
107
107
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
109
109
is not already available, but will not wait for :kbd: `Enter ` to be
110
110
pressed. If the pressed key was a special function key, this will
111
111
return ``'\000' `` or ``'\xe0' ``; the next call will return the keycode.
@@ -119,7 +119,7 @@ Console I/O
119
119
120
120
.. function :: getche()
121
121
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
123
123
printable character.
124
124
125
125
@@ -158,4 +158,93 @@ Other Functions
158
158
.. function :: heapmin()
159
159
160
160
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