diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/PC | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/PC')
-rw-r--r-- | contrib/tools/python3/src/PC/clinic/msvcrtmodule.c.h | 270 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/clinic/winreg.c.h | 118 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/clinic/winsound.c.h | 116 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/dl_nt.c | 2 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/errmap.h | 274 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/getpathp.c | 722 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/msvcrtmodule.c | 24 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/pyconfig.h | 42 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/python_ver_rc.h | 4 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/winreg.c | 386 |
10 files changed, 979 insertions, 979 deletions
diff --git a/contrib/tools/python3/src/PC/clinic/msvcrtmodule.c.h b/contrib/tools/python3/src/PC/clinic/msvcrtmodule.c.h index 1d6fc686dc..180c3e5fc5 100644 --- a/contrib/tools/python3/src/PC/clinic/msvcrtmodule.c.h +++ b/contrib/tools/python3/src/PC/clinic/msvcrtmodule.c.h @@ -37,7 +37,7 @@ PyDoc_STRVAR(msvcrt_locking__doc__, "individually."); #define MSVCRT_LOCKING_METHODDEF \ - {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, + {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, static PyObject * msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes); @@ -50,36 +50,36 @@ msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int mode; long nbytes; - if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[2])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - nbytes = PyLong_AsLong(args[2]); - if (nbytes == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + nbytes = PyLong_AsLong(args[2]); + if (nbytes == -1 && PyErr_Occurred()) { + goto exit; + } return_value = msvcrt_locking_impl(module, fd, mode, nbytes); exit: @@ -98,7 +98,7 @@ PyDoc_STRVAR(msvcrt_setmode__doc__, "Return value is the previous mode."); #define MSVCRT_SETMODE_METHODDEF \ - {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, + {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, static long msvcrt_setmode_impl(PyObject *module, int fd, int flags); @@ -111,27 +111,27 @@ msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) int flags; long _return_value; - if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = msvcrt_setmode_impl(module, fd, flags); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -153,7 +153,7 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, "to os.fdopen() to create a file object."); #define MSVCRT_OPEN_OSFHANDLE_METHODDEF \ - {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, + {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, static long msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); @@ -201,15 +201,15 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg) int fd; void *_return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(arg); + if (fd == -1 && PyErr_Occurred()) { goto exit; } - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } _return_value = msvcrt_get_osfhandle_impl(module, fd); if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; @@ -368,14 +368,14 @@ msvcrt_putch(PyObject *module, PyObject *arg) PyObject *return_value = NULL; char char_value; - if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { - char_value = PyBytes_AS_STRING(arg)[0]; - } - else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { - char_value = PyByteArray_AS_STRING(arg)[0]; - } - else { - _PyArg_BadArgument("putch", "argument", "a byte string of length 1", arg); + if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { + char_value = PyBytes_AS_STRING(arg)[0]; + } + else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { + char_value = PyByteArray_AS_STRING(arg)[0]; + } + else { + _PyArg_BadArgument("putch", "argument", "a byte string of length 1", arg); goto exit; } return_value = msvcrt_putch_impl(module, char_value); @@ -402,18 +402,18 @@ msvcrt_putwch(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int unicode_char; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { goto exit; } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); - goto exit; - } - unicode_char = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); + goto exit; + } + unicode_char = PyUnicode_READ_CHAR(arg, 0); return_value = msvcrt_putwch_impl(module, unicode_char); exit: @@ -442,14 +442,14 @@ msvcrt_ungetch(PyObject *module, PyObject *arg) PyObject *return_value = NULL; char char_value; - if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { - char_value = PyBytes_AS_STRING(arg)[0]; - } - else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { - char_value = PyByteArray_AS_STRING(arg)[0]; - } - else { - _PyArg_BadArgument("ungetch", "argument", "a byte string of length 1", arg); + if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { + char_value = PyBytes_AS_STRING(arg)[0]; + } + else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { + char_value = PyByteArray_AS_STRING(arg)[0]; + } + else { + _PyArg_BadArgument("ungetch", "argument", "a byte string of length 1", arg); goto exit; } return_value = msvcrt_ungetch_impl(module, char_value); @@ -476,18 +476,18 @@ msvcrt_ungetwch(PyObject *module, PyObject *arg) PyObject *return_value = NULL; int unicode_char; - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); + goto exit; + } + if (PyUnicode_READY(arg)) { goto exit; } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); - goto exit; - } - unicode_char = PyUnicode_READ_CHAR(arg, 0); + if (PyUnicode_GET_LENGTH(arg) != 1) { + _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); + goto exit; + } + unicode_char = PyUnicode_READ_CHAR(arg, 0); return_value = msvcrt_ungetwch_impl(module, unicode_char); exit: @@ -505,7 +505,7 @@ PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__, "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTFILE_METHODDEF \ - {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, + {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, static void * msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); @@ -545,7 +545,7 @@ PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__, "Only available on Debug builds."); #define MSVCRT_CRTSETREPORTMODE_METHODDEF \ - {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, + {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, static long msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); @@ -558,27 +558,27 @@ msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t narg int mode; long _return_value; - if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) { - goto exit; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - type = _PyLong_AsInt(args[0]); - if (type == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } + if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + type = _PyLong_AsInt(args[0]); + if (type == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -614,15 +614,15 @@ msvcrt_set_error_mode(PyObject *module, PyObject *arg) int mode; long _return_value; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(arg); + if (mode == -1 && PyErr_Occurred()) { goto exit; } - mode = _PyLong_AsInt(arg); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } _return_value = msvcrt_set_error_mode_impl(module, mode); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -653,15 +653,15 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) PyObject *return_value = NULL; unsigned int mode; - if (PyFloat_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = (unsigned int)PyLong_AsUnsignedLongMask(arg); + if (mode == (unsigned int)-1 && PyErr_Occurred()) { goto exit; } - mode = (unsigned int)PyLong_AsUnsignedLongMask(arg); - if (mode == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } return_value = msvcrt_SetErrorMode_impl(module, mode); exit: @@ -679,4 +679,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=7cc6ffaf64f268f7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7cc6ffaf64f268f7 input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/PC/clinic/winreg.c.h b/contrib/tools/python3/src/PC/clinic/winreg.c.h index 8fab1540a1..b7af1855ac 100644 --- a/contrib/tools/python3/src/PC/clinic/winreg.c.h +++ b/contrib/tools/python3/src/PC/clinic/winreg.c.h @@ -77,7 +77,7 @@ PyDoc_STRVAR(winreg_HKEYType___exit____doc__, "\n"); #define WINREG_HKEYTYPE___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))winreg_HKEYType___exit__, METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, + {"__exit__", (PyCFunction)(void(*)(void))winreg_HKEYType___exit__, METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, static PyObject * winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, @@ -88,19 +88,19 @@ winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "__exit__", 0}; - PyObject *argsbuf[3]; + static _PyArg_Parser _parser = {NULL, _keywords, "__exit__", 0}; + PyObject *argsbuf[3]; PyObject *exc_type; PyObject *exc_value; PyObject *traceback; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } - exc_type = args[0]; - exc_value = args[1]; - traceback = args[2]; + exc_type = args[0]; + exc_value = args[1]; + traceback = args[2]; return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); exit: @@ -138,7 +138,7 @@ PyDoc_STRVAR(winreg_ConnectRegistry__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CONNECTREGISTRY_METHODDEF \ - {"ConnectRegistry", (PyCFunction)(void(*)(void))winreg_ConnectRegistry, METH_FASTCALL, winreg_ConnectRegistry__doc__}, + {"ConnectRegistry", (PyCFunction)(void(*)(void))winreg_ConnectRegistry, METH_FASTCALL, winreg_ConnectRegistry__doc__}, static HKEY winreg_ConnectRegistry_impl(PyObject *module, @@ -186,7 +186,7 @@ PyDoc_STRVAR(winreg_CreateKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEY_METHODDEF \ - {"CreateKey", (PyCFunction)(void(*)(void))winreg_CreateKey, METH_FASTCALL, winreg_CreateKey__doc__}, + {"CreateKey", (PyCFunction)(void(*)(void))winreg_CreateKey, METH_FASTCALL, winreg_CreateKey__doc__}, static HKEY winreg_CreateKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -239,7 +239,7 @@ PyDoc_STRVAR(winreg_CreateKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_CREATEKEYEX_METHODDEF \ - {"CreateKeyEx", (PyCFunction)(void(*)(void))winreg_CreateKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, + {"CreateKeyEx", (PyCFunction)(void(*)(void))winreg_CreateKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, static HKEY winreg_CreateKeyEx_impl(PyObject *module, HKEY key, @@ -291,7 +291,7 @@ PyDoc_STRVAR(winreg_DeleteKey__doc__, "is removed. If the function fails, an OSError exception is raised."); #define WINREG_DELETEKEY_METHODDEF \ - {"DeleteKey", (PyCFunction)(void(*)(void))winreg_DeleteKey, METH_FASTCALL, winreg_DeleteKey__doc__}, + {"DeleteKey", (PyCFunction)(void(*)(void))winreg_DeleteKey, METH_FASTCALL, winreg_DeleteKey__doc__}, static PyObject * winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -339,7 +339,7 @@ PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, "On unsupported Windows versions, NotImplementedError is raised."); #define WINREG_DELETEKEYEX_METHODDEF \ - {"DeleteKeyEx", (PyCFunction)(void(*)(void))winreg_DeleteKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, + {"DeleteKeyEx", (PyCFunction)(void(*)(void))winreg_DeleteKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, static PyObject * winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, @@ -379,7 +379,7 @@ PyDoc_STRVAR(winreg_DeleteValue__doc__, " A string that identifies the value to remove."); #define WINREG_DELETEVALUE_METHODDEF \ - {"DeleteValue", (PyCFunction)(void(*)(void))winreg_DeleteValue, METH_FASTCALL, winreg_DeleteValue__doc__}, + {"DeleteValue", (PyCFunction)(void(*)(void))winreg_DeleteValue, METH_FASTCALL, winreg_DeleteValue__doc__}, static PyObject * winreg_DeleteValue_impl(PyObject *module, HKEY key, const Py_UNICODE *value); @@ -417,7 +417,7 @@ PyDoc_STRVAR(winreg_EnumKey__doc__, "raised, indicating no more values are available."); #define WINREG_ENUMKEY_METHODDEF \ - {"EnumKey", (PyCFunction)(void(*)(void))winreg_EnumKey, METH_FASTCALL, winreg_EnumKey__doc__}, + {"EnumKey", (PyCFunction)(void(*)(void))winreg_EnumKey, METH_FASTCALL, winreg_EnumKey__doc__}, static PyObject * winreg_EnumKey_impl(PyObject *module, HKEY key, int index); @@ -429,21 +429,21 @@ winreg_EnumKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) HKEY key; int index; - if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) { + goto exit; + } + if (!clinic_HKEY_converter(args[0], &key)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + index = _PyLong_AsInt(args[1]); + if (index == -1 && PyErr_Occurred()) { goto exit; } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - index = _PyLong_AsInt(args[1]); - if (index == -1 && PyErr_Occurred()) { - goto exit; - } return_value = winreg_EnumKey_impl(module, key, index); exit: @@ -475,7 +475,7 @@ PyDoc_STRVAR(winreg_EnumValue__doc__, " An integer that identifies the type of the value data."); #define WINREG_ENUMVALUE_METHODDEF \ - {"EnumValue", (PyCFunction)(void(*)(void))winreg_EnumValue, METH_FASTCALL, winreg_EnumValue__doc__}, + {"EnumValue", (PyCFunction)(void(*)(void))winreg_EnumValue, METH_FASTCALL, winreg_EnumValue__doc__}, static PyObject * winreg_EnumValue_impl(PyObject *module, HKEY key, int index); @@ -487,21 +487,21 @@ winreg_EnumValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs) HKEY key; int index; - if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) { + if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) { + goto exit; + } + if (!clinic_HKEY_converter(args[0], &key)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + index = _PyLong_AsInt(args[1]); + if (index == -1 && PyErr_Occurred()) { goto exit; } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - index = _PyLong_AsInt(args[1]); - if (index == -1 && PyErr_Occurred()) { - goto exit; - } return_value = winreg_EnumValue_impl(module, key, index); exit: @@ -567,7 +567,7 @@ winreg_FlushKey(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!clinic_HKEY_converter(arg, &key)) { + if (!clinic_HKEY_converter(arg, &key)) { goto exit; } return_value = winreg_FlushKey_impl(module, key); @@ -605,7 +605,7 @@ PyDoc_STRVAR(winreg_LoadKey__doc__, "tree."); #define WINREG_LOADKEY_METHODDEF \ - {"LoadKey", (PyCFunction)(void(*)(void))winreg_LoadKey, METH_FASTCALL, winreg_LoadKey__doc__}, + {"LoadKey", (PyCFunction)(void(*)(void))winreg_LoadKey, METH_FASTCALL, winreg_LoadKey__doc__}, static PyObject * winreg_LoadKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -649,7 +649,7 @@ PyDoc_STRVAR(winreg_OpenKey__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEY_METHODDEF \ - {"OpenKey", (PyCFunction)(void(*)(void))winreg_OpenKey, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__}, + {"OpenKey", (PyCFunction)(void(*)(void))winreg_OpenKey, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__}, static HKEY winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -701,7 +701,7 @@ PyDoc_STRVAR(winreg_OpenKeyEx__doc__, "If the function fails, an OSError exception is raised."); #define WINREG_OPENKEYEX_METHODDEF \ - {"OpenKeyEx", (PyCFunction)(void(*)(void))winreg_OpenKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, + {"OpenKeyEx", (PyCFunction)(void(*)(void))winreg_OpenKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, static HKEY winreg_OpenKeyEx_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -760,7 +760,7 @@ winreg_QueryInfoKey(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!clinic_HKEY_converter(arg, &key)) { + if (!clinic_HKEY_converter(arg, &key)) { goto exit; } return_value = winreg_QueryInfoKey_impl(module, key); @@ -790,7 +790,7 @@ PyDoc_STRVAR(winreg_QueryValue__doc__, "completeness."); #define WINREG_QUERYVALUE_METHODDEF \ - {"QueryValue", (PyCFunction)(void(*)(void))winreg_QueryValue, METH_FASTCALL, winreg_QueryValue__doc__}, + {"QueryValue", (PyCFunction)(void(*)(void))winreg_QueryValue, METH_FASTCALL, winreg_QueryValue__doc__}, static PyObject * winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); @@ -829,7 +829,7 @@ PyDoc_STRVAR(winreg_QueryValueEx__doc__, "The return value is a tuple of the value and the type_id."); #define WINREG_QUERYVALUEEX_METHODDEF \ - {"QueryValueEx", (PyCFunction)(void(*)(void))winreg_QueryValueEx, METH_FASTCALL, winreg_QueryValueEx__doc__}, + {"QueryValueEx", (PyCFunction)(void(*)(void))winreg_QueryValueEx, METH_FASTCALL, winreg_QueryValueEx__doc__}, static PyObject * winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name); @@ -873,7 +873,7 @@ PyDoc_STRVAR(winreg_SaveKey__doc__, "to the API."); #define WINREG_SAVEKEY_METHODDEF \ - {"SaveKey", (PyCFunction)(void(*)(void))winreg_SaveKey, METH_FASTCALL, winreg_SaveKey__doc__}, + {"SaveKey", (PyCFunction)(void(*)(void))winreg_SaveKey, METH_FASTCALL, winreg_SaveKey__doc__}, static PyObject * winreg_SaveKey_impl(PyObject *module, HKEY key, const Py_UNICODE *file_name); @@ -922,7 +922,7 @@ PyDoc_STRVAR(winreg_SetValue__doc__, "KEY_SET_VALUE access."); #define WINREG_SETVALUE_METHODDEF \ - {"SetValue", (PyCFunction)(void(*)(void))winreg_SetValue, METH_FASTCALL, winreg_SetValue__doc__}, + {"SetValue", (PyCFunction)(void(*)(void))winreg_SetValue, METH_FASTCALL, winreg_SetValue__doc__}, static PyObject * winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, @@ -993,7 +993,7 @@ PyDoc_STRVAR(winreg_SetValueEx__doc__, "the configuration registry to help the registry perform efficiently."); #define WINREG_SETVALUEEX_METHODDEF \ - {"SetValueEx", (PyCFunction)(void(*)(void))winreg_SetValueEx, METH_FASTCALL, winreg_SetValueEx__doc__}, + {"SetValueEx", (PyCFunction)(void(*)(void))winreg_SetValueEx, METH_FASTCALL, winreg_SetValueEx__doc__}, static PyObject * winreg_SetValueEx_impl(PyObject *module, HKEY key, @@ -1029,7 +1029,7 @@ PyDoc_STRVAR(winreg_DisableReflectionKey__doc__, " key\n" " An already open key, or any one of the predefined HKEY_* constants.\n" "\n" -"Will generally raise NotImplementedError if executed on a 32bit OS.\n" +"Will generally raise NotImplementedError if executed on a 32bit OS.\n" "\n" "If the key is not on the reflection list, the function succeeds but has\n" "no effect. Disabling reflection for a key does not affect reflection\n" @@ -1047,7 +1047,7 @@ winreg_DisableReflectionKey(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!clinic_HKEY_converter(arg, &key)) { + if (!clinic_HKEY_converter(arg, &key)) { goto exit; } return_value = winreg_DisableReflectionKey_impl(module, key); @@ -1065,7 +1065,7 @@ PyDoc_STRVAR(winreg_EnableReflectionKey__doc__, " key\n" " An already open key, or any one of the predefined HKEY_* constants.\n" "\n" -"Will generally raise NotImplementedError if executed on a 32bit OS.\n" +"Will generally raise NotImplementedError if executed on a 32bit OS.\n" "Restoring reflection for a key does not affect reflection of any\n" "subkeys."); @@ -1081,7 +1081,7 @@ winreg_EnableReflectionKey(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!clinic_HKEY_converter(arg, &key)) { + if (!clinic_HKEY_converter(arg, &key)) { goto exit; } return_value = winreg_EnableReflectionKey_impl(module, key); @@ -1099,7 +1099,7 @@ PyDoc_STRVAR(winreg_QueryReflectionKey__doc__, " key\n" " An already open key, or any one of the predefined HKEY_* constants.\n" "\n" -"Will generally raise NotImplementedError if executed on a 32bit OS."); +"Will generally raise NotImplementedError if executed on a 32bit OS."); #define WINREG_QUERYREFLECTIONKEY_METHODDEF \ {"QueryReflectionKey", (PyCFunction)winreg_QueryReflectionKey, METH_O, winreg_QueryReflectionKey__doc__}, @@ -1113,7 +1113,7 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HKEY key; - if (!clinic_HKEY_converter(arg, &key)) { + if (!clinic_HKEY_converter(arg, &key)) { goto exit; } return_value = winreg_QueryReflectionKey_impl(module, key); @@ -1121,4 +1121,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=015afbbd690eb59d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=015afbbd690eb59d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/PC/clinic/winsound.c.h b/contrib/tools/python3/src/PC/clinic/winsound.c.h index 00e9edf4d1..b37db4c6cb 100644 --- a/contrib/tools/python3/src/PC/clinic/winsound.c.h +++ b/contrib/tools/python3/src/PC/clinic/winsound.c.h @@ -14,7 +14,7 @@ PyDoc_STRVAR(winsound_PlaySound__doc__, " Flag values, ored together. See module documentation."); #define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)(void(*)(void))winsound_PlaySound, METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, + {"PlaySound", (PyCFunction)(void(*)(void))winsound_PlaySound, METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, static PyObject * winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); @@ -24,25 +24,25 @@ winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"sound", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "PlaySound", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "PlaySound", 0}; + PyObject *argsbuf[2]; PyObject *sound; int flags; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + sound = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { goto exit; } - sound = args[0]; - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } return_value = winsound_PlaySound_impl(module, sound, flags); exit: @@ -62,7 +62,7 @@ PyDoc_STRVAR(winsound_Beep__doc__, " How long the sound should play, in milliseconds."); #define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)(void(*)(void))winsound_Beep, METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, + {"Beep", (PyCFunction)(void(*)(void))winsound_Beep, METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, static PyObject * winsound_Beep_impl(PyObject *module, int frequency, int duration); @@ -72,33 +72,33 @@ winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"frequency", "duration", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Beep", 0}; - PyObject *argsbuf[2]; + static _PyArg_Parser _parser = {NULL, _keywords, "Beep", 0}; + PyObject *argsbuf[2]; int frequency; int duration; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + frequency = _PyLong_AsInt(args[0]); + if (frequency == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + duration = _PyLong_AsInt(args[1]); + if (duration == -1 && PyErr_Occurred()) { goto exit; } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - frequency = _PyLong_AsInt(args[0]); - if (frequency == -1 && PyErr_Occurred()) { - goto exit; - } - if (PyFloat_Check(args[1])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - duration = _PyLong_AsInt(args[1]); - if (duration == -1 && PyErr_Occurred()) { - goto exit; - } return_value = winsound_Beep_impl(module, frequency, duration); exit: @@ -114,7 +114,7 @@ PyDoc_STRVAR(winsound_MessageBeep__doc__, "x defaults to MB_OK."); #define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)(void(*)(void))winsound_MessageBeep, METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, + {"MessageBeep", (PyCFunction)(void(*)(void))winsound_MessageBeep, METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, static PyObject * winsound_MessageBeep_impl(PyObject *module, int type); @@ -124,31 +124,31 @@ winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"type", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "MessageBeep", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + static _PyArg_Parser _parser = {NULL, _keywords, "MessageBeep", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int type = MB_OK; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + type = _PyLong_AsInt(args[0]); + if (type == -1 && PyErr_Occurred()) { goto exit; } - if (!noptargs) { - goto skip_optional_pos; - } - if (PyFloat_Check(args[0])) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float" ); - goto exit; - } - type = _PyLong_AsInt(args[0]); - if (type == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: +skip_optional_pos: return_value = winsound_MessageBeep_impl(module, type); exit: return return_value; } -/*[clinic end generated code: output=28d1cd033282723d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=28d1cd033282723d input=a9049054013a1b77]*/ diff --git a/contrib/tools/python3/src/PC/dl_nt.c b/contrib/tools/python3/src/PC/dl_nt.c index 89feef0223..7f17ee1687 100644 --- a/contrib/tools/python3/src/PC/dl_nt.c +++ b/contrib/tools/python3/src/PC/dl_nt.c @@ -15,7 +15,7 @@ forgotten) from the programmer. // Python Globals HMODULE PyWin_DLLhModule = NULL; -const char *PyWin_DLLVersionString = MS_DLL_ID; +const char *PyWin_DLLVersionString = MS_DLL_ID; BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, diff --git a/contrib/tools/python3/src/PC/errmap.h b/contrib/tools/python3/src/PC/errmap.h index 420934b2b1..a7489ab75c 100644 --- a/contrib/tools/python3/src/PC/errmap.h +++ b/contrib/tools/python3/src/PC/errmap.h @@ -1,140 +1,140 @@ -int -winerror_to_errno(int winerror) +int +winerror_to_errno(int winerror) { - // Unwrap FACILITY_WIN32 HRESULT errors. - if ((winerror & 0xFFFF0000) == 0x80070000) { - winerror &= 0x0000FFFF; + // Unwrap FACILITY_WIN32 HRESULT errors. + if ((winerror & 0xFFFF0000) == 0x80070000) { + winerror &= 0x0000FFFF; + } + + // Winsock error codes (10000-11999) are errno values. + if (winerror >= 10000 && winerror < 12000) { + switch (winerror) { + case WSAEINTR: + case WSAEBADF: + case WSAEACCES: + case WSAEFAULT: + case WSAEINVAL: + case WSAEMFILE: + // Winsock definitions of errno values. See WinSock2.h + return winerror - 10000; + default: + return winerror; + } + } + + switch (winerror) { + case ERROR_FILE_NOT_FOUND: // 2 + case ERROR_PATH_NOT_FOUND: // 3 + case ERROR_INVALID_DRIVE: // 15 + case ERROR_NO_MORE_FILES: // 18 + case ERROR_BAD_NETPATH: // 53 + case ERROR_BAD_NET_NAME: // 67 + case ERROR_BAD_PATHNAME: // 161 + case ERROR_FILENAME_EXCED_RANGE: // 206 + return ENOENT; + + case ERROR_BAD_ENVIRONMENT: // 10 + return E2BIG; + + case ERROR_BAD_FORMAT: // 11 + case ERROR_INVALID_STARTING_CODESEG: // 188 + case ERROR_INVALID_STACKSEG: // 189 + case ERROR_INVALID_MODULETYPE: // 190 + case ERROR_INVALID_EXE_SIGNATURE: // 191 + case ERROR_EXE_MARKED_INVALID: // 192 + case ERROR_BAD_EXE_FORMAT: // 193 + case ERROR_ITERATED_DATA_EXCEEDS_64k: // 194 + case ERROR_INVALID_MINALLOCSIZE: // 195 + case ERROR_DYNLINK_FROM_INVALID_RING: // 196 + case ERROR_IOPL_NOT_ENABLED: // 197 + case ERROR_INVALID_SEGDPL: // 198 + case ERROR_AUTODATASEG_EXCEEDS_64k: // 199 + case ERROR_RING2SEG_MUST_BE_MOVABLE: // 200 + case ERROR_RELOC_CHAIN_XEEDS_SEGLIM: // 201 + case ERROR_INFLOOP_IN_RELOC_CHAIN: // 202 + return ENOEXEC; + + case ERROR_INVALID_HANDLE: // 6 + case ERROR_INVALID_TARGET_HANDLE: // 114 + case ERROR_DIRECT_ACCESS_HANDLE: // 130 + return EBADF; + + case ERROR_WAIT_NO_CHILDREN: // 128 + case ERROR_CHILD_NOT_COMPLETE: // 129 + return ECHILD; + + case ERROR_NO_PROC_SLOTS: // 89 + case ERROR_MAX_THRDS_REACHED: // 164 + case ERROR_NESTING_NOT_ALLOWED: // 215 + return EAGAIN; + + case ERROR_ARENA_TRASHED: // 7 + case ERROR_NOT_ENOUGH_MEMORY: // 8 + case ERROR_INVALID_BLOCK: // 9 + case ERROR_NOT_ENOUGH_QUOTA: // 1816 + return ENOMEM; + + case ERROR_ACCESS_DENIED: // 5 + case ERROR_CURRENT_DIRECTORY: // 16 + case ERROR_WRITE_PROTECT: // 19 + case ERROR_BAD_UNIT: // 20 + case ERROR_NOT_READY: // 21 + case ERROR_BAD_COMMAND: // 22 + case ERROR_CRC: // 23 + case ERROR_BAD_LENGTH: // 24 + case ERROR_SEEK: // 25 + case ERROR_NOT_DOS_DISK: // 26 + case ERROR_SECTOR_NOT_FOUND: // 27 + case ERROR_OUT_OF_PAPER: // 28 + case ERROR_WRITE_FAULT: // 29 + case ERROR_READ_FAULT: // 30 + case ERROR_GEN_FAILURE: // 31 + case ERROR_SHARING_VIOLATION: // 32 + case ERROR_LOCK_VIOLATION: // 33 + case ERROR_WRONG_DISK: // 34 + case ERROR_SHARING_BUFFER_EXCEEDED: // 36 + case ERROR_NETWORK_ACCESS_DENIED: // 65 + case ERROR_CANNOT_MAKE: // 82 + case ERROR_FAIL_I24: // 83 + case ERROR_DRIVE_LOCKED: // 108 + case ERROR_SEEK_ON_DEVICE: // 132 + case ERROR_NOT_LOCKED: // 158 + case ERROR_LOCK_FAILED: // 167 + case 35: // 35 (undefined) + return EACCES; + + case ERROR_FILE_EXISTS: // 80 + case ERROR_ALREADY_EXISTS: // 183 + return EEXIST; + + case ERROR_NOT_SAME_DEVICE: // 17 + return EXDEV; + + case ERROR_DIRECTORY: // 267 (bpo-12802) + return ENOTDIR; + + case ERROR_TOO_MANY_OPEN_FILES: // 4 + return EMFILE; + + case ERROR_DISK_FULL: // 112 + return ENOSPC; + + case ERROR_BROKEN_PIPE: // 109 + case ERROR_NO_DATA: // 232 (bpo-13063) + return EPIPE; + + case ERROR_DIR_NOT_EMPTY: // 145 + return ENOTEMPTY; + + case ERROR_NO_UNICODE_TRANSLATION: // 1113 + return EILSEQ; + + case ERROR_INVALID_FUNCTION: // 1 + case ERROR_INVALID_ACCESS: // 12 + case ERROR_INVALID_DATA: // 13 + case ERROR_INVALID_PARAMETER: // 87 + case ERROR_NEGATIVE_SEEK: // 131 + default: + return EINVAL; } - - // Winsock error codes (10000-11999) are errno values. - if (winerror >= 10000 && winerror < 12000) { - switch (winerror) { - case WSAEINTR: - case WSAEBADF: - case WSAEACCES: - case WSAEFAULT: - case WSAEINVAL: - case WSAEMFILE: - // Winsock definitions of errno values. See WinSock2.h - return winerror - 10000; - default: - return winerror; - } - } - - switch (winerror) { - case ERROR_FILE_NOT_FOUND: // 2 - case ERROR_PATH_NOT_FOUND: // 3 - case ERROR_INVALID_DRIVE: // 15 - case ERROR_NO_MORE_FILES: // 18 - case ERROR_BAD_NETPATH: // 53 - case ERROR_BAD_NET_NAME: // 67 - case ERROR_BAD_PATHNAME: // 161 - case ERROR_FILENAME_EXCED_RANGE: // 206 - return ENOENT; - - case ERROR_BAD_ENVIRONMENT: // 10 - return E2BIG; - - case ERROR_BAD_FORMAT: // 11 - case ERROR_INVALID_STARTING_CODESEG: // 188 - case ERROR_INVALID_STACKSEG: // 189 - case ERROR_INVALID_MODULETYPE: // 190 - case ERROR_INVALID_EXE_SIGNATURE: // 191 - case ERROR_EXE_MARKED_INVALID: // 192 - case ERROR_BAD_EXE_FORMAT: // 193 - case ERROR_ITERATED_DATA_EXCEEDS_64k: // 194 - case ERROR_INVALID_MINALLOCSIZE: // 195 - case ERROR_DYNLINK_FROM_INVALID_RING: // 196 - case ERROR_IOPL_NOT_ENABLED: // 197 - case ERROR_INVALID_SEGDPL: // 198 - case ERROR_AUTODATASEG_EXCEEDS_64k: // 199 - case ERROR_RING2SEG_MUST_BE_MOVABLE: // 200 - case ERROR_RELOC_CHAIN_XEEDS_SEGLIM: // 201 - case ERROR_INFLOOP_IN_RELOC_CHAIN: // 202 - return ENOEXEC; - - case ERROR_INVALID_HANDLE: // 6 - case ERROR_INVALID_TARGET_HANDLE: // 114 - case ERROR_DIRECT_ACCESS_HANDLE: // 130 - return EBADF; - - case ERROR_WAIT_NO_CHILDREN: // 128 - case ERROR_CHILD_NOT_COMPLETE: // 129 - return ECHILD; - - case ERROR_NO_PROC_SLOTS: // 89 - case ERROR_MAX_THRDS_REACHED: // 164 - case ERROR_NESTING_NOT_ALLOWED: // 215 - return EAGAIN; - - case ERROR_ARENA_TRASHED: // 7 - case ERROR_NOT_ENOUGH_MEMORY: // 8 - case ERROR_INVALID_BLOCK: // 9 - case ERROR_NOT_ENOUGH_QUOTA: // 1816 - return ENOMEM; - - case ERROR_ACCESS_DENIED: // 5 - case ERROR_CURRENT_DIRECTORY: // 16 - case ERROR_WRITE_PROTECT: // 19 - case ERROR_BAD_UNIT: // 20 - case ERROR_NOT_READY: // 21 - case ERROR_BAD_COMMAND: // 22 - case ERROR_CRC: // 23 - case ERROR_BAD_LENGTH: // 24 - case ERROR_SEEK: // 25 - case ERROR_NOT_DOS_DISK: // 26 - case ERROR_SECTOR_NOT_FOUND: // 27 - case ERROR_OUT_OF_PAPER: // 28 - case ERROR_WRITE_FAULT: // 29 - case ERROR_READ_FAULT: // 30 - case ERROR_GEN_FAILURE: // 31 - case ERROR_SHARING_VIOLATION: // 32 - case ERROR_LOCK_VIOLATION: // 33 - case ERROR_WRONG_DISK: // 34 - case ERROR_SHARING_BUFFER_EXCEEDED: // 36 - case ERROR_NETWORK_ACCESS_DENIED: // 65 - case ERROR_CANNOT_MAKE: // 82 - case ERROR_FAIL_I24: // 83 - case ERROR_DRIVE_LOCKED: // 108 - case ERROR_SEEK_ON_DEVICE: // 132 - case ERROR_NOT_LOCKED: // 158 - case ERROR_LOCK_FAILED: // 167 - case 35: // 35 (undefined) - return EACCES; - - case ERROR_FILE_EXISTS: // 80 - case ERROR_ALREADY_EXISTS: // 183 - return EEXIST; - - case ERROR_NOT_SAME_DEVICE: // 17 - return EXDEV; - - case ERROR_DIRECTORY: // 267 (bpo-12802) - return ENOTDIR; - - case ERROR_TOO_MANY_OPEN_FILES: // 4 - return EMFILE; - - case ERROR_DISK_FULL: // 112 - return ENOSPC; - - case ERROR_BROKEN_PIPE: // 109 - case ERROR_NO_DATA: // 232 (bpo-13063) - return EPIPE; - - case ERROR_DIR_NOT_EMPTY: // 145 - return ENOTEMPTY; - - case ERROR_NO_UNICODE_TRANSLATION: // 1113 - return EILSEQ; - - case ERROR_INVALID_FUNCTION: // 1 - case ERROR_INVALID_ACCESS: // 12 - case ERROR_INVALID_DATA: // 13 - case ERROR_INVALID_PARAMETER: // 87 - case ERROR_NEGATIVE_SEEK: // 131 - default: - return EINVAL; - } } diff --git a/contrib/tools/python3/src/PC/getpathp.c b/contrib/tools/python3/src/PC/getpathp.c index a4ee60848e..0e5a0dca33 100644 --- a/contrib/tools/python3/src/PC/getpathp.c +++ b/contrib/tools/python3/src/PC/getpathp.c @@ -29,7 +29,7 @@ - If we DO have a Python Home: The relevant sub-directories (Lib, DLLs, etc) are based on the Python Home - If we DO NOT have a Python Home, the core Python Path is - loaded from the registry. (This is the main PythonPath key, + loaded from the registry. (This is the main PythonPath key, and both HKLM and HKCU are combined to form the path) * Iff - we can not locate the Python Home, have not had a PYTHONPATH @@ -80,9 +80,9 @@ #include "Python.h" -#include "pycore_initconfig.h" // PyStatus -#include "pycore_pathconfig.h" // _PyPathConfig -#include "osdefs.h" // SEP, ALTSEP +#include "pycore_initconfig.h" // PyStatus +#include "pycore_pathconfig.h" // _PyPathConfig +#include "osdefs.h" // SEP, ALTSEP #include <wchar.h> #ifndef MS_WINDOWS @@ -90,7 +90,7 @@ #endif #include <windows.h> -#include <pathcch.h> +#include <pathcch.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -115,22 +115,22 @@ */ #ifndef LANDMARK -# define LANDMARK L"lib\\os.py" +# define LANDMARK L"lib\\os.py" #endif -#define INIT_ERR_BUFFER_OVERFLOW() _PyStatus_ERR("buffer overflow") - - +#define INIT_ERR_BUFFER_OVERFLOW() _PyStatus_ERR("buffer overflow") + + typedef struct { const wchar_t *path_env; /* PATH environment variable */ const wchar_t *home; /* PYTHONHOME environment variable */ - /* Registry key "Software\Python\PythonCore\X.Y\PythonPath" - where X.Y is the Python version (major.minor) */ + /* Registry key "Software\Python\PythonCore\X.Y\PythonPath" + where X.Y is the Python version (major.minor) */ wchar_t *machine_path; /* from HKEY_LOCAL_MACHINE */ wchar_t *user_path; /* from HKEY_CURRENT_USER */ - const wchar_t *pythonpath_env; + const wchar_t *pythonpath_env; } PyCalculatePath; @@ -165,37 +165,37 @@ reduce(wchar_t *dir) static int change_ext(wchar_t *dest, const wchar_t *src, const wchar_t *ext) { - if (src && src != dest) { - size_t src_len = wcsnlen_s(src, MAXPATHLEN+1); - size_t i = src_len; - if (i >= MAXPATHLEN+1) { - Py_FatalError("buffer overflow in getpathp.c's reduce()"); - } - - while (i > 0 && src[i] != '.' && !is_sep(src[i])) - --i; - - if (i == 0) { - dest[0] = '\0'; - return -1; - } - - if (is_sep(src[i])) { - i = src_len; - } - - if (wcsncpy_s(dest, MAXPATHLEN+1, src, i)) { - dest[0] = '\0'; - return -1; - } - } else { - wchar_t *s = wcsrchr(dest, L'.'); - if (s) { - s[0] = '\0'; - } + if (src && src != dest) { + size_t src_len = wcsnlen_s(src, MAXPATHLEN+1); + size_t i = src_len; + if (i >= MAXPATHLEN+1) { + Py_FatalError("buffer overflow in getpathp.c's reduce()"); + } + + while (i > 0 && src[i] != '.' && !is_sep(src[i])) + --i; + + if (i == 0) { + dest[0] = '\0'; + return -1; + } + + if (is_sep(src[i])) { + i = src_len; + } + + if (wcsncpy_s(dest, MAXPATHLEN+1, src, i)) { + dest[0] = '\0'; + return -1; + } + } else { + wchar_t *s = wcsrchr(dest, L'.'); + if (s) { + s[0] = '\0'; + } } - if (wcscat_s(dest, MAXPATHLEN+1, ext)) { + if (wcscat_s(dest, MAXPATHLEN+1, ext)) { dest[0] = '\0'; return -1; } @@ -252,24 +252,24 @@ ismodule(wchar_t *filename, int update_filename) static void join(wchar_t *buffer, const wchar_t *stuff) { - if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { - Py_FatalError("buffer overflow in getpathp.c's join()"); + if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { + Py_FatalError("buffer overflow in getpathp.c's join()"); } } -/* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." - and ".." to produce a direct, well-formed path. */ -static PyStatus -canonicalize(wchar_t *buffer, const wchar_t *path) +/* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." + and ".." to produce a direct, well-formed path. */ +static PyStatus +canonicalize(wchar_t *buffer, const wchar_t *path) { if (buffer == NULL) { - return _PyStatus_NO_MEMORY(); + return _PyStatus_NO_MEMORY(); } - if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { - return INIT_ERR_BUFFER_OVERFLOW(); + if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { + return INIT_ERR_BUFFER_OVERFLOW(); } - return _PyStatus_OK(); + return _PyStatus_OK(); } @@ -277,18 +277,18 @@ canonicalize(wchar_t *buffer, const wchar_t *path) 'prefix' is null terminated in bounds. join() ensures 'landmark' can not overflow prefix if too long. */ static int -gotlandmark(const wchar_t *prefix, const wchar_t *landmark) +gotlandmark(const wchar_t *prefix, const wchar_t *landmark) { - wchar_t filename[MAXPATHLEN+1]; - memset(filename, 0, sizeof(filename)); - wcscpy_s(filename, Py_ARRAY_LENGTH(filename), prefix); - join(filename, landmark); - return ismodule(filename, FALSE); + wchar_t filename[MAXPATHLEN+1]; + memset(filename, 0, sizeof(filename)); + wcscpy_s(filename, Py_ARRAY_LENGTH(filename), prefix); + join(filename, landmark); + return ismodule(filename, FALSE); } /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. - assumption provided by only caller, calculate_path() */ + assumption provided by only caller, calculate_path() */ static int search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path, const wchar_t *landmark) { @@ -304,21 +304,21 @@ search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path, const wchar_t *lan } -static int -get_dllpath(wchar_t *dllpath) -{ +static int +get_dllpath(wchar_t *dllpath) +{ +#ifdef Py_ENABLE_SHARED + extern HANDLE PyWin_DLLhModule; + if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, dllpath, MAXPATHLEN)) { + return 0; + } +#endif + return -1; +} + + #ifdef Py_ENABLE_SHARED - extern HANDLE PyWin_DLLhModule; - if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, dllpath, MAXPATHLEN)) { - return 0; - } -#endif - return -1; -} - - -#ifdef Py_ENABLE_SHARED - + /* a string loaded from the DLL at startup.*/ extern const char *PyWin_DLLVersionString; @@ -331,7 +331,7 @@ extern const char *PyWin_DLLVersionString; Returns NULL, or a pointer that should be freed. XXX - this code is pretty strange, as it used to also - work on Win16, where the buffer sizes were not available + work on Win16, where the buffer sizes were not available in advance. It could be simplied now Win16/Win32s is dead! */ static wchar_t * @@ -378,7 +378,7 @@ getpythonregpath(HKEY keyBase, int skipcore) goto done; } /* Find out how big our core buffer is, and how many subkeys we have */ - rc = RegQueryInfoKeyW(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, + rc = RegQueryInfoKeyW(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, NULL, NULL, &dataSize, NULL, NULL); if (rc!=ERROR_SUCCESS) { goto done; @@ -389,7 +389,7 @@ getpythonregpath(HKEY keyBase, int skipcore) /* Allocate a temp array of char buffers, so we only need to loop reading the registry once */ - ppPaths = PyMem_RawCalloc(numKeys, sizeof(WCHAR *)); + ppPaths = PyMem_RawCalloc(numKeys, sizeof(WCHAR *)); if (ppPaths==NULL) { goto done; } @@ -488,93 +488,93 @@ done: #endif /* Py_ENABLE_SHARED */ -static PyStatus -get_program_full_path(_PyPathConfig *pathconfig) +static PyStatus +get_program_full_path(_PyPathConfig *pathconfig) { - PyStatus status; + PyStatus status; const wchar_t *pyvenv_launcher; wchar_t program_full_path[MAXPATHLEN+1]; memset(program_full_path, 0, sizeof(program_full_path)); - if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) { - /* GetModuleFileName should never fail when passed NULL */ - return _PyStatus_ERR("Cannot determine program path"); - } - + if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) { + /* GetModuleFileName should never fail when passed NULL */ + return _PyStatus_ERR("Cannot determine program path"); + } + /* The launcher may need to force the executable path to a * different environment, so override it here. */ pyvenv_launcher = _wgetenv(L"__PYVENV_LAUNCHER__"); if (pyvenv_launcher && pyvenv_launcher[0]) { - /* If overridden, preserve the original full path */ - if (pathconfig->base_executable == NULL) { - pathconfig->base_executable = PyMem_RawMalloc( - sizeof(wchar_t) * (MAXPATHLEN + 1)); - if (pathconfig->base_executable == NULL) { - return _PyStatus_NO_MEMORY(); - } - - status = canonicalize(pathconfig->base_executable, - program_full_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - } - + /* If overridden, preserve the original full path */ + if (pathconfig->base_executable == NULL) { + pathconfig->base_executable = PyMem_RawMalloc( + sizeof(wchar_t) * (MAXPATHLEN + 1)); + if (pathconfig->base_executable == NULL) { + return _PyStatus_NO_MEMORY(); + } + + status = canonicalize(pathconfig->base_executable, + program_full_path); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + wcscpy_s(program_full_path, MAXPATHLEN+1, pyvenv_launcher); - /* bpo-35873: Clear the environment variable to avoid it being - * inherited by child processes. */ - _wputenv_s(L"__PYVENV_LAUNCHER__", L""); + /* bpo-35873: Clear the environment variable to avoid it being + * inherited by child processes. */ + _wputenv_s(L"__PYVENV_LAUNCHER__", L""); } - if (pathconfig->program_full_path == NULL) { - pathconfig->program_full_path = PyMem_RawMalloc( - sizeof(wchar_t) * (MAXPATHLEN + 1)); - if (pathconfig->program_full_path == NULL) { - return _PyStatus_NO_MEMORY(); - } - - status = canonicalize(pathconfig->program_full_path, - program_full_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - } - return _PyStatus_OK(); + if (pathconfig->program_full_path == NULL) { + pathconfig->program_full_path = PyMem_RawMalloc( + sizeof(wchar_t) * (MAXPATHLEN + 1)); + if (pathconfig->program_full_path == NULL) { + return _PyStatus_NO_MEMORY(); + } + + status = canonicalize(pathconfig->program_full_path, + program_full_path); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + return _PyStatus_OK(); } -static PyStatus -read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, - int *found) +static PyStatus +read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, + int *found) { - PyStatus status; - wchar_t *buf = NULL; - wchar_t *wline = NULL; - FILE *sp_file; - - sp_file = _Py_wfopen(path, L"r"); + PyStatus status; + wchar_t *buf = NULL; + wchar_t *wline = NULL; + FILE *sp_file; + + sp_file = _Py_wfopen(path, L"r"); if (sp_file == NULL) { - return _PyStatus_OK(); + return _PyStatus_OK(); } wcscpy_s(prefix, MAXPATHLEN+1, path); reduce(prefix); - pathconfig->isolated = 1; - pathconfig->site_import = 0; + pathconfig->isolated = 1; + pathconfig->site_import = 0; size_t bufsiz = MAXPATHLEN; size_t prefixlen = wcslen(prefix); - buf = (wchar_t*)PyMem_RawMalloc(bufsiz * sizeof(wchar_t)); + buf = (wchar_t*)PyMem_RawMalloc(bufsiz * sizeof(wchar_t)); if (buf == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; + status = _PyStatus_NO_MEMORY(); + goto done; } buf[0] = '\0'; while (!feof(sp_file)) { char line[MAXPATHLEN + 1]; - char *p = fgets(line, Py_ARRAY_LENGTH(line), sp_file); + char *p = fgets(line, Py_ARRAY_LENGTH(line), sp_file); if (!p) { break; } @@ -589,20 +589,20 @@ read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, } if (strcmp(line, "import site") == 0) { - pathconfig->site_import = 1; + pathconfig->site_import = 1; continue; } - else if (strncmp(line, "import ", 7) == 0) { - status = _PyStatus_ERR("only 'import site' is supported " - "in ._pth file"); - goto done; - } + else if (strncmp(line, "import ", 7) == 0) { + status = _PyStatus_ERR("only 'import site' is supported " + "in ._pth file"); + goto done; + } DWORD wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, NULL, 0); wchar_t *wline = (wchar_t*)PyMem_RawMalloc((wn + 1) * sizeof(wchar_t)); if (wline == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; + status = _PyStatus_NO_MEMORY(); + goto done; } wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, wline, wn + 1); wline[wn] = '\0'; @@ -613,8 +613,8 @@ read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, wchar_t *tmp = (wchar_t*)PyMem_RawRealloc(buf, (bufsiz + 1) * sizeof(wchar_t)); if (tmp == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; + status = _PyStatus_NO_MEMORY(); + goto done; } buf = tmp; } @@ -628,73 +628,73 @@ read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, _Py_BEGIN_SUPPRESS_IPH result = wcscat_s(buf, bufsiz, prefix); _Py_END_SUPPRESS_IPH - + if (result == EINVAL) { - status = _PyStatus_ERR("invalid argument during ._pth processing"); - goto done; + status = _PyStatus_ERR("invalid argument during ._pth processing"); + goto done; } else if (result == ERANGE) { - status = _PyStatus_ERR("buffer overflow during ._pth processing"); - goto done; + status = _PyStatus_ERR("buffer overflow during ._pth processing"); + goto done; } - + wchar_t *b = &buf[usedsiz]; join(b, wline); PyMem_RawFree(wline); - wline = NULL; + wline = NULL; + } + + if (pathconfig->module_search_path == NULL) { + pathconfig->module_search_path = _PyMem_RawWcsdup(buf); + if (pathconfig->module_search_path == NULL) { + status = _PyStatus_NO_MEMORY(); + goto done; + } } - if (pathconfig->module_search_path == NULL) { - pathconfig->module_search_path = _PyMem_RawWcsdup(buf); - if (pathconfig->module_search_path == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; - } - } - - *found = 1; - status = _PyStatus_OK(); - goto done; - -done: + *found = 1; + status = _PyStatus_OK(); + goto done; + +done: PyMem_RawFree(buf); - PyMem_RawFree(wline); + PyMem_RawFree(wline); fclose(sp_file); - return status; + return status; } static int -get_pth_filename(PyCalculatePath *calculate, wchar_t *filename, - const _PyPathConfig *pathconfig) +get_pth_filename(PyCalculatePath *calculate, wchar_t *filename, + const _PyPathConfig *pathconfig) { - if (!get_dllpath(filename) && - !change_ext(filename, filename, L"._pth") && - exists(filename)) - { - return 1; + if (!get_dllpath(filename) && + !change_ext(filename, filename, L"._pth") && + exists(filename)) + { + return 1; } - if (pathconfig->program_full_path[0] && - !change_ext(filename, pathconfig->program_full_path, L"._pth") && - exists(filename)) - { - return 1; + if (pathconfig->program_full_path[0] && + !change_ext(filename, pathconfig->program_full_path, L"._pth") && + exists(filename)) + { + return 1; } return 0; } -static PyStatus -calculate_pth_file(PyCalculatePath *calculate, _PyPathConfig *pathconfig, - wchar_t *prefix, int *found) +static PyStatus +calculate_pth_file(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + wchar_t *prefix, int *found) { - wchar_t filename[MAXPATHLEN+1]; + wchar_t filename[MAXPATHLEN+1]; - if (!get_pth_filename(calculate, filename, pathconfig)) { - return _PyStatus_OK(); + if (!get_pth_filename(calculate, filename, pathconfig)) { + return _PyStatus_OK(); } - return read_pth_file(pathconfig, prefix, filename, found); + return read_pth_file(pathconfig, prefix, filename, found); } @@ -702,62 +702,62 @@ calculate_pth_file(PyCalculatePath *calculate, _PyPathConfig *pathconfig, executable's directory and then in the parent directory. If found, open it for use when searching for prefixes. */ -static PyStatus -calculate_pyvenv_file(PyCalculatePath *calculate, - wchar_t *argv0_path, size_t argv0_path_len) +static PyStatus +calculate_pyvenv_file(PyCalculatePath *calculate, + wchar_t *argv0_path, size_t argv0_path_len) { - wchar_t filename[MAXPATHLEN+1]; + wchar_t filename[MAXPATHLEN+1]; const wchar_t *env_cfg = L"pyvenv.cfg"; - /* Filename: <argv0_path_len> / "pyvenv.cfg" */ - wcscpy_s(filename, MAXPATHLEN+1, argv0_path); - join(filename, env_cfg); + /* Filename: <argv0_path_len> / "pyvenv.cfg" */ + wcscpy_s(filename, MAXPATHLEN+1, argv0_path); + join(filename, env_cfg); - FILE *env_file = _Py_wfopen(filename, L"r"); + FILE *env_file = _Py_wfopen(filename, L"r"); if (env_file == NULL) { errno = 0; - /* Filename: <basename(basename(argv0_path_len))> / "pyvenv.cfg" */ - reduce(filename); - reduce(filename); - join(filename, env_cfg); + /* Filename: <basename(basename(argv0_path_len))> / "pyvenv.cfg" */ + reduce(filename); + reduce(filename); + join(filename, env_cfg); - env_file = _Py_wfopen(filename, L"r"); + env_file = _Py_wfopen(filename, L"r"); if (env_file == NULL) { errno = 0; - return _PyStatus_OK(); + return _PyStatus_OK(); } } /* Look for a 'home' variable and set argv0_path to it, if found */ - wchar_t *home = NULL; - PyStatus status = _Py_FindEnvConfigValue(env_file, L"home", &home); - if (_PyStatus_EXCEPTION(status)) { - fclose(env_file); - return status; - } - if (home) { - wcscpy_s(argv0_path, argv0_path_len, home); - PyMem_RawFree(home); + wchar_t *home = NULL; + PyStatus status = _Py_FindEnvConfigValue(env_file, L"home", &home); + if (_PyStatus_EXCEPTION(status)) { + fclose(env_file); + return status; + } + if (home) { + wcscpy_s(argv0_path, argv0_path_len, home); + PyMem_RawFree(home); } fclose(env_file); - return _PyStatus_OK(); + return _PyStatus_OK(); } static void -calculate_home_prefix(PyCalculatePath *calculate, - const wchar_t *argv0_path, - const wchar_t *zip_path, - wchar_t *prefix) +calculate_home_prefix(PyCalculatePath *calculate, + const wchar_t *argv0_path, + const wchar_t *zip_path, + wchar_t *prefix) { if (calculate->home == NULL || *calculate->home == '\0') { - if (zip_path[0] && exists(zip_path)) { - wcscpy_s(prefix, MAXPATHLEN+1, zip_path); + if (zip_path[0] && exists(zip_path)) { + wcscpy_s(prefix, MAXPATHLEN+1, zip_path); reduce(prefix); calculate->home = prefix; } - else if (search_for_prefix(prefix, argv0_path, LANDMARK)) { + else if (search_for_prefix(prefix, argv0_path, LANDMARK)) { calculate->home = prefix; } else { @@ -770,31 +770,31 @@ calculate_home_prefix(PyCalculatePath *calculate, } -static PyStatus -calculate_module_search_path(PyCalculatePath *calculate, - _PyPathConfig *pathconfig, - const wchar_t *argv0_path, - wchar_t *prefix, - const wchar_t *zip_path) +static PyStatus +calculate_module_search_path(PyCalculatePath *calculate, + _PyPathConfig *pathconfig, + const wchar_t *argv0_path, + wchar_t *prefix, + const wchar_t *zip_path) { int skiphome = calculate->home==NULL ? 0 : 1; #ifdef Py_ENABLE_SHARED - if (!Py_IgnoreEnvironmentFlag) { - calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, - skiphome); - calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome); - } + if (!Py_IgnoreEnvironmentFlag) { + calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, + skiphome); + calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome); + } #endif - pathconfig->module_search_path = calculate->pythonpath_env; - if (!pathconfig->module_search_path) { - pathconfig->module_search_path = pathconfig->program_full_path; + pathconfig->module_search_path = calculate->pythonpath_env; + if (!pathconfig->module_search_path) { + pathconfig->module_search_path = pathconfig->program_full_path; } - pathconfig->module_search_path = _PyMem_RawWcsdup(pathconfig->module_search_path); - return _PyStatus_OK(); + pathconfig->module_search_path = _PyMem_RawWcsdup(pathconfig->module_search_path); + return _PyStatus_OK(); /* We only use the default relative PYTHONPATH if we haven't anything better to use! */ - int skipdefault = (calculate->pythonpath_env != NULL || + int skipdefault = (calculate->pythonpath_env != NULL || calculate->home != NULL || calculate->machine_path != NULL || calculate->user_path != NULL); @@ -825,35 +825,35 @@ calculate_module_search_path(PyCalculatePath *calculate, bufsz *= wcslen(calculate->home); } bufsz += wcslen(PYTHONPATH) + 1; - bufsz += wcslen(argv0_path) + 1; + bufsz += wcslen(argv0_path) + 1; if (calculate->user_path) { bufsz += wcslen(calculate->user_path) + 1; } if (calculate->machine_path) { bufsz += wcslen(calculate->machine_path) + 1; } - bufsz += wcslen(zip_path) + 1; - if (calculate->pythonpath_env != NULL) { - bufsz += wcslen(calculate->pythonpath_env) + 1; + bufsz += wcslen(zip_path) + 1; + if (calculate->pythonpath_env != NULL) { + bufsz += wcslen(calculate->pythonpath_env) + 1; } wchar_t *buf, *start_buf; buf = PyMem_RawMalloc(bufsz * sizeof(wchar_t)); if (buf == NULL) { - return _PyStatus_NO_MEMORY(); + return _PyStatus_NO_MEMORY(); } start_buf = buf; - if (calculate->pythonpath_env) { + if (calculate->pythonpath_env) { if (wcscpy_s(buf, bufsz - (buf - start_buf), - calculate->pythonpath_env)) { + calculate->pythonpath_env)) { return INIT_ERR_BUFFER_OVERFLOW(); } buf = wcschr(buf, L'\0'); *buf++ = DELIM; } - if (zip_path[0]) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), zip_path)) { + if (zip_path[0]) { + if (wcscpy_s(buf, bufsz - (buf - start_buf), zip_path)) { return INIT_ERR_BUFFER_OVERFLOW(); } buf = wcschr(buf, L'\0'); @@ -910,8 +910,8 @@ calculate_module_search_path(PyCalculatePath *calculate, p = q+1; } } - if (argv0_path) { - wcscpy(buf, argv0_path); + if (argv0_path) { + wcscpy(buf, argv0_path); buf = wcschr(buf, L'\0'); *buf++ = DELIM; } @@ -953,99 +953,99 @@ calculate_module_search_path(PyCalculatePath *calculate, } } - pathconfig->module_search_path = start_buf; - return _PyStatus_OK(); + pathconfig->module_search_path = start_buf; + return _PyStatus_OK(); } -static PyStatus -calculate_path(PyCalculatePath *calculate, _PyPathConfig *pathconfig) +static PyStatus +calculate_path(PyCalculatePath *calculate, _PyPathConfig *pathconfig) { - PyStatus status; + PyStatus status; - status = get_program_full_path(pathconfig); - if (_PyStatus_EXCEPTION(status)) { - return status; + status = get_program_full_path(pathconfig); + if (_PyStatus_EXCEPTION(status)) { + return status; } /* program_full_path guaranteed \0 terminated in MAXPATH+1 bytes. */ - wchar_t argv0_path[MAXPATHLEN+1]; - memset(argv0_path, 0, sizeof(argv0_path)); + wchar_t argv0_path[MAXPATHLEN+1]; + memset(argv0_path, 0, sizeof(argv0_path)); + + wcscpy_s(argv0_path, MAXPATHLEN+1, pathconfig->program_full_path); + reduce(argv0_path); - wcscpy_s(argv0_path, MAXPATHLEN+1, pathconfig->program_full_path); - reduce(argv0_path); - wchar_t prefix[MAXPATHLEN+1]; memset(prefix, 0, sizeof(prefix)); /* Search for a sys.path file */ - int pth_found = 0; - status = calculate_pth_file(calculate, pathconfig, prefix, &pth_found); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - if (pth_found) { + int pth_found = 0; + status = calculate_pth_file(calculate, pathconfig, prefix, &pth_found); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + if (pth_found) { goto done; } - status = calculate_pyvenv_file(calculate, - argv0_path, Py_ARRAY_LENGTH(argv0_path)); - if (_PyStatus_EXCEPTION(status)) { - return status; - } + status = calculate_pyvenv_file(calculate, + argv0_path, Py_ARRAY_LENGTH(argv0_path)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } /* Calculate zip archive path from DLL or exe path */ - wchar_t zip_path[MAXPATHLEN+1]; - memset(zip_path, 0, sizeof(zip_path)); - - if (get_dllpath(zip_path) || change_ext(zip_path, zip_path, L".zip")) - { - if (change_ext(zip_path, pathconfig->program_full_path, L".zip")) { - zip_path[0] = L'\0'; - } - } - - calculate_home_prefix(calculate, argv0_path, zip_path, prefix); - - if (pathconfig->module_search_path == NULL) { - status = calculate_module_search_path(calculate, pathconfig, - argv0_path, prefix, zip_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } + wchar_t zip_path[MAXPATHLEN+1]; + memset(zip_path, 0, sizeof(zip_path)); + + if (get_dllpath(zip_path) || change_ext(zip_path, zip_path, L".zip")) + { + if (change_ext(zip_path, pathconfig->program_full_path, L".zip")) { + zip_path[0] = L'\0'; + } + } + + calculate_home_prefix(calculate, argv0_path, zip_path, prefix); + + if (pathconfig->module_search_path == NULL) { + status = calculate_module_search_path(calculate, pathconfig, + argv0_path, prefix, zip_path); + if (_PyStatus_EXCEPTION(status)) { + return status; + } } done: - if (pathconfig->prefix == NULL) { - pathconfig->prefix = _PyMem_RawWcsdup(prefix); - if (pathconfig->prefix == NULL) { - return _PyStatus_NO_MEMORY(); - } + if (pathconfig->prefix == NULL) { + pathconfig->prefix = _PyMem_RawWcsdup(prefix); + if (pathconfig->prefix == NULL) { + return _PyStatus_NO_MEMORY(); + } } - if (pathconfig->exec_prefix == NULL) { - pathconfig->exec_prefix = _PyMem_RawWcsdup(prefix); - if (pathconfig->exec_prefix == NULL) { - return _PyStatus_NO_MEMORY(); - } - } - - return _PyStatus_OK(); + if (pathconfig->exec_prefix == NULL) { + pathconfig->exec_prefix = _PyMem_RawWcsdup(prefix); + if (pathconfig->exec_prefix == NULL) { + return _PyStatus_NO_MEMORY(); + } + } + + return _PyStatus_OK(); +} + + +static PyStatus +calculate_init(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + const PyConfig *config) +{ + calculate->home = pathconfig->home; + calculate->path_env = _wgetenv(L"PATH"); + + calculate->pythonpath_env = config->pythonpath_env; + + return _PyStatus_OK(); } -static PyStatus -calculate_init(PyCalculatePath *calculate, _PyPathConfig *pathconfig, - const PyConfig *config) -{ - calculate->home = pathconfig->home; - calculate->path_env = _wgetenv(L"PATH"); - - calculate->pythonpath_env = config->pythonpath_env; - - return _PyStatus_OK(); -} - - static void calculate_free(PyCalculatePath *calculate) { @@ -1054,50 +1054,50 @@ calculate_free(PyCalculatePath *calculate) } -/* Calculate the Python path configuration. - - Inputs: - - - PyConfig.pythonpath_env: PYTHONPATH environment variable - - _PyPathConfig.home: Py_SetPythonHome() or PYTHONHOME environment variable - - PATH environment variable - - __PYVENV_LAUNCHER__ environment variable - - GetModuleFileNameW(NULL): fully qualified path of the executable file of - the current process - - ._pth configuration file - - pyvenv.cfg configuration file - - Registry key "Software\Python\PythonCore\X.Y\PythonPath" - of HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE where X.Y is the Python - version. - - Outputs, 'pathconfig' fields: - - - base_executable - - program_full_path - - module_search_path - - prefix - - exec_prefix - - isolated - - site_import - - If a field is already set (non NULL), it is left unchanged. */ -PyStatus -_PyPathConfig_Calculate(_PyPathConfig *pathconfig, const PyConfig *config) +/* Calculate the Python path configuration. + + Inputs: + + - PyConfig.pythonpath_env: PYTHONPATH environment variable + - _PyPathConfig.home: Py_SetPythonHome() or PYTHONHOME environment variable + - PATH environment variable + - __PYVENV_LAUNCHER__ environment variable + - GetModuleFileNameW(NULL): fully qualified path of the executable file of + the current process + - ._pth configuration file + - pyvenv.cfg configuration file + - Registry key "Software\Python\PythonCore\X.Y\PythonPath" + of HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE where X.Y is the Python + version. + + Outputs, 'pathconfig' fields: + + - base_executable + - program_full_path + - module_search_path + - prefix + - exec_prefix + - isolated + - site_import + + If a field is already set (non NULL), it is left unchanged. */ +PyStatus +_PyPathConfig_Calculate(_PyPathConfig *pathconfig, const PyConfig *config) { - PyStatus status; + PyStatus status; PyCalculatePath calculate; memset(&calculate, 0, sizeof(calculate)); - status = calculate_init(&calculate, pathconfig, config); - if (_PyStatus_EXCEPTION(status)) { + status = calculate_init(&calculate, pathconfig, config); + if (_PyStatus_EXCEPTION(status)) { goto done; } - status = calculate_path(&calculate, pathconfig); + status = calculate_path(&calculate, pathconfig); done: calculate_free(&calculate); - return status; + return status; } @@ -1119,29 +1119,29 @@ _Py_CheckPython3(void) python3_checked = 1; /* If there is a python3.dll next to the python3y.dll, - use that DLL */ - if (!get_dllpath(py3path)) { - reduce(py3path); - join(py3path, PY3_DLLNAME); - hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); - if (hPython3 != NULL) { - return 1; - } + use that DLL */ + if (!get_dllpath(py3path)) { + reduce(py3path); + join(py3path, PY3_DLLNAME); + hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + if (hPython3 != NULL) { + return 1; + } } - - /* If we can locate python3.dll in our application dir, - use that DLL */ - hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); + + /* If we can locate python3.dll in our application dir, + use that DLL */ + hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); if (hPython3 != NULL) { return 1; } - /* For back-compat, also search {sys.prefix}\DLLs, though - that has not been a normal install layout for a while */ + /* For back-compat, also search {sys.prefix}\DLLs, though + that has not been a normal install layout for a while */ wcscpy(py3path, Py_GetPrefix()); - if (py3path[0]) { - join(py3path, L"DLLs\\" PY3_DLLNAME); - hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); - } + if (py3path[0]) { + join(py3path, L"DLLs\\" PY3_DLLNAME); + hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + } return hPython3 != NULL; } diff --git a/contrib/tools/python3/src/PC/msvcrtmodule.c b/contrib/tools/python3/src/PC/msvcrtmodule.c index bdf9746b7a..faceb03fba 100644 --- a/contrib/tools/python3/src/PC/msvcrtmodule.c +++ b/contrib/tools/python3/src/PC/msvcrtmodule.c @@ -116,10 +116,10 @@ msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes) { int err; - if (PySys_Audit("msvcrt.locking", "iil", fd, mode, nbytes) < 0) { - return NULL; - } - + if (PySys_Audit("msvcrt.locking", "iil", fd, mode, nbytes) < 0) { + return NULL; + } + Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH err = _locking(fd, mode, nbytes); @@ -179,10 +179,10 @@ msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags) { int fd; - if (PySys_Audit("msvcrt.open_osfhandle", "Ki", handle, flags) < 0) { - return -1; - } - + if (PySys_Audit("msvcrt.open_osfhandle", "Ki", handle, flags) < 0) { + return -1; + } + _Py_BEGIN_SUPPRESS_IPH fd = _open_osfhandle((intptr_t)handle, flags); _Py_END_SUPPRESS_IPH @@ -209,10 +209,10 @@ msvcrt_get_osfhandle_impl(PyObject *module, int fd) { intptr_t handle = -1; - if (PySys_Audit("msvcrt.get_osfhandle", "(i)", fd) < 0) { - return NULL; - } - + if (PySys_Audit("msvcrt.get_osfhandle", "(i)", fd) < 0) { + return NULL; + } + _Py_BEGIN_SUPPRESS_IPH handle = _get_osfhandle(fd); _Py_END_SUPPRESS_IPH diff --git a/contrib/tools/python3/src/PC/pyconfig.h b/contrib/tools/python3/src/PC/pyconfig.h index 606e818e1d..b53ae107e5 100644 --- a/contrib/tools/python3/src/PC/pyconfig.h +++ b/contrib/tools/python3/src/PC/pyconfig.h @@ -126,18 +126,18 @@ WIN32 is still required for the locale module. #define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") #endif /* __INTEL_COMPILER */ #define PYD_PLATFORM_TAG "win_amd64" -#elif defined(_M_ARM64) -#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") -#define PYD_PLATFORM_TAG "win_arm64" +#elif defined(_M_ARM64) +#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") +#define PYD_PLATFORM_TAG "win_arm64" #else #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") #endif #endif /* MS_WIN64 */ /* set the version macros for the windows headers */ -/* Python 3.9+ requires Windows 8 or greater */ -#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ -#define Py_NTDDI NTDDI_WIN8 +/* Python 3.9+ requires Windows 8 or greater */ +#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ +#define Py_NTDDI NTDDI_WIN8 /* We only set these values when building Python - we don't want to force these values on extensions, as that will affect the prototypes and @@ -181,7 +181,7 @@ typedef _W64 int ssize_t; #define PYD_PLATFORM_TAG "win32" #elif defined(_M_ARM) #define COMPILER _Py_PASTE_VERSION("32 bit (ARM)") -#define PYD_PLATFORM_TAG "win_arm32" +#define PYD_PLATFORM_TAG "win_arm32" #else #define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") #endif @@ -268,11 +268,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ file in their Makefile (other compilers are generally taken care of by distutils.) */ # if defined(_DEBUG) -# pragma comment(lib,"python39_d.lib") +# pragma comment(lib,"python39_d.lib") # elif defined(Py_LIMITED_API) # pragma comment(lib,"python3.lib") # else -# pragma comment(lib,"python39.lib") +# pragma comment(lib,"python39.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ @@ -289,8 +289,8 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 8 # define SIZEOF_SIZE_T 8 -/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff - sizeof(off_t) > sizeof(long), and sizeof(long long) >= sizeof(off_t). +/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff + sizeof(off_t) > sizeof(long), and sizeof(long long) >= sizeof(off_t). On Win64 the second condition is not true, but if fpos_t replaces off_t then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 should define this. */ @@ -376,10 +376,10 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define to 1 if you have the <direct.h> header file. */ #define HAVE_DIRECT_H 1 -/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. - */ -#define HAVE_DECL_TZNAME 1 - +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#define HAVE_DECL_TZNAME 1 + /* Define if you have dirent.h. */ /* #define DIRENT 1 */ @@ -460,10 +460,10 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ (which you can't on SCO ODT 3.0). */ /* #undef SYS_SELECT_WITH_SYS_TIME */ -/* Define if you want build the _decimal module using a coroutine-local rather - than a thread-local context */ -#define WITH_DECIMAL_CONTEXTVAR 1 - +/* Define if you want build the _decimal module using a coroutine-local rather + than a thread-local context */ +#define WITH_DECIMAL_CONTEXTVAR 1 + /* Define if you want documentation strings in extension modules */ #define WITH_DOC_STRINGS 1 @@ -680,6 +680,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */ #define HAVE_X509_VERIFY_PARAM_SET1_HOST 1 -#define PLATLIBDIR "lib" - +#define PLATLIBDIR "lib" + #endif /* !Py_CONFIG_H */ diff --git a/contrib/tools/python3/src/PC/python_ver_rc.h b/contrib/tools/python3/src/PC/python_ver_rc.h index 133622925d..e6c1d24370 100644 --- a/contrib/tools/python3/src/PC/python_ver_rc.h +++ b/contrib/tools/python3/src/PC/python_ver_rc.h @@ -1,11 +1,11 @@ // Resource script for Python core DLL. // Currently only holds version information. // -#pragma code_page(1252) +#pragma code_page(1252) #include "winver.h" #define PYTHON_COMPANY "Python Software Foundation" -#define PYTHON_COPYRIGHT "Copyright \xA9 2001-2022 Python Software Foundation. Copyright \xA9 2000 BeOpen.com. Copyright \xA9 1995-2001 CNRI. Copyright \xA9 1991-1995 SMC." +#define PYTHON_COPYRIGHT "Copyright \xA9 2001-2022 Python Software Foundation. Copyright \xA9 2000 BeOpen.com. Copyright \xA9 1995-2001 CNRI. Copyright \xA9 1991-1995 SMC." #define MS_WINDOWS #include "modsupport.h" diff --git a/contrib/tools/python3/src/PC/winreg.c b/contrib/tools/python3/src/PC/winreg.c index 19fb947bde..fd1ccb7b83 100644 --- a/contrib/tools/python3/src/PC/winreg.c +++ b/contrib/tools/python3/src/PC/winreg.c @@ -12,10 +12,10 @@ */ -#define PY_SSIZE_T_CLEAN +#define PY_SSIZE_T_CLEAN #include "Python.h" -#include "structmember.h" // PyMemberDef -#include <windows.h> +#include "structmember.h" // PyMemberDef +#include <windows.h> static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); static BOOL clinic_HKEY_converter(PyObject *ob, void *p); @@ -84,7 +84,7 @@ PyDoc_STRVAR(PyHKEY_doc, "the object is destroyed. To guarantee cleanup, you can call either\n" "the Close() method on the PyHKEY, or the CloseKey() method.\n" "\n" -"All functions which accept a handle object also accept an integer --\n" +"All functions which accept a handle object also accept an integer --\n" "however, use of the handle object is encouraged.\n" "\n" "Functions:\n" @@ -293,9 +293,9 @@ winreg_HKEYType_Detach_impl(PyHKEYObject *self) /*[clinic end generated code: output=dda5a9e1a01ae78f input=dd2cc09e6c6ba833]*/ { void* ret; - if (PySys_Audit("winreg.PyHKEY.Detach", "n", (Py_ssize_t)self->hkey) < 0) { - return NULL; - } + if (PySys_Audit("winreg.PyHKEY.Detach", "n", (Py_ssize_t)self->hkey) < 0) { + return NULL; + } ret = (void*)self->hkey; self->hkey = 0; return PyLong_FromVoidPtr(ret); @@ -358,10 +358,10 @@ PyTypeObject PyHKEY_Type = sizeof(PyHKEYObject), 0, PyHKEY_deallocFunc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ &PyHKEY_NumberMethods, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -390,7 +390,7 @@ PyTypeObject PyHKEY_Type = PyObject * PyHKEY_New(HKEY hInit) { - PyHKEYObject *key = PyObject_New(PyHKEYObject, &PyHKEY_Type); + PyHKEYObject *key = PyObject_New(PyHKEYObject, &PyHKEY_Type); if (key) key->hkey = hInit; return (PyObject *)key; @@ -400,15 +400,15 @@ BOOL PyHKEY_Close(PyObject *ob_handle) { LONG rc; - HKEY key; + HKEY key; - if (!PyHKEY_AsHKEY(ob_handle, &key, TRUE)) { + if (!PyHKEY_AsHKEY(ob_handle, &key, TRUE)) { return FALSE; } - if (PyHKEY_Check(ob_handle)) { - ((PyHKEYObject*)ob_handle)->hkey = 0; - } - rc = key ? RegCloseKey(key) : ERROR_SUCCESS; + if (PyHKEY_Check(ob_handle)) { + ((PyHKEYObject*)ob_handle)->hkey = 0; + } + rc = key ? RegCloseKey(key) : ERROR_SUCCESS; if (rc != ERROR_SUCCESS) PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); return rc == ERROR_SUCCESS; @@ -521,18 +521,18 @@ fixupMultiSZ(wchar_t **str, wchar_t *data, int len) int i; wchar_t *Q; - if (len > 0 && data[len - 1] == '\0') { - Q = data + len - 1; - } - else { - Q = data + len; - } - - for (P = data, i = 0; P < Q; P++, i++) { + if (len > 0 && data[len - 1] == '\0') { + Q = data + len - 1; + } + else { + Q = data + len; + } + + for (P = data, i = 0; P < Q; P++, i++) { str[i] = P; - for (; P < Q && *P != '\0'; P++) { + for (; P < Q && *P != '\0'; P++) { ; - } + } } } @@ -540,20 +540,20 @@ static int countStrings(wchar_t *data, int len) { int strings; - wchar_t *P, *Q; - - if (len > 0 && data[len - 1] == '\0') { - Q = data + len - 1; - } - else { - Q = data + len; - } - - for (P = data, strings = 0; P < Q; P++, strings++) { - for (; P < Q && *P != '\0'; P++) { + wchar_t *P, *Q; + + if (len > 0 && data[len - 1] == '\0') { + Q = data + len - 1; + } + else { + Q = data + len; + } + + for (P = data, strings = 0; P < Q; P++, strings++) { + for (; P < Q && *P != '\0'; P++) { ; - } - } + } + } return strings; } @@ -646,10 +646,10 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) t = PyList_GET_ITEM(value, j); if (!PyUnicode_Check(t)) return FALSE; -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS wstr = PyUnicode_AsUnicodeAndSize(t, &len); -_Py_COMP_DIAG_POP +_Py_COMP_DIAG_POP if (wstr == NULL) return FALSE; size += Py_SAFE_DOWNCAST((len + 1) * sizeof(wchar_t), @@ -672,11 +672,11 @@ _Py_COMP_DIAG_POP Py_ssize_t len; t = PyList_GET_ITEM(value, j); -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS wstr = PyUnicode_AsUnicodeAndSize(t, &len); -_Py_COMP_DIAG_POP - assert(wstr); +_Py_COMP_DIAG_POP + assert(wstr); wcscpy(P, wstr); P += (len + 1); } @@ -773,15 +773,15 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ) } for (index = 0; index < s; index++) { - size_t slen = wcsnlen(str[index], len); - PyObject *uni = PyUnicode_FromWideChar(str[index], slen); + size_t slen = wcsnlen(str[index], len); + PyObject *uni = PyUnicode_FromWideChar(str[index], slen); if (uni == NULL) { Py_DECREF(obData); PyMem_Free(str); return NULL; } PyList_SET_ITEM(obData, index, uni); - len -= Py_SAFE_DOWNCAST(slen + 1, size_t, int); + len -= Py_SAFE_DOWNCAST(slen + 1, size_t, int); } PyMem_Free(str); @@ -850,10 +850,10 @@ winreg_ConnectRegistry_impl(PyObject *module, { HKEY retKey; long rc; - if (PySys_Audit("winreg.ConnectRegistry", "un", - computer_name, (Py_ssize_t)key) < 0) { - return NULL; - } + if (PySys_Audit("winreg.ConnectRegistry", "un", + computer_name, (Py_ssize_t)key) < 0) { + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegConnectRegistryW(computer_name, key, &retKey); Py_END_ALLOW_THREADS @@ -891,20 +891,20 @@ winreg_CreateKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) HKEY retKey; long rc; - if (PySys_Audit("winreg.CreateKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)KEY_WRITE) < 0) { - return NULL; - } + if (PySys_Audit("winreg.CreateKey", "nun", + (Py_ssize_t)key, sub_key, + (Py_ssize_t)KEY_WRITE) < 0) { + return NULL; + } rc = RegCreateKeyW(key, sub_key, &retKey); if (rc != ERROR_SUCCESS) { PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); return NULL; } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } + if (PySys_Audit("winreg.OpenKey/result", "n", + (Py_ssize_t)retKey) < 0) { + return NULL; + } return retKey; } @@ -941,21 +941,21 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, HKEY retKey; long rc; - if (PySys_Audit("winreg.CreateKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } + if (PySys_Audit("winreg.CreateKey", "nun", + (Py_ssize_t)key, sub_key, + (Py_ssize_t)access) < 0) { + return NULL; + } rc = RegCreateKeyExW(key, sub_key, reserved, NULL, 0, access, NULL, &retKey, NULL); if (rc != ERROR_SUCCESS) { PyErr_SetFromWindowsErrWithFunction(rc, "CreateKeyEx"); return NULL; } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } + if (PySys_Audit("winreg.OpenKey/result", "n", + (Py_ssize_t)retKey) < 0) { + return NULL; + } return retKey; } @@ -982,11 +982,11 @@ winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) /*[clinic end generated code: output=d2652a84f70e0862 input=b31d225b935e4211]*/ { long rc; - if (PySys_Audit("winreg.DeleteKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)0) < 0) { - return NULL; - } + if (PySys_Audit("winreg.DeleteKey", "nun", + (Py_ssize_t)key, sub_key, + (Py_ssize_t)0) < 0) { + return NULL; + } rc = RegDeleteKeyW(key, sub_key ); if (rc != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); @@ -1028,18 +1028,18 @@ winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, RDKEFunc pfn = NULL; long rc; - if (PySys_Audit("winreg.DeleteKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } + if (PySys_Audit("winreg.DeleteKey", "nun", + (Py_ssize_t)key, sub_key, + (Py_ssize_t)access) < 0) { + return NULL; + } /* Only available on 64bit platforms, so we must load it dynamically. */ - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS hMod = GetModuleHandleW(L"advapi32.dll"); if (hMod) - pfn = (RDKEFunc)GetProcAddress(hMod, "RegDeleteKeyExW"); - Py_END_ALLOW_THREADS + pfn = (RDKEFunc)GetProcAddress(hMod, "RegDeleteKeyExW"); + Py_END_ALLOW_THREADS if (!pfn) { PyErr_SetString(PyExc_NotImplementedError, "not implemented on this platform"); @@ -1071,10 +1071,10 @@ winreg_DeleteValue_impl(PyObject *module, HKEY key, const Py_UNICODE *value) /*[clinic end generated code: output=56fa9d21f3a54371 input=a78d3407a4197b21]*/ { long rc; - if (PySys_Audit("winreg.DeleteValue", "nu", - (Py_ssize_t)key, value) < 0) { - return NULL; - } + if (PySys_Audit("winreg.DeleteValue", "nu", + (Py_ssize_t)key, value) < 0) { + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegDeleteValueW(key, value); Py_END_ALLOW_THREADS @@ -1107,10 +1107,10 @@ winreg_EnumKey_impl(PyObject *module, HKEY key, int index) long rc; PyObject *retStr; - if (PySys_Audit("winreg.EnumKey", "ni", - (Py_ssize_t)key, index) < 0) { - return NULL; - } + if (PySys_Audit("winreg.EnumKey", "ni", + (Py_ssize_t)key, index) < 0) { + return NULL; + } /* The Windows docs claim that the max key name length is 255 * characters, plus a terminating nul character. However, * empirical testing demonstrates that it is possible to @@ -1169,10 +1169,10 @@ winreg_EnumValue_impl(PyObject *module, HKEY key, int index) PyObject *obData; PyObject *retVal; - if (PySys_Audit("winreg.EnumValue", "ni", - (Py_ssize_t)key, index) < 0) { - return NULL; - } + if (PySys_Audit("winreg.EnumValue", "ni", + (Py_ssize_t)key, index) < 0) { + return NULL; + } if ((rc = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &retValueSize, &retDataSize, NULL, NULL)) @@ -1256,11 +1256,11 @@ winreg_ExpandEnvironmentStrings_impl(PyObject *module, DWORD rc; PyObject *o; - if (PySys_Audit("winreg.ExpandEnvironmentStrings", "u", - string) < 0) { - return NULL; - } - + if (PySys_Audit("winreg.ExpandEnvironmentStrings", "u", + string) < 0) { + return NULL; + } + retValueSize = ExpandEnvironmentStringsW(string, retValue, 0); if (retValueSize == 0) { return PyErr_SetFromWindowsErrWithFunction(retValueSize, @@ -1352,10 +1352,10 @@ winreg_LoadKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, { long rc; - if (PySys_Audit("winreg.LoadKey", "nuu", - (Py_ssize_t)key, sub_key, file_name) < 0) { - return NULL; - } + if (PySys_Audit("winreg.LoadKey", "nuu", + (Py_ssize_t)key, sub_key, file_name) < 0) { + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegLoadKeyW(key, sub_key, file_name ); Py_END_ALLOW_THREADS @@ -1391,11 +1391,11 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, HKEY retKey; long rc; - if (PySys_Audit("winreg.OpenKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } + if (PySys_Audit("winreg.OpenKey", "nun", + (Py_ssize_t)key, sub_key, + (Py_ssize_t)access) < 0) { + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegOpenKeyExW(key, sub_key, reserved, access, &retKey); Py_END_ALLOW_THREADS @@ -1403,10 +1403,10 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx"); return NULL; } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } + if (PySys_Audit("winreg.OpenKey/result", "n", + (Py_ssize_t)retKey) < 0) { + return NULL; + } return retKey; } @@ -1447,30 +1447,30 @@ static PyObject * winreg_QueryInfoKey_impl(PyObject *module, HKEY key) /*[clinic end generated code: output=dc657b8356a4f438 input=c3593802390cde1f]*/ { - long rc; - DWORD nSubKeys, nValues; - FILETIME ft; - LARGE_INTEGER li; - PyObject *l; - PyObject *ret; - - if (PySys_Audit("winreg.QueryInfoKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - if ((rc = RegQueryInfoKeyW(key, NULL, NULL, 0, &nSubKeys, NULL, NULL, - &nValues, NULL, NULL, NULL, &ft)) - != ERROR_SUCCESS) { - return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); - } - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - l = PyLong_FromLongLong(li.QuadPart); - if (l == NULL) { - return NULL; - } - ret = Py_BuildValue("iiO", nSubKeys, nValues, l); - Py_DECREF(l); - return ret; + long rc; + DWORD nSubKeys, nValues; + FILETIME ft; + LARGE_INTEGER li; + PyObject *l; + PyObject *ret; + + if (PySys_Audit("winreg.QueryInfoKey", "n", (Py_ssize_t)key) < 0) { + return NULL; + } + if ((rc = RegQueryInfoKeyW(key, NULL, NULL, 0, &nSubKeys, NULL, NULL, + &nValues, NULL, NULL, NULL, &ft)) + != ERROR_SUCCESS) { + return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); + } + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + l = PyLong_FromLongLong(li.QuadPart); + if (l == NULL) { + return NULL; + } + ret = Py_BuildValue("iiO", nSubKeys, nValues, l); + Py_DECREF(l); + return ret; } /*[clinic input] @@ -1505,10 +1505,10 @@ winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) DWORD retSize = 0; wchar_t *tmp; - if (PySys_Audit("winreg.QueryValue", "nuu", - (Py_ssize_t)key, sub_key, NULL) < 0) { - return NULL; - } + if (PySys_Audit("winreg.QueryValue", "nuu", + (Py_ssize_t)key, sub_key, NULL) < 0) { + return NULL; + } rc = RegQueryValueW(key, sub_key, NULL, &retSize); if (rc == ERROR_MORE_DATA) retSize = 256; @@ -1576,10 +1576,10 @@ winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name) PyObject *obData; PyObject *result; - if (PySys_Audit("winreg.QueryValue", "nuu", - (Py_ssize_t)key, NULL, name) < 0) { - return NULL; - } + if (PySys_Audit("winreg.QueryValue", "nuu", + (Py_ssize_t)key, NULL, name) < 0) { + return NULL; + } rc = RegQueryValueExW(key, name, NULL, NULL, NULL, &bufSize); if (rc == ERROR_MORE_DATA) bufSize = 256; @@ -1653,10 +1653,10 @@ winreg_SaveKey_impl(PyObject *module, HKEY key, const Py_UNICODE *file_name) if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE)) return NULL; */ - if (PySys_Audit("winreg.SaveKey", "nu", - (Py_ssize_t)key, file_name) < 0) { - return NULL; - } + if (PySys_Audit("winreg.SaveKey", "nu", + (Py_ssize_t)key, file_name) < 0) { + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegSaveKeyW(key, file_name, pSA ); Py_END_ALLOW_THREADS @@ -1701,22 +1701,22 @@ winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, long rc; if (type != REG_SZ) { - PyErr_SetString(PyExc_TypeError, "type must be winreg.REG_SZ"); + PyErr_SetString(PyExc_TypeError, "type must be winreg.REG_SZ"); return NULL; } - if ((size_t)value_length >= PY_DWORD_MAX) { - PyErr_SetString(PyExc_OverflowError, "value is too long"); - return NULL; - } - - if (PySys_Audit("winreg.SetValue", "nunu#", - (Py_ssize_t)key, sub_key, (Py_ssize_t)type, - value, value_length) < 0) { - return NULL; - } - + if ((size_t)value_length >= PY_DWORD_MAX) { + PyErr_SetString(PyExc_OverflowError, "value is too long"); + return NULL; + } + + if (PySys_Audit("winreg.SetValue", "nunu#", + (Py_ssize_t)key, sub_key, (Py_ssize_t)type, + value, value_length) < 0) { + return NULL; + } + Py_BEGIN_ALLOW_THREADS - rc = RegSetValueW(key, sub_key, REG_SZ, value, (DWORD)(value_length + 1)); + rc = RegSetValueW(key, sub_key, REG_SZ, value, (DWORD)(value_length + 1)); Py_END_ALLOW_THREADS if (rc != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue"); @@ -1785,12 +1785,12 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key, "Could not convert the data to the specified type."); return NULL; } - if (PySys_Audit("winreg.SetValue", "nunO", - (Py_ssize_t)key, value_name, (Py_ssize_t)type, - value) < 0) { - PyMem_Free(data); - return NULL; - } + if (PySys_Audit("winreg.SetValue", "nunO", + (Py_ssize_t)key, value_name, (Py_ssize_t)type, + value) < 0) { + PyMem_Free(data); + return NULL; + } Py_BEGIN_ALLOW_THREADS rc = RegSetValueExW(key, value_name, 0, type, data, len); Py_END_ALLOW_THREADS @@ -1810,7 +1810,7 @@ winreg.DisableReflectionKey Disables registry reflection for 32bit processes running on a 64bit OS. -Will generally raise NotImplementedError if executed on a 32bit OS. +Will generally raise NotImplementedError if executed on a 32bit OS. If the key is not on the reflection list, the function succeeds but has no effect. Disabling reflection for a key does not affect reflection @@ -1819,25 +1819,25 @@ of any subkeys. static PyObject * winreg_DisableReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=830cce504cc764b4 input=70bece2dee02e073]*/ +/*[clinic end generated code: output=830cce504cc764b4 input=70bece2dee02e073]*/ { HMODULE hMod; typedef LONG (WINAPI *RDRKFunc)(HKEY); RDRKFunc pfn = NULL; LONG rc; - if (PySys_Audit("winreg.DisableReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - + if (PySys_Audit("winreg.DisableReflectionKey", "n", (Py_ssize_t)key) < 0) { + return NULL; + } + /* Only available on 64bit platforms, so we must load it dynamically.*/ - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS hMod = GetModuleHandleW(L"advapi32.dll"); if (hMod) pfn = (RDRKFunc)GetProcAddress(hMod, "RegDisableReflectionKey"); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS if (!pfn) { PyErr_SetString(PyExc_NotImplementedError, "not implemented on this platform"); @@ -1861,32 +1861,32 @@ winreg.EnableReflectionKey Restores registry reflection for the specified disabled key. -Will generally raise NotImplementedError if executed on a 32bit OS. +Will generally raise NotImplementedError if executed on a 32bit OS. Restoring reflection for a key does not affect reflection of any subkeys. [clinic start generated code]*/ static PyObject * winreg_EnableReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=86fa1385fdd9ce57 input=eeae770c6eb9f559]*/ +/*[clinic end generated code: output=86fa1385fdd9ce57 input=eeae770c6eb9f559]*/ { HMODULE hMod; typedef LONG (WINAPI *RERKFunc)(HKEY); RERKFunc pfn = NULL; LONG rc; - if (PySys_Audit("winreg.EnableReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - + if (PySys_Audit("winreg.EnableReflectionKey", "n", (Py_ssize_t)key) < 0) { + return NULL; + } + /* Only available on 64bit platforms, so we must load it dynamically.*/ - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS hMod = GetModuleHandleW(L"advapi32.dll"); if (hMod) pfn = (RERKFunc)GetProcAddress(hMod, "RegEnableReflectionKey"); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS if (!pfn) { PyErr_SetString(PyExc_NotImplementedError, "not implemented on this platform"); @@ -1910,12 +1910,12 @@ winreg.QueryReflectionKey Returns the reflection state for the specified key as a bool. -Will generally raise NotImplementedError if executed on a 32bit OS. +Will generally raise NotImplementedError if executed on a 32bit OS. [clinic start generated code]*/ static PyObject * winreg_QueryReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=4e774af288c3ebb9 input=a98fa51d55ade186]*/ +/*[clinic end generated code: output=4e774af288c3ebb9 input=a98fa51d55ade186]*/ { HMODULE hMod; typedef LONG (WINAPI *RQRKFunc)(HKEY, BOOL *); @@ -1923,18 +1923,18 @@ winreg_QueryReflectionKey_impl(PyObject *module, HKEY key) BOOL result; LONG rc; - if (PySys_Audit("winreg.QueryReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - + if (PySys_Audit("winreg.QueryReflectionKey", "n", (Py_ssize_t)key) < 0) { + return NULL; + } + /* Only available on 64bit platforms, so we must load it dynamically.*/ - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS hMod = GetModuleHandleW(L"advapi32.dll"); if (hMod) pfn = (RQRKFunc)GetProcAddress(hMod, "RegQueryReflectionKey"); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS if (!pfn) { PyErr_SetString(PyExc_NotImplementedError, "not implemented on this platform"); |