1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(msvcrt_heapmin__doc__,
6 "heapmin($module, /)\n"
7 "--\n"
8 "\n"
9 "Minimize the malloc() heap.\n"
10 "\n"
11 "Force the malloc() heap to clean itself up and return unused blocks\n"
12 "to the operating system. On failure, this raises OSError.");
13 
14 #define MSVCRT_HEAPMIN_METHODDEF    \
15     {"heapmin", (PyCFunction)msvcrt_heapmin, METH_NOARGS, msvcrt_heapmin__doc__},
16 
17 static PyObject *
18 msvcrt_heapmin_impl(PyObject *module);
19 
20 static PyObject *
msvcrt_heapmin(PyObject * module,PyObject * Py_UNUSED (ignored))21 msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored))
22 {
23     return msvcrt_heapmin_impl(module);
24 }
25 
26 PyDoc_STRVAR(msvcrt_locking__doc__,
27 "locking($module, fd, mode, nbytes, /)\n"
28 "--\n"
29 "\n"
30 "Lock part of a file based on file descriptor fd from the C runtime.\n"
31 "\n"
32 "Raises OSError on failure. The locked region of the file extends from\n"
33 "the current file position for nbytes bytes, and may continue beyond\n"
34 "the end of the file. mode must be one of the LK_* constants listed\n"
35 "below. Multiple regions in a file may be locked at the same time, but\n"
36 "may not overlap. Adjacent regions are not merged; they must be unlocked\n"
37 "individually.");
38 
39 #define MSVCRT_LOCKING_METHODDEF    \
40     {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__},
41 
42 static PyObject *
43 msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes);
44 
45 static PyObject *
msvcrt_locking(PyObject * module,PyObject * const * args,Py_ssize_t nargs)46 msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
47 {
48     PyObject *return_value = NULL;
49     int fd;
50     int mode;
51     long nbytes;
52 
53     if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) {
54         goto exit;
55     }
56     if (PyFloat_Check(args[0])) {
57         PyErr_SetString(PyExc_TypeError,
58                         "integer argument expected, got float" );
59         goto exit;
60     }
61     fd = _PyLong_AsInt(args[0]);
62     if (fd == -1 && PyErr_Occurred()) {
63         goto exit;
64     }
65     if (PyFloat_Check(args[1])) {
66         PyErr_SetString(PyExc_TypeError,
67                         "integer argument expected, got float" );
68         goto exit;
69     }
70     mode = _PyLong_AsInt(args[1]);
71     if (mode == -1 && PyErr_Occurred()) {
72         goto exit;
73     }
74     if (PyFloat_Check(args[2])) {
75         PyErr_SetString(PyExc_TypeError,
76                         "integer argument expected, got float" );
77         goto exit;
78     }
79     nbytes = PyLong_AsLong(args[2]);
80     if (nbytes == -1 && PyErr_Occurred()) {
81         goto exit;
82     }
83     return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
84 
85 exit:
86     return return_value;
87 }
88 
89 PyDoc_STRVAR(msvcrt_setmode__doc__,
90 "setmode($module, fd, mode, /)\n"
91 "--\n"
92 "\n"
93 "Set the line-end translation mode for the file descriptor fd.\n"
94 "\n"
95 "To set it to text mode, flags should be os.O_TEXT; for binary, it\n"
96 "should be os.O_BINARY.\n"
97 "\n"
98 "Return value is the previous mode.");
99 
100 #define MSVCRT_SETMODE_METHODDEF    \
101     {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__},
102 
103 static long
104 msvcrt_setmode_impl(PyObject *module, int fd, int flags);
105 
106 static PyObject *
msvcrt_setmode(PyObject * module,PyObject * const * args,Py_ssize_t nargs)107 msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
108 {
109     PyObject *return_value = NULL;
110     int fd;
111     int flags;
112     long _return_value;
113 
114     if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) {
115         goto exit;
116     }
117     if (PyFloat_Check(args[0])) {
118         PyErr_SetString(PyExc_TypeError,
119                         "integer argument expected, got float" );
120         goto exit;
121     }
122     fd = _PyLong_AsInt(args[0]);
123     if (fd == -1 && PyErr_Occurred()) {
124         goto exit;
125     }
126     if (PyFloat_Check(args[1])) {
127         PyErr_SetString(PyExc_TypeError,
128                         "integer argument expected, got float" );
129         goto exit;
130     }
131     flags = _PyLong_AsInt(args[1]);
132     if (flags == -1 && PyErr_Occurred()) {
133         goto exit;
134     }
135     _return_value = msvcrt_setmode_impl(module, fd, flags);
136     if ((_return_value == -1) && PyErr_Occurred()) {
137         goto exit;
138     }
139     return_value = PyLong_FromLong(_return_value);
140 
141 exit:
142     return return_value;
143 }
144 
145 PyDoc_STRVAR(msvcrt_open_osfhandle__doc__,
146 "open_osfhandle($module, handle, flags, /)\n"
147 "--\n"
148 "\n"
149 "Create a C runtime file descriptor from the file handle handle.\n"
150 "\n"
151 "The flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n"
152 "and os.O_TEXT. The returned file descriptor may be used as a parameter\n"
153 "to os.fdopen() to create a file object.");
154 
155 #define MSVCRT_OPEN_OSFHANDLE_METHODDEF    \
156     {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__},
157 
158 static long
159 msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags);
160 
161 static PyObject *
msvcrt_open_osfhandle(PyObject * module,PyObject * const * args,Py_ssize_t nargs)162 msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
163 {
164     PyObject *return_value = NULL;
165     void *handle;
166     int flags;
167     long _return_value;
168 
169     if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle",
170         &handle, &flags)) {
171         goto exit;
172     }
173     _return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
174     if ((_return_value == -1) && PyErr_Occurred()) {
175         goto exit;
176     }
177     return_value = PyLong_FromLong(_return_value);
178 
179 exit:
180     return return_value;
181 }
182 
183 PyDoc_STRVAR(msvcrt_get_osfhandle__doc__,
184 "get_osfhandle($module, fd, /)\n"
185 "--\n"
186 "\n"
187 "Return the file handle for the file descriptor fd.\n"
188 "\n"
189 "Raises OSError if fd is not recognized.");
190 
191 #define MSVCRT_GET_OSFHANDLE_METHODDEF    \
192     {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__},
193 
194 static void *
195 msvcrt_get_osfhandle_impl(PyObject *module, int fd);
196 
197 static PyObject *
msvcrt_get_osfhandle(PyObject * module,PyObject * arg)198 msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
199 {
200     PyObject *return_value = NULL;
201     int fd;
202     void *_return_value;
203 
204     if (PyFloat_Check(arg)) {
205         PyErr_SetString(PyExc_TypeError,
206                         "integer argument expected, got float" );
207         goto exit;
208     }
209     fd = _PyLong_AsInt(arg);
210     if (fd == -1 && PyErr_Occurred()) {
211         goto exit;
212     }
213     _return_value = msvcrt_get_osfhandle_impl(module, fd);
214     if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
215         goto exit;
216     }
217     return_value = PyLong_FromVoidPtr(_return_value);
218 
219 exit:
220     return return_value;
221 }
222 
223 PyDoc_STRVAR(msvcrt_kbhit__doc__,
224 "kbhit($module, /)\n"
225 "--\n"
226 "\n"
227 "Return true if a keypress is waiting to be read.");
228 
229 #define MSVCRT_KBHIT_METHODDEF    \
230     {"kbhit", (PyCFunction)msvcrt_kbhit, METH_NOARGS, msvcrt_kbhit__doc__},
231 
232 static long
233 msvcrt_kbhit_impl(PyObject *module);
234 
235 static PyObject *
msvcrt_kbhit(PyObject * module,PyObject * Py_UNUSED (ignored))236 msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored))
237 {
238     PyObject *return_value = NULL;
239     long _return_value;
240 
241     _return_value = msvcrt_kbhit_impl(module);
242     if ((_return_value == -1) && PyErr_Occurred()) {
243         goto exit;
244     }
245     return_value = PyLong_FromLong(_return_value);
246 
247 exit:
248     return return_value;
249 }
250 
251 PyDoc_STRVAR(msvcrt_getch__doc__,
252 "getch($module, /)\n"
253 "--\n"
254 "\n"
255 "Read a keypress and return the resulting character as a byte string.\n"
256 "\n"
257 "Nothing is echoed to the console. This call will block if a keypress is\n"
258 "not already available, but will not wait for Enter to be pressed. If the\n"
259 "pressed key was a special function key, this will return \'\\000\' or\n"
260 "\'\\xe0\'; the next call will return the keycode. The Control-C keypress\n"
261 "cannot be read with this function.");
262 
263 #define MSVCRT_GETCH_METHODDEF    \
264     {"getch", (PyCFunction)msvcrt_getch, METH_NOARGS, msvcrt_getch__doc__},
265 
266 static int
267 msvcrt_getch_impl(PyObject *module);
268 
269 static PyObject *
msvcrt_getch(PyObject * module,PyObject * Py_UNUSED (ignored))270 msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored))
271 {
272     PyObject *return_value = NULL;
273     char s[1];
274 
275     s[0] = msvcrt_getch_impl(module);
276     return_value = PyBytes_FromStringAndSize(s, 1);
277 
278     return return_value;
279 }
280 
281 PyDoc_STRVAR(msvcrt_getwch__doc__,
282 "getwch($module, /)\n"
283 "--\n"
284 "\n"
285 "Wide char variant of getch(), returning a Unicode value.");
286 
287 #define MSVCRT_GETWCH_METHODDEF    \
288     {"getwch", (PyCFunction)msvcrt_getwch, METH_NOARGS, msvcrt_getwch__doc__},
289 
290 static wchar_t
291 msvcrt_getwch_impl(PyObject *module);
292 
293 static PyObject *
msvcrt_getwch(PyObject * module,PyObject * Py_UNUSED (ignored))294 msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored))
295 {
296     PyObject *return_value = NULL;
297     wchar_t _return_value;
298 
299     _return_value = msvcrt_getwch_impl(module);
300     return_value = PyUnicode_FromOrdinal(_return_value);
301 
302     return return_value;
303 }
304 
305 PyDoc_STRVAR(msvcrt_getche__doc__,
306 "getche($module, /)\n"
307 "--\n"
308 "\n"
309 "Similar to getch(), but the keypress will be echoed if possible.");
310 
311 #define MSVCRT_GETCHE_METHODDEF    \
312     {"getche", (PyCFunction)msvcrt_getche, METH_NOARGS, msvcrt_getche__doc__},
313 
314 static int
315 msvcrt_getche_impl(PyObject *module);
316 
317 static PyObject *
msvcrt_getche(PyObject * module,PyObject * Py_UNUSED (ignored))318 msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored))
319 {
320     PyObject *return_value = NULL;
321     char s[1];
322 
323     s[0] = msvcrt_getche_impl(module);
324     return_value = PyBytes_FromStringAndSize(s, 1);
325 
326     return return_value;
327 }
328 
329 PyDoc_STRVAR(msvcrt_getwche__doc__,
330 "getwche($module, /)\n"
331 "--\n"
332 "\n"
333 "Wide char variant of getche(), returning a Unicode value.");
334 
335 #define MSVCRT_GETWCHE_METHODDEF    \
336     {"getwche", (PyCFunction)msvcrt_getwche, METH_NOARGS, msvcrt_getwche__doc__},
337 
338 static wchar_t
339 msvcrt_getwche_impl(PyObject *module);
340 
341 static PyObject *
msvcrt_getwche(PyObject * module,PyObject * Py_UNUSED (ignored))342 msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored))
343 {
344     PyObject *return_value = NULL;
345     wchar_t _return_value;
346 
347     _return_value = msvcrt_getwche_impl(module);
348     return_value = PyUnicode_FromOrdinal(_return_value);
349 
350     return return_value;
351 }
352 
353 PyDoc_STRVAR(msvcrt_putch__doc__,
354 "putch($module, char, /)\n"
355 "--\n"
356 "\n"
357 "Print the byte string char to the console without buffering.");
358 
359 #define MSVCRT_PUTCH_METHODDEF    \
360     {"putch", (PyCFunction)msvcrt_putch, METH_O, msvcrt_putch__doc__},
361 
362 static PyObject *
363 msvcrt_putch_impl(PyObject *module, char char_value);
364 
365 static PyObject *
msvcrt_putch(PyObject * module,PyObject * arg)366 msvcrt_putch(PyObject *module, PyObject *arg)
367 {
368     PyObject *return_value = NULL;
369     char char_value;
370 
371     if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
372         char_value = PyBytes_AS_STRING(arg)[0];
373     }
374     else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
375         char_value = PyByteArray_AS_STRING(arg)[0];
376     }
377     else {
378         _PyArg_BadArgument("putch", "argument", "a byte string of length 1", arg);
379         goto exit;
380     }
381     return_value = msvcrt_putch_impl(module, char_value);
382 
383 exit:
384     return return_value;
385 }
386 
387 PyDoc_STRVAR(msvcrt_putwch__doc__,
388 "putwch($module, unicode_char, /)\n"
389 "--\n"
390 "\n"
391 "Wide char variant of putch(), accepting a Unicode value.");
392 
393 #define MSVCRT_PUTWCH_METHODDEF    \
394     {"putwch", (PyCFunction)msvcrt_putwch, METH_O, msvcrt_putwch__doc__},
395 
396 static PyObject *
397 msvcrt_putwch_impl(PyObject *module, int unicode_char);
398 
399 static PyObject *
msvcrt_putwch(PyObject * module,PyObject * arg)400 msvcrt_putwch(PyObject *module, PyObject *arg)
401 {
402     PyObject *return_value = NULL;
403     int unicode_char;
404 
405     if (!PyUnicode_Check(arg)) {
406         _PyArg_BadArgument("putwch", "argument", "a unicode character", arg);
407         goto exit;
408     }
409     if (PyUnicode_READY(arg)) {
410         goto exit;
411     }
412     if (PyUnicode_GET_LENGTH(arg) != 1) {
413         _PyArg_BadArgument("putwch", "argument", "a unicode character", arg);
414         goto exit;
415     }
416     unicode_char = PyUnicode_READ_CHAR(arg, 0);
417     return_value = msvcrt_putwch_impl(module, unicode_char);
418 
419 exit:
420     return return_value;
421 }
422 
423 PyDoc_STRVAR(msvcrt_ungetch__doc__,
424 "ungetch($module, char, /)\n"
425 "--\n"
426 "\n"
427 "Opposite of getch.\n"
428 "\n"
429 "Cause the byte string char to be \"pushed back\" into the\n"
430 "console buffer; it will be the next character read by\n"
431 "getch() or getche().");
432 
433 #define MSVCRT_UNGETCH_METHODDEF    \
434     {"ungetch", (PyCFunction)msvcrt_ungetch, METH_O, msvcrt_ungetch__doc__},
435 
436 static PyObject *
437 msvcrt_ungetch_impl(PyObject *module, char char_value);
438 
439 static PyObject *
msvcrt_ungetch(PyObject * module,PyObject * arg)440 msvcrt_ungetch(PyObject *module, PyObject *arg)
441 {
442     PyObject *return_value = NULL;
443     char char_value;
444 
445     if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
446         char_value = PyBytes_AS_STRING(arg)[0];
447     }
448     else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
449         char_value = PyByteArray_AS_STRING(arg)[0];
450     }
451     else {
452         _PyArg_BadArgument("ungetch", "argument", "a byte string of length 1", arg);
453         goto exit;
454     }
455     return_value = msvcrt_ungetch_impl(module, char_value);
456 
457 exit:
458     return return_value;
459 }
460 
461 PyDoc_STRVAR(msvcrt_ungetwch__doc__,
462 "ungetwch($module, unicode_char, /)\n"
463 "--\n"
464 "\n"
465 "Wide char variant of ungetch(), accepting a Unicode value.");
466 
467 #define MSVCRT_UNGETWCH_METHODDEF    \
468     {"ungetwch", (PyCFunction)msvcrt_ungetwch, METH_O, msvcrt_ungetwch__doc__},
469 
470 static PyObject *
471 msvcrt_ungetwch_impl(PyObject *module, int unicode_char);
472 
473 static PyObject *
msvcrt_ungetwch(PyObject * module,PyObject * arg)474 msvcrt_ungetwch(PyObject *module, PyObject *arg)
475 {
476     PyObject *return_value = NULL;
477     int unicode_char;
478 
479     if (!PyUnicode_Check(arg)) {
480         _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg);
481         goto exit;
482     }
483     if (PyUnicode_READY(arg)) {
484         goto exit;
485     }
486     if (PyUnicode_GET_LENGTH(arg) != 1) {
487         _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg);
488         goto exit;
489     }
490     unicode_char = PyUnicode_READ_CHAR(arg, 0);
491     return_value = msvcrt_ungetwch_impl(module, unicode_char);
492 
493 exit:
494     return return_value;
495 }
496 
497 #if defined(_DEBUG)
498 
499 PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__,
500 "CrtSetReportFile($module, type, file, /)\n"
501 "--\n"
502 "\n"
503 "Wrapper around _CrtSetReportFile.\n"
504 "\n"
505 "Only available on Debug builds.");
506 
507 #define MSVCRT_CRTSETREPORTFILE_METHODDEF    \
508     {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__},
509 
510 static void *
511 msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file);
512 
513 static PyObject *
msvcrt_CrtSetReportFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs)514 msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
515 {
516     PyObject *return_value = NULL;
517     int type;
518     void *file;
519     void *_return_value;
520 
521     if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile",
522         &type, &file)) {
523         goto exit;
524     }
525     _return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
526     if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
527         goto exit;
528     }
529     return_value = PyLong_FromVoidPtr(_return_value);
530 
531 exit:
532     return return_value;
533 }
534 
535 #endif /* defined(_DEBUG) */
536 
537 #if defined(_DEBUG)
538 
539 PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__,
540 "CrtSetReportMode($module, type, mode, /)\n"
541 "--\n"
542 "\n"
543 "Wrapper around _CrtSetReportMode.\n"
544 "\n"
545 "Only available on Debug builds.");
546 
547 #define MSVCRT_CRTSETREPORTMODE_METHODDEF    \
548     {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__},
549 
550 static long
551 msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode);
552 
553 static PyObject *
msvcrt_CrtSetReportMode(PyObject * module,PyObject * const * args,Py_ssize_t nargs)554 msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
555 {
556     PyObject *return_value = NULL;
557     int type;
558     int mode;
559     long _return_value;
560 
561     if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) {
562         goto exit;
563     }
564     if (PyFloat_Check(args[0])) {
565         PyErr_SetString(PyExc_TypeError,
566                         "integer argument expected, got float" );
567         goto exit;
568     }
569     type = _PyLong_AsInt(args[0]);
570     if (type == -1 && PyErr_Occurred()) {
571         goto exit;
572     }
573     if (PyFloat_Check(args[1])) {
574         PyErr_SetString(PyExc_TypeError,
575                         "integer argument expected, got float" );
576         goto exit;
577     }
578     mode = _PyLong_AsInt(args[1]);
579     if (mode == -1 && PyErr_Occurred()) {
580         goto exit;
581     }
582     _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
583     if ((_return_value == -1) && PyErr_Occurred()) {
584         goto exit;
585     }
586     return_value = PyLong_FromLong(_return_value);
587 
588 exit:
589     return return_value;
590 }
591 
592 #endif /* defined(_DEBUG) */
593 
594 #if defined(_DEBUG)
595 
596 PyDoc_STRVAR(msvcrt_set_error_mode__doc__,
597 "set_error_mode($module, mode, /)\n"
598 "--\n"
599 "\n"
600 "Wrapper around _set_error_mode.\n"
601 "\n"
602 "Only available on Debug builds.");
603 
604 #define MSVCRT_SET_ERROR_MODE_METHODDEF    \
605     {"set_error_mode", (PyCFunction)msvcrt_set_error_mode, METH_O, msvcrt_set_error_mode__doc__},
606 
607 static long
608 msvcrt_set_error_mode_impl(PyObject *module, int mode);
609 
610 static PyObject *
msvcrt_set_error_mode(PyObject * module,PyObject * arg)611 msvcrt_set_error_mode(PyObject *module, PyObject *arg)
612 {
613     PyObject *return_value = NULL;
614     int mode;
615     long _return_value;
616 
617     if (PyFloat_Check(arg)) {
618         PyErr_SetString(PyExc_TypeError,
619                         "integer argument expected, got float" );
620         goto exit;
621     }
622     mode = _PyLong_AsInt(arg);
623     if (mode == -1 && PyErr_Occurred()) {
624         goto exit;
625     }
626     _return_value = msvcrt_set_error_mode_impl(module, mode);
627     if ((_return_value == -1) && PyErr_Occurred()) {
628         goto exit;
629     }
630     return_value = PyLong_FromLong(_return_value);
631 
632 exit:
633     return return_value;
634 }
635 
636 #endif /* defined(_DEBUG) */
637 
638 PyDoc_STRVAR(msvcrt_SetErrorMode__doc__,
639 "SetErrorMode($module, mode, /)\n"
640 "--\n"
641 "\n"
642 "Wrapper around SetErrorMode.");
643 
644 #define MSVCRT_SETERRORMODE_METHODDEF    \
645     {"SetErrorMode", (PyCFunction)msvcrt_SetErrorMode, METH_O, msvcrt_SetErrorMode__doc__},
646 
647 static PyObject *
648 msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode);
649 
650 static PyObject *
msvcrt_SetErrorMode(PyObject * module,PyObject * arg)651 msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
652 {
653     PyObject *return_value = NULL;
654     unsigned int mode;
655 
656     if (PyFloat_Check(arg)) {
657         PyErr_SetString(PyExc_TypeError,
658                         "integer argument expected, got float" );
659         goto exit;
660     }
661     mode = (unsigned int)PyLong_AsUnsignedLongMask(arg);
662     if (mode == (unsigned int)-1 && PyErr_Occurred()) {
663         goto exit;
664     }
665     return_value = msvcrt_SetErrorMode_impl(module, mode);
666 
667 exit:
668     return return_value;
669 }
670 
671 #ifndef MSVCRT_CRTSETREPORTFILE_METHODDEF
672     #define MSVCRT_CRTSETREPORTFILE_METHODDEF
673 #endif /* !defined(MSVCRT_CRTSETREPORTFILE_METHODDEF) */
674 
675 #ifndef MSVCRT_CRTSETREPORTMODE_METHODDEF
676     #define MSVCRT_CRTSETREPORTMODE_METHODDEF
677 #endif /* !defined(MSVCRT_CRTSETREPORTMODE_METHODDEF) */
678 
679 #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
680     #define MSVCRT_SET_ERROR_MODE_METHODDEF
681 #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
682 /*[clinic end generated code: output=7cc6ffaf64f268f7 input=a9049054013a1b77]*/
683