From 557fe04a6091ad323f168268d58648249b2946f2 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 21:07:55 +0300 Subject: [PATCH 01/13] bpo-9566: Silence liblzma warnings --- PCbuild/liblzma.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/liblzma.vcxproj b/PCbuild/liblzma.vcxproj index 4ace9d945f48d8..0934cc558c7179 100644 --- a/PCbuild/liblzma.vcxproj +++ b/PCbuild/liblzma.vcxproj @@ -64,7 +64,7 @@ ProgramDatabase Disabled $(lzmaDir)windows;$(lzmaDir)src/liblzma/common;$(lzmaDir)src/common;$(lzmaDir)src/liblzma/api;$(lzmaDir)src/liblzma/check;$(lzmaDir)src/liblzma/delta;$(lzmaDir)src/liblzma/lz;$(lzmaDir)src/liblzma/lzma;$(lzmaDir)src/liblzma/rangecoder;$(lzmaDir)src/liblzma/simple - 4028;4113;4244;4267;4996 + 4028;4113;4133;4244;4267;4996 From 6c57de03afb71b68b60074bf0e4750611663e7ef Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 21:12:25 +0300 Subject: [PATCH 02/13] bpo-9566: Silence tcl warnings --- PCbuild/tcl.vcxproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PCbuild/tcl.vcxproj b/PCbuild/tcl.vcxproj index 3dfd155810ff7b..19317134757578 100644 --- a/PCbuild/tcl.vcxproj +++ b/PCbuild/tcl.vcxproj @@ -65,6 +65,7 @@ symbols,msvcrt INSTALLDIR="$(OutDir.TrimEnd(`\`))" INSTALL_DIR="$(OutDir.TrimEnd(`\`))" DEBUGFLAGS="-wd4456 -wd4457 -wd4458 -wd4459 -wd4996" + WARNINGS="-W3 -wd4311 -wd4312" setlocal @(ExpectedOutputs->'if not exist "%(FullPath)" goto build',' ') @@ -72,8 +73,8 @@ goto :eof :build set VCINSTALLDIR=$(VCInstallDir) cd /D "$(tclDir)win" -nmake -f makefile.vc MACHINE=$(TclMachine) OPTS=$(TclOpts) $(TclDirs) $(DebugFlags) core shell dlls -nmake -f makefile.vc MACHINE=$(TclMachine) OPTS=$(TclOpts) $(TclDirs) $(DebugFlags) install-binaries install-libraries +nmake -f makefile.vc MACHINE=$(TclMachine) OPTS=$(TclOpts) $(TclDirs) $(DebugFlags) $(WarningsFlags) core shell dlls +nmake -f makefile.vc MACHINE=$(TclMachine) OPTS=$(TclOpts) $(TclDirs) $(DebugFlags) $(WarningsFlags) install-binaries install-libraries From a353e289e09fa8ac8d378942bcc61b6a31628070 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 21:27:09 +0300 Subject: [PATCH 03/13] bpo-9566: Silence tk warnings --- PCbuild/tk.vcxproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PCbuild/tk.vcxproj b/PCbuild/tk.vcxproj index a26318bbe786b8..1209ea95eb8f29 100644 --- a/PCbuild/tk.vcxproj +++ b/PCbuild/tk.vcxproj @@ -64,6 +64,7 @@ symbols,msvcrt TCLDIR="$(tclDir.TrimEnd(`\`))" INSTALLDIR="$(OutDir.TrimEnd(`\`))" DEBUGFLAGS="-wd4456 -wd4457 -wd4458 -wd4459 -wd4996" + WARNINGS="-W3 -wd4244 -wd4267 -wd4311 -wd4312 -wd4334" setlocal @(ExpectedOutputs->'if not exist "%(FullPath)" goto build',' ') @@ -71,8 +72,8 @@ goto :eof :build set VCINSTALLDIR=$(VCInstallDir) cd /D "$(tkDir)win" -nmake /nologo -f makefile.vc RC=rc MACHINE=$(TclMachine) OPTS=$(TkOpts) $(TkDirs) $(DebugFlags) all -nmake /nologo -f makefile.vc RC=rc MACHINE=$(TclMachine) OPTS=$(TkOpts) $(TkDirs) $(DebugFlags) install-binaries install-libraries +nmake /nologo -f makefile.vc RC=rc MACHINE=$(TclMachine) OPTS=$(TkOpts) $(TkDirs) $(DebugFlags) $(WarningsFlags) all +nmake /nologo -f makefile.vc RC=rc MACHINE=$(TclMachine) OPTS=$(TkOpts) $(TkDirs) $(DebugFlags) $(WarningsFlags) install-binaries install-libraries From 8f460753e969b0d4a1cdfdd279e60015be6232b0 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 21:31:56 +0300 Subject: [PATCH 04/13] bpo-9566: Silence tix warnings --- PCbuild/tix.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/tix.vcxproj b/PCbuild/tix.vcxproj index 7d6d8ca8a65cb9..6725ab70b002da 100644 --- a/PCbuild/tix.vcxproj +++ b/PCbuild/tix.vcxproj @@ -59,7 +59,7 @@ BUILDDIRTOP="$(BuildDirTop)" TCL_DIR="$(tclDir.TrimEnd(`\`))" TK_DIR="$(tkDir.TrimEnd(`\`))" INSTALL_DIR="$(OutDir.TrimEnd(`\`))" DEBUG=1 NODEBUG=0 TCL_DBGX=g TK_DBGX=g DEBUG=0 NODEBUG=1 - -c -W3 -nologo -MD -wd4028 -wd4090 + -c -W3 -nologo -MD -wd4028 -wd4090 -wd4244 -wd4267 -wd4312 setlocal @(ExpectedOutputs->'if not exist "%(FullPath)" goto build',' ') From 85594d6f4d973efa9d39da00804e7522f3497455 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 21:54:02 +0300 Subject: [PATCH 05/13] bpo-9566: Fix some library warnings --- Modules/binascii.c | 2 +- Modules/zlibmodule.c | 4 ++-- PC/winreg.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/binascii.c b/Modules/binascii.c index 1f9ff5a57b4596..1af6b7f98f255f 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -372,7 +372,7 @@ binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick) if (backtick && !bin_len) *ascii_data++ = '`'; else - *ascii_data++ = ' ' + bin_len; + *ascii_data++ = ' ' + (unsigned char)bin_len; for( ; bin_len > 0 || leftbits != 0 ; bin_len--, bin_data++ ) { /* Shift the data (or padding) into our buffer */ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index cfe7f88dc540ec..32dd817434709c 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -142,7 +142,7 @@ PyZlib_Free(voidpf ctx, void *ptr) static void arrange_input_buffer(z_stream *zst, Py_ssize_t *remains) { - zst->avail_in = Py_MIN((size_t)*remains, UINT_MAX); + zst->avail_in = (uInt)Py_MIN((size_t)*remains, UINT_MAX); *remains -= zst->avail_in; } @@ -177,7 +177,7 @@ arrange_output_buffer_with_maximum(z_stream *zst, PyObject **buffer, } } - zst->avail_out = Py_MIN((size_t)(length - occupied), UINT_MAX); + zst->avail_out = (uInt)Py_MIN((size_t)(length - occupied), UINT_MAX); zst->next_out = (Byte *)PyBytes_AS_STRING(*buffer) + occupied; return length; diff --git a/PC/winreg.c b/PC/winreg.c index 5efdc5e0efec6c..2d665f73186efa 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -905,7 +905,7 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, Py_UNICODE *sub_key, HKEY retKey; long rc; - rc = RegCreateKeyExW(key, sub_key, reserved, NULL, (DWORD)NULL, + rc = RegCreateKeyExW(key, sub_key, reserved, NULL, 0, access, NULL, &retKey, NULL); if (rc != ERROR_SUCCESS) { PyErr_SetFromWindowsErrWithFunction(rc, "CreateKeyEx"); From a7c064629c0e11ee79546ec26ccc78134852ead5 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 22:00:37 +0300 Subject: [PATCH 06/13] bpo-9566: Fix msvcrtmodule.c warnings --- PC/clinic/msvcrtmodule.c.h | 28 ++++++++-------- PC/msvcrtmodule.c | 68 ++++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index 046b0583b0ca4e..3102f4f1fece4d 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -121,13 +121,13 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, static long -msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags); +msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); static PyObject * msvcrt_open_osfhandle(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - intptr_t handle; + void *handle; int flags; long _return_value; @@ -160,7 +160,7 @@ PyDoc_STRVAR(msvcrt_get_osfhandle__doc__, #define MSVCRT_GET_OSFHANDLE_METHODDEF \ {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__}, -static intptr_t +static void * msvcrt_get_osfhandle_impl(PyObject *module, int fd); static PyObject * @@ -168,16 +168,16 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; int fd; - intptr_t _return_value; + void *_return_value; if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) { goto exit; } _return_value = msvcrt_get_osfhandle_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) { + if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; } - return_value = PyLong_FromVoidPtr((void *)_return_value); + return_value = PyLong_FromVoidPtr(_return_value); exit: return return_value; @@ -438,30 +438,30 @@ PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__, #define MSVCRT_CRTSETREPORTFILE_METHODDEF \ {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, -static long -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, int file); +static void * +msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); static PyObject * msvcrt_CrtSetReportFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; int type; - int file; - long _return_value; + void *file; + void *_return_value; if (!_PyArg_NoStackKeywords("CrtSetReportFile", kwnames)) { goto exit; } - if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportFile", + if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_INTPTR":CrtSetReportFile", &type, &file)) { goto exit; } _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); - if ((_return_value == -1) && PyErr_Occurred()) { + if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; } - return_value = PyLong_FromLong(_return_value); + return_value = PyLong_FromVoidPtr(_return_value); exit: return return_value; @@ -589,4 +589,4 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=9e82abfdd357b0da input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bf069e62089190cd input=a9049054013a1b77]*/ diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 59bf54fa0b7743..4a696fe9eb20e6 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -33,14 +33,18 @@ #endif /*[python input] -class intptr_t_converter(CConverter): - type = 'intptr_t' +class HANDLE_converter(CConverter): + type = 'void *' format_unit = '"_Py_PARSE_INTPTR"' -class handle_return_converter(long_return_converter): - type = 'intptr_t' - cast = '(void *)' - conversion_fn = 'PyLong_FromVoidPtr' +class HANDLE_return_converter(CReturnConverter): + type = 'void *' + + def render(self, function, data): + self.declare(data) + self.err_occurred_if("_return_value == INVALID_HANDLE_VALUE", data) + data.return_conversion.append( + 'return_value = PyLong_FromVoidPtr(_return_value);\n') class byte_char_return_converter(CReturnConverter): type = 'int' @@ -59,7 +63,7 @@ class wchar_t_return_converter(CReturnConverter): data.return_conversion.append( 'return_value = PyUnicode_FromOrdinal(_return_value);\n') [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=b59f1663dba11997]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=dab543102cf6345d]*/ /*[clinic input] module msvcrt @@ -152,7 +156,7 @@ msvcrt_setmode_impl(PyObject *module, int fd, int flags) /*[clinic input] msvcrt.open_osfhandle -> long - handle: intptr_t + handle: HANDLE flags: int / @@ -164,13 +168,13 @@ to os.fdopen() to create a file object. [clinic start generated code]*/ static long -msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags) -/*[clinic end generated code: output=cede871bf939d6e3 input=cb2108bbea84514e]*/ +msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags) +/*[clinic end generated code: output=b2fb97c4b515e4e6 input=d5db190a307cf4bb]*/ { int fd; _Py_BEGIN_SUPPRESS_IPH - fd = _open_osfhandle(handle, flags); + fd = _open_osfhandle((intptr_t)handle, flags); _Py_END_SUPPRESS_IPH if (fd == -1) PyErr_SetFromErrno(PyExc_OSError); @@ -179,7 +183,7 @@ msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags) } /*[clinic input] -msvcrt.get_osfhandle -> handle +msvcrt.get_osfhandle -> HANDLE fd: int / @@ -189,9 +193,9 @@ Return the file handle for the file descriptor fd. Raises OSError if fd is not recognized. [clinic start generated code]*/ -static intptr_t +static void * msvcrt_get_osfhandle_impl(PyObject *module, int fd) -/*[clinic end generated code: output=7ce761dd0de2b503 input=305900f4bfab76c7]*/ +/*[clinic end generated code: output=aca01dfe24637374 input=5fcfde9b17136aa2]*/ { intptr_t handle = -1; @@ -201,7 +205,7 @@ msvcrt_get_osfhandle_impl(PyObject *module, int fd) if (handle == -1) PyErr_SetFromErrno(PyExc_OSError); - return handle; + return (HANDLE)handle; } /* Console I/O */ @@ -389,10 +393,10 @@ msvcrt_ungetwch_impl(PyObject *module, int unicode_char) #ifdef _DEBUG /*[clinic input] -msvcrt.CrtSetReportFile -> long +msvcrt.CrtSetReportFile -> HANDLE type: int - file: int + file: HANDLE / Wrapper around _CrtSetReportFile. @@ -400,14 +404,14 @@ Wrapper around _CrtSetReportFile. Only available on Debug builds. [clinic start generated code]*/ -static long -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, int file) -/*[clinic end generated code: output=df291c7fe032eb68 input=bb8f721a604fcc45]*/ +static void * +msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file) +/*[clinic end generated code: output=9393e8c77088bbe9 input=290809b5f19e65b9]*/ { - long res; + HANDLE res; _Py_BEGIN_SUPPRESS_IPH - res = (long)_CrtSetReportFile(type, (_HFILE)file); + res = _CrtSetReportFile(type, file); _Py_END_SUPPRESS_IPH return res; @@ -540,6 +544,20 @@ insertint(PyObject *d, char *name, int value) } } +static void +insertptr(PyObject *d, char *name, void *value) +{ + PyObject *v = PyLong_FromVoidPtr(value); + if (v == NULL) { + /* Don't bother reporting this error */ + PyErr_Clear(); + } + else { + PyDict_SetItemString(d, name, v); + Py_DECREF(v); + } +} + PyMODINIT_FUNC PyInit_msvcrt(void) { @@ -568,9 +586,9 @@ PyInit_msvcrt(void) insertint(d, "CRTDBG_MODE_FILE", _CRTDBG_MODE_FILE); insertint(d, "CRTDBG_MODE_WNDW", _CRTDBG_MODE_WNDW); insertint(d, "CRTDBG_REPORT_MODE", _CRTDBG_REPORT_MODE); - insertint(d, "CRTDBG_FILE_STDERR", (int)_CRTDBG_FILE_STDERR); - insertint(d, "CRTDBG_FILE_STDOUT", (int)_CRTDBG_FILE_STDOUT); - insertint(d, "CRTDBG_REPORT_FILE", (int)_CRTDBG_REPORT_FILE); + insertptr(d, "CRTDBG_FILE_STDERR", _CRTDBG_FILE_STDERR); + insertptr(d, "CRTDBG_FILE_STDOUT", _CRTDBG_FILE_STDOUT); + insertptr(d, "CRTDBG_REPORT_FILE", _CRTDBG_REPORT_FILE); #endif /* constants for the crt versions */ From 181a36f6170adf831532b84652252dab803513d9 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 22:16:11 +0300 Subject: [PATCH 07/13] bpo-9566: Silence _bz2 warnings --- PCbuild/_bz2.vcxproj | 1 + PCbuild/liblzma.vcxproj | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PCbuild/_bz2.vcxproj b/PCbuild/_bz2.vcxproj index 9efb0d9a792d6c..65da7a4c31f899 100644 --- a/PCbuild/_bz2.vcxproj +++ b/PCbuild/_bz2.vcxproj @@ -64,6 +64,7 @@ $(bz2Dir);%(AdditionalIncludeDirectories) WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + 4244;4267;%(DisableSpecificWarnings) 0x1D170000 diff --git a/PCbuild/liblzma.vcxproj b/PCbuild/liblzma.vcxproj index 0934cc558c7179..f408b5478558cf 100644 --- a/PCbuild/liblzma.vcxproj +++ b/PCbuild/liblzma.vcxproj @@ -64,7 +64,7 @@ ProgramDatabase Disabled $(lzmaDir)windows;$(lzmaDir)src/liblzma/common;$(lzmaDir)src/common;$(lzmaDir)src/liblzma/api;$(lzmaDir)src/liblzma/check;$(lzmaDir)src/liblzma/delta;$(lzmaDir)src/liblzma/lz;$(lzmaDir)src/liblzma/lzma;$(lzmaDir)src/liblzma/rangecoder;$(lzmaDir)src/liblzma/simple - 4028;4113;4133;4244;4267;4996 + 4028;4113;4133;4244;4267;4996;%(DisableSpecificWarnings) From a639001c949ba53338a9ee047d2ec1efd2505e6f Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 22:22:46 +0300 Subject: [PATCH 08/13] bpo-9566: Fixed some _ssl warnings --- Modules/_ssl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c index a79a7470d20a3a..65b1ee8d5938ea 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1555,7 +1555,7 @@ cipher_to_dict(const SSL_CIPHER *cipher) cipher_protocol = SSL_CIPHER_get_version(cipher); cipher_id = SSL_CIPHER_get_id(cipher); SSL_CIPHER_description(cipher, buf, sizeof(buf) - 1); - len = strlen(buf); + len = (int)strlen(buf); if (len > 1 && buf[len-1] == '\n') buf[len-1] = '\0'; strength_bits = SSL_CIPHER_get_bits(cipher, &alg_bits); @@ -4073,7 +4073,7 @@ memory_bio_dealloc(PySSLMemoryBIO *self) static PyObject * memory_bio_get_pending(PySSLMemoryBIO *self, void *c) { - return PyLong_FromLong(BIO_ctrl_pending(self->bio)); + return PyLong_FromSize_t(BIO_ctrl_pending(self->bio)); } PyDoc_STRVAR(PySSL_memory_bio_pending_doc, @@ -4109,7 +4109,7 @@ _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len) int avail, nbytes; PyObject *result; - avail = BIO_ctrl_pending(self->bio); + avail = (int)BIO_ctrl_pending(self->bio); if ((len < 0) || (len > avail)) len = avail; From 6943cefdc411bfdd9defbf8e6cedbd65876c8540 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 22:27:40 +0300 Subject: [PATCH 09/13] bpo-9566: Fix _msi warnings --- PC/_msi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/PC/_msi.c b/PC/_msi.c index 9c3f9f6e18a34b..c028a88e05c112 100644 --- a/PC/_msi.c +++ b/PC/_msi.c @@ -948,8 +948,8 @@ static PyTypeObject msidb_Type = { }; #define Py_NOT_PERSIST(x, flag) \ - (x != (int)(flag) && \ - x != ((int)(flag) | MSIDBOPEN_PATCHFILE)) + (x != (SIZE_T)(flag) && \ + x != ((SIZE_T)(flag) | MSIDBOPEN_PATCHFILE)) #define Py_INVALID_PERSIST(x) \ (Py_NOT_PERSIST(x, MSIDBOPEN_READONLY) && \ @@ -972,7 +972,7 @@ static PyObject* msiopendb(PyObject *obj, PyObject *args) behavior. */ if (Py_INVALID_PERSIST(persist)) return msierror(ERROR_INVALID_PARAMETER); - status = MsiOpenDatabase(path, (LPCSTR)persist, &h); + status = MsiOpenDatabase(path, (LPCSTR)(SIZE_T)persist, &h); if (status != ERROR_SUCCESS) return msierror(status); @@ -1038,12 +1038,12 @@ PyInit__msi(void) if (m == NULL) return NULL; - PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (long)MSIDBOPEN_CREATEDIRECT); - PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (long)MSIDBOPEN_CREATE); - PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (long)MSIDBOPEN_DIRECT); - PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (long)MSIDBOPEN_READONLY); - PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (long)MSIDBOPEN_TRANSACT); - PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (long)MSIDBOPEN_PATCHFILE); + PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (long)(SIZE_T)MSIDBOPEN_CREATEDIRECT); + PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (long)(SIZE_T)MSIDBOPEN_CREATE); + PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (long)(SIZE_T)MSIDBOPEN_DIRECT); + PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (long)(SIZE_T)MSIDBOPEN_READONLY); + PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (long)(SIZE_T)MSIDBOPEN_TRANSACT); + PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (long)(SIZE_T)MSIDBOPEN_PATCHFILE); PyModule_AddIntMacro(m, MSICOLINFO_NAMES); PyModule_AddIntMacro(m, MSICOLINFO_TYPES); From 4c56c8682188c26b4b8384a5ff5ad73c43ab8caf Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Thu, 29 Jun 2017 22:32:34 +0300 Subject: [PATCH 10/13] bpo-9566: Silence _ctypes warnings --- PCbuild/_ctypes.vcxproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PCbuild/_ctypes.vcxproj b/PCbuild/_ctypes.vcxproj index 70bea457d2a9fe..43d51f82965d38 100644 --- a/PCbuild/_ctypes.vcxproj +++ b/PCbuild/_ctypes.vcxproj @@ -83,7 +83,9 @@ - + + 4267;%(DisableSpecificWarnings) + true From f47309302ba1f5ff36b3171dce209790a6063188 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Fri, 30 Jun 2017 00:47:17 +0300 Subject: [PATCH 11/13] Revert "bpo-9566: Fixed some _ssl warnings" This reverts commit a639001c949ba53338a9ee047d2ec1efd2505e6f. --- Modules/_ssl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 65b1ee8d5938ea..a79a7470d20a3a 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1555,7 +1555,7 @@ cipher_to_dict(const SSL_CIPHER *cipher) cipher_protocol = SSL_CIPHER_get_version(cipher); cipher_id = SSL_CIPHER_get_id(cipher); SSL_CIPHER_description(cipher, buf, sizeof(buf) - 1); - len = (int)strlen(buf); + len = strlen(buf); if (len > 1 && buf[len-1] == '\n') buf[len-1] = '\0'; strength_bits = SSL_CIPHER_get_bits(cipher, &alg_bits); @@ -4073,7 +4073,7 @@ memory_bio_dealloc(PySSLMemoryBIO *self) static PyObject * memory_bio_get_pending(PySSLMemoryBIO *self, void *c) { - return PyLong_FromSize_t(BIO_ctrl_pending(self->bio)); + return PyLong_FromLong(BIO_ctrl_pending(self->bio)); } PyDoc_STRVAR(PySSL_memory_bio_pending_doc, @@ -4109,7 +4109,7 @@ _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len) int avail, nbytes; PyObject *result; - avail = (int)BIO_ctrl_pending(self->bio); + avail = BIO_ctrl_pending(self->bio); if ((len < 0) || (len > avail)) len = avail; From e549c4ef4d0126c59cc5539e83d71d1edcaff132 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Fri, 30 Jun 2017 11:58:25 +0300 Subject: [PATCH 12/13] bpo-9566: Also consider NULL as a possible error in HANDLE_return_converter --- PC/clinic/msvcrtmodule.c.h | 6 +++--- PC/msvcrtmodule.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index 3102f4f1fece4d..1c50b129c2ba95 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -174,7 +174,7 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg) goto exit; } _return_value = msvcrt_get_osfhandle_impl(module, fd); - if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { + if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; } return_value = PyLong_FromVoidPtr(_return_value); @@ -458,7 +458,7 @@ msvcrt_CrtSetReportFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyO goto exit; } _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); - if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { + if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; } return_value = PyLong_FromVoidPtr(_return_value); @@ -589,4 +589,4 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=bf069e62089190cd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=990a62e1a66b7ab5 input=a9049054013a1b77]*/ diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 4a696fe9eb20e6..fa9ad9dfebade0 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -42,7 +42,9 @@ class HANDLE_return_converter(CReturnConverter): def render(self, function, data): self.declare(data) - self.err_occurred_if("_return_value == INVALID_HANDLE_VALUE", data) + self.err_occurred_if( + "_return_value == NULL || _return_value == INVALID_HANDLE_VALUE", + data) data.return_conversion.append( 'return_value = PyLong_FromVoidPtr(_return_value);\n') @@ -63,7 +65,7 @@ class wchar_t_return_converter(CReturnConverter): data.return_conversion.append( 'return_value = PyUnicode_FromOrdinal(_return_value);\n') [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=dab543102cf6345d]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=2b25dc89e9e59534]*/ /*[clinic input] module msvcrt From 87bf08c027184bb084233efae8866d24e89ded53 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Fri, 30 Jun 2017 12:01:12 +0300 Subject: [PATCH 13/13] bpo-9566: whitespace fixes --- PCbuild/_bz2.vcxproj | 2 +- PCbuild/tcl.vcxproj | 2 +- PCbuild/tk.vcxproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PCbuild/_bz2.vcxproj b/PCbuild/_bz2.vcxproj index 65da7a4c31f899..b3ab378c6ed16a 100644 --- a/PCbuild/_bz2.vcxproj +++ b/PCbuild/_bz2.vcxproj @@ -64,7 +64,7 @@ $(bz2Dir);%(AdditionalIncludeDirectories) WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - 4244;4267;%(DisableSpecificWarnings) + 4244;4267;%(DisableSpecificWarnings) 0x1D170000 diff --git a/PCbuild/tcl.vcxproj b/PCbuild/tcl.vcxproj index 19317134757578..37750c31fcc4b9 100644 --- a/PCbuild/tcl.vcxproj +++ b/PCbuild/tcl.vcxproj @@ -65,7 +65,7 @@ symbols,msvcrt INSTALLDIR="$(OutDir.TrimEnd(`\`))" INSTALL_DIR="$(OutDir.TrimEnd(`\`))" DEBUGFLAGS="-wd4456 -wd4457 -wd4458 -wd4459 -wd4996" - WARNINGS="-W3 -wd4311 -wd4312" + WARNINGS="-W3 -wd4311 -wd4312" setlocal @(ExpectedOutputs->'if not exist "%(FullPath)" goto build',' ') diff --git a/PCbuild/tk.vcxproj b/PCbuild/tk.vcxproj index 1209ea95eb8f29..537fc5357928b1 100644 --- a/PCbuild/tk.vcxproj +++ b/PCbuild/tk.vcxproj @@ -64,7 +64,7 @@ symbols,msvcrt TCLDIR="$(tclDir.TrimEnd(`\`))" INSTALLDIR="$(OutDir.TrimEnd(`\`))" DEBUGFLAGS="-wd4456 -wd4457 -wd4458 -wd4459 -wd4996" - WARNINGS="-W3 -wd4244 -wd4267 -wd4311 -wd4312 -wd4334" + WARNINGS="-W3 -wd4244 -wd4267 -wd4311 -wd4312 -wd4334" setlocal @(ExpectedOutputs->'if not exist "%(FullPath)" goto build',' ')