msvcrtmodule.c.h 18 KB

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