Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 18 | msvcrt_heapmin_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 19 | |
| 20 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 21 | msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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" |
Serhiy Storchaka | 55fe1ae | 2017-04-16 10:46:38 +0300 | [diff] [blame] | 32 | "Raises OSError on failure. The locked region of the file extends from\n" |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 40 | {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 41 | |
| 42 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 43 | msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 44 | |
| 45 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 46 | msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 47 | { |
| 48 | PyObject *return_value = NULL; |
| 49 | int fd; |
| 50 | int mode; |
| 51 | long nbytes; |
| 52 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 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()) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 81 | goto exit; |
| 82 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 101 | {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 102 | |
| 103 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 104 | msvcrt_setmode_impl(PyObject *module, int fd, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 105 | |
| 106 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 107 | msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 108 | { |
| 109 | PyObject *return_value = NULL; |
| 110 | int fd; |
| 111 | int flags; |
| 112 | long _return_value; |
| 113 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 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()) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 133 | goto exit; |
| 134 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 135 | _return_value = msvcrt_setmode_impl(module, fd, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 136 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 137 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 138 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 156 | {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 157 | |
| 158 | static long |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 159 | msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 160 | |
| 161 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 162 | msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 163 | { |
| 164 | PyObject *return_value = NULL; |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 165 | void *handle; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 166 | int flags; |
| 167 | long _return_value; |
| 168 | |
Segev Finer | a80e985 | 2017-07-27 06:15:18 +0300 | [diff] [blame] | 169 | if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle", |
Sylvain | 7445381 | 2017-06-10 06:51:48 +0200 | [diff] [blame] | 170 | &handle, &flags)) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 171 | goto exit; |
| 172 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 173 | _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 174 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 175 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 176 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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" |
Serhiy Storchaka | 55fe1ae | 2017-04-16 10:46:38 +0300 | [diff] [blame] | 189 | "Raises OSError if fd is not recognized."); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 190 | |
| 191 | #define MSVCRT_GET_OSFHANDLE_METHODDEF \ |
| 192 | {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__}, |
| 193 | |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 194 | static void * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 195 | msvcrt_get_osfhandle_impl(PyObject *module, int fd); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 196 | |
| 197 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 198 | msvcrt_get_osfhandle(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 199 | { |
| 200 | PyObject *return_value = NULL; |
| 201 | int fd; |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 202 | void *_return_value; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 203 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 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()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 211 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 212 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 213 | _return_value = msvcrt_get_osfhandle_impl(module, fd); |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 214 | if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 215 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 216 | } |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 217 | return_value = PyLong_FromVoidPtr(_return_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 233 | msvcrt_kbhit_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 234 | |
| 235 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 236 | msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 237 | { |
| 238 | PyObject *return_value = NULL; |
| 239 | long _return_value; |
| 240 | |
| 241 | _return_value = msvcrt_kbhit_impl(module); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 242 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 243 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 244 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 267 | msvcrt_getch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 268 | |
| 269 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 270 | msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 291 | msvcrt_getwch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 292 | |
| 293 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 294 | msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 315 | msvcrt_getche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 316 | |
| 317 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 318 | msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 339 | msvcrt_getwche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 340 | |
| 341 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 342 | msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 363 | msvcrt_putch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 364 | |
| 365 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 366 | msvcrt_putch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 367 | { |
| 368 | PyObject *return_value = NULL; |
| 369 | char char_value; |
| 370 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 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 { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 378 | _PyArg_BadArgument("putch", "argument", "a byte string of length 1", arg); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 379 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 380 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 381 | return_value = msvcrt_putch_impl(module, char_value); |
| 382 | |
| 383 | exit: |
| 384 | return return_value; |
| 385 | } |
| 386 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 397 | msvcrt_putwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 398 | |
| 399 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 400 | msvcrt_putwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 401 | { |
| 402 | PyObject *return_value = NULL; |
| 403 | int unicode_char; |
| 404 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 405 | if (!PyUnicode_Check(arg)) { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 406 | _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 407 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 408 | } |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 409 | if (PyUnicode_READY(arg)) { |
| 410 | goto exit; |
| 411 | } |
| 412 | if (PyUnicode_GET_LENGTH(arg) != 1) { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 413 | _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 414 | goto exit; |
| 415 | } |
| 416 | unicode_char = PyUnicode_READ_CHAR(arg, 0); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 417 | return_value = msvcrt_putwch_impl(module, unicode_char); |
| 418 | |
| 419 | exit: |
| 420 | return return_value; |
| 421 | } |
| 422 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 437 | msvcrt_ungetch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 438 | |
| 439 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 440 | msvcrt_ungetch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 441 | { |
| 442 | PyObject *return_value = NULL; |
| 443 | char char_value; |
| 444 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 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 { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 452 | _PyArg_BadArgument("ungetch", "argument", "a byte string of length 1", arg); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 453 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 454 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 455 | return_value = msvcrt_ungetch_impl(module, char_value); |
| 456 | |
| 457 | exit: |
| 458 | return return_value; |
| 459 | } |
| 460 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 471 | msvcrt_ungetwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 472 | |
| 473 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 474 | msvcrt_ungetwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 475 | { |
| 476 | PyObject *return_value = NULL; |
| 477 | int unicode_char; |
| 478 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 479 | if (!PyUnicode_Check(arg)) { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 480 | _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 481 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 482 | } |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 483 | if (PyUnicode_READY(arg)) { |
| 484 | goto exit; |
| 485 | } |
| 486 | if (PyUnicode_GET_LENGTH(arg) != 1) { |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 487 | _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 488 | goto exit; |
| 489 | } |
| 490 | unicode_char = PyUnicode_READ_CHAR(arg, 0); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 491 | return_value = msvcrt_ungetwch_impl(module, unicode_char); |
| 492 | |
| 493 | exit: |
| 494 | return return_value; |
| 495 | } |
| 496 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 508 | {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 509 | |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 510 | static void * |
| 511 | msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 512 | |
| 513 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 514 | msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 515 | { |
| 516 | PyObject *return_value = NULL; |
| 517 | int type; |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 518 | void *file; |
| 519 | void *_return_value; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 520 | |
Segev Finer | a80e985 | 2017-07-27 06:15:18 +0300 | [diff] [blame] | 521 | if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile", |
Sylvain | 7445381 | 2017-06-10 06:51:48 +0200 | [diff] [blame] | 522 | &type, &file)) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 523 | goto exit; |
| 524 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 525 | _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 526 | if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 527 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 528 | } |
Segev Finer | 679b566 | 2017-07-27 01:17:57 +0300 | [diff] [blame] | 529 | return_value = PyLong_FromVoidPtr(_return_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 548 | {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 549 | |
| 550 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 551 | msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 552 | |
| 553 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 554 | msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 555 | { |
| 556 | PyObject *return_value = NULL; |
| 557 | int type; |
| 558 | int mode; |
| 559 | long _return_value; |
| 560 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 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()) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 580 | goto exit; |
| 581 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 582 | _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 583 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 584 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 585 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 608 | msvcrt_set_error_mode_impl(PyObject *module, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 609 | |
| 610 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 611 | msvcrt_set_error_mode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 612 | { |
| 613 | PyObject *return_value = NULL; |
| 614 | int mode; |
| 615 | long _return_value; |
| 616 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 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()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 624 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 625 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 626 | _return_value = msvcrt_set_error_mode_impl(module, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 627 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 628 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 629 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 648 | msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 649 | |
| 650 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 651 | msvcrt_SetErrorMode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 652 | { |
| 653 | PyObject *return_value = NULL; |
| 654 | unsigned int mode; |
| 655 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 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()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 663 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 664 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 665 | return_value = msvcrt_SetErrorMode_impl(module, mode); |
| 666 | |
| 667 | exit: |
| 668 | return return_value; |
| 669 | } |
| 670 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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) */ |
Serhiy Storchaka | 96631dc | 2019-08-29 18:29:59 +0300 | [diff] [blame^] | 682 | /*[clinic end generated code: output=7cc6ffaf64f268f7 input=a9049054013a1b77]*/ |