From 756c4a7107e1a3ef7afc95fe3a55b04105cbb172 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 9 Jun 2016 16:01:19 +0300 Subject: Regenerate Argument Clinic code for issue #23026. --- PC/clinic/winreg.c.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 338e33d39a..5176130014 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -907,7 +907,7 @@ PyDoc_STRVAR(winreg_SetValueEx__doc__, " An integer that specifies the type of the data, one of:\n" " REG_BINARY -- Binary data in any form.\n" " REG_DWORD -- A 32-bit number.\n" -" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n" +" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD\n" " REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n" " REG_EXPAND_SZ -- A null-terminated string that contains unexpanded\n" " references to environment variables (for example,\n" @@ -917,6 +917,8 @@ PyDoc_STRVAR(winreg_SetValueEx__doc__, " by two null characters. Note that Python handles\n" " this termination automatically.\n" " REG_NONE -- No defined value type.\n" +" REG_QWORD -- A 64-bit number.\n" +" REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD.\n" " REG_RESOURCE_LIST -- A device-driver resource list.\n" " REG_SZ -- A null-terminated string.\n" " value\n" @@ -1056,4 +1058,4 @@ winreg_QueryReflectionKey(PyModuleDef *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=5e346dccc296f9f1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0b71782e9b37b12a input=a9049054013a1b77]*/ -- cgit v1.2.1 From a397e56d2aad76fe5cacd54a2ecbdb03702985c7 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 9 Jun 2016 16:16:06 +0300 Subject: Issue #26305: Argument Clinic now uses braces in C code as required by PEP 7. --- PC/clinic/msvcrtmodule.c.h | 59 ++++++++++++++++++++----------- PC/clinic/winreg.c.h | 86 ++++++++++++++++++++++++++++++---------------- PC/clinic/winsound.c.h | 11 +++--- 3 files changed, 103 insertions(+), 53 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index c8e6ed8533..24e18cd5fb 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -51,8 +51,9 @@ msvcrt_locking(PyModuleDef *module, PyObject *args) long nbytes; if (!PyArg_ParseTuple(args, "iil:locking", - &fd, &mode, &nbytes)) + &fd, &mode, &nbytes)) { goto exit; + } return_value = msvcrt_locking_impl(module, fd, mode, nbytes); exit: @@ -85,11 +86,13 @@ msvcrt_setmode(PyModuleDef *module, PyObject *args) long _return_value; if (!PyArg_ParseTuple(args, "ii:setmode", - &fd, &flags)) + &fd, &flags)) { goto exit; + } _return_value = msvcrt_setmode_impl(module, fd, flags); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -122,11 +125,13 @@ msvcrt_open_osfhandle(PyModuleDef *module, PyObject *args) long _return_value; if (!PyArg_ParseTuple(args, ""_Py_PARSE_INTPTR"i:open_osfhandle", - &handle, &flags)) + &handle, &flags)) { goto exit; + } _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -154,11 +159,13 @@ msvcrt_get_osfhandle(PyModuleDef *module, PyObject *arg) int fd; Py_intptr_t _return_value; - if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) + if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) { goto exit; + } _return_value = msvcrt_get_osfhandle_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromVoidPtr((void *)_return_value); exit: @@ -184,8 +191,9 @@ msvcrt_kbhit(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) long _return_value; _return_value = msvcrt_kbhit_impl(module); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -312,8 +320,9 @@ msvcrt_putch(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; char char_value; - if (!PyArg_Parse(arg, "c:putch", &char_value)) + if (!PyArg_Parse(arg, "c:putch", &char_value)) { goto exit; + } return_value = msvcrt_putch_impl(module, char_value); exit: @@ -338,8 +347,9 @@ msvcrt_putwch(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; int unicode_char; - if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) + if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) { goto exit; + } return_value = msvcrt_putwch_impl(module, unicode_char); exit: @@ -368,8 +378,9 @@ msvcrt_ungetch(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; char char_value; - if (!PyArg_Parse(arg, "c:ungetch", &char_value)) + if (!PyArg_Parse(arg, "c:ungetch", &char_value)) { goto exit; + } return_value = msvcrt_ungetch_impl(module, char_value); exit: @@ -394,8 +405,9 @@ msvcrt_ungetwch(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; int unicode_char; - if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) + if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) { goto exit; + } return_value = msvcrt_ungetwch_impl(module, unicode_char); exit: @@ -427,11 +439,13 @@ msvcrt_CrtSetReportFile(PyModuleDef *module, PyObject *args) long _return_value; if (!PyArg_ParseTuple(args, "ii:CrtSetReportFile", - &type, &file)) + &type, &file)) { goto exit; + } _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -465,11 +479,13 @@ msvcrt_CrtSetReportMode(PyModuleDef *module, PyObject *args) long _return_value; if (!PyArg_ParseTuple(args, "ii:CrtSetReportMode", - &type, &mode)) + &type, &mode)) { goto exit; + } _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -501,11 +517,13 @@ msvcrt_set_error_mode(PyModuleDef *module, PyObject *arg) int mode; long _return_value; - if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) + if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) { goto exit; + } _return_value = msvcrt_set_error_mode_impl(module, mode); - if ((_return_value == -1) && PyErr_Occurred()) + if ((_return_value == -1) && PyErr_Occurred()) { goto exit; + } return_value = PyLong_FromLong(_return_value); exit: @@ -532,8 +550,9 @@ msvcrt_SetErrorMode(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; unsigned int mode; - if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) + if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) { goto exit; + } return_value = msvcrt_SetErrorMode_impl(module, mode); exit: @@ -551,4 +570,4 @@ exit: #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=16613d3119a1fd44 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=636de3460aecbca7 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 5176130014..f3a4cd1f69 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -93,8 +93,9 @@ winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) PyObject *traceback; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:__exit__", _keywords, - &exc_type, &exc_value, &traceback)) + &exc_type, &exc_value, &traceback)) { goto exit; + } return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); exit: @@ -147,11 +148,13 @@ winreg_ConnectRegistry(PyModuleDef *module, PyObject *args) HKEY _return_value; if (!PyArg_ParseTuple(args, "ZO&:ConnectRegistry", - &computer_name, clinic_HKEY_converter, &key)) + &computer_name, clinic_HKEY_converter, &key)) { goto exit; + } _return_value = winreg_ConnectRegistry_impl(module, computer_name, key); - if (_return_value == NULL) + if (_return_value == NULL) { goto exit; + } return_value = PyHKEY_FromHKEY(_return_value); exit: @@ -192,11 +195,13 @@ winreg_CreateKey(PyModuleDef *module, PyObject *args) HKEY _return_value; if (!PyArg_ParseTuple(args, "O&Z:CreateKey", - clinic_HKEY_converter, &key, &sub_key)) + clinic_HKEY_converter, &key, &sub_key)) { goto exit; + } _return_value = winreg_CreateKey_impl(module, key, sub_key); - if (_return_value == NULL) + if (_return_value == NULL) { goto exit; + } return_value = PyHKEY_FromHKEY(_return_value); exit: @@ -247,11 +252,13 @@ winreg_CreateKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) HKEY _return_value; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:CreateKeyEx", _keywords, - clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) + clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; + } _return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) + if (_return_value == NULL) { goto exit; + } return_value = PyHKEY_FromHKEY(_return_value); exit: @@ -290,8 +297,9 @@ winreg_DeleteKey(PyModuleDef *module, PyObject *args) Py_UNICODE *sub_key; if (!PyArg_ParseTuple(args, "O&u:DeleteKey", - clinic_HKEY_converter, &key, &sub_key)) + clinic_HKEY_converter, &key, &sub_key)) { goto exit; + } return_value = winreg_DeleteKey_impl(module, key, sub_key); exit: @@ -341,8 +349,9 @@ winreg_DeleteKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) int reserved = 0; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&u|ii:DeleteKeyEx", _keywords, - clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) + clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) { goto exit; + } return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved); exit: @@ -374,8 +383,9 @@ winreg_DeleteValue(PyModuleDef *module, PyObject *args) Py_UNICODE *value; if (!PyArg_ParseTuple(args, "O&Z:DeleteValue", - clinic_HKEY_converter, &key, &value)) + clinic_HKEY_converter, &key, &value)) { goto exit; + } return_value = winreg_DeleteValue_impl(module, key, value); exit: @@ -411,8 +421,9 @@ winreg_EnumKey(PyModuleDef *module, PyObject *args) int index; if (!PyArg_ParseTuple(args, "O&i:EnumKey", - clinic_HKEY_converter, &key, &index)) + clinic_HKEY_converter, &key, &index)) { goto exit; + } return_value = winreg_EnumKey_impl(module, key, index); exit: @@ -457,8 +468,9 @@ winreg_EnumValue(PyModuleDef *module, PyObject *args) int index; if (!PyArg_ParseTuple(args, "O&i:EnumValue", - clinic_HKEY_converter, &key, &index)) + clinic_HKEY_converter, &key, &index)) { goto exit; + } return_value = winreg_EnumValue_impl(module, key, index); exit: @@ -483,8 +495,9 @@ winreg_ExpandEnvironmentStrings(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; Py_UNICODE *string; - if (!PyArg_Parse(arg, "u:ExpandEnvironmentStrings", &string)) + if (!PyArg_Parse(arg, "u:ExpandEnvironmentStrings", &string)) { goto exit; + } return_value = winreg_ExpandEnvironmentStrings_impl(module, string); exit: @@ -522,8 +535,9 @@ winreg_FlushKey(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) + if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) { goto exit; + } return_value = winreg_FlushKey_impl(module, key); exit: @@ -574,8 +588,9 @@ winreg_LoadKey(PyModuleDef *module, PyObject *args) Py_UNICODE *file_name; if (!PyArg_ParseTuple(args, "O&uu:LoadKey", - clinic_HKEY_converter, &key, &sub_key, &file_name)) + clinic_HKEY_converter, &key, &sub_key, &file_name)) { goto exit; + } return_value = winreg_LoadKey_impl(module, key, sub_key, file_name); exit: @@ -620,11 +635,13 @@ winreg_OpenKey(PyModuleDef *module, PyObject *args, PyObject *kwargs) HKEY _return_value; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKey", _keywords, - clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) + clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; + } _return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) + if (_return_value == NULL) { goto exit; + } return_value = PyHKEY_FromHKEY(_return_value); exit: @@ -669,11 +686,13 @@ winreg_OpenKeyEx(PyModuleDef *module, PyObject *args, PyObject *kwargs) HKEY _return_value; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKeyEx", _keywords, - clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) + clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; + } _return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) + if (_return_value == NULL) { goto exit; + } return_value = PyHKEY_FromHKEY(_return_value); exit: @@ -707,8 +726,9 @@ winreg_QueryInfoKey(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) + if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) { goto exit; + } return_value = winreg_QueryInfoKey_impl(module, key); exit: @@ -749,8 +769,9 @@ winreg_QueryValue(PyModuleDef *module, PyObject *args) Py_UNICODE *sub_key; if (!PyArg_ParseTuple(args, "O&Z:QueryValue", - clinic_HKEY_converter, &key, &sub_key)) + clinic_HKEY_converter, &key, &sub_key)) { goto exit; + } return_value = winreg_QueryValue_impl(module, key, sub_key); exit: @@ -787,8 +808,9 @@ winreg_QueryValueEx(PyModuleDef *module, PyObject *args) Py_UNICODE *name; if (!PyArg_ParseTuple(args, "O&Z:QueryValueEx", - clinic_HKEY_converter, &key, &name)) + clinic_HKEY_converter, &key, &name)) { goto exit; + } return_value = winreg_QueryValueEx_impl(module, key, name); exit: @@ -830,8 +852,9 @@ winreg_SaveKey(PyModuleDef *module, PyObject *args) Py_UNICODE *file_name; if (!PyArg_ParseTuple(args, "O&u:SaveKey", - clinic_HKEY_converter, &key, &file_name)) + clinic_HKEY_converter, &key, &file_name)) { goto exit; + } return_value = winreg_SaveKey_impl(module, key, file_name); exit: @@ -883,8 +906,9 @@ winreg_SetValue(PyModuleDef *module, PyObject *args) Py_ssize_clean_t value_length; if (!PyArg_ParseTuple(args, "O&Zku#:SetValue", - clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length)) + clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length)) { goto exit; + } return_value = winreg_SetValue_impl(module, key, sub_key, type, value, value_length); exit: @@ -952,8 +976,9 @@ winreg_SetValueEx(PyModuleDef *module, PyObject *args) PyObject *value; if (!PyArg_ParseTuple(args, "O&ZOkO:SetValueEx", - clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value)) + clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value)) { goto exit; + } return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value); exit: @@ -987,8 +1012,9 @@ winreg_DisableReflectionKey(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) + if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) { goto exit; + } return_value = winreg_DisableReflectionKey_impl(module, key); exit: @@ -1020,8 +1046,9 @@ winreg_EnableReflectionKey(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) + if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) { goto exit; + } return_value = winreg_EnableReflectionKey_impl(module, key); exit: @@ -1051,11 +1078,12 @@ winreg_QueryReflectionKey(PyModuleDef *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) + if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) { goto exit; + } return_value = winreg_QueryReflectionKey_impl(module, key); exit: return return_value; } -/*[clinic end generated code: output=0b71782e9b37b12a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ca128bfa212d8d1f input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index dca5a429f3..e649363fe2 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -27,8 +27,9 @@ winsound_PlaySound(PyModuleDef *module, PyObject *args) int flags; if (!PyArg_ParseTuple(args, "Zi:PlaySound", - &sound, &flags)) + &sound, &flags)) { goto exit; + } return_value = winsound_PlaySound_impl(module, sound, flags); exit: @@ -61,8 +62,9 @@ winsound_Beep(PyModuleDef *module, PyObject *args) int duration; if (!PyArg_ParseTuple(args, "ii:Beep", - &frequency, &duration)) + &frequency, &duration)) { goto exit; + } return_value = winsound_Beep_impl(module, frequency, duration); exit: @@ -90,11 +92,12 @@ winsound_MessageBeep(PyModuleDef *module, PyObject *args) int x = MB_OK; if (!PyArg_ParseTuple(args, "|i:MessageBeep", - &x)) + &x)) { goto exit; + } return_value = winsound_MessageBeep_impl(module, x); exit: return return_value; } -/*[clinic end generated code: output=c5b018ac9dc1f500 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a5f53e42d4396bb4 input=a9049054013a1b77]*/ -- cgit v1.2.1 From 96d299b2b87dd2311bcc94cbab7b1cfa2c30ccba Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 14 Aug 2016 10:52:18 +0300 Subject: Issue #27574: Decreased an overhead of parsing keyword arguments in functions implemented with using Argument Clinic. --- PC/clinic/winreg.c.h | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 264dcf0c61..e7836e4fe2 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -87,12 +87,13 @@ static PyObject * winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - static char *_keywords[] = {"exc_type", "exc_value", "traceback", NULL}; + static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; + static _PyArg_Parser _parser = {"OOO:__exit__", _keywords, 0}; PyObject *exc_type; PyObject *exc_value; PyObject *traceback; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:__exit__", _keywords, + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, &exc_type, &exc_value, &traceback)) { goto exit; } @@ -244,14 +245,15 @@ static PyObject * winreg_CreateKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static _PyArg_Parser _parser = {"O&Z|ii:CreateKeyEx", _keywords, 0}; HKEY key; Py_UNICODE *sub_key; int reserved = 0; REGSAM access = KEY_WRITE; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:CreateKeyEx", _keywords, + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -342,13 +344,14 @@ static PyObject * winreg_DeleteKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - static char *_keywords[] = {"key", "sub_key", "access", "reserved", NULL}; + static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL}; + static _PyArg_Parser _parser = {"O&u|ii:DeleteKeyEx", _keywords, 0}; HKEY key; Py_UNICODE *sub_key; REGSAM access = KEY_WOW64_64KEY; int reserved = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&u|ii:DeleteKeyEx", _keywords, + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) { goto exit; } @@ -627,14 +630,15 @@ static PyObject * winreg_OpenKey(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static _PyArg_Parser _parser = {"O&Z|ii:OpenKey", _keywords, 0}; HKEY key; Py_UNICODE *sub_key; int reserved = 0; REGSAM access = KEY_READ; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKey", _keywords, + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -678,14 +682,15 @@ static PyObject * winreg_OpenKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - static char *_keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; + static _PyArg_Parser _parser = {"O&Z|ii:OpenKeyEx", _keywords, 0}; HKEY key; Py_UNICODE *sub_key; int reserved = 0; REGSAM access = KEY_READ; HKEY _return_value; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKeyEx", _keywords, + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -1086,4 +1091,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=c35ce71f825424d1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5b53d19cbe3f37cd input=a9049054013a1b77]*/ -- cgit v1.2.1 From d4c6b44f0689ed5f7f98eed08bcaeb3a8cb164bc Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Mon, 5 Sep 2016 16:31:21 -0500 Subject: Closes #11620: Fix support for SND_MEMORY in winsound.PlaySound. Based on a patch by Tim Lesher. --- PC/clinic/winsound.c.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index cdb20454a5..a4c393856f 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -17,16 +17,16 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, {"PlaySound", (PyCFunction)winsound_PlaySound, METH_VARARGS, winsound_PlaySound__doc__}, static PyObject * -winsound_PlaySound_impl(PyObject *module, Py_UNICODE *sound, int flags); +winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); static PyObject * winsound_PlaySound(PyObject *module, PyObject *args) { PyObject *return_value = NULL; - Py_UNICODE *sound; + PyObject *sound; int flags; - if (!PyArg_ParseTuple(args, "Zi:PlaySound", + if (!PyArg_ParseTuple(args, "Oi:PlaySound", &sound, &flags)) { goto exit; } @@ -100,4 +100,4 @@ winsound_MessageBeep(PyObject *module, PyObject *args) exit: return return_value; } -/*[clinic end generated code: output=1044b2adf3c67014 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b999334e2e444ad2 input=a9049054013a1b77]*/ -- cgit v1.2.1 From 1b330a040ac363eea07d1e0e0c4dc8b1f4d8b02c Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Tue, 6 Sep 2016 16:32:43 -0500 Subject: Closes #27982: Allow keyword arguments to winsound functions --- PC/clinic/winsound.c.h | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index a4c393856f..766479ada2 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -3,7 +3,7 @@ preserve [clinic start generated code]*/ PyDoc_STRVAR(winsound_PlaySound__doc__, -"PlaySound($module, sound, flags, /)\n" +"PlaySound($module, /, sound, flags)\n" "--\n" "\n" "A wrapper around the Windows PlaySound API.\n" @@ -14,19 +14,21 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, " Flag values, ored together. See module documentation."); #define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)winsound_PlaySound, METH_VARARGS, winsound_PlaySound__doc__}, + {"PlaySound", (PyCFunction)winsound_PlaySound, METH_VARARGS|METH_KEYWORDS, winsound_PlaySound__doc__}, static PyObject * winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); static PyObject * -winsound_PlaySound(PyObject *module, PyObject *args) +winsound_PlaySound(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; + static const char * const _keywords[] = {"sound", "flags", NULL}; + static _PyArg_Parser _parser = {"Oi:PlaySound", _keywords, 0}; PyObject *sound; int flags; - if (!PyArg_ParseTuple(args, "Oi:PlaySound", + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, &sound, &flags)) { goto exit; } @@ -37,7 +39,7 @@ exit: } PyDoc_STRVAR(winsound_Beep__doc__, -"Beep($module, frequency, duration, /)\n" +"Beep($module, /, frequency, duration)\n" "--\n" "\n" "A wrapper around the Windows Beep API.\n" @@ -49,19 +51,21 @@ PyDoc_STRVAR(winsound_Beep__doc__, " How long the sound should play, in milliseconds."); #define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)winsound_Beep, METH_VARARGS, winsound_Beep__doc__}, + {"Beep", (PyCFunction)winsound_Beep, METH_VARARGS|METH_KEYWORDS, winsound_Beep__doc__}, static PyObject * winsound_Beep_impl(PyObject *module, int frequency, int duration); static PyObject * -winsound_Beep(PyObject *module, PyObject *args) +winsound_Beep(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; + static const char * const _keywords[] = {"frequency", "duration", NULL}; + static _PyArg_Parser _parser = {"ii:Beep", _keywords, 0}; int frequency; int duration; - if (!PyArg_ParseTuple(args, "ii:Beep", + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, &frequency, &duration)) { goto exit; } @@ -72,7 +76,7 @@ exit: } PyDoc_STRVAR(winsound_MessageBeep__doc__, -"MessageBeep($module, x=MB_OK, /)\n" +"MessageBeep($module, /, type=MB_OK)\n" "--\n" "\n" "Call Windows MessageBeep(x).\n" @@ -80,24 +84,26 @@ PyDoc_STRVAR(winsound_MessageBeep__doc__, "x defaults to MB_OK."); #define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_VARARGS, winsound_MessageBeep__doc__}, + {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_VARARGS|METH_KEYWORDS, winsound_MessageBeep__doc__}, static PyObject * -winsound_MessageBeep_impl(PyObject *module, int x); +winsound_MessageBeep_impl(PyObject *module, int type); static PyObject * -winsound_MessageBeep(PyObject *module, PyObject *args) +winsound_MessageBeep(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - int x = MB_OK; + static const char * const _keywords[] = {"type", NULL}; + static _PyArg_Parser _parser = {"|i:MessageBeep", _keywords, 0}; + int type = MB_OK; - if (!PyArg_ParseTuple(args, "|i:MessageBeep", - &x)) { + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + &type)) { goto exit; } - return_value = winsound_MessageBeep_impl(module, x); + return_value = winsound_MessageBeep_impl(module, type); exit: return return_value; } -/*[clinic end generated code: output=b999334e2e444ad2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=40b3d3ef2faefb15 input=a9049054013a1b77]*/ -- cgit v1.2.1 From b799c960150c910abd8e633001f14079a6360a7e Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 8 Sep 2016 09:29:11 -0700 Subject: clinic: PY_LONG_LONG -> long long --- PC/clinic/msvcrtmodule.c.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index a5b4ccf379..6935cad7b0 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -113,13 +113,13 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_VARARGS, msvcrt_open_osfhandle__doc__}, static long -msvcrt_open_osfhandle_impl(PyObject *module, Py_intptr_t handle, int flags); +msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags); static PyObject * msvcrt_open_osfhandle(PyObject *module, PyObject *args) { PyObject *return_value = NULL; - Py_intptr_t handle; + intptr_t handle; int flags; long _return_value; @@ -148,7 +148,7 @@ PyDoc_STRVAR(msvcrt_get_osfhandle__doc__, #define MSVCRT_GET_OSFHANDLE_METHODDEF \ {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__}, -static Py_intptr_t +static intptr_t msvcrt_get_osfhandle_impl(PyObject *module, int fd); static PyObject * @@ -156,7 +156,7 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; int fd; - Py_intptr_t _return_value; + intptr_t _return_value; if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) { goto exit; @@ -569,4 +569,4 @@ exit: #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=ece8106c0592ff1f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ae04e2b50eef8b63 input=a9049054013a1b77]*/ -- cgit v1.2.1 From daa2ed44798ad45ac665321cae21a23661d0e044 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Sep 2016 20:00:13 -0700 Subject: Issue #27810: Rerun Argument Clinic on all modules --- PC/clinic/winreg.c.h | 32 ++++++++++++++++---------------- PC/clinic/winsound.c.h | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'PC/clinic') diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index e7836e4fe2..c7d5b9e452 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -77,14 +77,14 @@ PyDoc_STRVAR(winreg_HKEYType___exit____doc__, "\n"); #define WINREG_HKEYTYPE___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)winreg_HKEYType___exit__, METH_VARARGS|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, + {"__exit__", (PyCFunction)winreg_HKEYType___exit__, METH_FASTCALL, winreg_HKEYType___exit____doc__}, static PyObject * winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, PyObject *exc_value, PyObject *traceback); static PyObject * -winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) +winreg_HKEYType___exit__(PyHKEYObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; @@ -93,7 +93,7 @@ winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *args, PyObject *kwargs) PyObject *exc_value; PyObject *traceback; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &exc_type, &exc_value, &traceback)) { goto exit; } @@ -235,14 +235,14 @@ PyDoc_STRVAR(winreg_CreateKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEYEX_METHODDEF \ - {"CreateKeyEx", (PyCFunction)winreg_CreateKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, + {"CreateKeyEx", (PyCFunction)winreg_CreateKeyEx, METH_FASTCALL, winreg_CreateKeyEx__doc__}, static HKEY winreg_CreateKeyEx_impl(PyObject *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_CreateKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) +winreg_CreateKeyEx(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -253,7 +253,7 @@ winreg_CreateKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) REGSAM access = KEY_WRITE; HKEY _return_value; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -334,14 +334,14 @@ PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, "On unsupported Windows versions, NotImplementedError is raised."); #define WINREG_DELETEKEYEX_METHODDEF \ - {"DeleteKeyEx", (PyCFunction)winreg_DeleteKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, + {"DeleteKeyEx", (PyCFunction)winreg_DeleteKeyEx, METH_FASTCALL, winreg_DeleteKeyEx__doc__}, static PyObject * winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, Py_UNICODE *sub_key, REGSAM access, int reserved); static PyObject * -winreg_DeleteKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) +winreg_DeleteKeyEx(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL}; @@ -351,7 +351,7 @@ winreg_DeleteKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) REGSAM access = KEY_WOW64_64KEY; int reserved = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) { goto exit; } @@ -620,14 +620,14 @@ PyDoc_STRVAR(winreg_OpenKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEY_METHODDEF \ - {"OpenKey", (PyCFunction)winreg_OpenKey, METH_VARARGS|METH_KEYWORDS, winreg_OpenKey__doc__}, + {"OpenKey", (PyCFunction)winreg_OpenKey, METH_FASTCALL, winreg_OpenKey__doc__}, static HKEY winreg_OpenKey_impl(PyObject *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_OpenKey(PyObject *module, PyObject *args, PyObject *kwargs) +winreg_OpenKey(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -638,7 +638,7 @@ winreg_OpenKey(PyObject *module, PyObject *args, PyObject *kwargs) REGSAM access = KEY_READ; HKEY _return_value; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -672,14 +672,14 @@ PyDoc_STRVAR(winreg_OpenKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEYEX_METHODDEF \ - {"OpenKeyEx", (PyCFunction)winreg_OpenKeyEx, METH_VARARGS|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, + {"OpenKeyEx", (PyCFunction)winreg_OpenKeyEx, METH_FASTCALL, winreg_OpenKeyEx__doc__}, static HKEY winreg_OpenKeyEx_impl(PyObject *module, HKEY key, Py_UNICODE *sub_key, int reserved, REGSAM access); static PyObject * -winreg_OpenKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) +winreg_OpenKeyEx(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; @@ -690,7 +690,7 @@ winreg_OpenKeyEx(PyObject *module, PyObject *args, PyObject *kwargs) REGSAM access = KEY_READ; HKEY _return_value; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) { goto exit; } @@ -1091,4 +1091,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=5b53d19cbe3f37cd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=16dd06be6e14b86e input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index 766479ada2..52d25b2434 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -14,13 +14,13 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, " Flag values, ored together. See module documentation."); #define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)winsound_PlaySound, METH_VARARGS|METH_KEYWORDS, winsound_PlaySound__doc__}, + {"PlaySound", (PyCFunction)winsound_PlaySound, METH_FASTCALL, winsound_PlaySound__doc__}, static PyObject * winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); static PyObject * -winsound_PlaySound(PyObject *module, PyObject *args, PyObject *kwargs) +winsound_PlaySound(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sound", "flags", NULL}; @@ -28,7 +28,7 @@ winsound_PlaySound(PyObject *module, PyObject *args, PyObject *kwargs) PyObject *sound; int flags; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &sound, &flags)) { goto exit; } @@ -51,13 +51,13 @@ PyDoc_STRVAR(winsound_Beep__doc__, " How long the sound should play, in milliseconds."); #define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)winsound_Beep, METH_VARARGS|METH_KEYWORDS, winsound_Beep__doc__}, + {"Beep", (PyCFunction)winsound_Beep, METH_FASTCALL, winsound_Beep__doc__}, static PyObject * winsound_Beep_impl(PyObject *module, int frequency, int duration); static PyObject * -winsound_Beep(PyObject *module, PyObject *args, PyObject *kwargs) +winsound_Beep(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"frequency", "duration", NULL}; @@ -65,7 +65,7 @@ winsound_Beep(PyObject *module, PyObject *args, PyObject *kwargs) int frequency; int duration; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &frequency, &duration)) { goto exit; } @@ -84,20 +84,20 @@ PyDoc_STRVAR(winsound_MessageBeep__doc__, "x defaults to MB_OK."); #define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_VARARGS|METH_KEYWORDS, winsound_MessageBeep__doc__}, + {"MessageBeep", (PyCFunction)winsound_MessageBeep, METH_FASTCALL, winsound_MessageBeep__doc__}, static PyObject * winsound_MessageBeep_impl(PyObject *module, int type); static PyObject * -winsound_MessageBeep(PyObject *module, PyObject *args, PyObject *kwargs) +winsound_MessageBeep(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; static const char * const _keywords[] = {"type", NULL}; static _PyArg_Parser _parser = {"|i:MessageBeep", _keywords, 0}; int type = MB_OK; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &type)) { goto exit; } @@ -106,4 +106,4 @@ winsound_MessageBeep(PyObject *module, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=40b3d3ef2faefb15 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bfe16b2b8b490cb1 input=a9049054013a1b77]*/ -- cgit v1.2.1 From 3d0d1e31a864f8eac69b4fd63ccd947fb0d7c58b Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 3 Oct 2016 09:04:58 -0700 Subject: Issue #28217: Adds _testconsole module to test console input. Fixes some issues found by the tests. --- PC/clinic/_testconsole.c.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 PC/clinic/_testconsole.c.h (limited to 'PC/clinic') diff --git a/PC/clinic/_testconsole.c.h b/PC/clinic/_testconsole.c.h new file mode 100644 index 0000000000..93860cf5b2 --- /dev/null +++ b/PC/clinic/_testconsole.c.h @@ -0,0 +1,82 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(_testconsole_write_input__doc__, +"write_input($module, /, file, s)\n" +"--\n" +"\n" +"Writes UTF-16-LE encoded bytes to the console as if typed by a user."); + +#define _TESTCONSOLE_WRITE_INPUT_METHODDEF \ + {"write_input", (PyCFunction)_testconsole_write_input, METH_FASTCALL, _testconsole_write_input__doc__}, + +static PyObject * +_testconsole_write_input_impl(PyObject *module, PyObject *file, + PyBytesObject *s); + +static PyObject * +_testconsole_write_input(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"file", "s", NULL}; + static _PyArg_Parser _parser = {"OS:write_input", _keywords, 0}; + PyObject *file; + PyBytesObject *s; + + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + &file, &s)) { + goto exit; + } + return_value = _testconsole_write_input_impl(module, file, s); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(_testconsole_read_output__doc__, +"read_output($module, /, file)\n" +"--\n" +"\n" +"Reads a str from the console as written to stdout."); + +#define _TESTCONSOLE_READ_OUTPUT_METHODDEF \ + {"read_output", (PyCFunction)_testconsole_read_output, METH_FASTCALL, _testconsole_read_output__doc__}, + +static PyObject * +_testconsole_read_output_impl(PyObject *module, PyObject *file); + +static PyObject * +_testconsole_read_output(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"file", NULL}; + static _PyArg_Parser _parser = {"O:read_output", _keywords, 0}; + PyObject *file; + + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + &file)) { + goto exit; + } + return_value = _testconsole_read_output_impl(module, file); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef _TESTCONSOLE_WRITE_INPUT_METHODDEF + #define _TESTCONSOLE_WRITE_INPUT_METHODDEF +#endif /* !defined(_TESTCONSOLE_WRITE_INPUT_METHODDEF) */ + +#ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF + #define _TESTCONSOLE_READ_OUTPUT_METHODDEF +#endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */ +/*[clinic end generated code: output=3a8dc0c421807c41 input=a9049054013a1b77]*/ -- cgit v1.2.1