diff -urN pywin32-220-orig/Pythonwin/Scintilla/src/Document.cxx pywin32-220/Pythonwin/Scintilla/src/Document.cxx --- pywin32-220-orig/Pythonwin/Scintilla/src/Document.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/src/Document.cxx 2016-08-28 20:42:19 +0800 @@ -1059,8 +1059,8 @@ } if (found) { if ((!word && !wordStart) || - word && IsWordAt(pos, pos + lengthFind) || - wordStart && IsWordStartAt(pos)) + (word && IsWordAt(pos, pos + lengthFind)) || + (wordStart && IsWordStartAt(pos))) return pos; } } @@ -1075,8 +1075,8 @@ } if (found) { if ((!word && !wordStart) || - word && IsWordAt(pos, pos + lengthFind) || - wordStart && IsWordStartAt(pos)) + (word && IsWordAt(pos, pos + lengthFind)) || + (wordStart && IsWordStartAt(pos))) return pos; } } diff -urN pywin32-220-orig/Pythonwin/Scintilla/src/Editor.cxx pywin32-220/Pythonwin/Scintilla/src/Editor.cxx --- pywin32-220-orig/Pythonwin/Scintilla/src/Editor.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/src/Editor.cxx 2017-05-10 12:33:27 +0800 @@ -1873,13 +1873,13 @@ ll->positions[charInLine + 1] = ((((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx; } else if (controlCharSymbol < 32) { - if (ctrlCharWidth[ll->chars[charInLine]] == 0) { + if (ctrlCharWidth[(int)ll->chars[charInLine]] == 0) { const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); // +3 For a blank on front and rounded edge each side: - ctrlCharWidth[ll->chars[charInLine]] = + ctrlCharWidth[(int)ll->chars[charInLine]] = surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3; } - ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]]; + ll->positions[charInLine + 1] = ctrlCharWidth[(int)ll->chars[charInLine]]; } else { char cc[2] = { static_cast(controlCharSymbol), '\0' }; surface->MeasureWidths(ctrlCharsFont, cc, 1, @@ -3660,7 +3660,7 @@ char txt[2]; txt[0] = static_cast(ch); txt[1] = '\0'; - NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); + NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); } } @@ -7398,7 +7398,7 @@ break; case SCI_GETDOCPOINTER: - return reinterpret_cast(pdoc); + return reinterpret_cast(pdoc); case SCI_SETDOCPOINTER: CancelModes(); @@ -7410,7 +7410,7 @@ if (doc) { doc->AddRef(); } - return reinterpret_cast(doc); + return reinterpret_cast(doc); } case SCI_ADDREFDOCUMENT: @@ -7591,7 +7591,7 @@ return convertPastes ? 1 : 0; case SCI_GETCHARACTERPOINTER: - return reinterpret_cast(pdoc->BufferPointer()); + return reinterpret_cast(pdoc->BufferPointer()); default: return DefWndProc(iMessage, wParam, lParam); diff -urN pywin32-220-orig/Pythonwin/Scintilla/src/PositionCache.cxx pywin32-220/Pythonwin/Scintilla/src/PositionCache.cxx --- pywin32-220-orig/Pythonwin/Scintilla/src/PositionCache.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/src/PositionCache.cxx 2016-09-30 19:56:24 +0800 @@ -126,7 +126,7 @@ } bool LineLayout::InLine(int offset, int line) const { - return ((offset >= LineStart(line)) && (offset < LineStart(line + 1)) || + return (((offset >= LineStart(line)) && (offset < LineStart(line + 1))) || ((offset == numCharsInLine) && (line == (lines-1)))); } diff -urN pywin32-220-orig/Pythonwin/Scintilla/src/RESearch.cxx pywin32-220/Pythonwin/Scintilla/src/RESearch.cxx --- pywin32-220-orig/Pythonwin/Scintilla/src/RESearch.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/src/RESearch.cxx 2017-05-10 10:21:39 +0800 @@ -449,11 +449,12 @@ char mask; /* xor mask -CCL/NCL */ int c1, c2, prevChar; - if (!pattern || !length) + if (!pattern || !length) { if (sta) return 0; else return badpat("No previous regular expression"); + } sta = NOP; const char *p=pattern; /* pattern pointer */ @@ -869,13 +870,13 @@ return NOTFOUND; break; case BOT: - bopat[*ap++] = lp; + bopat[(int)*ap++] = lp; break; case EOT: - eopat[*ap++] = lp; + eopat[(int)*ap++] = lp; break; case BOW: - if (lp!=bol && iswordc(ci.CharAt(lp-1)) || !iswordc(ci.CharAt(lp))) + if ((lp!=bol && iswordc(ci.CharAt(lp-1))) || !iswordc(ci.CharAt(lp))) return NOTFOUND; break; case EOW: diff -urN pywin32-220-orig/Pythonwin/Scintilla/src/UniConversion.cxx pywin32-220/Pythonwin/Scintilla/src/UniConversion.cxx --- pywin32-220-orig/Pythonwin/Scintilla/src/UniConversion.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/src/UniConversion.cxx 2016-09-30 20:06:02 +0800 @@ -48,7 +48,7 @@ i++; unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff); putf[k++] = static_cast(0xF0 | (xch >> 18)); - putf[k++] = static_cast(0x80 | (xch >> 12) & 0x3f); + putf[k++] = static_cast(0x80 | ((xch >> 12) & 0x3f)); putf[k++] = static_cast(0x80 | ((xch >> 6) & 0x3f)); putf[k++] = static_cast(0x80 | (xch & 0x3f)); } else { diff -urN pywin32-220-orig/Pythonwin/Scintilla/win32/PlatWin.cxx pywin32-220/Pythonwin/Scintilla/win32/PlatWin.cxx --- pywin32-220-orig/Pythonwin/Scintilla/win32/PlatWin.cxx 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Scintilla/win32/PlatWin.cxx 2017-03-28 09:11:10 +0800 @@ -12,6 +12,7 @@ #include #include +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #include #include @@ -607,17 +608,17 @@ HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); byte pixVal[4] = {0}; - DWORD valEmpty = *(reinterpret_cast(pixVal)); + DWORD valEmpty = *(reinterpret_cast(*pixVal)); pixVal[0] = static_cast(GetBValue(fill.AsLong()) * alphaFill / 255); pixVal[1] = static_cast(GetGValue(fill.AsLong()) * alphaFill / 255); pixVal[2] = static_cast(GetRValue(fill.AsLong()) * alphaFill / 255); pixVal[3] = static_cast(alphaFill); - DWORD valFill = *(reinterpret_cast(pixVal)); + DWORD valFill = *(reinterpret_cast(*pixVal)); pixVal[0] = static_cast(GetBValue(outline.AsLong()) * alphaOutline / 255); pixVal[1] = static_cast(GetGValue(outline.AsLong()) * alphaOutline / 255); pixVal[2] = static_cast(GetRValue(outline.AsLong()) * alphaOutline / 255); pixVal[3] = static_cast(alphaOutline); - DWORD valOutline = *(reinterpret_cast(pixVal)); + DWORD valOutline = *(reinterpret_cast(*pixVal)); DWORD *pixels = reinterpret_cast(image); for (int y=0; y #include +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #include #include @@ -568,7 +569,7 @@ static UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { CHARSETINFO ci = { 0, 0, { { 0, 0, 0, 0 }, { 0, 0 } } }; - BOOL bci = ::TranslateCharsetInfo((DWORD*)characterSet, + BOOL bci = ::TranslateCharsetInfo((DWORD*)&characterSet, &ci, TCI_SRCCHARSET); UINT cp; @@ -767,7 +768,7 @@ case WM_CHAR: if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) { if (::IsWindowUnicode(MainHWND()) || keysAlwaysUnicode) { - wchar_t wcs[2] = {wParam, 0}; + wchar_t wcs[2] = {(wchar_t)wParam, 0}; if (IsUnicodeMode()) { // For a wide character version of the window: char utfval[4]; @@ -1028,7 +1029,7 @@ #endif default: - return ScintillaBase::WndProc(iMessage, wParam, lParam); + return WndProc(iMessage, wParam, lParam); } return 0l; } @@ -2323,7 +2324,7 @@ bool ScintillaWin::HasCaretSizeChanged() { if ( ( (0 != vs.caretWidth) && (sysCaretWidth != vs.caretWidth) ) - || (0 != vs.lineHeight) && (sysCaretHeight != vs.lineHeight) + || ( (0 != vs.lineHeight) && (sysCaretHeight != vs.lineHeight) ) ) { return true; } diff -urN pywin32-220-orig/Pythonwin/Scintilla/win32/scintilla_mingw.mak pywin32-220/Pythonwin/Scintilla/win32/scintilla_mingw.mak --- pywin32-220-orig/Pythonwin/Scintilla/win32/scintilla_mingw.mak 1970-01-01 08:00:00 +0800 +++ pywin32-220/Pythonwin/Scintilla/win32/scintilla_mingw.mak 2017-05-10 16:12:45 +0800 @@ -0,0 +1,226 @@ +# Make file for Scintilla on Windows +# Copyright 1998-2010 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# This makefile assumes the MinGW32 version of GCC 4.x is used and changes will +# be needed to use other compilers. + +.SUFFIXES: .cxx + +RANLIB ?= ranlib +WINDRES ?= windres +CXX = g++ + +DIR_O=$(SUB_DIR_O) +DIR_BIN=$(SUB_DIR_BIN) + +COMPONENT = $(DIR_BIN)/scintilla.dll +LEXCOMPONENT = $(DIR_BIN)/scilexer.dll +LEXLIB = Lexers.a + +vpath %.h ../src ../include +vpath %.cxx ../src + +LDFLAGS=-shared -static-libstdc++ -static-libgcc -s +LIBS=-luser32 -lgdi32 -limm32 -lole32 -luuid +INCLUDEDIRS=-I../include -I../src + +CXXBASEFLAGS=-std=c++11 -Wall -fpermissive -fno-strict-aliasing + +ifeq ($(QUIET), 1) +CXXBASEFLAGS=$(CXXBASEFLAGS) -w +endif + +ifeq ($(DEBUG), 1) +CXXFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(INCLUDEDIRS) +else +CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(INCLUDEDIRS) +endif + + +.PHONY: all clean silent + +all: $(COMPONENT) | silent + +clean: + rm -f $(DIR_O)/*.o $(DIR_O)/*.pdb $(COMPONENT) $(LEXCOMPONENT) \ + $(DIR_O)/*.res $(DIR_BIN)/*.map $(DIR_BIN)/*.exp $(DIR_BIN)/*.pdb $(DIR_BIN)/*.a + +silent: + @: + +SOBJS = \ + $(DIR_O)/AutoComplete.o \ + $(DIR_O)/CallTip.o \ + $(DIR_O)/CellBuffer.o \ + $(DIR_O)/CharClassify.o \ + $(DIR_O)/ContractionState.o \ + $(DIR_O)/Decoration.o \ + $(DIR_O)/Document.o \ + $(DIR_O)/Editor.o \ + $(DIR_O)/Indicator.o \ + $(DIR_O)/KeyMap.o \ + $(DIR_O)/LineMarker.o \ + $(DIR_O)/PlatWin.o \ + $(DIR_O)/PositionCache.o \ + $(DIR_O)/PropSet.o \ + $(DIR_O)/RESearch.o \ + $(DIR_O)/RunStyles.o \ + $(DIR_O)/ScintillaBase.o \ + $(DIR_O)/ScintillaWin.o \ + $(DIR_O)/Style.o \ + $(DIR_O)/UniConversion.o \ + $(DIR_O)/ViewStyle.o \ + $(DIR_O)/XPM.o + +LEXOBJS=\ + $(DIR_O)/LexAbaqus.o \ + $(DIR_O)/LexAda.o \ + $(DIR_O)/LexAPDL.o \ + $(DIR_O)/LexAsm.o \ + $(DIR_O)/LexAsn1.o \ + $(DIR_O)/LexASY.o \ + $(DIR_O)/LexAU3.o \ + $(DIR_O)/LexAVE.o \ + $(DIR_O)/LexBaan.o \ + $(DIR_O)/LexBash.o \ + $(DIR_O)/LexBasic.o \ + $(DIR_O)/LexBullant.o \ + $(DIR_O)/LexCaml.o \ + $(DIR_O)/LexCLW.o \ + $(DIR_O)/LexCmake.o \ + $(DIR_O)/LexConf.o \ + $(DIR_O)/LexCPP.o \ + $(DIR_O)/LexCrontab.o \ + $(DIR_O)/LexCsound.o \ + $(DIR_O)/LexCSS.o \ + $(DIR_O)/LexD.o \ + $(DIR_O)/LexEiffel.o \ + $(DIR_O)/LexErlang.o \ + $(DIR_O)/LexEScript.o \ + $(DIR_O)/LexFlagship.o \ + $(DIR_O)/LexForth.o \ + $(DIR_O)/LexFortran.o \ + $(DIR_O)/LexGAP.o \ + $(DIR_O)/LexGui4Cli.o \ + $(DIR_O)/LexHaskell.o \ + $(DIR_O)/LexHTML.o \ + $(DIR_O)/LexInno.o \ + $(DIR_O)/LexKix.o \ + $(DIR_O)/LexLisp.o \ + $(DIR_O)/LexLout.o \ + $(DIR_O)/LexLua.o \ + $(DIR_O)/LexMagik.o \ + $(DIR_O)/LexMatlab.o \ + $(DIR_O)/LexMetapost.o \ + $(DIR_O)/LexMMIXAL.o \ + $(DIR_O)/LexMPT.o \ + $(DIR_O)/LexMSSQL.o \ + $(DIR_O)/LexMySQL.o \ + $(DIR_O)/LexNsis.o \ + $(DIR_O)/LexOpal.o \ + $(DIR_O)/LexOthers.o \ + $(DIR_O)/LexPascal.o \ + $(DIR_O)/LexPB.o \ + $(DIR_O)/LexPerl.o \ + $(DIR_O)/LexPLM.o \ + $(DIR_O)/LexPOV.o \ + $(DIR_O)/LexPowerShell.o \ + $(DIR_O)/LexProgress.o \ + $(DIR_O)/LexPS.o \ + $(DIR_O)/LexPython.o \ + $(DIR_O)/LexR.o \ + $(DIR_O)/LexRebol.o \ + $(DIR_O)/LexRuby.o \ + $(DIR_O)/LexScriptol.o \ + $(DIR_O)/LexSmalltalk.o \ + $(DIR_O)/LexSpecman.o \ + $(DIR_O)/LexSpice.o \ + $(DIR_O)/LexSQL.o \ + $(DIR_O)/LexTADS3.o \ + $(DIR_O)/LexTCL.o \ + $(DIR_O)/LexTeX.o \ + $(DIR_O)/LexVB.o \ + $(DIR_O)/LexVerilog.o \ + $(DIR_O)/LexVHDL.o \ + $(DIR_O)/LexYAML.o + +LOBJS=\ + $(DIR_O)/AutoComplete.o \ + $(DIR_O)/CallTip.o \ + $(DIR_O)/CellBuffer.o \ + $(DIR_O)/CharClassify.o \ + $(DIR_O)/ContractionState.o \ + $(DIR_O)/Decoration.o \ + $(DIR_O)/Document.o \ + $(DIR_O)/DocumentAccessor.o \ + $(DIR_O)/Editor.o \ + $(DIR_O)/ExternalLexer.o \ + $(DIR_O)/Indicator.o \ + $(DIR_O)/KeyMap.o \ + $(DIR_O)/KeyWords.o \ + $(DIR_O)/LineMarker.o \ + $(DIR_O)/PlatWin.o \ + $(DIR_O)/PositionCache.o \ + $(DIR_O)/PropSet.o \ + $(DIR_O)/RESearch.o \ + $(DIR_O)/RunStyles.o \ + $(DIR_O)/Style.o \ + $(DIR_O)/StyleContext.o \ + $(DIR_O)/UniConversion.o \ + $(DIR_O)/ViewStyle.o \ + $(DIR_O)/XPM.o \ + $(LEXOBJS) + +$(DIR_O)/ScintRes.rc.o: ScintRes.rc + $(WINDRES) ScintRes.rc $@ + +$(COMPONENT): $(SOBJS) $(DIR_O)/ScintRes.rc.o + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(DIR_O)/ScintRes.rc.o $(LIBS) + +$(LEXCOMPONENT): $(LOBJS) $(DIR_O)/ScintRes.rc.o + $(CXX) $(LDFLAGS) -o $@ $(LOBJS) $(DIR_O)/ScintRes.rc.o $(LIBS) + +$(LEXLIB): $(LOBJS) + $(AR) rc $@ $^ + $(RANLIB) $@ + +# Define how to build all the objects and what they depend on + +$(DIR_O)/%.o: %.cxx + $(CXX) $(CXXFLAGS) -c $< -o $@ + +# Some source files are compiled into more than one object because of different conditional compilation +$(DIR_O)/ScintillaBaseL.o: ../src/ScintillaBase.cxx + $(CXX) $(CXXFLAGS) -DSCI_LEXER -c ../src/ScintillaBase.cxx -o $@ + +$(DIR_O)/ScintillaWinL.o: ScintillaWin.cxx + $(CXX) $(CXXFLAGS) -DSCI_LEXER -c ScintillaWin.cxx -o $@ + +$(DIR_O)/ScintillaWinS.o: ScintillaWin.cxx + $(CXX) $(CXXFLAGS) -DSTATIC_BUILD -c ScintillaWin.cxx -o $@ + + +$(DIR_O)/ScintillaBaseL.o: ../src/ScintillaBase.cxx ../include/Platform.h \ + ../include/Scintilla.h ../include/PropSet.h ../include/SString.h \ + ../src/ContractionState.h ../src/SVector.h ../src/SplitVector.h \ + ../src/Partitioning.h ../src/RunStyles.h ../src/CellBuffer.h \ + ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ + ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ + ../src/AutoComplete.h ../src/CharClassify.h ../src/Decoration.h \ + ../src/Document.h ../src/Editor.h ../src/ScintillaBase.h +$(DIR_O)/ScintillaWinL.o: ScintillaWin.cxx ../include/Platform.h \ + ../include/Scintilla.h ../include/SString.h ../src/ContractionState.h \ + ../src/SVector.h ../src/SplitVector.h ../src/Partitioning.h \ + ../src/RunStyles.h ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h \ + ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h ../src/Style.h \ + ../src/AutoComplete.h ../src/ViewStyle.h ../src/CharClassify.h \ + ../src/Decoration.h ../src/Document.h ../src/Editor.h \ + ../src/ScintillaBase.h ../src/UniConversion.h +$(DIR_O)/ScintillaWinS.o: ScintillaWin.cxx ../include/Platform.h \ + ../include/Scintilla.h ../include/SString.h ../src/ContractionState.h \ + ../src/SVector.h ../src/SplitVector.h ../src/Partitioning.h \ + ../src/RunStyles.h ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h \ + ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h ../src/Style.h \ + ../src/AutoComplete.h ../src/ViewStyle.h ../src/CharClassify.h \ + ../src/Decoration.h ../src/Document.h ../src/Editor.h \ + ../src/ScintillaBase.h ../src/UniConversion.h diff -urN pywin32-220-orig/Pythonwin/Win32uiHostGlue.h pywin32-220/Pythonwin/Win32uiHostGlue.h --- pywin32-220-orig/Pythonwin/Win32uiHostGlue.h 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/Win32uiHostGlue.h 2017-05-10 03:32:49 +0800 @@ -130,13 +130,17 @@ TCHAR fname[MAX_PATH*2]; + TCHAR pywin_dir[40]; + wsprintf(pywin_dir, _T("lib\\python%d.%d\\site-packages\\pythonwin"), PY_MAJOR_VERSION, PY_MINOR_VERSION); + HMODULE hModCore = NULL; // There are 2 cases we care about: // * pythonwin.exe next to win32ui, in lib\site-packages\pythonwin // * pythonwin.exe next to python.exe, in sys.home - this is for // older style installs and for custom layouts. // * a kind-of sub-case - handle the PCBuild directory - TCHAR *py_dll_candidates[] = { + const TCHAR *py_dll_candidates[] = { +#ifdef _MSC_VER _T("..\\..\\.."), // lib\site-packages\pythonwin #ifdef _M_X64 _T("..\\..\\..\\PCBuild\\amd64"), @@ -150,20 +154,38 @@ #else _T("PCBuild"), #endif +#else + _T(""), + _T("bin"), + _T("..\\..\\..\\..") + _T("..\\..\\..\\..\\bin"), // lib/pythonX.Y/site-packages/pythonwin +#endif }; TCHAR py_dll[20]; +#ifdef _MSC_VER #ifdef _DEBUG wsprintf(py_dll, _T("Python%d%d_d.dll"), PY_MAJOR_VERSION, PY_MINOR_VERSION); #else wsprintf(py_dll, _T("Python%d%d.dll"), PY_MAJOR_VERSION, PY_MINOR_VERSION); #endif +#else +#ifdef _DEBUG + wsprintf(py_dll, _T("libpython%d.%d_d.dll"), PY_MAJOR_VERSION, PY_MINOR_VERSION); +#else + wsprintf(py_dll, _T("libython%d.%d.dll"), PY_MAJOR_VERSION, PY_MINOR_VERSION); +#endif +#endif // try it simple - if we can load the module we are done. HMODULE hModWin32ui = LoadLibrary(szWinui_Name); if (hModWin32ui==NULL) { // try an installed version (old versions installed pythonwin.exe next // to python.exe - but we shouldn't get here if pythonwin.exe is next // to win32ui) +#ifdef _MSC_VER wsprintf(fname, _T("%s\\%s\\%s"), app_dir, _T("lib\\site-packages\\pythonwin"), szWinui_Name); +#else + wsprintf(fname, _T("%s\\%s\\%s"), app_dir, pywin_dir, szWinui_Name); +#endif hModWin32ui = LoadLibrary(fname); } if (hModWin32ui==NULL) { @@ -199,9 +221,10 @@ int (__cdecl *pfnIsInit)(void); pfnIsInit = (int (__cdecl *)(void))GetProcAddress(hModCore, "Py_IsInitialized"); BOOL bShouldInitPython; - if (pfnIsInit) - bShouldFinalizePython = bShouldInitPython = !(*pfnIsInit)(); - else { + if (pfnIsInit) { + bShouldFinalizePython = !(*pfnIsInit)(); + bShouldInitPython = !(*pfnIsInit)(); + } else { bShouldFinalizePython = FALSE; // Dont cleanup if we cant tell (this wont happen - Im paranoid :-) bShouldInitPython = TRUE; } diff -urN pywin32-220-orig/Pythonwin/ddemodule.h pywin32-220/Pythonwin/ddemodule.h --- pywin32-220-orig/Pythonwin/ddemodule.h 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/ddemodule.h 2017-03-15 01:29:13 +0800 @@ -88,7 +88,7 @@ class PythonDDEStringItem : public CDDEStringItem { public: - PythonDDEStringItem::~PythonDDEStringItem() {Python_delete_assoc(this);} + ~PythonDDEStringItem() {Python_delete_assoc(this);} }; class PyDDEStringItem : public ui_assoc_CObject @@ -103,7 +103,7 @@ { public: PythonDDEConv(CDDEServer* pServer) : CDDEConv(pServer) {;} - PythonDDEConv::~PythonDDEConv() {Python_delete_assoc(this);} + ~PythonDDEConv() {Python_delete_assoc(this);} }; class PyDDEConv : public ui_assoc_CObject diff -urN pywin32-220-orig/Pythonwin/ddeserver.cpp pywin32-220/Pythonwin/ddeserver.cpp --- pywin32-220-orig/Pythonwin/ddeserver.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/ddeserver.cpp 2016-09-12 00:14:59 +0800 @@ -30,7 +30,7 @@ CEnterLeavePython _celp; Py_XDECREF(m_obSystemTopic); CDDEServerSystemTopic *pT; - if (pT=PyDDEServerSystemTopic::GetTopic(ob)) { + if (pT==PyDDEServerSystemTopic::GetTopic(ob)) { m_obSystemTopic = ob; Py_INCREF(m_obSystemTopic); return pT; diff -urN pywin32-220-orig/Pythonwin/dllmain.cpp pywin32-220/Pythonwin/dllmain.cpp --- pywin32-220-orig/Pythonwin/dllmain.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/dllmain.cpp 2017-03-28 09:11:10 +0800 @@ -126,7 +126,7 @@ // Do the WinMain thang... // AFX internal initialization - if (!AfxWinInit(hWin32uiDll, NULL, _T(""), SW_NORMAL)) + if (!AfxWinInit(hWin32uiDll, NULL, (LPTSTR)_T(""), SW_NORMAL)) return 0; // App global initializations (rare) diff -urN pywin32-220-orig/Pythonwin/pythonpsheet.cpp pywin32-220/Pythonwin/pythonpsheet.cpp --- pywin32-220-orig/Pythonwin/pythonpsheet.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/pythonpsheet.cpp 2017-05-01 22:22:25 +0800 @@ -192,7 +192,7 @@ return CPropertySheet::WindowProc(message, wParam, lParam); return res; } -#endif PYWIN_WITH_WINDOWPROC +#endif // PYWIN_WITH_WINDOWPROC extern BOOL bInFatalShutdown; diff -urN pywin32-220-orig/Pythonwin/pythonwin.h pywin32-220/Pythonwin/pythonwin.h --- pywin32-220-orig/Pythonwin/pythonwin.h 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/pythonwin.h 2016-09-20 16:11:30 +0800 @@ -24,7 +24,7 @@ private: // Overrides - virtual CDocument *CPythonWinApp::OpenDocumentFile(LPCTSTR lpszFileName); + virtual CDocument *OpenDocumentFile(LPCTSTR lpszFileName); virtual BOOL PreTranslateMessage(MSG *pMsg); virtual BOOL InitInstance(); virtual BOOL InitApplication(); diff -urN pywin32-220-orig/Pythonwin/stdafx.h pywin32-220/Pythonwin/stdafx.h --- pywin32-220-orig/Pythonwin/stdafx.h 2016-01-09 17:49:18 +0800 +++ pywin32-220/Pythonwin/stdafx.h 2017-05-16 20:44:30 +0800 @@ -5,6 +5,11 @@ #define WIN32_LEAN_AND_MEAN +#ifndef _MSC_VER +#define _WIN32_WINNT 0x0601 +#define _WIN32_IE 0x0601 +#endif + #ifndef WINVER // we don't need this, but vs2009 makes noise without it set to something - // and this is what we currently use... diff -urN pywin32-220-orig/Pythonwin/stddde.cpp pywin32-220/Pythonwin/stddde.cpp --- pywin32-220-orig/Pythonwin/stddde.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/stddde.cpp 2017-03-28 09:11:10 +0800 @@ -28,7 +28,7 @@ typedef struct _CFTAGNAME { WORD wFmt; - char* pszName; + const char* pszName; } CFTAGNAME, FAR *PCFTAGNAME; // @@ -1059,7 +1059,7 @@ CBTEMPLATE* thisDynamicCallback = (CBTEMPLATE*)&this->DynamicCallback ; if (!(make_template(thisDynamicCallback, (DWORD)this, DynDDECallback) )) return false ; -#endif _CALLHACK_ +#endif // _CALLHACK_ //CT END // // Make sure the application hasn't requested any filter options diff -urN pywin32-220-orig/Pythonwin/win32ImageList.cpp pywin32-220/Pythonwin/win32ImageList.cpp --- pywin32-220-orig/Pythonwin/win32ImageList.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/win32ImageList.cpp 2017-04-30 11:20:08 +0800 @@ -79,7 +79,7 @@ &crMask) // @pyparmalt1 int|crMask||Color used to generate a mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to one. &&PyWinObject_AsResourceId(obID, &bitmapID, FALSE)){ if (IS_INTRESOURCE(bitmapID)) - bRet = pList->Create(MAKEINTRESOURCE(bitmapID),cx,nGrow,crMask); + bRet = pList->Create(MAKEINTRESOURCE((ULONG_PTR)bitmapID),cx,nGrow,crMask); else bRet = pList->Create(bitmapID,cx,nGrow,crMask); PyWinObject_FreeResourceId(bitmapID); diff -urN pywin32-220-orig/Pythonwin/win32app.cpp pywin32-220/Pythonwin/win32app.cpp --- pywin32-220-orig/Pythonwin/win32app.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/win32app.cpp 2017-05-06 02:02:31 +0800 @@ -21,7 +21,7 @@ extern CWnd *GetWndPtr(PyObject *self); PyObject *PyCWinApp::pExistingAppObject = NULL; -char *errmsgAlreadyInit = "The application has already been initialised"; +const char *errmsgAlreadyInit = "The application has already been initialised"; ///////////////////////////////////////////////////////////////////// // @@ -284,7 +284,7 @@ if (!PyWinObject_AsResourceId(obid, &csid, TRUE)) return NULL; if (IS_INTRESOURCE(csid)) - hc = GetApp()->LoadCursor((UINT)csid); + hc = GetApp()->LoadCursor((UINT_PTR)csid); else hc = GetApp()->LoadCursor(csid); PyWinObject_FreeResourceId(csid); diff -urN pywin32-220-orig/Pythonwin/win32cmdui.cpp pywin32-220/Pythonwin/win32cmdui.cpp --- pywin32-220-orig/Pythonwin/win32cmdui.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/win32cmdui.cpp 2017-05-08 17:21:01 +0800 @@ -29,7 +29,7 @@ hMod = GetModuleHandle(buf); } if (hMod) { - void *rc = GetProcAddress(hMod, procName); + void *rc = (void*)GetProcAddress(hMod, procName); if (rc==NULL) RETURN_ERR("The Python COM extensions do not export the required functions"); return rc; @@ -47,12 +47,12 @@ void* pExtra, AFX_CMDHANDLERINFO*pHandlerInfo) { // Let MFC deal with the file menu. - if (nCode==CN_UPDATE_COMMAND_UI && nID==ID_FILE_MRU_FILE1) + if (nCode==(int)CN_UPDATE_COMMAND_UI && nID==(UINT)ID_FILE_MRU_FILE1) return FALSE; #ifndef _AFX_NO_OCC_SUPPORT // OLE control events are a special case - if (nCode == CN_EVENT) + if (nCode == (int)CN_EVENT) { AFX_EVENT *pEvent = (AFX_EVENT*)pExtra; PyObject *method; @@ -102,7 +102,7 @@ if (pObj != NULL && pObj->is_uiobject (&PyCCmdTarget::type)) { - if (nCode == CN_UPDATE_COMMAND_UI) { + if (nCode == (int)CN_UPDATE_COMMAND_UI) { CCmdUI *pUI = (CCmdUI *)pExtra; PyObject *method; if (pObj->pCommandUpdateHookList && diff -urN pywin32-220-orig/Pythonwin/win32dlg.cpp pywin32-220/Pythonwin/win32dlg.cpp --- pywin32-220-orig/Pythonwin/win32dlg.cpp 2011-03-19 10:51:18 +0800 +++ pywin32-220/Pythonwin/win32dlg.cpp 2017-05-16 19:46:47 +0800 @@ -421,7 +421,7 @@ int id; PyObject *obAttr; PyObject *o1 = NULL, *o2 = NULL; - char *szType = "s"; + char *szType = (char*)"s"; if (!PyArg_ParseTuple(ob, "iO|sOO", &id, &obAttr, &szType, &o1, &o2 )) { set_exchange_error( "must be tuple of control_id, key ...", i); break; diff -urN pywin32-220-orig/Pythonwin/win32dlg.h pywin32-220/Pythonwin/win32dlg.h --- pywin32-220-orig/Pythonwin/win32dlg.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32dlg.h 2016-09-01 05:26:29 +0800 @@ -9,8 +9,8 @@ class PYW_EXPORT PyCDialog : public PyCWnd { public: MAKE_PY_CTOR(PyCDialog) - static PyObject *PyCDialog::create( PyObject *self, PyObject *args ); - static PyObject *PyCDialog::createIndirect( PyObject *self, PyObject *args ); + static PyObject *create( PyObject *self, PyObject *args ); + static PyObject *createIndirect( PyObject *self, PyObject *args ); PyObject *ddlist; PyObject *dddict; HGLOBAL hTemplate; diff -urN pywin32-220-orig/Pythonwin/win32dlgbar.cpp pywin32-220/Pythonwin/win32dlgbar.cpp --- pywin32-220-orig/Pythonwin/win32dlgbar.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32dlgbar.cpp 2017-04-30 11:19:39 +0800 @@ -63,7 +63,7 @@ BOOL rc; GUI_BGN_SAVE; if (IS_INTRESOURCE(szTemplate)) - rc=pDialog->Create(pParent, MAKEINTRESOURCE(szTemplate), style, id); + rc=pDialog->Create(pParent, MAKEINTRESOURCE((ULONG_PTR)szTemplate), style, id); else rc=pDialog->Create(pParent, szTemplate, style, id); GUI_END_SAVE; diff -urN pywin32-220-orig/Pythonwin/win32dll.cpp pywin32-220/Pythonwin/win32dll.cpp --- pywin32-220-orig/Pythonwin/win32dll.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32dll.cpp 2017-05-01 22:21:05 +0800 @@ -21,7 +21,7 @@ } dll_object::~dll_object() { - if (bDidLoadLibrary = TRUE) { + if (bDidLoadLibrary == TRUE) { ::FreeLibrary (GetDll()); TRACE("Python object freeing DLL reference\n"); } diff -urN pywin32-220-orig/Pythonwin/win32gdi.h pywin32-220/Pythonwin/win32gdi.h --- pywin32-220-orig/Pythonwin/win32gdi.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32gdi.h 2017-03-08 01:44:03 +0800 @@ -2,7 +2,7 @@ #pragma once class PyCGdiObject : public ui_assoc_CObject { -friend static PyObject *ui_dc_select_object (PyObject *self, PyObject *args); +static PyObject *ui_dc_select_object (PyObject *self, PyObject *args); public: static ui_type_CObject type; static CGdiObject *GetGdiObject( PyObject *self, DWORD type=0 ); diff -urN pywin32-220-orig/Pythonwin/win32menu.h pywin32-220/Pythonwin/win32menu.h --- pywin32-220-orig/Pythonwin/win32menu.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32menu.h 2016-09-06 03:36:23 +0800 @@ -1,7 +1,7 @@ // menu class class PyCMenu : public ui_assoc_object { protected: - PyCMenu::PyCMenu() {return;} + PyCMenu() {return;} virtual void SetAssocInvalid(); virtual bool CheckCppObject(ui_type *ui_type_check) const; public: diff -urN pywin32-220-orig/Pythonwin/win32notify.cpp pywin32-220/Pythonwin/win32notify.cpp --- pywin32-220-orig/Pythonwin/win32notify.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32notify.cpp 2017-05-16 19:08:06 +0800 @@ -265,7 +265,7 @@ gui_print_error(); return FALSE; } - char *fmt; + const char *fmt; /* NMTOOLBAR format needs to be adjusted for 64-bit, and already doesn't work for 32-bit since PyNotifyMakeExtraTuple doesn't have a case for 'b' @@ -346,7 +346,7 @@ if (fmt==NULL) ob2 = PyWinLong_FromVoidPtr(pHdr + 1); else - ob2 = PyNotifyMakeExtraTuple(pHdr, fmt); + ob2 = PyNotifyMakeExtraTuple(pHdr, (char*)fmt); } if (ob2==NULL){ gui_print_error(); @@ -372,7 +372,7 @@ // Result should be a tuple of the LRESULT and a tuple to fill the appropriate // struct for this particular message if (PyArg_ParseTuple(result, "O&O", PyWinLong_AsVoidPtr, &rc, &obOther)) - PyNotifyParseExtraTuple( pHdr, obOther, fmt); + PyNotifyParseExtraTuple( pHdr, obOther, (char*)fmt); if (PyErr_Occurred()){ gui_print_error(); PyErr_Format(ui_module_error, "Error parsing OnNotify() extra return info for code %d, fmt='%s'", code, fmt); diff -urN pywin32-220-orig/Pythonwin/win32oleDlgInsert.cpp pywin32-220/Pythonwin/win32oleDlgInsert.cpp --- pywin32-220-orig/Pythonwin/win32oleDlgInsert.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32oleDlgInsert.cpp 2017-05-16 18:57:17 +0800 @@ -109,7 +109,7 @@ if (!PyWinObject_AsTCHAR(ob, &szTemp, FALSE)) return FALSE; _tcsncpy(fileNameBuf, szTemp, sizeof(fileNameBuf)/sizeof(fileNameBuf[0])); - fileNameBuf[sizeof(fileNameBuf)-1]='\0'; + fileNameBuf[(sizeof(fileNameBuf)-1)/sizeof(fileNameBuf[0])]='\0'; PyWinObject_FreeTCHAR(szTemp); } else @@ -127,7 +127,7 @@ ob = PyObject_GetAttrString(obDict, "oleRender"); if (ob){ pConv->oleRender = PyInt_AsLong(ob); - if (pConv->oleRender == -1 && PyErr_Occurred()) + if ((int)pConv->oleRender == -1 && PyErr_Occurred()) return FALSE; } else diff -urN pywin32-220-orig/Pythonwin/win32prop.cpp pywin32-220/Pythonwin/win32prop.cpp --- pywin32-220-orig/Pythonwin/win32prop.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32prop.cpp 2017-03-28 09:11:10 +0800 @@ -129,7 +129,7 @@ if (IS_INTRESOURCE(Caption)){ GUI_BGN_SAVE; - pPS = new CPythonPropertySheet(MAKEINTRESOURCE(Caption), pParent, iSelect); + pPS = new CPythonPropertySheet(MAKEINTRESOURCE((ULONG_PTR)Caption), pParent, iSelect); GUI_END_SAVE; } else{ @@ -367,7 +367,7 @@ // @pymethod |PyCPropertySheet|EndDialog|Closes the dialog, with the specified result. PyObject *ui_propsheet_end_dialog( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; int result; // @pyparm int|result||The result to be returned by DoModal. @@ -429,7 +429,7 @@ // @pymethod |PyCPropertySheet|PressButton|Simulates the choice of the specified button in a property sheet. PyObject *ui_propsheet_press_button( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; int button; // @pyparm int|button||The button to press @@ -451,7 +451,7 @@ // @pymethod |PyCPropertySheet|SetWizardButtons|Enables the wizard buttons PyObject *ui_propsheet_set_wizard_buttons( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; int flags; // @pyparm int|flags||The wizard flags @@ -466,7 +466,7 @@ // @pymethod |PyCPropertySheet|SetWizardMode|Enables the wizard mode PyObject *ui_propsheet_set_wizard_mode( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; CHECK_NO_ARGS2(args,SetWizardMode); GUI_BGN_SAVE; @@ -478,7 +478,7 @@ // @pymethod |PyCPropertySheet|SetFinishText|Sets the text for the Finish button PyObject *ui_propsheet_set_finish_text( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; TCHAR *text; PyObject *obtext; @@ -497,10 +497,10 @@ // @pymethod |PyCPropertySheet|SetPSHBit|Sets or clears a bit in m_psh.dwFlags PyObject *ui_propsheet_set_pshbit( PyObject *self, PyObject *args ) { - CPropertySheet *pPS = pPS=GetPropSheet(self); + CPropertySheet *pPS = GetPropSheet(self); if (!pPS) return NULL; DWORD bitMask = 0; - BOOL bitValue = 0; + BOOL bitValue = 0; if (!PyArg_ParseTuple( args, "ii", &bitMask, // @pyparm int|bitMask||The PSH_* bit mask constant @@ -600,10 +600,10 @@ return NULL; if (IS_INTRESOURCE(Template)){ - if (!PropSheetCheckForPageCreate((UINT)Template)) + if (!PropSheetCheckForPageCreate((UINT_PTR)Template)) return NULL; GUI_BGN_SAVE; - pPP = new CPythonPropertyPage((UINT)Template, idCaption); + pPP = new CPythonPropertyPage((UINT_PTR)Template, idCaption); GUI_END_SAVE; } else{ diff -urN pywin32-220-orig/Pythonwin/win32splitter.h pywin32-220/Pythonwin/win32splitter.h --- pywin32-220-orig/Pythonwin/win32splitter.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32splitter.h 2017-04-09 23:33:16 +0800 @@ -9,7 +9,7 @@ DECLARE_DYNAMIC( CPythonSplitter ); public: CPythonSplitter(); - virtual BOOL CPythonSplitter::CreateView(int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext); + virtual BOOL CreateView(int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext); protected: BOOL bHaveAllChildren; virtual void PostNcDestroy(); diff -urN pywin32-220-orig/Pythonwin/win32toolbar.cpp pywin32-220/Pythonwin/win32toolbar.cpp --- pywin32-220-orig/Pythonwin/win32toolbar.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32toolbar.cpp 2017-03-28 09:11:10 +0800 @@ -31,13 +31,13 @@ class PyCDockContext : public ui_assoc_object{ public: static ui_type type; - PyCDockContext() {;} + PyCDockContext() {} static CDockContext *GetDockContext(PyObject *); MAKE_PY_CTOR(PyCDockContext); virtual PyObject *getattro(PyObject *obname); virtual int setattro(PyObject *obname, PyObject *v); protected: - virtual ~PyCDockContext() {;} + virtual ~PyCDockContext() {} }; enum MyTypes { @@ -468,13 +468,13 @@ return -1; if (strcmp(name, "dwStyle")==0) { pCtlBar->m_dwStyle = PyInt_AsLong(v); - if (pCtlBar->m_dwStyle == -1 && PyErr_Occurred()) + if ((int)pCtlBar->m_dwStyle == -1 && PyErr_Occurred()) return -1; return 0; } if (strcmp(name, "dwDockStyle")==0) { pCtlBar->m_dwDockStyle = PyInt_AsLong(v); - if (pCtlBar->m_dwDockStyle == -1 && PyErr_Occurred()) + if ((int)pCtlBar->m_dwDockStyle == -1 && PyErr_Occurred()) return -1; return 0; } @@ -693,7 +693,7 @@ return NULL; if (IS_INTRESOURCE(szId)) - rc = pToolBar->LoadBitmap(MAKEINTRESOURCE(szId)); + rc = pToolBar->LoadBitmap(MAKEINTRESOURCE((ULONG_PTR)szId)); else rc = pToolBar->LoadBitmap(szId); PyWinObject_FreeResourceId(szId); @@ -723,7 +723,7 @@ return NULL; if (IS_INTRESOURCE(szId)) - rc = pToolBar->LoadToolBar(MAKEINTRESOURCE(szId)); + rc = pToolBar->LoadToolBar(MAKEINTRESOURCE((ULONG_PTR)szId)); else rc = pToolBar->LoadToolBar(szId); PyWinObject_FreeResourceId(szId); diff -urN pywin32-220-orig/Pythonwin/win32ui.h pywin32-220/Pythonwin/win32ui.h --- pywin32-220-orig/Pythonwin/win32ui.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32ui.h 2017-03-28 09:11:10 +0800 @@ -175,7 +175,7 @@ #if defined(_DEBUG) && defined(TRACK_PYTHON_OBJECTS) #define MAKE_PY_CTOR(classname) static ui_base_class * classname::PyObConstruct(void) {return new classname;} #else -#define MAKE_PY_CTOR(classname) static ui_base_class * classname::PyObConstruct(void) { \ +#define MAKE_PY_CTOR(classname) static ui_base_class * PyObConstruct(void) { \ BOOL bOld = AfxEnableMemoryTracking(FALSE); \ ui_base_class * ret = new classname; \ AfxEnableMemoryTracking(bOld); \ @@ -385,7 +385,7 @@ PYW_EXPORT void Python_addpath( const TCHAR *paths ); -BOOL AFXAPI PyAfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2); +static BOOL AFXAPI PyAfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2); extern BOOL PASCAL AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn); #endif // __filename_h__ diff -urN pywin32-220-orig/Pythonwin/win32ui.rc pywin32-220/Pythonwin/win32ui.rc --- pywin32-220-orig/Pythonwin/win32ui.rc 2016-09-12 01:11:22 +0800 +++ pywin32-220/Pythonwin/win32ui.rc 2017-03-03 23:55:03 +0800 @@ -1066,6 +1066,7 @@ // Dialog Info // +#ifdef _MSC_VER IDD_PP_EDITOR DLGINIT BEGIN IDC_COMBO1, 0x403, 8, 0 @@ -1107,6 +1108,7 @@ 0x6520, 0x6378, 0x7065, 0x6974, 0x6e6f, "\000" 0 END +#endif ///////////////////////////////////////////////////////////////////////////// diff -urN pywin32-220-orig/Pythonwin/win32uiExt.h pywin32-220/Pythonwin/win32uiExt.h --- pywin32-220-orig/Pythonwin/win32uiExt.h 2013-06-13 17:40:32 +0800 +++ pywin32-220/Pythonwin/win32uiExt.h 2017-05-09 13:41:01 +0800 @@ -474,9 +474,9 @@ // @xref CVirtualHelper helper( "OnOK", this ); if (!helper.HaveHandler()) { - if (m_lpDialogTemplate == NULL && m_hDialogTemplate == NULL) + if (this->m_lpDialogTemplate == NULL && this->m_hDialogTemplate == NULL) // non modal dialog. - DestroyWindow(); + this->DestroyWindow(); else T::OnOK(); } else { @@ -501,8 +501,8 @@ } } void DoOnCancel() { - if (m_lpDialogTemplate == NULL && m_hDialogTemplate == NULL) - DestroyWindow(); + if (this->m_lpDialogTemplate == NULL && this->m_hDialogTemplate == NULL) + this->DestroyWindow(); else T::OnCancel(); } @@ -868,8 +868,8 @@ // End of ctor hacks!!!! afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM) { - PreInitDialog(); - LRESULT result = Default(); + this->PreInitDialog(); + LRESULT result = this->Default(); CVirtualHelper helper( "HandleInitDialog", this ); BOOL hresult; if (helper.HaveHandler()) { @@ -888,22 +888,22 @@ CString csText; - CWnd* ctl = GetDlgItem(IDC_PRINT_FROM); + CWnd* ctl = this->GetDlgItem(IDC_PRINT_FROM); ctl->GetWindowText(csText); - m_pd.nFromPage = _ttoi(csText); + this->m_pd.nFromPage = _ttoi(csText); - ctl = GetDlgItem(IDC_PRINT_TO); + ctl = this->GetDlgItem(IDC_PRINT_TO); ctl->GetWindowText(csText); - m_pd.nToPage = _ttoi(csText); + this->m_pd.nToPage = _ttoi(csText); - ctl = GetDlgItem(IDC_PRINT_COPIES); + ctl = this->GetDlgItem(IDC_PRINT_COPIES); ctl->GetWindowText( csText ); - if (m_pd.Flags&PD_USEDEVMODECOPIES) { - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock((HGLOBAL)m_pd.hDevMode); + if (this->m_pd.Flags&PD_USEDEVMODECOPIES) { + LPDEVMODE devMode = (LPDEVMODE)::GlobalLock((HGLOBAL)this->m_pd.hDevMode); devMode->dmCopies =_ttoi(csText); - ::GlobalUnlock((HGLOBAL)m_pd.hDevMode); + ::GlobalUnlock((HGLOBAL)this->m_pd.hDevMode); } - m_pd.nCopies = _ttoi(csText); + this->m_pd.nCopies = _ttoi(csText); CVirtualHelper helper( "OnOK", this ); if (helper.HaveHandler()) { @@ -925,46 +925,46 @@ } afx_msg void HandlePrintToFile() { - CWnd* ctl = GetDlgItem(IDC_PRINT_TO_FILE); + CWnd* ctl = this->GetDlgItem(IDC_PRINT_TO_FILE); int val = ((CButton*)ctl)->GetCheck(); if (val) { // was checked, now will not be... - m_pd.Flags |= PD_PRINTTOFILE; + this->m_pd.Flags |= PD_PRINTTOFILE; } else { // was not checked, now will be... - m_pd.Flags &= ~PD_PRINTTOFILE; + this->m_pd.Flags &= ~PD_PRINTTOFILE; } } afx_msg void HandleCollate() { - CWnd* ctl = GetDlgItem(IDC_PRINT_COLLATE); + CWnd* ctl = this->GetDlgItem(IDC_PRINT_COLLATE); int val = ((CButton*)ctl)->GetCheck(); - int useDevMode = (m_pd.Flags&PD_USEDEVMODECOPIES || - m_pd.Flags&PD_USEDEVMODECOPIESANDCOLLATE); + int useDevMode = (this->m_pd.Flags&PD_USEDEVMODECOPIES || + this->m_pd.Flags&PD_USEDEVMODECOPIESANDCOLLATE); LPDEVMODE devMode; if (useDevMode) { - devMode = (LPDEVMODE)::GlobalLock((HGLOBAL)m_pd.hDevMode); + devMode = (LPDEVMODE)::GlobalLock((HGLOBAL)this->m_pd.hDevMode); } if (val) { // was checked, now will not be... - m_pd.Flags |= PD_COLLATE; + this->m_pd.Flags |= PD_COLLATE; } else { // was not checked, now will be... - m_pd.Flags &= ~PD_COLLATE; + this->m_pd.Flags &= ~PD_COLLATE; } if (useDevMode) { devMode->dmCollate = DMCOLLATE_TRUE; - ::GlobalUnlock((HGLOBAL)m_pd.hDevMode); + ::GlobalUnlock((HGLOBAL)this->m_pd.hDevMode); } } afx_msg void HandlePrintRange(UINT nID) { - CheckRadioButton(IDC_PRINT_RANGE_ALL, + this->CheckRadioButton(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, nID); - m_pd.Flags &= ~(PD_ALLPAGES|PD_SELECTION|PD_PAGENUMS); + this->m_pd.Flags &= ~(PD_ALLPAGES|PD_SELECTION|PD_PAGENUMS); if (nID==IDC_PRINT_RANGE_ALL) { - m_pd.Flags |= PD_ALLPAGES; + this->m_pd.Flags |= PD_ALLPAGES; } else if (nID==IDC_PRINT_RANGE_SELECTION) { - m_pd.Flags |= PD_SELECTION; + this->m_pd.Flags |= PD_SELECTION; } else if (nID==IDC_PRINT_RANGE_PAGES) { - m_pd.Flags |= PD_PAGENUMS; + this->m_pd.Flags |= PD_PAGENUMS; } } diff -urN pywin32-220-orig/Pythonwin/win32uimodule.cpp pywin32-220/Pythonwin/win32uimodule.cpp --- pywin32-220-orig/Pythonwin/win32uimodule.cpp 2012-04-30 17:46:46 +0800 +++ pywin32-220/Pythonwin/win32uimodule.cpp 2017-03-28 09:11:10 +0800 @@ -454,7 +454,7 @@ posLast = posFirst; while (paths[posLast]!=0 && paths[posLast]!=';') posLast++; - int len = min(sizeof(workBuf)-1,posLast - posFirst); + int len = min((sizeof(workBuf)-1)/sizeof(workBuf[0]),posLast - posFirst); if (len>0) { _tcsncpy(workBuf, paths+posFirst, len ); workBuf[len]=0; @@ -680,7 +680,7 @@ PyErr_Restore(PyExc_RuntimeError, value, traceback); } else PyErr_Restore(type, value, traceback); - fprintf(stderr, "%s\n", context); + fprintf(stderr, "%S\n", context); // Now print it. PyErr_Print(); } diff -urN pywin32-220-orig/Pythonwin/win32util.cpp pywin32-220/Pythonwin/win32util.cpp --- pywin32-220-orig/Pythonwin/win32util.cpp 2012-01-02 12:24:30 +0800 +++ pywin32-220/Pythonwin/win32util.cpp 2017-05-16 19:55:04 +0800 @@ -240,20 +240,20 @@ // Font conversion utilities // // -static char *szFontHeight = "height"; -static char *szFontWidth = "width"; -static char *szFontEscapement = "escapement"; -static char *szFontOrientation = "orientation"; -static char *szFontWeight = "weight"; -static char *szFontItalic = "italic"; -static char *szFontUnderline = "underline"; -static char *szFontStrikeOut = "strike out"; -static char *szFontCharSet = "charset"; -static char *szFontOutPrecision = "out precision"; -static char *szFontClipPrecision = "clip precision"; -static char *szFontQuality = "quality"; -static char *szFontPitch = "pitch and family"; -static char *szFontName = "name"; +static char *szFontHeight = (char*)"height"; +static char *szFontWidth = (char*)"width"; +static char *szFontEscapement = (char*)"escapement"; +static char *szFontOrientation = (char*)"orientation"; +static char *szFontWeight = (char*)"weight"; +static char *szFontItalic = (char*)"italic"; +static char *szFontUnderline = (char*)"underline"; +static char *szFontStrikeOut = (char*)"strike out"; +static char *szFontCharSet = (char*)"charset"; +static char *szFontOutPrecision = (char*)"out precision"; +static char *szFontClipPrecision = (char*)"clip precision"; +static char *szFontQuality = (char*)"quality"; +static char *szFontPitch = (char*)"pitch and family"; +static char *szFontName = (char*)"name"; PyObject *LogFontToDict(const LOGFONT &lf) { @@ -419,10 +419,10 @@ return FALSE; } else { pItem->state = PyInt_AsLong(ob); - if (pItem->state == -1 && PyErr_Occurred()) + if ((int)pItem->state == -1 && PyErr_Occurred()) return FALSE; pItem->stateMask = PyInt_AsLong(ob2); - if (pItem->stateMask == -1 && PyErr_Occurred()) + if ((int)pItem->stateMask == -1 && PyErr_Occurred()) return FALSE; pItem->mask |= LVIF_STATE; } @@ -664,10 +664,10 @@ // @tupleitem 1|int|state|Item state. If specified, the stateMask must also be specified. // @tupleitem 2|int|stateMask|Item state mask pItem->state = PyInt_AsLong(ob); - if (pItem->state == -1 && PyErr_Occurred()) + if ((int)pItem->state == -1 && PyErr_Occurred()) return FALSE; pItem->stateMask = PyInt_AsLong(ob2); - if (pItem->stateMask == -1 && PyErr_Occurred()) + if ((int)pItem->stateMask == -1 && PyErr_Occurred()) return FALSE; pItem->mask |= TVIF_STATE; } diff -urN pywin32-220-orig/Pythonwin/win32view.cpp pywin32-220/Pythonwin/win32view.cpp --- pywin32-220-orig/Pythonwin/win32view.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32view.cpp 2017-05-01 22:22:11 +0800 @@ -1130,7 +1130,7 @@ GUI_BGN_SAVE; if (IS_INTRESOURCE(szTemplate)) - pView = new CPythonFormView(MAKEINTRESOURCE(szTemplate)); + pView = new CPythonFormView(MAKEINTRESOURCE((ULONG_PTR)szTemplate)); else pView = new CPythonFormView(szTemplate); ((CProtectedView *)pView)->SetDocument(pDoc); diff -urN pywin32-220-orig/Pythonwin/win32virt.cpp pywin32-220/Pythonwin/win32virt.cpp --- pywin32-220-orig/Pythonwin/win32virt.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/Pythonwin/win32virt.cpp 2017-05-06 02:17:25 +0800 @@ -90,7 +90,7 @@ gui_print_error(); // this will probably fail if we are already inside the exception handler PyObject *obRepr = PyObject_Repr(handler); - char *szRepr = ""; + const char *szRepr = ""; if (obRepr){ if (PyString_Check(obRepr)) szRepr = PyString_AS_STRING(obRepr); diff -urN pywin32-220-orig/Pythonwin/win32win.cpp pywin32-220/Pythonwin/win32win.cpp --- pywin32-220-orig/Pythonwin/win32win.cpp 2011-03-19 10:52:26 +0800 +++ pywin32-220/Pythonwin/win32win.cpp 2017-05-06 02:17:47 +0800 @@ -27,7 +27,7 @@ #include "reswin32ui.h" #include "AFXSTAT_.H" -static char *szErrMsgBadHandle = "The window handle does not specify a valid window"; +static const char *szErrMsgBadHandle = "The window handle does not specify a valid window"; #define CHECK_HWND_VALID(pWnd) if (!::IsWindow((pWnd)->m_hWnd)) RETURN_ERR(szErrMsgBadHandle); extern BOOL bInFatalShutdown; @@ -3332,7 +3332,7 @@ CString base_repr = PyCCmdTarget::repr(); UINT_PTR numMsg = pMessageHookList ? pMessageHookList->GetCount() : 0; UINT_PTR numKey = pKeyHookList ? pKeyHookList->GetCount() : 0; - TCHAR *hookStr = obKeyStrokeHandler ? _T(" (AllKeys Hook Active)") : _T(""); + const TCHAR *hookStr = obKeyStrokeHandler ? _T(" (AllKeys Hook Active)") : _T(""); csRet.Format(_T("%s, mh=%Iu, kh=%Iu%s"), (const TCHAR *)base_repr, numMsg, numKey, hookStr); return csRet; } @@ -3602,7 +3602,7 @@ CControlBar *pControlBar = PyCControlBar::GetControlBar(ob); if (pControlBar==NULL) return NULL; - CRect *pRect = (rect.left==rect.right==0) ? NULL : ▭ + CRect *pRect = (rect.left==0 && rect.right==0) ? NULL : ▭ PyObject *rc; GUI_BGN_SAVE; __try { diff -urN pywin32-220-orig/SWIG/swig_lib/python/pythoncom.i pywin32-220/SWIG/swig_lib/python/pythoncom.i --- pywin32-220-orig/SWIG/swig_lib/python/pythoncom.i 2011-03-19 10:51:20 +0800 +++ pywin32-220/SWIG/swig_lib/python/pythoncom.i 2017-05-16 03:05:30 +0800 @@ -8,6 +8,10 @@ %typedef long HRESULT_KEEP; // This will keep HRESULT, and return typedef long FLAGS; +typedef WCHAR OLECHAR; +typedef OLECHAR* BSTR; +typedef MAPIERROR MAPIERROR; +typedef ADRLIST ADRLIST; %typemap(python,out) HRESULT { $target = Py_None; diff -urN pywin32-220-orig/SWIG/swig_lib/python/pywintypes.i pywin32-220/SWIG/swig_lib/python/pywintypes.i --- pywin32-220-orig/SWIG/swig_lib/python/pywintypes.i 2015-08-24 19:05:04 +0800 +++ pywin32-220/SWIG/swig_lib/python/pywintypes.i 2017-05-10 02:06:29 +0800 @@ -33,6 +33,8 @@ typedef unsigned long ULONG; %apply unsigned long {ULONG}; +typedef STARTUPINFO STARTUPINFO; +%apply STARTUPINFO {STARTUPINFO}; %{ #include "PyWinTypes.h" @@ -53,6 +55,7 @@ } // Override the SWIG default for this. +%typedef PyObject PyObject; %typemap(python,out) PyObject *{ if ($source==NULL) return NULL; // get out now! $target = $source; @@ -62,7 +65,7 @@ // Map API functions that return BOOL to // functions that return None, but raise exceptions. // These functions must set the win32 LastError. -%typedef BOOL BOOLAPI +%typedef BOOL BOOLAPI; %typemap(python,out) BOOLAPI { $target = Py_None; @@ -79,7 +82,7 @@ } } -%typedef DWORD DWORDAPI +%typedef DWORD DWORDAPI; %typemap(python,out) DWORDAPI { $target = Py_None; @@ -108,11 +111,13 @@ } } +%typedef TCHAR TCHAR; %typemap(python,in) TCHAR * { if (!PyWinObject_AsTCHAR($source, &$target, FALSE)) return NULL; } +%typedef WCHAR WCHAR; %typemap(python,arginit) TCHAR *,OLECHAR *, WCHAR * { $target = NULL; @@ -198,6 +203,7 @@ return NULL; } +%typedef OVERLAPPED OVERLAPPED; %typemap(python,in) OVERLAPPED * { if (!PyWinObject_AsOVERLAPPED($source, &$target, TRUE)) @@ -252,6 +258,7 @@ } +%typedef SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; %typemap(python,in) SECURITY_ATTRIBUTES *{ if (!PyWinObject_AsSECURITY_ATTRIBUTES($source, &$target)) @@ -406,6 +413,7 @@ // LARGE_INTEGER support // //--------------------------------------------------------------------------- +%typedef LARGE_INTEGER LARGE_INTEGER; %typemap(python,in) LARGE_INTEGER { if (!PyWinObject_AsLARGE_INTEGER($source, &$target)) return NULL; @@ -415,6 +423,7 @@ if (!PyWinObject_AsLARGE_INTEGER($source, $target)) return NULL; } +%typedef ULARGE_INTEGER ULARGE_INTEGER; %typemap(python,in) ULARGE_INTEGER { if (!PyWinObject_AsULARGE_INTEGER($source, &$target)) return NULL; @@ -529,6 +538,7 @@ // TIME // //--------------------------------------------------------------------------- +%typedef FILETIME FILETIME; %typemap(python,in) FILETIME * { if (!PyWinObject_AsFILETIME($source, $target, FALSE)) return NULL; @@ -567,6 +577,7 @@ // SOCKET support. // //--------------------------------------------------------------------------- +%typedef UINT_PTR SOCKET; %typemap(python,in) SOCKET *(SOCKET sockettemp) { $target = &sockettemp; @@ -596,6 +607,6 @@ #endif PyWinGlobals_Ensure(); PyDict_SetItemString(d, "error", PyWinExc_ApiError); -#endif SWIG_PYTHONCOM +#endif // SWIG_PYTHONCOM %} diff -urN pywin32-220-orig/com/win32com/src/ErrorUtils.cpp pywin32-220/com/win32com/src/ErrorUtils.cpp --- pywin32-220-orig/com/win32com/src/ErrorUtils.cpp 2012-08-06 12:10:48 +0800 +++ pywin32-220/com/win32com/src/ErrorUtils.cpp 2017-03-28 09:11:10 +0800 @@ -1124,40 +1124,40 @@ static const RANGE_ENTRY hrRangeTable[] = { - MAKE_RANGE_ENTRY(CACHE_E), - MAKE_RANGE_ENTRY(CACHE_S), - MAKE_RANGE_ENTRY(CLASSFACTORY_E), - MAKE_RANGE_ENTRY(CLASSFACTORY_S), - MAKE_RANGE_ENTRY(CLIENTSITE_E), - MAKE_RANGE_ENTRY(CLIENTSITE_S), - MAKE_RANGE_ENTRY(CLIPBRD_E), - MAKE_RANGE_ENTRY(CLIPBRD_S), - MAKE_RANGE_ENTRY(CONVERT10_E), - MAKE_RANGE_ENTRY(CONVERT10_S), - MAKE_RANGE_ENTRY(CO_E), - MAKE_RANGE_ENTRY(CO_S), - MAKE_RANGE_ENTRY(DATA_E), - MAKE_RANGE_ENTRY(DATA_S), - MAKE_RANGE_ENTRY(DRAGDROP_E), - MAKE_RANGE_ENTRY(DRAGDROP_S), - MAKE_RANGE_ENTRY(ENUM_E), - MAKE_RANGE_ENTRY(ENUM_S), - MAKE_RANGE_ENTRY(INPLACE_E), - MAKE_RANGE_ENTRY(INPLACE_S), - MAKE_RANGE_ENTRY(MARSHAL_E), - MAKE_RANGE_ENTRY(MARSHAL_S), - MAKE_RANGE_ENTRY(MK_E), - MAKE_RANGE_ENTRY(MK_S), - MAKE_RANGE_ENTRY(OLEOBJ_E), - MAKE_RANGE_ENTRY(OLEOBJ_S), - MAKE_RANGE_ENTRY(OLE_E), - MAKE_RANGE_ENTRY(OLE_S), - MAKE_RANGE_ENTRY(REGDB_E), - MAKE_RANGE_ENTRY(REGDB_S), - MAKE_RANGE_ENTRY(VIEW_E), - MAKE_RANGE_ENTRY(VIEW_S), - MAKE_RANGE_ENTRY(CONNECT_E), - MAKE_RANGE_ENTRY(CONNECT_S), + MAKE_RANGE_ENTRY((LONG)CACHE_E), + MAKE_RANGE_ENTRY((LONG)CACHE_S), + MAKE_RANGE_ENTRY((LONG)CLASSFACTORY_E), + MAKE_RANGE_ENTRY((LONG)CLASSFACTORY_S), + MAKE_RANGE_ENTRY((LONG)CLIENTSITE_E), + MAKE_RANGE_ENTRY((LONG)CLIENTSITE_S), + MAKE_RANGE_ENTRY((LONG)CLIPBRD_E), + MAKE_RANGE_ENTRY((LONG)CLIPBRD_S), + MAKE_RANGE_ENTRY((LONG)CONVERT10_E), + MAKE_RANGE_ENTRY((LONG)CONVERT10_S), + MAKE_RANGE_ENTRY((LONG)CO_E), + MAKE_RANGE_ENTRY((LONG)CO_S), + MAKE_RANGE_ENTRY((LONG)DATA_E), + MAKE_RANGE_ENTRY((LONG)DATA_S), + MAKE_RANGE_ENTRY((LONG)DRAGDROP_E), + MAKE_RANGE_ENTRY((LONG)DRAGDROP_S), + MAKE_RANGE_ENTRY((LONG)ENUM_E), + MAKE_RANGE_ENTRY((LONG)ENUM_S), + MAKE_RANGE_ENTRY((LONG)INPLACE_E), + MAKE_RANGE_ENTRY((LONG)INPLACE_S), + MAKE_RANGE_ENTRY((LONG)MARSHAL_E), + MAKE_RANGE_ENTRY((LONG)MARSHAL_S), + MAKE_RANGE_ENTRY((LONG)MK_E), + MAKE_RANGE_ENTRY((LONG)MK_S), + MAKE_RANGE_ENTRY((LONG)OLEOBJ_E), + MAKE_RANGE_ENTRY((LONG)OLEOBJ_S), + MAKE_RANGE_ENTRY((LONG)OLE_E), + MAKE_RANGE_ENTRY((LONG)OLE_S), + MAKE_RANGE_ENTRY((LONG)REGDB_E), + MAKE_RANGE_ENTRY((LONG)REGDB_S), + MAKE_RANGE_ENTRY((LONG)VIEW_E), + MAKE_RANGE_ENTRY((LONG)VIEW_S), + MAKE_RANGE_ENTRY((LONG)CONNECT_E), + MAKE_RANGE_ENTRY((LONG)CONNECT_S), }; #undef MAKE_RANGE_ENTRY diff -urN pywin32-220-orig/com/win32com/src/PyFactory.cpp pywin32-220/com/win32com/src/PyFactory.cpp --- pywin32-220-orig/com/win32com/src/PyFactory.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32com/src/PyFactory.cpp 2017-03-28 09:11:10 +0800 @@ -48,7 +48,7 @@ { LONG cRef = InterlockedDecrement(&m_cRef); if ( cRef == 0 ) - delete this; + operator delete(this); return cRef; } diff -urN pywin32-220-orig/com/win32com/src/PyIUnknown.cpp pywin32-220/com/win32com/src/PyIUnknown.cpp --- pywin32-220-orig/com/win32com/src/PyIUnknown.cpp 2012-08-06 12:10:48 +0800 +++ pywin32-220/com/win32com/src/PyIUnknown.cpp 2017-03-28 09:11:10 +0800 @@ -89,7 +89,7 @@ } } - /* successful QI; need to release it + // successful QI; need to release it pdisp->Release(); } } diff -urN pywin32-220-orig/com/win32com/src/PythonCOM.cpp pywin32-220/com/win32com/src/PythonCOM.cpp --- pywin32-220-orig/com/win32com/src/PythonCOM.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/com/win32com/src/PythonCOM.cpp 2017-03-28 09:11:10 +0800 @@ -684,7 +684,7 @@ HRESULT hr; IInternalUnwrapPythonObject *pUnwrapper; if (S_OK!=(hr=((PyIUnknown *)ob)->m_obj->QueryInterface(IID_IInternalUnwrapPythonObject, (void **)&pUnwrapper))) { - PyErr_Format(PyExc_ValueError, "argument is not a Python gateway (0x%x)", hr); + PyErr_Format(PyExc_ValueError, "argument is not a Python gateway (0x%X)", hr); return NULL; } PyObject *retval; @@ -2119,7 +2119,7 @@ // No reference added to obFlags. if (obFlags) { coinit_flags = PyInt_AsUnsignedLongMask(obFlags); - if (coinit_flags == -1 && PyErr_Occurred()) + if ((int)coinit_flags == -1 && PyErr_Occurred()) PYWIN_MODULE_INIT_RETURN_ERROR; } else PyErr_Clear(); // Error raised by no coinit_flags attribute. diff -urN pywin32-220-orig/com/win32com/src/dllmain.cpp pywin32-220/com/win32com/src/dllmain.cpp --- pywin32-220-orig/com/win32com/src/dllmain.cpp 2015-05-20 16:57:32 +0800 +++ pywin32-220/com/win32com/src/dllmain.cpp 2017-03-28 09:11:10 +0800 @@ -138,7 +138,7 @@ ** tell us). */ - /* We don't assume anything about Python's init state here! + /* We don't assume anything about Python's init state here! */ /* ** we don't need to be notified about threads @@ -315,7 +315,7 @@ PySys_SetArgv(argc, argv); #else PySys_SetArgv(argc, __wargv); -#endif; +#endif if (PyRun_SimpleFile(fp, (char *)fileName) != 0) { // Convert the Python error to a HRESULT. diff -urN pywin32-220-orig/com/win32com/src/extensions/PyIPropertySetStorage.cpp pywin32-220/com/win32com/src/extensions/PyIPropertySetStorage.cpp --- pywin32-220-orig/com/win32com/src/extensions/PyIPropertySetStorage.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/com/win32com/src/extensions/PyIPropertySetStorage.cpp 2017-03-28 09:11:10 +0800 @@ -179,7 +179,7 @@ TmpPyObject obfmtid = PyWinObject_FromIID(rfmtid); if (obfmtid==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Create"); - hr = InvokeViaPolicy("Create", &result, "OOkk", obfmtid, obclsid, grfFlags, grfMode); + hr = InvokeViaPolicy("Create", &result, "OOkk", &obfmtid, &obclsid, grfFlags, grfMode); } if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params @@ -199,7 +199,7 @@ if (obfmtid==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Open"); if (ppprstg==NULL) return E_POINTER; PyObject *result; - HRESULT hr=InvokeViaPolicy("Open", &result, "Ok", obfmtid, grfMode); + HRESULT hr=InvokeViaPolicy("Open", &result, "Ok", &obfmtid, grfMode); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params if (!PyCom_InterfaceFromPyInstanceOrObject(result, IID_IPropertyStorage, (void **)ppprstg, FALSE)) diff -urN pywin32-220-orig/com/win32com/src/extensions/PyIPropertyStorage.cpp pywin32-220/com/win32com/src/extensions/PyIPropertyStorage.cpp --- pywin32-220-orig/com/win32com/src/extensions/PyIPropertyStorage.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/com/win32com/src/extensions/PyIPropertyStorage.cpp 2017-03-28 09:11:10 +0800 @@ -969,7 +969,7 @@ TmpPyObject obpropvars = PyObject_FromPROPVARIANTs((PROPVARIANT *)rgpropvar, cpspec); if (obpropvars==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("WriteMultiple"); - hr=InvokeViaPolicy("WriteMultiple", NULL, "OOk", obpropspecs, obpropvars, propidNameFirst); + hr=InvokeViaPolicy("WriteMultiple", NULL, "OOk", &obpropspecs, &obpropvars, propidNameFirst); } return hr; } @@ -1063,7 +1063,7 @@ TmpPyObject obnames = PyWinObject_FromWCHARArray(rglpwstrName, cpropid); if (obnames==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("WritePropertyNames"); - return InvokeViaPolicy("WritePropertyNames", NULL, "OO", obpropids, obnames); + return InvokeViaPolicy("WritePropertyNames", NULL, "OO", &obpropids, &obnames); } } @@ -1147,7 +1147,7 @@ Py_INCREF(Py_None); obmtime = Py_None; } - hr =InvokeViaPolicy("SetTimes", NULL, "OOO", obctime, obatime, obmtime); + hr =InvokeViaPolicy("SetTimes", NULL, "OOO", &obctime, &obatime, &obmtime); } return hr; } diff -urN pywin32-220-orig/com/win32com/src/include/PythonCOM.h pywin32-220/com/win32com/src/include/PythonCOM.h --- pywin32-220-orig/com/win32com/src/include/PythonCOM.h 2013-06-13 17:40:32 +0800 +++ pywin32-220/com/win32com/src/include/PythonCOM.h 2017-03-28 09:11:10 +0800 @@ -110,15 +110,48 @@ #ifdef __MINGW32__ // Special Mingw32 considerations. -#define NO_PYCOM_IDISPATCHEX -#define NO_PYCOM_IPROVIDECLASSINFO -#define NO_PYCOM_ISERVICEPROVIDER -#define NO_PYCOM_ENUMSTATPROPSTG -#define NO_PYCOM_IPROPERTYSTORAGE +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 +#undef _WIN32_IE +#define _WIN32_IE 0x0700 + #define __try try -#define __except catch +#define __except(filter) catch(...) #include +#ifndef BUILD_PYTHONCOM + +// axcontrol, shell +DEFINE_GUID(IID_IStorage, 0x0000000b, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_IStream, 0x0000000c, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_IBindCtx, 0x0000000e, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_IPersist, 0x0000010c, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_IDataObject, 0x0000010e, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_IOleWindow, 0x00000114, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); + +#include +#include +#include + +DEFINE_GUID(IID_NULL, 0x00000000, 0x0000, 0x0000, 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00); +DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); + +// adsi +DEFINE_GUID(IID_IDispatch, 0x00020400, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); + +// axscript +DEFINE_GUID(IID_ITypeInfo, 0x00020401, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); + +// shell +DEFINE_GUID(IID_IEmptyVolumeCache, 0x8fce5227, 0x04da, 0x11d1, 0xa0,0x04, 0x00,0x80,0x5f,0x8a,0xbe,0x06); +DEFINE_GUID(IID_IEmptyVolumeCache2, 0x02b7e3ba, 0x4db3, 0x11d2, 0xb2,0xd9, 0x00,0xc0,0x4f,0x8e,0xec,0x8c); +DEFINE_GUID(IID_IEmptyVolumeCacheCallBack, 0x6e793361, 0x73c6, 0x11d0, 0x84,0x69, 0x00,0xaa,0x00,0x44,0x29,0x01); +DEFINE_GUID(FMTID_SummaryInformation, 0xf29f85e0, 0x4ff9, 0x1068, 0xab,0x91, 0x08,0x00,0x2b,0x27,0xb3,0xd9); +DEFINE_GUID(FMTID_MediaFileSummaryInformation, 0x64440492, 0x4c8b, 0x11d1, 0x8b,0x70, 0x08,0x00,0x36,0xb1,0x1a,0x03); +DEFINE_GUID(FMTID_ImageSummaryInformation, 0x6444048f, 0x4c8b, 0x11d1, 0x8b,0x70, 0x08,0x00,0x36,0xb1,0x1a,0x03); +DEFINE_GUID(FMTID_AudioSummaryInformation, 0x64440490, 0x4c8b, 0x11d1, 0x8b,0x70, 0x08,0x00,0x36,0xb1,0x1a,0x03); +#endif + #endif // __MINGW32__ #include // Standard Win32 Types @@ -444,9 +477,9 @@ // We need to dynamically create C++ Python objects // These helpers allow each type object to create it. -#define MAKE_PYCOM_CTOR(classname) static PyIUnknown * classname::PyObConstruct(IUnknown *pInitObj) {return new classname(pInitObj);} +#define MAKE_PYCOM_CTOR(classname) static PyIUnknown * PyObConstruct(IUnknown *pInitObj) {return new classname(pInitObj);} #define MAKE_PYCOM_CTOR_ERRORINFO(classname, iid) \ - static PyIUnknown * classname::PyObConstruct(IUnknown *pInitObj) {return new classname(pInitObj);} \ + static PyIUnknown * PyObConstruct(IUnknown *pInitObj) {return new classname(pInitObj);} \ static PyObject *SetPythonCOMError(PyObject *self, HRESULT hr) {return PyCom_BuildPyException(hr, GetI(self), iid);} #define GET_PYCOM_CTOR(classname) classname::PyObConstruct diff -urN pywin32-220-orig/com/win32com/src/include/PythonCOMServer.h pywin32-220/com/win32com/src/include/PythonCOMServer.h --- pywin32-220-orig/com/win32com/src/include/PythonCOMServer.h 2012-12-27 16:31:56 +0800 +++ pywin32-220/com/win32com/src/include/PythonCOMServer.h 2017-03-28 09:11:10 +0800 @@ -29,7 +29,7 @@ // other than IUnknown #define PYGATEWAY_MAKE_SUPPORT2(classname, IInterface, theIID, gatewaybaseclass) \ public: \ - static HRESULT classname::PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *unkBase, void **ppResult, REFIID iid) { \ + static HRESULT PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *unkBase, void **ppResult, REFIID iid) { \ if (ppResult==NULL) return E_INVALIDARG; \ classname *newob = new classname(pPyInstance); \ newob->m_pBaseObject = unkBase; \ @@ -123,7 +123,7 @@ // Basically just PYGATEWAY_MAKE_SUPPORT(PyGatewayBase, IDispatch, IID_IDispatch); // but with special handling as its the base class. - static HRESULT PyGatewayBase::PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *gatewayBase, void **ppResult, REFIID iid) + static HRESULT PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *gatewayBase, void **ppResult, REFIID iid) { if (ppResult==NULL) return E_INVALIDARG; PyGatewayBase *obNew = new PyGatewayBase(pPyInstance); diff -urN pywin32-220-orig/com/win32com/src/oleargs.cpp pywin32-220/com/win32com/src/oleargs.cpp --- pywin32-220-orig/com/win32com/src/oleargs.cpp 2013-06-13 19:14:50 +0800 +++ pywin32-220/com/win32com/src/oleargs.cpp 2017-03-28 09:11:10 +0800 @@ -823,7 +823,7 @@ LARGE_INTEGER ll; hres = SafeArrayGetElement(psa, arrayIndices, &ll); if (FAILED(hres)) break; - subitem = PyWinObject_FromPY_LONG_LONG(ll); + subitem = PyWinObject_FromLARGE_INTEGER(ll); break; } case VT_R4: { @@ -921,7 +921,7 @@ ULARGE_INTEGER ll; hres = SafeArrayGetElement(psa, arrayIndices, &ll); if (FAILED(hres)) break; - subitem = PyWinObject_FromUPY_LONG_LONG(ll); + subitem = PyWinObject_FromULARGE_INTEGER(ll); break; } case VT_INT: { diff -urN pywin32-220-orig/com/win32com/src/univgw.cpp pywin32-220/com/win32com/src/univgw.cpp --- pywin32-220-orig/com/win32com/src/univgw.cpp 2012-08-06 12:10:50 +0800 +++ pywin32-220/com/win32com/src/univgw.cpp 2017-03-28 09:11:10 +0800 @@ -265,7 +265,7 @@ } *(int*)(code+30) = index; - *(void**)(code+36) = &univgw_dispatch; + *(void**)(code+36) = (void*)&univgw_dispatch; DWORD oldprotect; if (!VirtualProtect(code, sizeof(wrapper), PAGE_EXECUTE, &oldprotect)) { diff -urN pywin32-220-orig/com/win32comext/adsi/src/PyADSIUtil.cpp pywin32-220/com/win32comext/adsi/src/PyADSIUtil.cpp --- pywin32-220-orig/com/win32comext/adsi/src/PyADSIUtil.cpp 2011-05-02 12:39:48 +0800 +++ pywin32-220/com/win32comext/adsi/src/PyADSIUtil.cpp 2017-03-28 09:11:10 +0800 @@ -326,7 +326,7 @@ } static struct PyMemberDef memberlist[]; - static PyTypeObject PyADS_OBJECT_INFO::Type; + static PyTypeObject Type; protected: PyObject *obRDN, *obObjectDN, *obParentDN, *obClassName; }; @@ -488,7 +488,7 @@ //#pragma warning( disable : 4251 ) static struct PyMemberDef memberlist[]; //#pragma warning( default : 4251 ) - static PyTypeObject PyADS_ATTR_INFO::Type; + static PyTypeObject Type; protected: DWORD dwControlCode; ADSTYPE dwADsType; diff -urN pywin32-220-orig/com/win32comext/adsi/src/PyIDirectorySearch.i pywin32-220/com/win32comext/adsi/src/PyIDirectorySearch.i --- pywin32-220-orig/com/win32comext/adsi/src/PyIDirectorySearch.i 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/adsi/src/PyIDirectorySearch.i 2017-05-10 01:40:14 +0800 @@ -103,7 +103,7 @@ if (FAILED(_result)) PyCom_BuildPyException(_result, _swig_self, IID_IDirectoryObject); else { - ret = PyInt_FromLong((long)handle); + ret = PyInt_FromLong((LONG_PTR)handle); } PyADSI_FreeNames(names, cnames); PyWinObject_FreeWCHAR(szFilter); @@ -155,7 +155,7 @@ PyObject *ret = NULL; Py_BEGIN_ALLOW_THREADS - _result = (HRESULT )_swig_self->GetColumn((ADS_SEARCH_HANDLE)handle, szName, &col); + _result = (HRESULT )_swig_self->GetColumn((ADS_SEARCH_HANDLE)&handle, szName, &col); Py_END_ALLOW_THREADS if (FAILED(_result)) PyCom_BuildPyException(_result, _swig_self, IID_IDirectoryObject); @@ -190,7 +190,7 @@ PyObject *ret = NULL; WCHAR *szName = NULL; Py_BEGIN_ALLOW_THREADS - _result = (HRESULT )_swig_self->GetNextColumnName((ADS_SEARCH_HANDLE)handle, &szName); + _result = (HRESULT )_swig_self->GetNextColumnName((ADS_SEARCH_HANDLE)&handle, &szName); Py_END_ALLOW_THREADS if (FAILED(_result)) PyCom_BuildPyException(_result, _swig_self, IID_IDirectoryObject); diff -urN pywin32-220-orig/com/win32comext/adsi/src/PyIDsObjectPicker.i pywin32-220/com/win32comext/adsi/src/PyIDsObjectPicker.i --- pywin32-220-orig/com/win32comext/adsi/src/PyIDsObjectPicker.i 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/adsi/src/PyIDsObjectPicker.i 2017-03-28 09:11:10 +0800 @@ -77,7 +77,7 @@ $target = &temp; } %typemap(python,argout) IDataObject **OUTPUT { - MAKE_OUTPUT_INTERFACE($source, $target, IID_IDataObject) + MAKE_OUTPUT_INTERFACE($source, $target, __uuidof(IDataObject)) } // @pyswig |InvokeDialog|Displays a modal object picker dialog box and returns the user's selections. diff -urN pywin32-220-orig/com/win32comext/adsi/src/adsi.i pywin32-220/com/win32comext/adsi/src/adsi.i --- pywin32-220-orig/com/win32comext/adsi/src/adsi.i 2011-05-02 12:39:48 +0800 +++ pywin32-220/com/win32comext/adsi/src/adsi.i 2017-03-28 09:11:10 +0800 @@ -179,7 +179,7 @@ return NULL; IEnumVARIANT *pev; - if (!PyCom_InterfaceFromPyInstanceOrObject(obEnum, IID_IEnumVARIANT, (LPVOID *)&pev, FALSE)) + if (!PyCom_InterfaceFromPyInstanceOrObject(obEnum, __uuidof(IEnumVARIANT), (LPVOID *)&pev, FALSE)) return NULL; VARIANT *rgVar = new VARIANT[celt]; diff -urN pywin32-220-orig/com/win32comext/adsi/src/adsilib.i pywin32-220/com/win32comext/adsi/src/adsilib.i --- pywin32-220-orig/com/win32comext/adsi/src/adsilib.i 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/adsi/src/adsilib.i 2016-06-29 14:55:57 +0800 @@ -1,5 +1,10 @@ /* ADSI SWIG Support */ +typedef VARIANT VARIANT; +typedef ADS_OBJECT_INFO ADS_OBJECT_INFO; +typedef IDataObject IDataObject; +typedef IDispatch IDispatch; + %{ #include "pyadsiutil.h" diff -urN pywin32-220-orig/com/win32comext/authorization/src/PyGSecurityInformation.h pywin32-220/com/win32comext/authorization/src/PyGSecurityInformation.h --- pywin32-220-orig/com/win32comext/authorization/src/PyGSecurityInformation.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/authorization/src/PyGSecurityInformation.h 2016-06-29 14:58:49 +0800 @@ -22,7 +22,7 @@ ObjectInfoAcquired=FALSE; } PYGATEWAY_MAKE_SUPPORT2(PyGSecurityInformation, ISecurityInformation, IID_ISecurityInformation, PyGatewayBase) - PyGSecurityInformation::~PyGSecurityInformation(void); + ~PyGSecurityInformation(void); // ISecurityInformation // @pymeth GetObjectInformation|Returns information identifying the object diff -urN pywin32-220-orig/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp pywin32-220/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp --- pywin32-220-orig/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2017-03-28 09:11:10 +0800 @@ -225,7 +225,7 @@ } if (ok && (UINT)PySequence_Length(cmds) != cCmds) { PyErr_Format(PyExc_ValueError, "Sequence must have %d items (got %d)", - cCmds, PySequence_Length(cmds)); + (int)cCmds, PySequence_Length(cmds)); ok = FALSE; } diff -urN pywin32-220-orig/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp pywin32-220/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp --- pywin32-220-orig/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp 2017-03-28 09:11:10 +0800 @@ -406,7 +406,7 @@ /* [in] */ BOOL fErase) { PY_GATEWAY_METHOD; - HRESULT hr=InvokeViaPolicy("InvalidateRgn", NULL, "li", (long)hRGN, fErase); + HRESULT hr=InvokeViaPolicy("InvalidateRgn", NULL, "li", (long*)hRGN, fErase); return hr; } diff -urN pywin32-220-orig/com/win32comext/axcontrol/src/PyIViewObject.cpp pywin32-220/com/win32comext/axcontrol/src/PyIViewObject.cpp --- pywin32-220-orig/com/win32comext/axcontrol/src/PyIViewObject.cpp 2012-08-06 12:10:50 +0800 +++ pywin32-220/com/win32comext/axcontrol/src/PyIViewObject.cpp 2017-03-28 09:11:10 +0800 @@ -262,7 +262,7 @@ if (oblprcBounds==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *oblprcWBounds = Py_BuildValue("llll", lprcWBounds->left,lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom); if (oblprcWBounds==NULL) return PyCom_HandlePythonFailureToCOM(); - PyObject *obFuncContinue = PyLong_FromVoidPtr(pfnContinue); + PyObject *obFuncContinue = PyLong_FromVoidPtr((void*)pfnContinue); if (obFuncContinue==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *obContinue = PyWinObject_FromULONG_PTR(dwContinue); HRESULT hr=InvokeViaPolicy("Draw", NULL, "iiOOiiOOOO", dwDrawAspect, lindex, obpvAspect, obptd, hdcTargetDev, hdcDraw, oblprcBounds, oblprcWBounds, obFuncContinue, obContinue); diff -urN pywin32-220-orig/com/win32comext/axdebug/src/stdafx.h pywin32-220/com/win32comext/axdebug/src/stdafx.h --- pywin32-220-orig/com/win32comext/axdebug/src/stdafx.h 2011-03-19 10:51:20 +0800 +++ pywin32-220/com/win32comext/axdebug/src/stdafx.h 2017-04-04 22:50:22 +0800 @@ -28,6 +28,7 @@ #if defined(__REQUIRED_RPCNDR_H_VERSION__) // for some strange reason, these no longer exist in dbgprop.h !?!? +#ifdef _MSC_VER enum __MIDL___MIDL_itf_dbgprop_0000_0001 { DBGPROP_ATTRIB_NO_ATTRIB = 0, DBGPROP_ATTRIB_VALUE_IS_INVALID = 0x8, @@ -59,6 +60,7 @@ DBGPROP_INFO_AUTOEXPAND = 0x8000000 }; typedef DWORD DBGPROP_INFO_FLAGS; +#endif enum { EX_DBGPROP_INFO_ID =0x0100, diff -urN pywin32-220-orig/com/win32comext/bits/src/bits_pch.h pywin32-220/com/win32comext/bits/src/bits_pch.h --- pywin32-220-orig/com/win32comext/bits/src/bits_pch.h 2012-01-02 15:13:32 +0800 +++ pywin32-220/com/win32comext/bits/src/bits_pch.h 2017-03-19 02:45:21 +0800 @@ -1,7 +1,11 @@ // bits_pch.h : header file for PCH generation for the BITS COM extension #include +#ifdef _MSC_VER #include +#else +#include +#endif BOOL PyObject_AsBG_FILE_INFO_LIST(PyObject *ob, ULONG *pnum, BG_FILE_INFO **fi); void PyObject_FreeBG_FILE_INFO_LIST(ULONG pnum, BG_FILE_INFO *fi); diff -urN pywin32-220-orig/com/win32comext/ifilter/src/PyIFilter.cpp pywin32-220/com/win32comext/ifilter/src/PyIFilter.cpp --- pywin32-220-orig/com/win32comext/ifilter/src/PyIFilter.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/com/win32comext/ifilter/src/PyIFilter.cpp 2017-03-28 09:11:10 +0800 @@ -210,7 +210,7 @@ IStorage *pstgDest; BOOL bPythonIsHappy = TRUE; - if (!PyCom_InterfaceFromPyObject(obStg, IID_IStorage, (void **)&pstgDest, FALSE /* bNoneOK */)) + if (!PyCom_InterfaceFromPyObject(obStg, __uuidof(IStorage), (void **)&pstgDest, FALSE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) @@ -242,7 +242,7 @@ IStream *pstm; BOOL bPythonIsHappy = TRUE; - if (!PyCom_InterfaceFromPyObject(obStg, IID_IStream, (void **)&pstm, FALSE /* bNoneOK */)) + if (!PyCom_InterfaceFromPyObject(obStg, __uuidof(IStream), (void **)&pstm, FALSE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) diff -urN pywin32-220-orig/com/win32comext/ifilter/src/stdafx.h pywin32-220/com/win32comext/ifilter/src/stdafx.h --- pywin32-220-orig/com/win32comext/ifilter/src/stdafx.h 2012-01-02 15:25:04 +0800 +++ pywin32-220/com/win32comext/ifilter/src/stdafx.h 2017-04-05 00:54:16 +0800 @@ -13,7 +13,9 @@ #include #include +#ifdef _MSC_VER #define MISSING_PROPSTG +#endif #ifdef MISSING_PROPSTG // Ack - NTQuery.h is failing with the Vista SDK - pull in what we need // Problem is missing propstg.h, and all the work-arounds are uglier than diff -urN pywin32-220-orig/com/win32comext/mapi/src/PyIConverterSession.i pywin32-220/com/win32comext/mapi/src/PyIConverterSession.i --- pywin32-220-orig/com/win32comext/mapi/src/PyIConverterSession.i 2013-11-25 10:10:46 +0800 +++ pywin32-220/com/win32comext/mapi/src/PyIConverterSession.i 2016-06-29 15:03:45 +0800 @@ -72,9 +72,12 @@ IMessage *pMsg = NULL; if (!PyCom_InterfaceFromPyObject(obStream, IID_IStream, (void **)&pStream, FALSE)) - goto done; + if (pStream) + pStream->Release(); + if (!PyCom_InterfaceFromPyObject(obMsg, IID_IMessage, (void **)&pMsg, FALSE)) - goto done; + if (pMsg) + pMsg->Release(); PY_INTERFACE_PRECALL; hRes = _swig_self->MIMEToMAPI(pStream, pMsg, NULL, flags); @@ -88,12 +91,6 @@ result = Py_None; } -done: - if (pStream) - pStream->Release(); - if (pMsg) - pMsg->Release(); - return result; } @@ -115,9 +112,12 @@ IMessage *pMsg = NULL; if (!PyCom_InterfaceFromPyObject(obMsg, IID_IMessage, (void **)&pMsg, FALSE)) - goto done; + if (pStream) + pStream->Release(); + if (!PyCom_InterfaceFromPyObject(obStream, IID_IStream, (void **)&pStream, FALSE)) - goto done; + if (pMsg) + pMsg->Release(); PY_INTERFACE_PRECALL; hRes = _swig_self->MAPIToMIMEStm(pMsg, pStream, flags); @@ -131,12 +131,6 @@ result = Py_None; } -done: - if (pStream) - pStream->Release(); - if (pMsg) - pMsg->Release(); - return result; } diff -urN pywin32-220-orig/com/win32comext/mapi/src/mapi.i pywin32-220/com/win32comext/mapi/src/mapi.i --- pywin32-220-orig/com/win32comext/mapi/src/mapi.i 2015-08-24 18:50:10 +0800 +++ pywin32-220/com/win32comext/mapi/src/mapi.i 2017-05-14 18:58:10 +0800 @@ -571,7 +571,7 @@ PY_INTERFACE_POSTCALL; if (FAILED(hr)) return OleSetOleError(hr); - return PyInt_FromLong((long)pSession); + return PyInt_FromLong((LONG_PTR)pSession); } %} // @pyswig |CloseIMsgSession| @@ -579,7 +579,7 @@ %{ PyObject *PyCloseIMsgSession(PyObject *self, PyObject *args) { - long session = 0; + LONG_PTR session = 0; if (!PyArg_ParseTuple(args, "l:CloseIMsgSession", &session)) return NULL; PY_INTERFACE_PRECALL; @@ -603,7 +603,7 @@ long flags = 0; HRESULT hr = E_FAIL; PyObject *rc = NULL; - long lSession; + LONG_PTR lSession; if (!PyArg_ParseTuple(args, "lOO|Oll:OpenIMsgOnIStg", &lSession, // @pyparm object|session|| @@ -825,20 +825,16 @@ return NULL; if (!PyWinObject_AsString(obFileName, &filename, TRUE)) - goto done; + PyWinObject_FreeString(filename); if (!PyWinObject_AsString(obPrefix, &prefix, TRUE)) - goto done; + PyWinObject_FreeString(prefix); PY_INTERFACE_PRECALL; // mapiutil.h incorrectly declares OpenStreamOnFile taking type LPTSTR hRes = OpenStreamOnFile(MAPIAllocateBuffer, MAPIFreeBuffer, flags, (LPTSTR)filename, (LPTSTR)prefix, &pStream); PY_INTERFACE_POSTCALL; - done: - PyWinObject_FreeString(filename); - PyWinObject_FreeString(prefix); - if (PyErr_Occurred()) return NULL; @@ -867,7 +863,7 @@ return NULL; if (!PyCom_InterfaceFromPyObject(obProp, IID_IMAPIProp, (void **)&pProp, FALSE)) - goto done; + if (pProp) pProp->Release(); PY_INTERFACE_PRECALL; hRes = HrGetOneProp(pProp, propTag, &pPV); @@ -875,10 +871,10 @@ if (FAILED(hRes)) { OleSetOleError(hRes); - goto done; + if (pProp) pProp->Release(); } if ((ret = PyMAPIObject_FromSPropValue(pPV)) == NULL) - goto done; + MAPIFreeBuffer(pPV); // PyMAPIObject_FromSPropValue does not raise an exception for types // it cannot handle so that GetProps doesn't blow up. Since we are processing @@ -887,15 +883,12 @@ PyLong_AsUnsignedLong(PyTuple_GET_ITEM(ret, 0)) != PT_NULL) { char buf[128]; - sprintf(buf, "Unsupported MAPI property type 0x%X", PROP_TYPE(pPV->ulPropTag)); + sprintf(buf, "Unsupported MAPI property type 0x%lu", PROP_TYPE(pPV->ulPropTag)); PyErr_SetString(PyExc_TypeError, buf); Py_DECREF(ret); ret = NULL; } -done: - if (pProp) pProp->Release(); - MAPIFreeBuffer(pPV); - + return ret; } %} @@ -919,14 +912,14 @@ return NULL; if (!PyCom_InterfaceFromPyObject(obProp, IID_IMAPIProp, (void **)&pProp, FALSE)) - goto done; + if (pProp) pProp->Release(); if (S_OK != (hRes=MAPIAllocateBuffer(sizeof(SPropValue), (void **)&pPV))) { OleSetOleError(hRes); - goto done; + MAPIFreeBuffer(pPV); } if (!PyMAPIObject_AsSPropValue(obPropValue, pPV, pPV)) - goto done; + MAPIFreeBuffer(pPV); PY_INTERFACE_PRECALL; hRes = HrSetOneProp(pProp, pPV); @@ -934,13 +927,10 @@ if (FAILED(hRes)) { OleSetOleError(hRes); - goto done; + if (pProp) pProp->Release(); } Py_INCREF(Py_None); ret = Py_None; -done: - if (pProp) pProp->Release(); - MAPIFreeBuffer(pPV); return ret; } diff -urN pywin32-220-orig/com/win32comext/mapi/src/mapilib.i pywin32-220/com/win32comext/mapi/src/mapilib.i --- pywin32-220-orig/com/win32comext/mapi/src/mapilib.i 2015-08-24 18:41:34 +0800 +++ pywin32-220/com/win32comext/mapi/src/mapilib.i 2017-05-14 12:56:52 +0800 @@ -7,6 +7,30 @@ typedef unsigned long BOOKMARK; %apply unsigned long {BOOKMARK}; +typedef IID IID; +typedef MAPIUID MAPIUID; +typedef MAPIINIT_0 MAPIINIT_0; +typedef IMAPISession IMAPISession; +typedef IMAPITable IMAPITable; +typedef IMAPIProp IMAPIProp; +typedef IMAPIFolder IMAPIFolder; +typedef IMAPIProgress IMAPIProgress; +typedef IMAPIAdviseSink IMAPIAdviseSink; +typedef IAddrBook IAddrBook; +typedef IAttach IAttach; +typedef IProfAdmin IProfAdmin; +typedef IProfSect IProfSect; +typedef IProviderAdmin IProviderAdmin; +typedef IMsgServiceAdmin IMsgServiceAdmin; +typedef IStream IStream; +typedef IMessage IMessage; +typedef IMsgStore IMsgStore; +typedef SRowSet SRowSet; +typedef SPropTagArray SPropTagArray; +typedef SRestriction SRestriction; +typedef SSortOrderSet SSortOrderSet; +typedef SBinaryArray SBinaryArray; + // A MAPIUID is close enough to an IID for now! %typemap(python,in) MAPIUID *INPUT(MAPIUID temp) { diff -urN pywin32-220-orig/com/win32comext/mapi/src/mapiutil.cpp pywin32-220/com/win32comext/mapi/src/mapiutil.cpp --- pywin32-220-orig/com/win32comext/mapi/src/mapiutil.cpp 2015-01-05 16:14:18 +0800 +++ pywin32-220/com/win32comext/mapi/src/mapiutil.cpp 2017-03-28 09:11:10 +0800 @@ -354,7 +354,7 @@ default: { char buf[128]; - sprintf(buf, "Unsupported MAPI property type 0x%X", PROP_TYPE(pv->ulPropTag)); + sprintf(buf, "Unsupported MAPI property type 0x%lu", PROP_TYPE(pv->ulPropTag));// PyErr_SetString(PyExc_TypeError, buf); ok = FALSE; } @@ -504,7 +504,7 @@ break; default: - printf("File %s: Unsupported MAPI property type 0x%X", __FILE__, PROP_TYPE(pv->ulPropTag)); + printf("File %s: Unsupported MAPI property type 0x%lu", __FILE__, PROP_TYPE(pv->ulPropTag)); /* Dont set exception, as this prevents otherwise valid props from being returned */ @@ -612,7 +612,7 @@ // of property values. SRow *pRow = (*ppResult)->aRow+i; pRow->cValues = PySequence_Length(rowObject); - if (pRow->cValues==-1) + if ((int)pRow->cValues==-1) goto done; if (pRow->cValues==0) diff -urN pywin32-220-orig/com/win32comext/propsys/src/PyPROPVARIANT.cpp pywin32-220/com/win32comext/propsys/src/PyPROPVARIANT.cpp --- pywin32-220-orig/com/win32comext/propsys/src/PyPROPVARIANT.cpp 2012-09-24 10:17:36 +0800 +++ pywin32-220/com/win32comext/propsys/src/PyPROPVARIANT.cpp 2017-05-15 23:47:19 +0800 @@ -3,9 +3,37 @@ #include "PythonCOM.h" #include "PyPROPVARIANT.h" +#ifdef _MSC_VER #include "propvarutil.h" +#endif #include "float.h" +#ifndef _MSC_VER +enum tagPROPVAR_CHANGE_FLAGS +{ + PVCHF_DEFAULT = 0x00000000, + PVCHF_NOVALUEPROP = 0x00000001, + PVCHF_ALPHABOOL = 0x00000002, + PVCHF_NOUSEROVERRIDE = 0x00000004, + PVCHF_LOCALBOOL = 0x00000008, + PVCHF_NOHEXSTRING = 0x00000010, +}; + +typedef int PROPVAR_CHANGE_FLAGS; + +PSSTDAPI PropVariantChangeType( + PROPVARIANT *ppropvarDest, + REFPROPVARIANT propvarSrc, + PROPVAR_CHANGE_FLAGS flags, + VARTYPE vt +); + +PSSTDAPI PropVariantToStringAlloc( + REFPROPVARIANT propvar, + PWSTR *ppszOut +); +#endif + // @doc - This file contains autoduck documentation // --------------------------------------------------- diff -urN pywin32-220-orig/com/win32comext/propsys/src/propsys.cpp pywin32-220/com/win32comext/propsys/src/propsys.cpp --- pywin32-220-orig/com/win32comext/propsys/src/propsys.cpp 2012-11-24 15:56:54 +0800 +++ pywin32-220/com/win32comext/propsys/src/propsys.cpp 2017-03-28 09:11:10 +0800 @@ -38,6 +38,13 @@ #include "propvarutil.h" #include "Shobjidl.h" +#ifndef _MSC_VER +DEFINE_GUID(CLSID_PropertyChangeArray, 0x380f5cad, 0x1b5e, 0x42f2, 0x80,0x5d, 0x63,0x7f,0xd3,0x92,0xd3,0x1e); + +PSSTDAPI StgSerializePropVariant(const PROPVARIANT *pvar, SERIALIZEDPROPERTYVALUE **ppProp, ULONG *pcb); +PSSTDAPI StgDeserializePropVariant(const SERIALIZEDPROPERTYVALUE *pprop, ULONG *cbMax, PROPVARIANT *pvar); +#endif + #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); // Not available on Vista or earlier typedef HRESULT (WINAPI *PFNSHGetPropertyStoreForWindow)(HWND, REFIID, void **); @@ -313,7 +320,7 @@ if (!PyWinObject_AsReadBuffer(ob, (void **)&pspv, &bufsize)) return NULL; PY_INTERFACE_PRECALL; - hr = StgDeserializePropVariant(pspv, bufsize, &pv); + hr = StgDeserializePropVariant(pspv, &bufsize, &pv); PY_INTERFACE_POSTCALL; if (FAILED(hr)) return PyCom_BuildPyException(hr); diff -urN pywin32-220-orig/com/win32comext/shell/src/PyICategorizer.cpp pywin32-220/com/win32comext/shell/src/PyICategorizer.cpp --- pywin32-220-orig/com/win32comext/shell/src/PyICategorizer.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/com/win32comext/shell/src/PyICategorizer.cpp 2017-05-16 00:47:06 +0800 @@ -65,7 +65,7 @@ for (DWORD tuple_index=0; tuple_indexGetDefaultCategory( &guid, &scid ); diff -urN pywin32-220-orig/com/win32comext/shell/src/shell.cpp pywin32-220/com/win32comext/shell/src/shell.cpp --- pywin32-220-orig/com/win32comext/shell/src/shell.cpp 2015-05-20 16:36:50 +0800 +++ pywin32-220/com/win32comext/shell/src/shell.cpp 2017-03-28 09:11:10 +0800 @@ -2317,7 +2317,7 @@ Py_INCREF(Py_None); return Py_None; } - if (cb < sizeof(UINT)) + if ((size_t)cb < sizeof(UINT)) return PyErr_Format(PyExc_ValueError, "The buffer is way too small!"); fgd = (FILEGROUPDESCRIPTORA *)buf; fgdw = (FILEGROUPDESCRIPTORW *)buf; diff -urN pywin32-220-orig/com/win32comext/shell/src/shell_pch.h pywin32-220/com/win32comext/shell/src/shell_pch.h --- pywin32-220-orig/com/win32comext/shell/src/shell_pch.h 2013-06-13 17:40:32 +0800 +++ pywin32-220/com/win32comext/shell/src/shell_pch.h 2017-03-28 09:11:10 +0800 @@ -8,6 +8,30 @@ #include #include +#ifndef _MSC_VER +DEFINE_GUID(IID_IAsyncOperation, 0x3d8b0590, 0xf691, 0x11d2, 0x8e,0xa9, 0x00,0x60,0x97,0xdf,0x5b,0xd4); +class IAsyncOperation : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE SetAsyncMode( + BOOL fDoOpAsync) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetAsyncMode( + BOOL *pfIsOpAsync) = 0; + + virtual HRESULT STDMETHODCALLTYPE StartOperation( + IBindCtx *pbcReserved) = 0; + + virtual HRESULT STDMETHODCALLTYPE InOperation( + BOOL *pfInAsyncOp) = 0; + + virtual HRESULT STDMETHODCALLTYPE EndOperation( + HRESULT hResult, + IBindCtx *pbcReserved, + DWORD dwEffects) = 0; +}; +#endif /* !_MSC_VER */ + BOOL PyObject_AsPIDL(PyObject *ob, LPITEMIDLIST *ppidl, BOOL bNoneOK = FALSE, UINT *pcb = NULL); PyObject *PyObject_FromPIDL(LPCITEMIDLIST pidl, BOOL bFreeSystemPIDL); void PyObject_FreePIDL( LPCITEMIDLIST pidl ); diff -urN pywin32-220-orig/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp pywin32-220/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp --- pywin32-220-orig/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp 2017-03-18 00:35:43 +0800 @@ -489,13 +489,14 @@ PyObject *obworkitem_data=NULL; if ( !PyArg_ParseTuple(args, "O:PyIScheduledWorkItem::SetWorkItemData", &obworkitem_data)) return NULL; - if (obworkitem_data!=Py_None) + if (obworkitem_data!=Py_None){ if (PyString_AsStringAndSize(obworkitem_data, (CHAR **)&workitem_data, &data_len)==-1) return NULL; else // Task Scheduler won't take an empty string for data anymore ?????? if (data_len==0) workitem_data=NULL; + } HRESULT hr; PY_INTERFACE_PRECALL; diff -urN pywin32-220-orig/isapi/src/PyExtensionObjects.cpp pywin32-220/isapi/src/PyExtensionObjects.cpp --- pywin32-220-orig/isapi/src/PyExtensionObjects.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/isapi/src/PyExtensionObjects.cpp 2017-05-10 03:27:44 +0800 @@ -625,7 +625,7 @@ BOOL bRes; Py_BEGIN_ALLOW_THREADS EXTENSION_CONTROL_BLOCK * ecb = pecb->m_pcb->GetECB(); - bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID)f, NULL,NULL); + bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID)&f, NULL,NULL); Py_END_ALLOW_THREADS if (!bRes) return SetPyECBError("ServerSupportFunction(HSE_REQ_SET_FLUSH_FLAG)"); @@ -820,7 +820,7 @@ BOOL bRes; Py_BEGIN_ALLOW_THREADS - bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_IO_COMPLETION, DoIOCallback, NULL, NULL); + bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_IO_COMPLETION, (LPVOID)DoIOCallback, NULL, NULL); Py_END_ALLOW_THREADS if (!bRes) return SetPyECBError("ServerSupportFunction(HSE_REQ_IO_COMPLETION)"); diff -urN pywin32-220-orig/isapi/src/PyFilterObjects.cpp pywin32-220/isapi/src/PyFilterObjects.cpp --- pywin32-220-orig/isapi/src/PyFilterObjects.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/isapi/src/PyFilterObjects.cpp 2017-03-28 09:11:10 +0800 @@ -321,7 +321,7 @@ // but docs clearly have second as unused. Either way, I can't see the // specific header! bRes = phfc->m_pfc->ServerSupportFunction(SF_REQ_SEND_RESPONSE_HEADER, - status, (DWORD)header, 0); + status, (DWORD_PTR)header, 0); Py_END_ALLOW_THREADS if (!bRes) return SetPyHFCError("SendResponseHeader"); diff -urN pywin32-220-orig/isapi/src/PythonEng.h pywin32-220/isapi/src/PythonEng.h --- pywin32-220-orig/isapi/src/PythonEng.h 2011-03-19 10:51:22 +0800 +++ pywin32-220/isapi/src/PythonEng.h 2016-06-29 15:08:01 +0800 @@ -65,7 +65,7 @@ PyObject *DoCallback(HANDLER_TYPE typ, PyObject *args); bool LoadHandler(bool reload); - bool CPythonHandler::CheckCallback(const char *cbname, PyObject **cb); + bool CheckCallback(const char *cbname, PyObject **cb); const char *m_namefactory; const char *m_nameinit; const char *m_namedo; diff -urN pywin32-220-orig/isapi/src/StdAfx.h pywin32-220/isapi/src/StdAfx.h --- pywin32-220-orig/isapi/src/StdAfx.h 2013-06-13 17:40:32 +0800 +++ pywin32-220/isapi/src/StdAfx.h 2017-05-10 03:24:57 +0800 @@ -45,6 +45,10 @@ // avoid anyone accidently using the wrong WRITE_RESTRICTED... #undef WRITE_RESTRICTED +#ifndef _MSC_VER +#define HSE_REQ_SET_FLUSH_FLAG (HSE_REQ_END_RESERVED+43) +#endif + // See PEP-353 - this is the "official" test... #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) // 2.3 and before have no Py_ssize_t diff -urN pywin32-220-orig/isapi/src/Utils.cpp pywin32-220/isapi/src/Utils.cpp --- pywin32-220-orig/isapi/src/Utils.cpp 2012-01-28 15:06:42 +0800 +++ pywin32-220/isapi/src/Utils.cpp 2016-06-29 15:08:07 +0800 @@ -127,7 +127,7 @@ return; GetModuleFileNameW(g_hInstance, mod_name, - sizeof mod_name/sizeof WCHAR); + sizeof mod_name/sizeof(WCHAR)); if (!mod_name[0]) { OutputDebugString(_T("GetModuleFileNameW failed!")); return; diff -urN pywin32-220-orig/pywin32_testall.py pywin32-220/pywin32_testall.py --- pywin32-220-orig/pywin32_testall.py 2011-03-19 10:51:22 +0800 +++ pywin32-220/pywin32_testall.py 2017-11-28 11:10:44 +0800 @@ -75,8 +75,8 @@ find_and_run(maybes, 'testall.py', "2") # adodbapi - maybes = [os.path.join(this_dir, "adodbapi", "tests"), - os.path.join(site_packages, "adodbapi", "tests"), + maybes = [os.path.join(this_dir, "adodbapi", "test"), + os.path.join(site_packages, "adodbapi", "test"), ] find_and_run(maybes, 'adodbapitest.py') # This script has a hard-coded sql server name in it, (and markh typically diff -urN pywin32-220-orig/setup.py pywin32-220/setup.py --- pywin32-220-orig/setup.py 2016-01-11 17:19:52 +0800 +++ pywin32-220/setup.py 2020-09-28 11:54:49 +0800 @@ -97,7 +97,8 @@ # py24 and earlier bdist_msi = None -from distutils.msvccompiler import get_build_version +if 'MSC' in sys.version: + from distutils.msvccompiler import get_build_version from distutils import log # some modules need a static CRT to avoid problems caused by them having a @@ -109,7 +110,7 @@ from distutils import dir_util, file_util from distutils.sysconfig import get_python_lib, get_config_vars from distutils.filelist import FileList -from distutils.errors import DistutilsExecError +from distutils.errors import CCompilerError, DistutilsExecError import distutils.util # prevent the new in 3.5 suffix of "cpXX-win32" from being added. @@ -229,7 +230,7 @@ # to prevent the extension from loading. For more details, see # http://bugs.python.org/issue7833 - that issue has a patch, but it is # languishing and will probably never be fixed for Python 2.6... -if sys.version_info > (2,6): +if 'MSC' in sys.version and sys.version_info > (2,6): from distutils.spawn import spawn from distutils.msvc9compiler import MSVCCompiler MSVCCompiler._orig_spawn = MSVCCompiler.spawn @@ -298,9 +299,15 @@ delattr(self, '_want_assembly_kept') MSVCCompiler.spawn = monkeypatched_spawn MSVCCompiler.link = monkeypatched_link +else: + from distutils.spawn import spawn + from distutils.cygwinccompiler import Mingw32CCompiler sdk_dir = find_platform_sdk_dir() +if 'GCC' in sys.version: + sdk_dir = os.environ.get("SDKDIR") + mfc_dir = os.environ.get("MFCDIR") class WinExt (Extension): # Base class for all win32 extensions, with some predefined @@ -333,7 +340,7 @@ implib_name=None, delay_load_libraries="", ): - libary_dirs = library_dirs, + library_dirs = library_dirs include_dirs = ['com/win32com/src/include', 'win32/src'] + include_dirs libraries=libraries.split() @@ -342,7 +349,8 @@ if export_symbol_file: export_symbols = export_symbols or [] - export_symbols.extend(self.parse_def_file(export_symbol_file)) + if 'MSC' in sys.version: + export_symbols.extend(self.parse_def_file(export_symbol_file)) # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. @@ -420,7 +428,7 @@ def finalize_options(self, build_ext): # distutils doesn't define this function for an Extension - it is # our own invention, and called just before the extension is built. - if not build_ext.mingw32: + if 'MSC' in sys.version: if self.pch_header: self.extra_compile_args = self.extra_compile_args or [] # /YX doesn't work in vs2008 or vs2003/64 @@ -505,12 +513,96 @@ if "/SUBSYSTEM:WINDOWS" in self.extra_link_args: self.extra_link_args.append("/ENTRY:wWinMainCRTStartup") + else: + # Set our C++ standard + self.extra_compile_args.append("-std=c++14") + + # MinGW doesn't define these + self.extra_compile_args.append("-D__WIN32__") + self.extra_compile_args.append("-DWINNT") + if build_ext.plat_name == "win-i686": + self.extra_compile_args.append("-D_M_IX86") + else: + self.extra_compile_args.append("-D_M_AMD64") + self.extra_compile_args.append("-D_M_X64") + + # Handle Unicode - if unicode_mode is None, then it means True + # for py3k, false for py2 + unicode_mode = self.unicode_mode + if unicode_mode is None: + unicode_mode = is_py3k + if unicode_mode: + self.extra_compile_args.append("-D_UNICODE") + self.extra_compile_args.append("-DUNICODE") + else: + self.extra_compile_args.append("-D_MBCS") + + # If someone needs a specially named implib created, handle that + if self.implib_name: + implib = os.path.join(build_ext.build_temp, self.implib_name) + if build_ext.debug: + suffix = "_d" + else: + suffix = "" + self.extra_link_args.append("-Wl,--out-implib,%s%s.dll.a" % (implib, suffix)) + + # Avoid dll hell please + if "static-libstdc++" not in get_config_vars()["LDSHARED"]: + self.extra_link_args.append("-static-libgcc", "-static-libstdc++") + if unicode_mode: + self.extra_link_args.append("-municode") + if build_ext.plat_name == "win-i686": + self.extra_link_args.append("-m32") + else: + self.extra_link_args.append("-m64") + + # Silenced some annoying warnings + self.extra_compile_args.append("-Wno-attributes") + self.extra_compile_args.append("-Wno-conversion-null") + self.extra_compile_args.append("-Wno-invalid-offsetof") + self.extra_compile_args.append("-Wno-maybe-uninitialized") + self.extra_compile_args.append("-Wno-return-type") + self.extra_compile_args.append("-Wno-sign-compare") + self.extra_compile_args.append("-Wno-strict-aliasing") + self.extra_compile_args.append("-Wno-unknown-pragmas") + self.extra_compile_args.append("-Wno-unused") + self.extra_compile_args.append("-Wno-write-strings") + class WinExt_pythonwin(WinExt): def __init__ (self, name, **kw): if 'unicode_mode' not in kw: kw['unicode_mode']=None kw.setdefault("extra_compile_args", []).extend( - ['-D_AFXDLL', '-D_AFXEXT','-D_MBCS']) + ['-D_AFXDLL', '-D_AFXEXT']) + + if 'GCC' in sys.version: + kw.setdefault("extra_compile_args", []).extend( + ['-DMINGW_HAS_SECURE_API=1', '-D_MD']) + kw.setdefault("extra_compile_args", []).extend( + ['-mthreads', '-fexceptions', '-frtti']) + + if is_py3k: + kw["libraries"] = kw.get("libraries", "") + " mfc100u" + else: + kw["libraries"] = kw.get("libraries", "") + " mfc100" + + if name in ['win32ui']: + kw["libraries"] = kw.get("libraries", "") + " winspool" + elif name in ['win32uiole']: + kw["libraries"] = kw.get("libraries", "") + " win32ui pythoncom" + elif name in ['dde']: + kw["libraries"] = kw.get("libraries", "") + " win32ui" + kw["libraries"] = kw.get("libraries", "") + " pywintypes" + + kw.setdefault("extra_link_args", []).extend(['-mthreads', '-mwindows', '-nodefaultlibs']) + + # Allow multiple definition of _Unwind_Resume *fix this* + kw.setdefault("extra_link_args", []).extend(['-Wl,-allow-multiple']) + + kw.setdefault("extra_link_args", []).extend([ + '-Wl,-Bstatic,-lstdc++', '-Wl,-Bstatic,-lmingw32,-lgcc,-lgcc_eh,-lmoldname,-lmingwex', + '-Wl,-Bdynamic,-loleaut32,-lgdi32,-lcomdlg32,-ladvapi32,-lshell32,-luser32,-lkernel32', + '-Wl,-Bstatic,-liconv,-lmingwthrd,-lmingw32,-lgcc,-lgcc_eh,-lmoldname,-lmingwex,-lmsvcr100']) WinExt.__init__(self, name, **kw) def get_pywin32_dir(self): @@ -518,6 +610,8 @@ class WinExt_win32(WinExt): def __init__ (self, name, **kw): + if 'GCC' in sys.version and name not in ['_win32sysloader']: + kw["libraries"] = kw.get("libraries", "") + " pywintypes" WinExt.__init__(self, name, **kw) def get_pywin32_dir(self): return "win32" @@ -531,6 +625,10 @@ class WinExt_win32com(WinExt): def __init__ (self, name, **kw): kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32" + if 'GCC' in sys.version: + if name in ['axcontrol', 'internet', 'propsys', 'shell']: + kw["libraries"] = kw.get("libraries", "") + " uuid" + kw["libraries"] = kw.get("libraries", "") + " pythoncom pywintypes" # COM extensions require later windows headers. if not kw.get("windows_h_version"): @@ -578,8 +676,13 @@ # Additional utility functions are only available for 32-bit builds. pass else: - libs += " version user32 advapi32 Ex2KSdk sadapi netapi32" + if 'MSC' in sys.version: + libs += " version user32 advapi32 Ex2KSdk sadapi netapi32" + else: + libs += " ex2ksdk version mapi32 advapi32 user32 netapi32" kw["libraries"] = libs + if 'GCC' in sys.version: + kw.setdefault('extra_compile_args', []).append("-DEXCHANGE_RE") WinExt_win32com.__init__(self, name, **kw) def get_pywin32_dir(self): @@ -593,6 +696,8 @@ # to use our own copy of that file with that SDK, we fail to link. if os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")): kw.setdefault('extra_compile_args', []).append("/DHAVE_SDK_ACTIVDBG") + if 'GCC' in sys.version: + kw.setdefault('extra_compile_args', []).append("-DHAVE_SDK_ACTIVDBG") WinExt_win32com.__init__(self, name, **kw) # A hacky extension class for pywintypesXX.dll and pythoncomXX.dll @@ -1414,6 +1519,506 @@ return new_sources +class mingw_build_ext(build_ext): + + def finalize_options(self): + build_ext.finalize_options(self) + self.windows_h_version = None + # The pywintypes library is created in the build_temp directory, + # so we need to add this to library_dirs + self.library_dirs.append(self.build_temp) + + # Add extra SDK include dir & library dir + if self.plat_name == 'win-x86_64': + amd64_dir = "/amd64" + x64_dir = "/x64" + else: + amd64_dir = "" + x64_dir = "" + # Windows SDK dirs + self.include_dirs.append(sdk_dir + '/include') + self.library_dirs.append(sdk_dir + '/lib' + x64_dir) + # VC++ dirs + self.include_dirs.append(mfc_dir + '/atlmfc/include') + self.library_dirs.append(mfc_dir + '/atlmfc/lib' + amd64_dir) + + self.excluded_extensions = [] # list of (ext, why) + self.swig_cpp = True + if not hasattr(self, 'plat_name'): + # Old Python version that doesn't support cross-compile + self.plat_name = distutils.util.get_platform() + + def _why_cant_build_extension(self, ext): + # Return None, or a reason it can't be built. + if self.plat_name == 'win-x86_64' and ext.name in ['exchange', 'exchdapi']: + return "No 64-bit library for utility functions available." + + if ext.name in ['win32ui', 'win32uiole', 'dde', 'Pythonwin']: + return "Unsupported due to different ABI implementations." + + def _build_scintilla(self): + path = 'Pythonwin/Scintilla/win32' + makefile = 'scintilla_mingw.mak' + makeargs = [] + + if self.debug: + makeargs.append("DEBUG=1") + if not self.verbose: + makeargs.append("QUIET=1") + # We build the DLL into our own temp directory, then copy it to the + # real directory - this avoids the generated .lib/.exp + build_temp = os.path.abspath(os.path.join(self.build_temp, "scintilla")) + self.mkpath(build_temp) + makeargs.append("SUB_DIR_O=%s" % build_temp) + makeargs.append("SUB_DIR_BIN=%s" % build_temp) + + # Deliberately not using self.spawn() to avoid stdout from always + # printing the parsed arguments for the makefile. + cwd = os.getcwd() + os.chdir(path) + try: + import subprocess + cmd = subprocess.call(['make', '-f', makefile] + makeargs) + finally: + os.chdir(cwd) + + # The DLL goes into the Pythonwin directory. + if self.debug: + base_name = "scintilla_d.dll" + else: + base_name = "scintilla.dll" + self.copy_file( + os.path.join(self.build_temp, "scintilla", base_name), + os.path.join(self.build_lib, "pythonwin")) + + def _build_pycom_loader(self): + # the base compiler strips out the manifest from modules it builds + # which can't be done for this module - having the manifest is the + # reason it needs to exist! + # At least this is made easier by it not depending on Python itself, + # so the compile and link are simple... + suffix = "%d%d" % (sys.version_info[0], sys.version_info[1]) + if self.debug: + suffix += '_d' + src = r"com/win32com/src/PythonCOMLoader.cpp" + build_temp = os.path.abspath(self.build_temp) + obj = os.path.join(build_temp, os.path.splitext(src)[0]+".o") + dll = os.path.join(self.build_lib, "win32", "pythoncomloader"+suffix+".dll") + if self.force or newer_group([src], obj, 'newer'): + ccargs = ['gcc', '-c'] + ccargs.append('-DDLL_DELEGATE=\\"pythoncom%s.dll\\"' % (suffix,)) + ccargs.append(src) + ccargs.append('-o' + obj) + if self.debug: + ccargs.append("-DDEBUG") + self.spawn(ccargs) + + rcsrc = r"com/win32com/src/PythonCOMLoader.rc" + rcobj = os.path.join(build_temp, os.path.splitext(rcsrc)[0]+".rc.o") + if self.force or newer_group([rcsrc], rcobj, 'newer'): + wargs = ['windres', '-i', rcsrc, '-o', rcobj] + self.spawn(wargs) + + if self.force or newer_group([obj], dll, 'newer'): + largs = ['gcc', '-shared'] + largs.append('-static-libgcc') + largs.append('-o' + dll) + largs.append('-Wl,--out-implib,' + os.path.join(build_temp, "pythoncomloader.dll.a")) + largs.append(obj) + largs.append(rcobj) + self.spawn(largs) + + def build_extensions(self): + # First, sanity-check the 'extensions' list + self.check_extensions_list(self.extensions) + + self.found_libraries = {} + + if not hasattr(self.compiler, 'initialized'): + # 2.3 and earlier initialized at construction + self.compiler.initialized = True + else: + if not self.compiler.initialized: + self.compiler.initialize() + + # Here we hack a "pywin32" directory (one of 'win32', 'win32com', + # 'pythonwin' etc), as distutils doesn't seem to like the concept + # of multiple top-level directories. + assert self.package is None + for ext in self.extensions: + try: + self.package = ext.get_pywin32_dir() + except AttributeError: + raise RuntimeError("Not a win32 package!") + self.build_extension(ext) + + for ext in W32_exe_files: + ext.finalize_options(self) + why = self._why_cant_build_extension(ext) + if why is not None: + self.excluded_extensions.append((ext, why)) + assert why, "please give a reason, or None" + print "Skipping %s: %s" % (ext.name, why) + continue + + try: + self.package = ext.get_pywin32_dir() + except AttributeError: + raise RuntimeError("Not a win32 package!") + self.build_exefile(ext) + + # Only build scintilla if Pythonwin extensions are enabled + pythonwin_dir = os.path.join(self.build_temp, "pythonwin") + if os.path.exists(pythonwin_dir): + self._build_scintilla() + # Copy cpp lib files needed to create Python COM extensions + clib_files = (['win32', 'pywintypes%s.dll.a'], + ['win32com', 'pythoncom%s.dll.a'], + ['win32com', 'axscript%s.dll.a']) + for clib_file in clib_files: + target_dir = os.path.join(self.build_lib, clib_file[0], "libs") + if not os.path.exists(target_dir): + self.mkpath(target_dir) + suffix = "" + if self.debug: + suffix = "_d" + fname = clib_file[1] % suffix + self.copy_file( + os.path.join(self.build_temp, fname), target_dir) + + # The MFC DLLs. + try: + target_dir = os.path.join(self.build_lib, "pythonwin") + if is_py3k: + mfc_files = ["mfc100mu.dll"] + else: + mfc_files = ["mfc100m.dll"] + if self.plat_name == 'win-x86_64': + plat_dir = "x64" + else: + plat_dir = "x86" + + # Find the redist directory. + target_file = os.path.join(target_dir, "Pythonwin.exe") + if os.path.exists(target_file): + mfcdll_dir = os.path.join(mfc_dir, "redist", plat_dir, "Microsoft.VC100.MFC") + if not os.path.isdir(mfcdll_dir): + raise RuntimeError("Can't find the redist dir at %r" % (mfcdll_dir)) + for f in mfc_files: + self.copy_file(os.path.join(mfcdll_dir, f), target_dir) + except (EnvironmentError, RuntimeError), exc: + if os.path.exists(target_file): + print "Can't find the installed MFC DLL:", exc + pass + + def build_exefile(self, ext): + sources = ext.sources + if sources is None or type(sources) not in (list, tuple): + raise DistutilsSetupError( + ("in 'ext_modules' option (extension '%s'), " + + "'sources' must be present and must be " + + "a list of source filenames") % ext.name) + sources = list(sources) + + fullname = self.get_ext_fullname(ext.name) + if self.inplace: + # ignore build-lib -- put the compiled extension into + # the source tree along with pure Python modules + + modpath = string.split(fullname, '.') + package = string.join(modpath[0:-1], '.') + base = modpath[-1] + + build_py = self.get_finalized_command('build_py') + package_dir = build_py.get_package_dir(package) + ext_filename = os.path.join(package_dir, + self.get_ext_filename(base)) + else: + ext_filename = os.path.join(self.build_lib, + self.get_ext_filename(fullname)) + depends = sources + ext.depends + if not (self.force or newer_group(depends, ext_filename, 'newer')): + log.debug("skipping '%s' executable (up-to-date)", ext.name) + return + else: + log.info("building '%s' executable", ext.name) + + for source in ext.sources: + if "Pythonwin" in ext.name and source.endswith(".rc"): + build_temp = os.path.join(self.build_temp, ext.name) + self.mkpath(os.path.join(build_temp, ext.name)) + obj = os.path.join(build_temp, os.path.splitext(source)[0]+".rc.o") + incdir = "-I" + mfc_dir + "/atlmfc/include" + if self.force or newer_group([source], obj, 'newer'): + try: + self.spawn(["windres", "-i", source, "-o", obj, incdir]) + except CCompilerError: + raise + + # First, scan the sources for SWIG definition files (.i), run + # SWIG on 'em to create .c files, and modify the sources list + # accordingly. + sources = self.swig_sources(sources, ext) + + # Next, compile the source code to object files. + + # XXX not honouring 'define_macros' or 'undef_macros' -- the + # CCompiler API needs to change to accommodate this, and I + # want to do one thing at a time! + + # Two possible sources for extra compiler arguments: + # - 'extra_compile_args' in Extension object + # - CFLAGS environment variable (not particularly + # elegant, but people seem to expect it and I + # guess it's useful) + # The environment variable should take precedence, and + # any sensible compiler will give precedence to later + # command line args. Hence we combine them in order: + extra_args = ext.extra_compile_args or [] + + macros = ext.define_macros[:] + for undef in ext.undef_macros: + macros.append((undef,)) + # Note: custom 'output_dir' needed due to servicemanager.pyd and + # pythonservice.exe being built from the same .cpp file - without + # this, distutils gets confused, as they both try and use the same + # .obj. + output_dir = os.path.join(self.build_temp, ext.name) + kw = {'output_dir': output_dir, + 'macros': macros, + 'include_dirs': ext.include_dirs, + 'debug': self.debug, + 'extra_postargs': extra_args, + 'depends': ext.depends, + } + objects = self.compiler.compile(sources, **kw) + + # XXX -- this is a Vile HACK! + # + # The setup.py script for Python on Unix needs to be able to + # get this list so it can perform all the clean up needed to + # avoid keeping object files around when cleaning out a failed + # build of an extension module. Since Distutils does not + # track dependencies, we have to get rid of intermediates to + # ensure all the intermediates will be properly re-built. + # + self._built_objects = objects[:] + + # Now link the object files together into a "shared object" -- + # of course, first we have to figure out all the other things + # that go into the mix. + if ext.extra_objects: + objects.extend(ext.extra_objects) + extra_args = ext.extra_link_args or [] + + # 2.2 has no 'language' support + kw = { 'libraries': self.get_libraries(ext), + 'library_dirs': ext.library_dirs, + 'runtime_library_dirs': ext.runtime_library_dirs, + 'extra_postargs': extra_args, + 'debug': self.debug, + 'build_temp': self.build_temp, + } + + # Detect target language, if not provided + language = ext.language or self.compiler.detect_language(sources) + kw["target_lang"] = language + + self.compiler.link( + "executable", + objects, ext_filename, **kw) + + def build_extension(self, ext): + # It is well known that some of these extensions are difficult to + # build, requiring various hard-to-track libraries etc. So we + # check the extension list for the extra libraries explicitly + # listed. We then search for this library the same way the C + # compiler would - if we can't find a library, we exclude the + # extension from the build. + # Note we can't do this in advance, as some of the .lib files + # we depend on may be built as part of the process - thus we can + # only check an extension's lib files as we are building it. + why = self._why_cant_build_extension(ext) + if why is not None: + self.excluded_extensions.append((ext, why)) + assert why, "please give a reason, or None" + print "Skipping %s: %s" % (ext.name, why) + return + self.current_extension = ext + + ext.finalize_options(self) + + for source in ext.sources: + if "win32ui" in ext.name and source.endswith(".rc"): + build_temp = os.path.abspath(self.build_temp) + self.mkpath(os.path.join(build_temp, "Pythonwin")) + obj = os.path.join(build_temp, os.path.splitext(source)[0]+".rc.o") + incdir = "-I" + sdk_dir + "/atlmfc/include" + if self.force or newer_group([source], obj, 'newer'): + try: + self.spawn(["windres", "-i", source, "-o", obj, incdir]) + except CCompilerError: + raise + + # ensure the SWIG .i files are treated as dependencies. + for source in ext.sources: + if source.endswith(".i"): + self.find_swig() # for the side-effect of the environment value. + # Find the swig_lib .i files we care about for dependency tracking. + ext.swig_deps = glob.glob(os.path.join(os.environ["SWIG_LIB"], "python", "*.i")) + ext.depends.extend(ext.swig_deps) + break + else: + ext.swig_deps = None + + try: + build_ext.build_extension(self, ext) + except CCompilerError, why: + print "WARNING: building of extension '%s' failed" % (ext.name) + print "" + raise + + def get_ext_filename(self, name): + # The pywintypes and pythoncom extensions have special names + extra_dll = self.debug and "_d.dll" or ".dll" + extra_exe = self.debug and "_d.exe" or ".exe" + # *sob* - python fixed this bug in python 3.1 (bug 6403) + # So in the fixed versions we only get the base name, and if the + # output name is simply 'dir\name' we need to do nothing. + + # The pre 3.1 pywintypes + if name == "pywin32_system32.pywintypes": + return r"pywin32_system32/pywintypes%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) + # 3.1+ pywintypes + elif name == "pywintypes": + return r"pywintypes%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) + # pre 3.1 pythoncom + elif name == "pywin32_system32.pythoncom": + return r"pywin32_system32/pythoncom%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) + # 3.1+ pythoncom + elif name == "pythoncom": + return r"pythoncom%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) + # Pre 3.1 rest. + elif name.endswith("win32.perfmondata"): + return r"win32/perfmondata" + extra_dll + elif name.endswith("win32.pythonservice"): + return r"win32/pythonservice" + extra_exe + elif name.endswith("pythonwin.Pythonwin"): + return r"pythonwin/Pythonwin" + extra_exe + elif name.endswith("isapi.PyISAPI_loader"): + return r"isapi/PyISAPI_loader" + extra_dll + # The post 3.1 rest + elif name in ['perfmondata', 'PyISAPI_loader']: + return name + extra_dll + elif name in ['pythonservice', 'Pythonwin']: + return name + extra_exe + + return build_ext.get_ext_filename(self, name) + + def get_export_symbols(self, ext): + if ext.is_regular_dll: + return None + return build_ext.get_export_symbols(self, ext) + + def find_swig(self): + if "SWIG" in os.environ: + swig = os.environ["SWIG"] + else: + # We know where our swig is + swig = os.path.abspath(r"swig/swig.exe") + lib = os.path.join(os.path.dirname(swig), "swig_lib") + os.environ["SWIG_LIB"] = lib + return swig + + def swig_sources(self, sources, ext=None): + new_sources = [] + swig_sources = [] + swig_targets = {} + # XXX this drops generated C/C++ files into the source tree, which + # is fine for developers who want to distribute the generated + # source -- but there should be an option to put SWIG output in + # the temp dir. + # Adding py3k to the mix means we *really* need to move to generating + # to the temp dir... + target_ext = '.cpp' + for source in sources: + (base, sext) = os.path.splitext(source) + if sext == ".i": # SWIG interface file + if os.path.split(base)[1] in swig_include_files: + continue + swig_sources.append(source) + # Patch up the filenames for various special cases... + if os.path.basename(base) in swig_interface_parents: + swig_targets[source] = base + target_ext + elif self.current_extension.name == "winxpgui" and \ + os.path.basename(base)=="win32gui": + # More vile hacks. winxpmodule is built from win32gui.i - + # just different #defines are setup for windows.h. + new_target = os.path.join(os.path.dirname(base), + "winxpgui_swig%s" % (target_ext,)) + swig_targets[source] = new_target + new_sources.append(new_target) + else: + new_target = '%s_swig%s' % (base, target_ext) + new_sources.append(new_target) + swig_targets[source] = new_target + else: + new_sources.append(source) + + if not swig_sources: + return new_sources + + swig = self.find_swig() + for source in swig_sources: + swig_cmd = [swig, "-python", "-c++", "-v"] + swig_cmd.append("-dnone",) # we never use the .doc files. + swig_cmd.extend(self.current_extension.extra_swig_commands) + if not is_py3k: + swig_cmd.append("-DSWIG_PY2K") + if distutils.util.get_platform() == 'win-x86_64': + swig_cmd.append("-DSWIG_PY64BIT") + else: + swig_cmd.append("-DSWIG_PY32BIT") + target = swig_targets[source] + try: + interface_parent = swig_interface_parents[ + os.path.basename(os.path.splitext(source)[0])] + except KeyError: + # "normal" swig file - no special win32 issues. + pass + else: + # Using win32 extensions to SWIG for generating COM classes. + if interface_parent is not None: + # generating a class, not a module. + swig_cmd.append("-pythoncom") + if interface_parent: + # A class deriving from other than the default + swig_cmd.extend( + ["-com_interface_parent", interface_parent]) + + # This 'newer' check helps python 2.2 builds, which otherwise + # *always* regenerate the .cpp files, meaning every future + # build for any platform sees these as dirty. + # This could probably go once we generate .cpp into the temp dir. + fqsource = os.path.abspath(source) + fqtarget = os.path.abspath(target) + rebuild = self.force or (ext and newer_group(ext.swig_deps + [fqsource], fqtarget)) + log.debug("should swig %s->%s=%s", source, target, rebuild) + if rebuild: + swig_cmd.extend(["-o", fqtarget, fqsource]) + log.info("swigging %s to %s", source, target) + out_dir = os.path.dirname(source) + cwd = os.getcwd() + os.chdir(out_dir) + try: + self.spawn(swig_cmd) + finally: + os.chdir(cwd) + else: + log.info("skipping swig of %s", source) + + return new_sources + class my_install(install): def run(self): install.run(self) @@ -1432,7 +2037,10 @@ if not self.dry_run and not self.root: # We must run the script we just installed into Scripts, as it # may have had 2to3 run over it. - filename = os.path.join(self.prefix, "Scripts", "pywin32_postinstall.py") + if 'MSC' in sys.version: + filename = os.path.join(self.prefix, "Scripts", "pywin32_postinstall.py") + else: + filename = os.path.join(self.prefix, "bin", "pywin32_postinstall.py") if not os.path.isfile(filename): raise RuntimeError("Can't find '%s'" % (filename,)) print "Executing post install script..." @@ -1447,24 +2055,31 @@ # hacks to get a subclassed compiler in. # (otherwise we replace all of build_extension!) def my_new_compiler(**kw): - if 'compiler' in kw and kw['compiler'] in (None, 'msvc'): + if 'compiler' in kw and kw['compiler'] in (None, 'msvc', 'mingw32'): return my_compiler() return orig_new_compiler(**kw) # No way to cleanly wedge our compiler sub-class in. -from distutils import ccompiler, msvccompiler +if 'MSC' in sys.version: + from distutils import ccompiler, msvccompiler +else: + from distutils import ccompiler, cygwinccompiler orig_new_compiler = ccompiler.new_compiler ccompiler.new_compiler = my_new_compiler -base_compiler = msvccompiler.MSVCCompiler +if 'MSC' in sys.version: + base_compiler = msvccompiler.MSVCCompiler +else: + base_compiler = cygwinccompiler.Mingw32CCompiler class my_compiler(base_compiler): # Just one GUIDS.CPP and it gives trouble on mainwin too. Maybe I # should just rename the file, but a case-only rename is likely to be # worse! This can probably go away once we kill the VS project files # though, as we can just specify the lowercase name in the module def. - _cpp_extensions = base_compiler._cpp_extensions + [".CPP"] - src_extensions = base_compiler.src_extensions + [".CPP"] + if 'MSC' in sys.version: + _cpp_extensions = base_compiler._cpp_extensions + [".CPP"] + src_extensions = base_compiler.src_extensions + [".CPP"] def link(self, target_desc, @@ -1476,7 +2091,7 @@ runtime_library_dirs=None, export_symbols=None, debug=0, *args, **kw): - msvccompiler.MSVCCompiler.link( self, + base_compiler.link( self, target_desc, objects, output_filename, @@ -1496,7 +2111,12 @@ except ImportError: ok = False if ok: - stamp_script = os.path.join(sys.prefix, "Lib", "site-packages", + if 'MSC' in sys.version: + stamp_script = os.path.join(sys.prefix, "Lib", "site-packages", + "win32", "lib", "win32verstamp.py") + else: + stamp_script = os.path.join(sys.prefix, "lib", "python%d.%d" + % (sys.version_info[0], sys.version_info[1]), "site-packages", "win32", "lib", "win32verstamp.py") ok = os.path.isfile(stamp_script) if ok: @@ -1515,8 +2135,10 @@ log.info("VersionStamp failed: %s", msg) ok = False if not ok: - log.info('Unable to import verstamp, no version info will be added') - + if 'MSC' in sys.version: + log.info('Unable to import verstamp, no version info will be added') + else: + pass ################################################################ @@ -1540,6 +2162,10 @@ ################################################################ +pywintypes_lib = "" +if 'GCC' in sys.version: + pywintypes_lib = "pywintypes" + pywintypes = WinExt_system32('pywintypes', sources = [ "win32/src/PyACL.cpp", @@ -1564,6 +2190,7 @@ ], extra_compile_args = ['-DBUILD_PYWINTYPES'], libraries = "advapi32 user32 ole32 oleaut32", + implib_name = pywintypes_lib, pch_header = "PyWinTypes.h", ) @@ -1598,8 +2225,8 @@ """), ("timer", "user32", None, None, "win32/src/timermodule.cpp"), ("win2kras", "rasapi32", None, 0x0500, "win32/src/win2krasmodule.cpp"), - ("win32cred", "AdvAPI32 credui", True, 0x0501, 'win32/src/win32credmodule.cpp'), - ("win32crypt", "Crypt32 Advapi32", True, 0x0500, """ + ("win32cred", "advapi32 credui", True, 0x0501, 'win32/src/win32credmodule.cpp'), + ("win32crypt", "advapi32 crypt32", True, 0x0500, """ win32/src/win32crypt/win32cryptmodule.cpp win32/src/win32crypt/win32crypt_structs.cpp win32/src/win32crypt/PyCERTSTORE.cpp @@ -1610,7 +2237,7 @@ win32/src/win32crypt/PyCRYPTPROV.cpp win32/src/win32crypt/PyCTL_CONTEXT.cpp """), - ("win32file", "", None, 0x0500, """ + ("win32file", "ws2_32 mswsock", None, 0x0500, """ win32/src/win32file.i win32/src/win32file_comm.cpp """), @@ -1630,7 +2257,7 @@ ("win32pipe", "", None, None, 'win32/src/win32pipe.i win32/src/win32popen.cpp'), ("win32print", "winspool user32 gdi32", None, 0x0500, "win32/src/win32print/win32print.cpp"), ("win32process", "advapi32 user32", None, 0x0500, "win32/src/win32process.i"), - ("win32profile", "Userenv", True, None, 'win32/src/win32profilemodule.cpp'), + ("win32profile", "userenv", True, None, 'win32/src/win32profilemodule.cpp'), ("win32ras", "rasapi32 user32", None, 0x0500, "win32/src/win32rasmodule.cpp"), ("win32security", "advapi32 user32 netapi32", True, 0x0500, """ win32/src/win32security.i @@ -1651,7 +2278,7 @@ win32/src/win32inet_winhttp.cpp """), ("win32console", "kernel32", True, 0x0501, "win32/src/win32consolemodule.cpp"), - ("win32ts", "WtsApi32", True, 0x0501, "win32/src/win32tsmodule.cpp"), + ("win32ts", "wtsapi32", True, 0x0501, "win32/src/win32tsmodule.cpp"), ("_win32sysloader", "", None, 0x0501, "win32/src/_win32sysloader.cpp"), ("win32transaction", "kernel32", True, 0x0501, "win32/src/win32transactionmodule.cpp"), @@ -1678,7 +2305,7 @@ win32_extensions += [ WinExt_win32("win32evtlog", sources = """ - win32\\src\\win32evtlog_messages.mc win32\\src\\win32evtlog.i + win32/src/win32evtlog_messages.mc win32/src/win32evtlog.i """.split(), libraries="advapi32 oleaut32", delay_load_libraries="wevtapi", @@ -1716,7 +2343,7 @@ # winxptheme WinExt_win32("_winxptheme", sources = ["win32/src/_winxptheme.i"], - libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", + libraries="gdi32 user32 comdlg32 comctl32 shell32 uxtheme", windows_h_version=0x0500, ), ] @@ -1738,6 +2365,8 @@ # but of-course the Vista SDK does it differently... elif sdk_dir and os.path.exists(os.path.join(sdk_dir, "VC", "Lib", "RunTmChk.lib")): win32help_libs += " RunTmChk" +elif 'GCC' in sys.version: + win32help_libs += " runtmchk" win32_extensions += [ WinExt_win32('win32help', sources = ["win32/src/win32helpmodule.cpp"], @@ -1762,6 +2391,11 @@ 'win32com' : 'com/win32com/src', } +pythoncom_lib = pythoncom_dep = "" +if 'GCC' in sys.version: + pythoncom_lib = "pythoncom" + pythoncom_dep = " uuid pywintypes" + # The COM modules. pythoncom = WinExt_system32('pythoncom', sources=(""" @@ -1832,9 +2466,10 @@ %(win32com)s/include/PyIEnumContextProps.h %(win32com)s/include/PyIClientSecurity.h %(win32com)s/include/PyIServerSecurity.h """ % dirs).split(), - libraries = "oleaut32 ole32 user32 urlmon", + libraries = "oleaut32 ole32 user32 urlmon" + pythoncom_dep, export_symbol_file = 'com/win32com/src/PythonCOM.def', extra_compile_args = ['-DBUILD_PYTHONCOM'], + implib_name = pythoncom_lib, pch_header = "stdafx.h", windows_h_version = 0x500, base_address = dll_base_address, @@ -1842,7 +2477,7 @@ dll_base_address += 0x80000 # pythoncom is large! com_extensions = [pythoncom] com_extensions += [ - WinExt_win32com('adsi', libraries="ACTIVEDS ADSIID user32 advapi32", + WinExt_win32com('adsi', libraries="activeds adsiid user32 advapi32", sources=(""" %(adsi)s/adsi.i %(adsi)s/adsi.cpp %(adsi)s/PyIADsContainer.i %(adsi)s/PyIADsContainer.cpp @@ -1872,7 +2507,7 @@ WinExt_win32com('axscript', sources=(""" %(axscript)s/AXScript.cpp - %(axscript)s/GUIDS.CPP %(axscript)s/PyGActiveScript.cpp + %(axscript)s/GUIDS.cpp %(axscript)s/PyGActiveScript.cpp %(axscript)s/PyGActiveScriptError.cpp %(axscript)s/PyGActiveScriptParse.cpp %(axscript)s/PyGActiveScriptSite.cpp %(axscript)s/PyGObjectSafety.cpp %(axscript)s/PyIActiveScript.cpp %(axscript)s/PyIActiveScriptError.cpp @@ -2098,7 +2733,7 @@ %(taskscheduler)s/PyITaskTrigger.cpp """ % dirs).split()), - WinExt_win32com('bits', libraries='Bits', pch_header="bits_pch.h", + WinExt_win32com('bits', libraries='bits', pch_header="bits_pch.h", sources=(""" %(bits)s/bits.cpp %(bits)s/PyIBackgroundCopyManager.cpp @@ -2196,7 +2831,7 @@ "Pythonwin/win32win.cpp", ], extra_compile_args = ['-DBUILD_PYW'], - pch_header="stdafx.h", base_address=dll_base_address, + pch_header="stdafx.h", depends = [ "Pythonwin/stdafx.h", "Pythonwin/win32uiExt.h", @@ -2244,6 +2879,7 @@ "Pythonwin/Win32uiHostGlue.h", "Pythonwin/win32win.h", ], + implib_name="win32ui", optional_headers=['afxres.h']), WinExt_pythonwin("win32uiole", sources = [ @@ -2306,12 +2942,20 @@ ) ) +console_mode = windows_mode = [] +if 'MSC' in sys.version: + console_mode = ["/SUBSYSTEM:CONSOLE"] + windows_mode = ["/SUBSYSTEM:WINDOWS"] +else: + console_mode = ["-mconsole", "-nostartfiles"] + windows_mode = ["-mwindows"] + W32_exe_files = [ WinExt_win32("pythonservice", sources=[os.path.join("win32", "src", s) for s in "PythonService.cpp PythonService.rc".split()], unicode_mode = True, - extra_link_args=["/SUBSYSTEM:CONSOLE"], + extra_link_args=console_mode, libraries = "user32 advapi32 ole32 shell32"), WinExt_pythonwin("Pythonwin", sources = [ @@ -2319,7 +2963,7 @@ "Pythonwin/pythonwin.rc", "Pythonwin/stdafxpw.cpp", ], - extra_link_args=["/SUBSYSTEM:WINDOWS"], + extra_link_args=windows_mode, optional_headers=['afxres.h']), ] @@ -2485,6 +3129,8 @@ dll_base_addresses[name] = dll_base_address dll_base_address += 0x30000 +if 'GCC' in sys.version: + my_build_ext = mingw_build_ext cmdclass = { 'install': my_install, 'build': my_build, @@ -2494,6 +3140,9 @@ 'build_scripts' : my_build_scripts, } +if 'bdist_msi' in sys.argv: + build_id = "%s.%d.%d" % (build_id, sys.version_info[0], sys.version_info[1]) + dist = setup(name="pywin32", version=str(build_id), description="Python for Window Extensions", diff -urN pywin32-220-orig/win32/src/PerfMon/MappingManager.cpp pywin32-220/win32/src/PerfMon/MappingManager.cpp --- pywin32-220-orig/win32/src/PerfMon/MappingManager.cpp 2012-01-02 14:44:48 +0800 +++ pywin32-220/win32/src/PerfMon/MappingManager.cpp 2017-09-28 11:09:58 +0800 @@ -84,7 +84,7 @@ m_pControl->ControlSize = sizeof(MappingManagerControlData); m_pControl->TotalSize = sizeof(MappingManagerControlData); _tcsncpy(m_pControl->ServiceName, szServiceName, MMCD_SERVICE_SIZE); - m_pControl->ServiceName[MMCD_SERVICE_SIZE]=_T('\0'); + m_pControl->ServiceName[MMCD_SERVICE_SIZE / sizeof(TCHAR)]=_T('\0'); _tcsncpy(m_pControl->EventSourceName, szEventSourceName, MMCD_EVENTSOURCE_SIZE); m_pControl->EventSourceName[MMCD_EVENTSOURCE_SIZE]=_T('\0'); diff -urN pywin32-220-orig/win32/src/PerfMon/perfmondata.cpp pywin32-220/win32/src/PerfMon/perfmondata.cpp --- pywin32-220-orig/win32/src/PerfMon/perfmondata.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PerfMon/perfmondata.cpp 2016-06-29 15:48:42 +0800 @@ -445,7 +445,7 @@ --*/ { HKEY hAppKey; - TCHAR LogLevelKeyName[] = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"); + TCHAR LogLevelKeyName[] = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"); TCHAR LogLevelValueName[] = _T("EventLogLevel"); LONG lStatus; diff -urN pywin32-220-orig/win32/src/PyDEVMODE.cpp pywin32-220/win32/src/PyDEVMODE.cpp --- pywin32-220-orig/win32/src/PyDEVMODE.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PyDEVMODE.cpp 2017-03-28 09:11:10 +0800 @@ -361,7 +361,7 @@ #ifndef UNICODE BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODE *ppDEVMODE, BOOL bNoneOk) { - if (ob==Py_None) + if (ob==Py_None){ if (bNoneOk){ *ppDEVMODE=NULL; return TRUE; @@ -370,6 +370,7 @@ PyErr_SetString(PyExc_ValueError,"PyDEVMODE cannot be None in this context"); return FALSE; } + } if (!PyDEVMODE_Check(ob)) return FALSE; *ppDEVMODE=((PyDEVMODEA *)ob)->GetDEVMODE(); @@ -755,7 +756,7 @@ BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODEW *ppDEVMODE, BOOL bNoneOk) { - if (ob==Py_None) + if (ob==Py_None){ if (bNoneOk){ *ppDEVMODE=NULL; return TRUE; @@ -764,6 +765,7 @@ PyErr_SetString(PyExc_ValueError,"PyDEVMODE cannot be None in this context"); return FALSE; } + } if (!PyDEVMODEW_Check(ob)) return FALSE; *ppDEVMODE=((PyDEVMODEW *)ob)->GetDEVMODE(); diff -urN pywin32-220-orig/win32/src/PyHANDLE.cpp pywin32-220/win32/src/PyHANDLE.cpp --- pywin32-220-orig/win32/src/PyHANDLE.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PyHANDLE.cpp 2017-03-28 09:11:10 +0800 @@ -144,7 +144,11 @@ 0, /* nb_coerce (allowed to be zero) - removed in 3.0 */ #endif PyHANDLE::intFunc, /* nb_int */ +#if (PY_VERSION_HEX > 0x03000000) + 0, +#else PyHANDLE::longFunc, /* nb_long */ +#endif PyHANDLE::unaryFailureFunc, /* nb_float */ // These removed in 3.0 #if (PY_VERSION_HEX < 0x03000000) diff -urN pywin32-220-orig/win32/src/PySECURITY_DESCRIPTOR.cpp pywin32-220/win32/src/PySECURITY_DESCRIPTOR.cpp --- pywin32-220-orig/win32/src/PySECURITY_DESCRIPTOR.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PySECURITY_DESCRIPTOR.cpp 2017-03-28 09:11:10 +0800 @@ -786,7 +786,7 @@ { ob_type = &PySECURITY_DESCRIPTORType; _Py_NewReference(this); - cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); + cb = max((SIZE_T)cb, SECURITY_DESCRIPTOR_MIN_LENGTH); PSECURITY_DESCRIPTOR psd = malloc(cb); this->m_psd=NULL; if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)) diff -urN pywin32-220-orig/win32/src/PySecurityObjects.h pywin32-220/win32/src/PySecurityObjects.h --- pywin32-220-orig/win32/src/PySecurityObjects.h 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PySecurityObjects.h 2017-03-28 09:11:10 +0800 @@ -36,7 +36,7 @@ static void deallocFunc(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *obname); static int setattro(PyObject *self, PyObject *obname, PyObject *v); - static struct PYWINTYPES_EXPORT PyMemberDef members[]; + static struct PyMemberDef members[]; static struct PyMethodDef methods[]; static PyObject *get_SECURITY_DESCRIPTOR(PyObject *self, void *unused); @@ -121,7 +121,7 @@ static PyObject *GetSubAuthorityCount(PyObject *self, PyObject *args); static PyObject *GetSubAuthority(PyObject *self, PyObject *args); static PyObject *GetSidIdentifierAuthority(PyObject *self, PyObject *args); - static struct PyMethodDef PySID::methods[]; + static struct PyMethodDef methods[]; protected: PSID m_psid; @@ -159,7 +159,7 @@ /* Python support */ int compare(PyObject *ob); static void deallocFunc(PyObject *ob); - static struct PyMethodDef PyACL::methods[]; + static struct PyMethodDef methods[]; static PyObject *Initialize(PyObject *self, PyObject *args); static PyObject *IsValid(PyObject *self, PyObject *args); diff -urN pywin32-220-orig/win32/src/PyWinObjects.h pywin32-220/win32/src/PyWinObjects.h --- pywin32-220-orig/win32/src/PyWinObjects.h 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PyWinObjects.h 2017-03-28 09:11:10 +0800 @@ -52,7 +52,7 @@ PyObject *str(); PyObject *repr(); int compare(PyObject *ob); - PyObject *PyTime::richcompare(PyObject *other, int op); + PyObject *richcompare(PyObject *other, int op); int print(FILE *fp, int flags); Py_hash_t hash(void); diff -urN pywin32-220-orig/win32/src/PyWinTypes.h pywin32-220/win32/src/PyWinTypes.h --- pywin32-220-orig/win32/src/PyWinTypes.h 2015-12-21 09:49:10 +0800 +++ pywin32-220/win32/src/PyWinTypes.h 2017-03-28 09:11:10 +0800 @@ -43,6 +43,17 @@ #include "windows.h" #undef WRITE_RESTRICTED // stop anyone using the wrong one accidently... +#ifndef _MSC_VER +#define min(x,y) ((x) < (y) ? (x) : (y)) +#define max(x,y) ((x) > (y) ? (x) : (y)) + +#ifndef __try +#define __try try +#endif +#ifndef __except +#define __except(filter) catch(...) +#endif +#endif // Helpers for our modules. // Some macros to help the pywin32 modules co-exist in py2x and py3k. @@ -176,7 +187,7 @@ # ifdef BUILD_PYWINTYPES /* We are building pywintypesxx.dll */ # define PYWINTYPES_EXPORT __declspec(dllexport) -#else +# else /* This module uses pywintypesxx.dll */ # define PYWINTYPES_EXPORT __declspec(dllimport) # if defined(_MSC_VER) @@ -803,7 +814,7 @@ #endif /* MAINWIN */ // catch/__except -#if defined(__MINGW32__) || defined(MAINWIN) +#ifdef MAINWIN #define PYWINTYPES_EXCEPT catch(...) #else #define PYWINTYPES_EXCEPT __except( EXCEPTION_EXECUTE_HANDLER ) diff -urN pywin32-220-orig/win32/src/PyWinTypesmodule.cpp pywin32-220/win32/src/PyWinTypesmodule.cpp --- pywin32-220-orig/win32/src/PyWinTypesmodule.cpp 2012-09-24 10:17:36 +0800 +++ pywin32-220/win32/src/PyWinTypesmodule.cpp 2017-03-28 09:11:10 +0800 @@ -1139,7 +1139,12 @@ } // Function to format a python traceback into a character string. +#ifdef _MSC_VER #define GPEM_ERROR(what) {errorMsg = "";goto done;} +#else +#define GPEM_ERROR(what) {errorMsg = "";goto done;} +#endif + char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) { // Sleep (30000); // Time enough to attach the debugger (barely) diff -urN pywin32-220-orig/win32/src/PythonService.cpp pywin32-220/win32/src/PythonService.cpp --- pywin32-220-orig/win32/src/PythonService.cpp 2012-09-24 10:17:36 +0800 +++ pywin32-220/win32/src/PythonService.cpp 2017-03-28 09:11:10 +0800 @@ -14,6 +14,11 @@ // We use DCOM constants and possible CoInitializeEx. #define _WIN32_DCOM +#ifndef _MSC_VER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 // for PBT_POWERSETTINGCHANGE, POWERBROADCAST_SETTING +#endif + #include "PyWinTypes.h" #include "objbase.h" #include "tchar.h" @@ -114,7 +119,7 @@ DWORD WINAPI service_ctrl_ex(DWORD, DWORD, LPVOID, LPVOID); VOID WINAPI service_ctrl(DWORD); -BOOL RegisterPythonServiceExe(void); +static BOOL RegisterPythonServiceExe(void); static PY_SERVICE_TABLE_ENTRY *FindPythonServiceEntry(LPCTSTR svcName); @@ -302,7 +307,7 @@ if (!PyWinObject_AsTCHAR(obName, &msg)) return NULL; _tcsncpy(g_szEventSourceName, msg, - sizeof g_szEventSourceName/sizeof TCHAR); + sizeof g_szEventSourceName/sizeof(TCHAR)); PyWinObject_FreeTCHAR(msg); g_bRegisteredEventSource = FALSE; // so this name re-registered. if (registerNow) @@ -680,10 +685,10 @@ { if (evtsrc_name && *evtsrc_name) _tcsncpy(g_szEventSourceName, evtsrc_name, - sizeof g_szEventSourceName/sizeof TCHAR); + sizeof g_szEventSourceName/sizeof(TCHAR)); if (evtsrc_file && *evtsrc_file) _tcsncpy(g_szEventSourceFileName, evtsrc_file, - sizeof g_szEventSourceFileName/sizeof TCHAR); + sizeof g_szEventSourceFileName/sizeof(TCHAR)); return TRUE; } @@ -887,7 +892,7 @@ if (instance) ReportPythonError(E_PYS_NOT_CONTROL_HANDLER); // else no instance - an error has already been reported. - if (!bServiceDebug) + if (!bServiceDebug) { if (g_RegisterServiceCtrlHandlerEx) { // Use 2K/XP extended registration if available pe->sshStatusHandle = g_RegisterServiceCtrlHandlerEx(lpszArgv[0], @@ -897,6 +902,7 @@ pe->sshStatusHandle = RegisterServiceCtrlHandler(lpszArgv[0], service_ctrl); } + } } // No instance - we can't start. if (!instance) { @@ -1156,7 +1162,7 @@ DWORD errCode = GetLastError(); if (errCode==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) { // We are not being run by the SCM - print a debug message. - printf("%s - Python Service Manager\n", argv[0]); + printf("%S - Python Service Manager\n", argv[0]); printf("Options:\n"); #ifndef BUILD_FREEZE printf(" -register - register the EXE - this should generally not be necessary.\n"); @@ -1167,7 +1173,7 @@ } else { // Some other nasty error - log it. ReportAPIError(PYS_E_API_CANT_START_SERVICE, errCode); - printf("Could not start the service - error %d\n", errCode); + printf("Could not start the service - error %lu\n", errCode); // Just incase the error was caused by this EXE not being registered #ifndef BUILD_FREEZE RegisterPythonServiceExe(); @@ -1332,7 +1338,7 @@ const int fnameBufSize = MAX_PATH + 1; TCHAR fnameBuf[fnameBufSize]; if (GetModuleFileName( NULL, fnameBuf, fnameBufSize)==0) { - printf("Registration failed due to GetModuleFileName() failing (error %d)\n", GetLastError()); + printf("Registration failed due to GetModuleFileName() failing (error %lu)\n", GetLastError()); return FALSE; } assert (Py_IsInitialized()); @@ -1353,7 +1359,7 @@ if ((rc=RegSetValue(HKEY_LOCAL_MACHINE, keyBuf, REG_SZ, fnameBuf, _tcslen(fnameBuf)))!=ERROR_SUCCESS) { - printf("Registration failed due to RegSetValue() of service EXE - error %d\n", rc); + printf("Registration failed due to RegSetValue() of service EXE - error %lu\n", rc); return FALSE; } // don't bother registering in the event log - do it when we write a log entry. @@ -1443,7 +1449,7 @@ if (!g_szEventSourceFileName[0]) GetModuleFileName(g_hdll, g_szEventSourceFileName, - sizeof g_szEventSourceFileName/sizeof TCHAR); + sizeof g_szEventSourceFileName/sizeof(TCHAR)); HKEY hkey; TCHAR keyName[MAX_PATH]; @@ -1575,12 +1581,12 @@ Py_DECREF(f); if (!hmod) { - PyErr_Format(PyExc_RuntimeError, "servicemanager.__file__ could not be loaded - win32 error code is %d", GetLastError()); + PyErr_Format(PyExc_RuntimeError, "servicemanager.__file__ could not be loaded - win32 error code is %lu", GetLastError()); goto failed; } proc = GetProcAddress(hmod, "PythonService_main"); if (!proc) { - PyErr_Format(PyExc_RuntimeError, "servicemanager.__file__ does not contain PythonService_main - win32 error code is %d", GetLastError()); + PyErr_Format(PyExc_RuntimeError, "servicemanager.__file__ does not contain PythonService_main - win32 error code is %lu", GetLastError()); goto failed; } // A little thread-state dance, as our module will attempt to acquire it. diff -urN pywin32-220-orig/win32/src/PythonServiceMessages.mc pywin32-220/win32/src/PythonServiceMessages.mc --- pywin32-220-orig/win32/src/PythonServiceMessages.mc 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/PythonServiceMessages.mc 2017-03-28 09:11:10 +0800 @@ -134,6 +134,7 @@ Severity=Error SymbolicName=E_UNUSED2 Language=English +Unknown error. . MessageId=0x8 diff -urN pywin32-220-orig/win32/src/_winxptheme.i pywin32-220/win32/src/_winxptheme.i --- pywin32-220-orig/win32/src/_winxptheme.i 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/_winxptheme.i 2017-03-28 09:11:10 +0800 @@ -15,7 +15,9 @@ %include "pywintypes.i" %{ +#undef _WIN32_IE #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 //#define ISOLATION_AWARE_ENABLED 1 @@ -93,6 +95,8 @@ return NULL; } +%typedef RECT RECT; + %typemap(python,ignore) RECT *OUTPUT(RECT temp) { $target = &temp; diff -urN pywin32-220-orig/win32/src/odbc.cpp pywin32-220/win32/src/odbc.cpp --- pywin32-220-orig/win32/src/odbc.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/win32/src/odbc.cpp 2017-03-28 09:11:10 +0800 @@ -105,8 +105,8 @@ } static void cursorDealloc(PyObject *self); -PyMethodDef cursorMethods[]; -PyMemberDef cursorMembers[]; +extern PyMethodDef cursorMethods[]; +extern PyMemberDef cursorMembers[]; static PyTypeObject Cursor_Type = { @@ -152,8 +152,8 @@ static void connectionDealloc(PyObject *self); -PyMethodDef connectionMethods[]; -PyMemberDef connectionMembers[]; +extern struct PyMethodDef connectionMethods[]; +extern struct PyMemberDef connectionMembers[]; static PyTypeObject Connection_Type = { PYWIN_OBJECT_HEAD @@ -458,7 +458,7 @@ } /* @object connection|An object representing an ODBC connection */ -static struct PyMethodDef connectionMethods[] = { +struct PyMethodDef connectionMethods[] = { { "setautocommit", odbcSetAutoCommit, 1 }, /* @pymeth setautocommit|Sets the autocommit mode. */ { "commit", odbcCommit, 1 } , /* @pymeth commit|Commits a transaction. */ { "rollback", odbcRollback, 1 } , /* @pymeth rollback|Rollsback a transaction. */ @@ -467,7 +467,7 @@ {0, 0} }; -static PyMemberDef connectionMembers[] = { +struct PyMemberDef connectionMembers[] = { {"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY}, {NULL} }; @@ -1092,8 +1092,8 @@ parseContext ctx; initParseContext(&ctx, in); - while (*out++ = doParse(&ctx)) - ; + while (*out++ == doParse(&ctx)) + return NULL; return ctx.parmCount; } @@ -1797,7 +1797,7 @@ } /* @object cursor|An object representing an ODBC cursor. */ -static PyMethodDef cursorMethods[] = { +PyMethodDef cursorMethods[] = { { "close", odbcCurClose, 1} , /* @pymeth close|Closes the cursor */ { "execute", odbcCurExec, 1} , /* @pymeth execute|Execute some SQL */ { "fetchone", odbcCurFetchOne, 1} , /* @pymeth fetchone|Fetch one row of data */ @@ -1808,7 +1808,7 @@ {0, 0} }; -static PyMemberDef cursorMembers[] = { +PyMemberDef cursorMembers[] = { {"description", T_OBJECT, offsetof(cursorObject, description), READONLY}, {"error", T_OBJECT, offsetof(cursorObject, cursorError), READONLY}, {NULL} diff -urN pywin32-220-orig/win32/src/stddde.h pywin32-220/win32/src/stddde.h --- pywin32-220-orig/win32/src/stddde.h 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/stddde.h 2017-03-28 09:11:10 +0800 @@ -65,9 +65,9 @@ return TRUE; } protected: - UINT m_wFmt; DWORD m_instance; HSZ m_hszItem; + UINT m_wFmt; HDDEDATA *m_hret; }; diff -urN pywin32-220-orig/win32/src/win2krasmodule.cpp pywin32-220/win32/src/win2krasmodule.cpp --- pywin32-220-orig/win32/src/win2krasmodule.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win2krasmodule.cpp 2017-03-28 09:11:10 +0800 @@ -190,7 +190,7 @@ }; -#define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc +#define ADD_CONSTANT(tok) if (int rc=PyModule_AddIntConstant(module, #tok, tok)) return rc static int AddConstants(PyObject *module) { diff -urN pywin32-220-orig/win32/src/win32api_display.cpp pywin32-220/win32/src/win32api_display.cpp --- pywin32-220-orig/win32/src/win32api_display.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32api_display.cpp 2017-03-28 09:11:10 +0800 @@ -144,29 +144,33 @@ if (name==NULL) return NULL; - if (strcmp(name,"DeviceName")==0) + if (strcmp(name,"DeviceName")==0){ if (pdisplay_device->DeviceName[31]==0) // in case DeviceName fills space and has no trailing NULL return PyWinObject_FromTCHAR(pdisplay_device->DeviceName); else return PyWinObject_FromTCHAR(pdisplay_device->DeviceName, 32); + } - if (strcmp(name,"DeviceString")==0) + if (strcmp(name,"DeviceString")==0){ if (pdisplay_device->DeviceString[127]==0) // in case DeviceString fills space and has no trailing NULL return PyWinObject_FromTCHAR(pdisplay_device->DeviceString); else return PyWinObject_FromTCHAR(pdisplay_device->DeviceString, 128); + } - if (strcmp(name,"DeviceID")==0) + if (strcmp(name,"DeviceID")==0){ if (pdisplay_device->DeviceID[127]==0) // in case DeviceID fills space and has no trailing NULL return PyWinObject_FromTCHAR(pdisplay_device->DeviceID); else return PyWinObject_FromTCHAR(pdisplay_device->DeviceID, 128); + } - if (strcmp(name,"DeviceKey")==0) + if (strcmp(name,"DeviceKey")==0){ if (pdisplay_device->DeviceKey[127]==0) // in case DeviceKey fills space and has no trailing NULL return PyWinObject_FromTCHAR(pdisplay_device->DeviceKey); else return PyWinObject_FromTCHAR(pdisplay_device->DeviceKey, 128); + } return PyObject_GenericGetAttr(self,obname); } @@ -253,7 +257,7 @@ BOOL PyWinObject_AsDISPLAY_DEVICE(PyObject *ob, PDISPLAY_DEVICE *ppDISPLAY_DEVICE, BOOL bNoneOk) { - if (ob==Py_None) + if (ob==Py_None){ if (bNoneOk){ *ppDISPLAY_DEVICE=NULL; return TRUE; @@ -262,6 +266,7 @@ PyErr_SetString(PyExc_ValueError,"PyDISPLAY_DEVICE cannot be None in this context"); return FALSE; } + } if (!PyDISPLAY_DEVICE_Check(ob)) return FALSE; *ppDISPLAY_DEVICE=((PyDISPLAY_DEVICE *)ob)->GetDISPLAY_DEVICE(); diff -urN pywin32-220-orig/win32/src/win32apimodule.cpp pywin32-220/win32/src/win32apimodule.cpp --- pywin32-220-orig/win32/src/win32apimodule.cpp 2014-10-06 08:59:42 +0800 +++ pywin32-220/win32/src/win32apimodule.cpp 2017-03-28 09:11:10 +0800 @@ -587,7 +587,7 @@ if (rc==(HINSTANCE)31) PyErr_SetString(PyWinExc_ApiError, "FindExecutable: There is no association for the file"); else - PyWin_SetAPIError("FindExecutable", (int)rc); + PyWin_SetAPIError("FindExecutable", (INT_PTR)rc); } else ret=Py_BuildValue("(NN)", PyWinLong_FromHANDLE(rc), PyWinObject_FromTCHAR(res)); @@ -1369,7 +1369,7 @@ return NULL; // @pyseeapi LoadCursor PyW32_BEGIN_ALLOW_THREADS - HCURSOR ret = ::LoadCursor(hInstance, MAKEINTRESOURCE(id)); + HCURSOR ret = ::LoadCursor(hInstance, MAKEINTRESOURCE((ULONG_PTR)id)); PyW32_END_ALLOW_THREADS PyWinObject_FreeResourceId(id); if (ret==NULL) ReturnAPIError("LoadCursor"); @@ -2025,7 +2025,7 @@ if (proc==NULL) return ReturnAPIError("GetProcAddress"); // @pyseeapi GetProcAddress - return PyWinLong_FromVoidPtr(proc); + return PyWinLong_FromVoidPtr((PVOID)proc); } // @pymethod |win32api|GetDllDirectory|Returns the DLL search path @@ -4735,7 +4735,7 @@ PyW32_END_ALLOW_THREADS // @pyseeapi ShellExecute if (rc <= (HINSTANCE)32) - PyWin_SetAPIError("ShellExecute", (int)rc ); + PyWin_SetAPIError("ShellExecute", (INT_PTR)rc ); else ret = PyWinLong_FromVoidPtr(rc); } @@ -5774,10 +5774,10 @@ } PyThreadState *stateSave = PyThreadState_Swap(NULL); PyThreadState_Swap(stateSave); - _try { + __try { ret = PyObject_CallObject(obFunc, obArgs); } - _except( PyApplyExceptionFilter( GetExceptionCode(), + __except( PyApplyExceptionFilter( GetExceptionCode(), GetExceptionInformation(), obHandler, &exc_type, diff -urN pywin32-220-orig/win32/src/win32clipboardmodule.cpp pywin32-220/win32/src/win32clipboardmodule.cpp --- pywin32-220-orig/win32/src/win32clipboardmodule.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32clipboardmodule.cpp 2017-03-28 09:11:10 +0800 @@ -1152,7 +1152,7 @@ }; -#define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc +#define ADD_CONSTANT(tok) if (int rc=PyModule_AddIntConstant(module, #tok, tok)) return rc static int AddConstants(PyObject *module) { diff -urN pywin32-220-orig/win32/src/win32consolemodule.cpp pywin32-220/win32/src/win32consolemodule.cpp --- pywin32-220-orig/win32/src/win32consolemodule.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/win32/src/win32consolemodule.cpp 2017-03-28 09:11:10 +0800 @@ -1293,9 +1293,9 @@ &char_info.Attributes)) // @pyparm int|FillAttribute||Text attributes to apply to FillCharacter return NULL; if (PyWinObject_AsSMALL_RECT(obscrollrect, &pscrollrect, FALSE) - &&PyWinObject_AsSMALL_RECT(obcliprect, &pcliprect, TRUE) - &&PyWinObject_AsCOORD(obdestcoord, &pdestcoord, FALSE) - &&PyWinObject_AsSingleWCHAR(obfillchar, &char_info.Char.UnicodeChar)) + && PyWinObject_AsSMALL_RECT(obcliprect, &pcliprect, TRUE) + && PyWinObject_AsCOORD(obdestcoord, &pdestcoord, FALSE) + && PyWinObject_AsSingleWCHAR(obfillchar, &char_info.Char.UnicodeChar)){ if (!ScrollConsoleScreenBuffer(((PyConsoleScreenBuffer *)self)->m_handle, pscrollrect, pcliprect, *pdestcoord, &char_info)) PyWin_SetAPIError("ScrollConsoleScreenBuffer"); @@ -1303,6 +1303,7 @@ Py_INCREF(Py_None); return Py_None; } + } return NULL; } @@ -1809,14 +1810,15 @@ return NULL; CHECK_PFN(AddConsoleAlias); if (PyWinObject_AsWCHAR(obsource, &source, FALSE) - &&PyWinObject_AsWCHAR(obtarget, &target, TRUE) - &&PyWinObject_AsWCHAR(obexename, &exename, FALSE)) + && PyWinObject_AsWCHAR(obtarget, &target, TRUE) + && PyWinObject_AsWCHAR(obexename, &exename, FALSE)){ if (!(*pfnAddConsoleAlias)(source, target, exename)) PyWin_SetAPIError("AddConsoleAlias"); else{ Py_INCREF(Py_None); ret=Py_None; } + } PyWinObject_FreeWCHAR(source); PyWinObject_FreeWCHAR(target); PyWinObject_FreeWCHAR(exename); diff -urN pywin32-220-orig/win32/src/win32crypt/win32cryptmodule.cpp pywin32-220/win32/src/win32crypt/win32cryptmodule.cpp --- pywin32-220-orig/win32/src/win32crypt/win32cryptmodule.cpp 2014-01-25 14:15:48 +0800 +++ pywin32-220/win32/src/win32crypt/win32cryptmodule.cpp 2017-03-28 11:11:10 +0800 @@ -509,11 +509,12 @@ PyWin_SetAPIError("CertEnumSystemStore"); } - if (pvSystemStoreLocationPara!=NULL) + if (pvSystemStoreLocationPara!=NULL){ if (dwFlags & CERT_SYSTEM_STORE_RELOCATE_FLAG) PyWinObject_FreeWCHAR((WCHAR *)cssrp.pwszSystemStore); else PyWinObject_FreeWCHAR((WCHAR *)pvSystemStoreLocationPara); + } return ret; } @@ -597,34 +598,34 @@ } else{ switch((ULONG_PTR)StoreProvider){ - case CERT_STORE_PROV_PHYSICAL: - case CERT_STORE_PROV_FILENAME: - case CERT_STORE_PROV_SYSTEM: - case CERT_STORE_PROV_SYSTEM_REGISTRY: - case CERT_STORE_PROV_LDAP:{ + case (ULONG_PTR)CERT_STORE_PROV_PHYSICAL: + case (ULONG_PTR)CERT_STORE_PROV_FILENAME: + case (ULONG_PTR)CERT_STORE_PROV_SYSTEM: + case (ULONG_PTR)CERT_STORE_PROV_SYSTEM_REGISTRY: + case (ULONG_PTR)CERT_STORE_PROV_LDAP:{ if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) return NULL; free_wchar=TRUE; break; } - case CERT_STORE_PROV_REG:{ + case (ULONG_PTR)CERT_STORE_PROV_REG:{ if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) return NULL; break; } - case CERT_STORE_PROV_FILE:{ + case (ULONG_PTR)CERT_STORE_PROV_FILE:{ if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) return NULL; break; } - case CERT_STORE_PROV_SERIALIZED: - case CERT_STORE_PROV_PKCS7:{ + case (ULONG_PTR)CERT_STORE_PROV_SERIALIZED: + case (ULONG_PTR)CERT_STORE_PROV_PKCS7:{ if (!PyWinObject_AsReadBuffer(obpvPara, (void **)&crypt_data_blob.pbData, &crypt_data_blob.cbData)) return NULL; pvPara=(void *)&crypt_data_blob; break; } - case CERT_STORE_PROV_MEMORY:{ + case (ULONG_PTR)CERT_STORE_PROV_MEMORY:{ // pvPara is not used, warn if something passed in if (obpvPara != Py_None) PyErr_Warn(PyExc_RuntimeWarning, "Para ignored for CERT_STORE_PROV_MEMORY"); diff -urN pywin32-220-orig/win32/src/win32dynamicdialog.cpp pywin32-220/win32/src/win32dynamicdialog.cpp --- pywin32-220-orig/win32/src/win32dynamicdialog.cpp 2013-06-13 17:40:32 +0800 +++ pywin32-220/win32/src/win32dynamicdialog.cpp 2017-03-28 09:11:10 +0800 @@ -54,7 +54,7 @@ #endif #include "win32dynamicdialog.h" -static void DwordAlign(PCHAR *ptr) +void DwordAlign(PCHAR *ptr) { size_t offset = ((ULONG_PTR)*ptr) & 0x03; if (offset > 0) @@ -629,7 +629,7 @@ goto cleanup; if (IS_INTRESOURCE(wclass)) - ret = dlg->Add((WORD)wclass, &tpl, caption); + ret = dlg->Add((LPWSTR)wclass, &tpl, caption); else ret = dlg->Add(wclass, &tpl, caption, datalen, data); diff -urN pywin32-220-orig/win32/src/win32event.i pywin32-220/win32/src/win32event.i --- pywin32-220-orig/win32/src/win32event.i 2014-04-01 15:16:30 +0800 +++ pywin32-220/win32/src/win32event.i 2017-03-28 09:11:10 +0800 @@ -5,13 +5,14 @@ %{ //#define UNICODE +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 %} %include "typemaps.i" %include "pywin32.i" -%typedef void *NULL_ONLY +%typedef void *NULL_ONLY; %typemap(python,in) NULL_ONLY { if ($source != Py_None) { @@ -23,6 +24,7 @@ // only seem able to make this work with an incorrect level of // indirection, and fixing it up inline with a temp. +%typedef PTIMERAPCROUTINE PTIMERAPCROUTINE; %typemap(python,in) PTIMERAPCROUTINE *(PTIMERAPCROUTINE temp) { if ($source != Py_None) { PyErr_SetString(PyExc_TypeError, "This param must be None"); @@ -93,7 +95,6 @@ BOOLAPI CancelWaitableTimer(PyHANDLE handle); #endif -#end // @pyswig |CreateEvent|Creates a waitable event // @rdesc The result is a handle to the created object @@ -387,7 +388,7 @@ BOOL bAlertable // @pyparm bool|bAlertable||alertable wait flag. ); #endif -%typedef DWORD DWORD_WAITAPI +%typedef DWORD DWORD_WAITAPI; %typemap(python,except) DWORD_WAITAPI { Py_BEGIN_ALLOW_THREADS $function diff -urN pywin32-220-orig/win32/src/win32evtlog.i pywin32-220/win32/src/win32evtlog.i --- pywin32-220-orig/win32/src/win32evtlog.i 2015-05-20 16:36:50 +0800 +++ pywin32-220/win32/src/win32evtlog.i 2017-03-28 09:11:10 +0800 @@ -4,9 +4,18 @@ // The Evt* functions are only available on Vista and later. Attempting to call // them on XP will result in the process exiting, rather than a python exception. +%{ +#ifndef _MSC_VER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 // for EVT_SUBSCRIBE_NOTIFY_ACTION +#endif +%} + %include "typemaps.i" %include "pywin32.i" +%typedef HANDLE EVT_HANDLE; + %{ #include @@ -15,6 +24,12 @@ #include "PyWinObjects.h" #include "WinEvt.h" +#ifndef _MSC_VER +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa385781%28v=vs.85%29.aspx +#define EVT_VARIANT_TYPE_ARRAY 128 +#define EVT_VARIANT_TYPE_MASK 0x7F +#endif + // @object PyEVTLOG_HANDLE|Object representing a handle to the windows event log. // Identical to , but calls CloseEventLog() on destruction class PyEVTLOG_HANDLE: public PyHANDLE diff -urN pywin32-220-orig/win32/src/win32file.i pywin32-220/win32/src/win32file.i --- pywin32-220-orig/win32/src/win32file.i 2015-05-20 17:06:02 +0800 +++ pywin32-220/win32/src/win32file.i 2017-03-28 09:11:10 +0800 @@ -24,9 +24,9 @@ %{ #ifndef MS_WINCE //#define FAR -#ifndef _WIN32_WINNT +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 -#endif + #include "winsock2.h" #include "mswsock.h" #include "pywintypes.h" @@ -54,6 +54,9 @@ %include "typemaps.i" %include "pywin32.i" +%typedef DCB DCB; +%typedef COMMTIMEOUTS COMMTIMEOUTS; + %{ #ifdef PYWIN_HAVE_DATETIME_CAPI @@ -1404,11 +1407,11 @@ // the filename is exactly 1 byte! Not clear the best way to // check this, but this works for now - is it at least the size of // the *head* of the struct. - if (nbytes < sizeof DWORD*3+2) + if (nbytes < sizeof((DWORD*)3+2)) return ret; DWORD nbytes_read = 0; while (1) { - PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof WCHAR); + PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof(WCHAR)); if (!fname) { Py_DECREF(ret); return NULL; @@ -5351,7 +5354,7 @@ return NULL; WCHAR *wpathin; - if (wpathin=PyUnicode_AsUnicode(obpathin)){ + if (wpathin==PyUnicode_AsUnicode(obpathin)){ if (htrans) CHECK_PFN(GetFullPathNameTransactedW); WCHAR *wpathret=NULL, *wfilepart, *wpathsave=NULL; @@ -5390,7 +5393,7 @@ PyErr_Clear(); char *cpathin; - if (cpathin=PyString_AsString(obpathin)){ + if (cpathin==PyString_AsString(obpathin)){ if (htrans) CHECK_PFN(GetFullPathNameTransactedA); char *cpathret=NULL, *cfilepart, *cpathsave=NULL; diff -urN pywin32-220-orig/win32/src/win32file_comm.cpp pywin32-220/win32/src/win32file_comm.cpp --- pywin32-220-orig/win32/src/win32file_comm.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32file_comm.cpp 2017-03-28 09:11:10 +0800 @@ -175,7 +175,7 @@ #define GET_BITFIELD_ENTRY(bitfield_name) \ else if (strcmp(name, #bitfield_name)==0) { \ - return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); \ + return PyInt_FromLong(pydcb->m_DCB.bitfield_name); \ } \ PyObject *PyDCB::getattro(PyObject *self, PyObject *obname) @@ -186,7 +186,7 @@ return NULL; if (0) // boot up our macro magic (the macro starts with an 'else') - ; + return NULL; GET_BITFIELD_ENTRY(fBinary) GET_BITFIELD_ENTRY(fParity) GET_BITFIELD_ENTRY(fOutxCtsFlow) @@ -210,7 +210,7 @@ PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ return -1; \ } \ - pydcb->m_DCB.##bitfield_name = PyInt_AsLong(v); \ + pydcb->m_DCB.bitfield_name = PyInt_AsLong(v); \ return 0; \ } \ @@ -369,7 +369,7 @@ #undef GET_BITFIELD_ENTRY #define GET_BITFIELD_ENTRY(bitfield_name) \ else if (strcmp(name, #bitfield_name)==0) { \ - return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.##bitfield_name); \ + return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.bitfield_name); \ } \ PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname) @@ -379,7 +379,7 @@ if (!name) return NULL; if (0) // boot up our macro magic (the macro starts with an 'else') - ; + return NULL; GET_BITFIELD_ENTRY(fCtsHold ) GET_BITFIELD_ENTRY(fDsrHold) GET_BITFIELD_ENTRY(fRlsdHold) @@ -398,7 +398,7 @@ PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ return -1; \ } \ - pyCOMSTAT->m_COMSTAT.##bitfield_name = PyInt_AsLong(v); \ + pyCOMSTAT->m_COMSTAT.bitfield_name = PyInt_AsLong(v); \ return 0; \ } \ diff -urN pywin32-220-orig/win32/src/win32gui.i pywin32-220/win32/src/win32gui.i --- pywin32-220-orig/win32/src/win32gui.i 2014-01-25 14:15:48 +0800 +++ pywin32-220/win32/src/win32gui.i 2017-03-28 09:11:10 +0800 @@ -14,7 +14,9 @@ %{ // #define UNICODE // #define _UNICODE // for CRT string functions +#undef _WIN32_IE #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #ifdef WINXPGUI // This changes the entire world for XP! @@ -25,6 +27,17 @@ %include "typemaps.i" %include "pywintypes.i" +%typedef POINT POINT; +%typedef RECT RECT; +%typedef MSG MSG; +%typedef TRACKMOUSEEVENT TRACKMOUSEEVENT; +%typedef PAINTSTRUCT PAINTSTRUCT; +%typedef ICONINFO ICONINFO; +%typedef LOGFONT LOGFONT; +%typedef MENUITEMINFO MENUITEMINFO; +%typedef NOTIFYICONDATA NOTIFYICONDATA; +%typedef OPENFILENAME OPENFILENAME; + %{ #undef PyHANDLE #include "pywinobjects.h" @@ -373,14 +386,14 @@ } %apply COLORREF {long}; -typedef long COLORREF +typedef long COLORREF; typedef HANDLE WPARAM; typedef HANDLE LPARAM; typedef HANDLE LRESULT; typedef int UINT; -%typedef void *NULL_ONLY +%typedef void *NULL_ONLY; %typemap(python,in) NULL_ONLY { if ($source != Py_None) { @@ -1767,9 +1780,9 @@ %native (PyGetBufferAddressAndLen) PyGetBufferAddressAndLen; -%typedef TCHAR *STRING_OR_ATOM_CW -%typedef TCHAR *RESOURCE_ID -%typedef TCHAR *RESOURCE_ID_NULLOK +%typedef TCHAR *STRING_OR_ATOM_CW; +%typedef TCHAR *RESOURCE_ID; +%typedef TCHAR *RESOURCE_ID_NULLOK; %typemap(python,arginit) STRING_OR_ATOM_CW, RESOURCE_ID, RESOURCE_ID_NULLOK{ $target=NULL; @@ -4596,15 +4609,15 @@ %typemap (python, in) MENUITEMINFO *INPUT (Py_ssize_t target_size){ if (0 != PyObject_AsReadBuffer($source, (const void **)&$target, &target_size)) return NULL; - if (sizeof MENUITEMINFO != target_size) - return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof MENUITEMINFO, target_size); + if (sizeof(MENUITEMINFO) != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof(MENUITEMINFO), target_size); } %typemap (python,in) MENUITEMINFO *BOTH(Py_ssize_t target_size) { if (0 != PyObject_AsWriteBuffer($source, (void **)&$target, &target_size)) return NULL; - if (sizeof MENUITEMINFO != target_size) - return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof MENUITEMINFO, target_size); + if (sizeof(MENUITEMINFO) != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof(MENUITEMINFO), target_size); } %typemap (python, in) MENUINFO *INPUT (Py_ssize_t target_size){ @@ -4750,8 +4763,8 @@ if (0 != PyObject_AsReadBuffer(obInfo, (const void **)&pInfo, &cbInfo)) return NULL; - if (sizeof MENUINFO != cbInfo) - return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte string/buffer (got %d bytes)", sizeof MENUINFO, cbInfo); + if (sizeof(MENUINFO) != cbInfo) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte string/buffer (got %d bytes)", sizeof(MENUINFO), cbInfo); Py_BEGIN_ALLOW_THREADS result = (*pfnSetMenuInfo)(hmenu, pInfo); @@ -4787,8 +4800,8 @@ if (0 != PyObject_AsWriteBuffer(obInfo, (void **)&pInfo, &cbInfo)) return NULL; - if (sizeof MENUINFO != cbInfo) - return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte buffer (got %d bytes)", sizeof MENUINFO, cbInfo); + if (sizeof(MENUINFO) != cbInfo) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte buffer (got %d bytes)", sizeof(MENUINFO), cbInfo); Py_BEGIN_ALLOW_THREADS result = (*pfnGetMenuInfo)(hmenu, pInfo); @@ -7506,13 +7519,13 @@ "structure says it has %d bytes, but %d was provided", (int)struct_bytes, (int)nbytes); // @pyseeapi RegisterDeviceNotification - HDEVNOTIFY not; + HDEVNOTIFY notify; Py_BEGIN_ALLOW_THREADS - not = RegisterDeviceNotification(handle, (void *)filter, flags); + notify = RegisterDeviceNotification(handle, (void *)filter, flags); Py_END_ALLOW_THREADS - if (not == NULL) + if (notify == NULL) return PyWin_SetAPIError("RegisterDeviceNotification"); - return PyWinObject_FromHDEVNOTIFY(not); + return PyWinObject_FromHDEVNOTIFY(notify); } %} %native(RegisterDeviceNotification) PyRegisterDeviceNotification; diff -urN pywin32-220-orig/win32/src/win32helpmodule.cpp pywin32-220/win32/src/win32helpmodule.cpp --- pywin32-220-orig/win32/src/win32helpmodule.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32helpmodule.cpp 2017-03-28 09:11:10 +0800 @@ -18,7 +18,7 @@ #include "PyWinTypes.h" #include "htmlhelp.h" -#define DllExport _declspec(dllexport) +#define DllExport __declspec(dllexport) #define PyW32_BEGIN_ALLOW_THREADS PyThreadState *_save = PyEval_SaveThread(); @@ -2390,7 +2390,7 @@ cmd data must be a PyHH_AKLINK object"); return NULL; } - data = (DWORD)pAKLink; + data = (DWORD_PTR)pAKLink; break; case HH_CLOSE_ALL: @@ -2414,7 +2414,7 @@ cmd data must be a string"); return NULL; } - data = (DWORD)PyString_AsString(dataOb); + data = (DWORD_PTR)PyString_AsString(dataOb); break; case HH_DISPLAY_SEARCH: @@ -2428,7 +2428,7 @@ "HH_DISPLAY_SEARCH data must be a PyHH_FTS_QUERY object"); return NULL; } - data = (DWORD)pFTS_Query; + data = (DWORD_PTR)pFTS_Query; break; case HH_DISPLAY_TEXT_POPUP: @@ -2437,7 +2437,7 @@ "HH_DISPLAY_TEXT_POPUP data must be a PyHH_POPUP object"); return NULL; } - data = (DWORD)pPopup; + data = (DWORD_PTR)pPopup; break; case HH_DISPLAY_TOC: @@ -2451,7 +2451,7 @@ if (dataOb==Py_None) { data = 0; } else if (PyString_Check(dataOb)) { - data = (DWORD)PyString_AsString(dataOb); + data = (DWORD_PTR)PyString_AsString(dataOb); } else { PyErr_SetString(PyExc_TypeError, "HH_DISPLAY_TOC and HH_DISPLAY_TOPIC \ @@ -2473,7 +2473,7 @@ "HH_GET_WIN_TYPE file must be a string"); return NULL; } - data = (DWORD)&pWinType; + data = (DWORD_PTR)&pWinType; break; case HH_HELP_CONTEXT: @@ -2492,7 +2492,7 @@ case HH_INITIALIZE: file = NULL; - data = (DWORD)&dwCookie; + data = (DWORD_PTR)&dwCookie; break; case HH_PRETRANSLATEMESSAGE: @@ -2512,7 +2512,7 @@ "HH_SET_WIN_TYPE data must be a PyHH_WINTYPE object"); return NULL; } - data = (DWORD)pWinType; + data = (DWORD_PTR)pWinType; break; case HH_TP_HELP_CONTEXTMENU: @@ -2551,7 +2551,7 @@ data tuple items must be integers"); return NULL; } - data = (DWORD)ctlIDs; + data = (DWORD_PTR)ctlIDs; break; case HH_UNINITIALIZE: @@ -2628,7 +2628,7 @@ // Module constants: -#define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc +#define ADD_CONSTANT(tok) if (int rc=PyModule_AddIntConstant(module, #tok, tok)) return rc int AddConstants(PyObject *module) { diff -urN pywin32-220-orig/win32/src/win32inet.i pywin32-220/win32/src/win32inet.i --- pywin32-220-orig/win32/src/win32inet.i 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32inet.i 2017-03-28 09:11:10 +0800 @@ -16,6 +16,13 @@ #undef PyHANDLE // undef earlier define, so we are back to the class. #include "pywinobjects.h" +#ifndef _MSC_VER +#define INTERNET_OPTION_HTTP_DECODING 65 +#define INTERNET_OPTION_CODEPAGE_PATH 100 +#define INTERNET_OPTION_CODEPAGE_EXTRA 101 +#define INTERNET_OPTION_IDN 102 +#endif + void CALLBACK PyHINTERNET_StatusChange( HINTERNET hInternet, DWORD_PTR dwContext, diff -urN pywin32-220-orig/win32/src/win32inet_winhttp.cpp pywin32-220/win32/src/win32inet_winhttp.cpp --- pywin32-220-orig/win32/src/win32inet_winhttp.cpp 2012-01-02 14:46:46 +0800 +++ pywin32-220/win32/src/win32inet_winhttp.cpp 2017-03-28 09:11:10 +0800 @@ -128,8 +128,8 @@ i->dwAccessType, // @tupleitem 0|int|dwAccessType| i->lpszProxy, // @tupleitem 2|string|lpszProxy| i->lpszProxyBypass); // @tupleitem 3|string|lpszProxy| - if (i->lpszProxy) GlobalFree(i->lpszProxy); - if (i->lpszProxyBypass) GlobalFree(i->lpszProxyBypass); + if (i->lpszProxy) GlobalFree((void*)i->lpszProxy); + if (i->lpszProxyBypass) GlobalFree((void*)i->lpszProxyBypass); return ret; } diff -urN pywin32-220-orig/win32/src/win32net/win32netmisc.cpp pywin32-220/win32/src/win32net/win32netmisc.cpp --- pywin32-220-orig/win32/src/win32net/win32netmisc.cpp 2011-03-19 10:51:22 +0800 +++ pywin32-220/win32/src/win32net/win32netmisc.cpp 2017-03-28 09:11:10 +0800 @@ -1333,7 +1333,7 @@ #if WINVER >= 0x0500 -extern "C" NetValidateNamefunc pfnNetValidateName=NULL; +NetValidateNamefunc pfnNetValidateName=NULL; // @pymethod |win32net|NetValidateName|Checks that domain/machine/workgroup name is valid for given context // @rdesc Returns none if valid, exception if not // @comm If Account and Password aren't passed, current logon credentials are used @@ -1378,8 +1378,8 @@ return ret; } -extern "C" NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy=NULL; -extern "C" NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree=NULL; +NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy=NULL; +NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree=NULL; static void PyObject_CleanupAUTH_INPUT(NET_VALIDATE_AUTHENTICATION_INPUT_ARG *p) { diff -urN pywin32-220-orig/win32/src/win32pdhmodule.cpp pywin32-220/win32/src/win32pdhmodule.cpp --- pywin32-220-orig/win32/src/win32pdhmodule.cpp 2012-06-22 11:08:42 +0800 +++ pywin32-220/win32/src/win32pdhmodule.cpp 2017-03-28 09:11:10 +0800 @@ -1016,7 +1016,7 @@ #define SET_BOOL(r, i) { \ if (i|DriverName||Name of driver to remove // @comm Does not delete associated driver files - use if this is required if (PyArg_ParseTuple(args,"OOO:DeletePrinterDriver", &observername, &obenvironment, &obdrivername) - &&PyWinObject_AsWCHAR(observername, &servername, TRUE) - &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) - &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + && PyWinObject_AsWCHAR(observername, &servername, TRUE) + && PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + && PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)){ if (DeletePrinterDriverW(servername, environment, drivername)){ Py_INCREF(Py_None); ret=Py_None; } else PyWin_SetAPIError("DeletePrinterDriver"); + } if (servername!=NULL) PyWinObject_FreeWCHAR(servername); @@ -2536,15 +2538,16 @@ // @pyparm int|VersionFlag||Can be 0,1,2, or 3. Only used if DPD_DELETE_SPECIFIC_VERSION is specified in DeleteFlag if (PyArg_ParseTuple(args,"OOOll:DeletePrinterDriverEx", &observername, &obenvironment, &obdrivername, &deleteflag, &versionflag) - &&PyWinObject_AsWCHAR(observername, &servername, TRUE) - &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) - &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + && PyWinObject_AsWCHAR(observername, &servername, TRUE) + && PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + && PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)){ if ((*pfnDeletePrinterDriverEx)(servername, environment, drivername, deleteflag, versionflag)){ Py_INCREF(Py_None); ret=Py_None; } else PyWin_SetAPIError("DeletePrinterDriverEx"); + } if (servername!=NULL) PyWinObject_FreeWCHAR(servername); diff -urN pywin32-220-orig/win32/src/win32process.i pywin32-220/win32/src/win32process.i --- pywin32-220-orig/win32/src/win32process.i 2013-06-13 17:40:32 +0800 +++ pywin32-220/win32/src/win32process.i 2017-03-28 09:11:10 +0800 @@ -1097,7 +1097,7 @@ #endif // MS_WINCE // Special result handling for SuspendThread and ResumeThread -%typedef DWORD DWORD_SR_THREAD +%typedef DWORD DWORD_SR_THREAD; %typemap(python,out) DWORD_SR_THREAD { $target = PyInt_FromLong($source); } diff -urN pywin32-220-orig/win32/src/win32rasmodule.cpp pywin32-220/win32/src/win32rasmodule.cpp --- pywin32-220-orig/win32/src/win32rasmodule.cpp 2012-01-02 14:42:24 +0800 +++ pywin32-220/win32/src/win32rasmodule.cpp 2017-03-28 09:11:10 +0800 @@ -463,7 +463,7 @@ if (obCallback==Py_None) { pNotification = NULL; } else if (PyCallable_Check(obCallback)) { - pNotification = PyRasDialFunc1; + pNotification = (void*)PyRasDialFunc1; notType = 1; } else if (PyInt_Check(obCallback)) { if (!PyWinLong_AsVoidPtr(obCallback, &pNotification)) @@ -725,7 +725,7 @@ TCHAR buf[512]; // @pyseeapi RasGetErrorString - if (rc=RasGetErrorString(error, buf, sizeof(buf)/sizeof(buf[0]))) + if (int rc=RasGetErrorString(error, buf, sizeof(buf)/sizeof(buf[0]))) return ReturnRasError("RasGetErrorString"); return PyWinObject_FromTCHAR(buf); } @@ -741,7 +741,7 @@ return NULL; // @pyseeapi RasHangUp - if (rc=RasHangUp(hras)) + if (int rc=RasHangUp(hras)) return ReturnRasError("RasHangup"); Py_INCREF(Py_None); return Py_None; @@ -810,9 +810,9 @@ {NULL, NULL} }; -#define ADD_CONSTANT(tok) if (rc = PyModule_AddIntConstant(module, #tok, tok)) return rc -#define ADD_ENUM(parta, partb) if (rc = PyModule_AddIntConstant(module, #parta "_" #partb, parta::partb)) return rc -#define ADD_ENUM3(parta, partb, partc) if (rc = PyModule_AddIntConstant(module, #parta "_" #partb "_" #partc, parta::partb::partc)) return rc +#define ADD_CONSTANT(tok) if (int rc = PyModule_AddIntConstant(module, #tok, tok)) return rc +#define ADD_ENUM(parta, partb) if (int rc = PyModule_AddIntConstant(module, #parta "_" #partb, parta::partb)) return rc +#define ADD_ENUM3(parta, partb, partc) if (int rc = PyModule_AddIntConstant(module, #parta "_" #partb "_" #partc, parta::partb::partc)) return rc static int AddConstants(PyObject *module) { diff -urN pywin32-220-orig/win32/src/win32security.i pywin32-220/win32/src/win32security.i --- pywin32-220-orig/win32/src/win32security.i 2012-09-24 10:17:38 +0800 +++ pywin32-220/win32/src/win32security.i 2017-03-28 09:11:10 +0800 @@ -5,6 +5,7 @@ %module win32security // An interface to the win32 security API's %{ +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 // We are 2k specific %} @@ -76,7 +77,7 @@ typedef PSecurityFunctionTableW (SEC_ENTRY *InitSecurityInterfacefunc)(void); static InitSecurityInterfacefunc pfnInitSecurityInterface=NULL; -extern PSecurityFunctionTableW psecurityfunctiontable=NULL; +PSecurityFunctionTableW psecurityfunctiontable=NULL; typedef BOOL (WINAPI *TranslateNamefunc)(LPCTSTR, EXTENDED_NAME_FORMAT, EXTENDED_NAME_FORMAT, LPTSTR, PULONG); static TranslateNamefunc pfnTranslateName=NULL; @@ -89,20 +90,20 @@ // function pointers used in win32security_sspi.cpp and win32security_ds.cpp -extern DsBindfunc pfnDsBind=NULL; -extern DsUnBindfunc pfnDsUnBind=NULL; -extern DsGetSpnfunc pfnDsGetSpn=NULL; -extern DsWriteAccountSpnfunc pfnDsWriteAccountSpn=NULL; -extern DsFreeSpnArrayfunc pfnDsFreeSpnArray=NULL; -extern DsGetDcNamefunc pfnDsGetDcName=NULL; -extern DsCrackNamesfunc pfnDsCrackNames=NULL; -extern DsListInfoForServerfunc pfnDsListInfoForServer=NULL; -extern DsListServersForDomainInSitefunc pfnDsListServersForDomainInSite=NULL; -extern DsListServersInSitefunc pfnDsListServersInSite=NULL; -extern DsListSitesfunc pfnDsListSites=NULL; -extern DsListDomainsInSitefunc pfnDsListDomainsInSite=NULL; -extern DsListRolesfunc pfnDsListRoles=NULL; -extern DsFreeNameResultfunc pfnDsFreeNameResult=NULL; +DsBindfunc pfnDsBind=NULL; +DsUnBindfunc pfnDsUnBind=NULL; +DsGetSpnfunc pfnDsGetSpn=NULL; +DsWriteAccountSpnfunc pfnDsWriteAccountSpn=NULL; +DsFreeSpnArrayfunc pfnDsFreeSpnArray=NULL; +DsGetDcNamefunc pfnDsGetDcName=NULL; +DsCrackNamesfunc pfnDsCrackNames=NULL; +DsListInfoForServerfunc pfnDsListInfoForServer=NULL; +DsListServersForDomainInSitefunc pfnDsListServersForDomainInSite=NULL; +DsListServersInSitefunc pfnDsListServersInSite=NULL; +DsListSitesfunc pfnDsListSites=NULL; +DsListDomainsInSitefunc pfnDsListDomainsInSite=NULL; +DsListRolesfunc pfnDsListRoles=NULL; +DsFreeNameResultfunc pfnDsFreeNameResult=NULL; static HMODULE advapi32_dll=NULL; static HMODULE secur32_dll =NULL; @@ -449,7 +450,7 @@ BOOL PyWinObject_AsLSA_UNICODE_STRING(PyObject *obstr, LSA_UNICODE_STRING *plsaus, BOOL bNoneOk) { DWORD len = 0; - ZeroMemory(plsaus, sizeof(plsaus)); + ZeroMemory(plsaus, sizeof(plsaus)/sizeof(WCHAR)); if (!PyWinObject_AsWCHAR(obstr, &plsaus->Buffer, bNoneOk, &len)) return FALSE; // Length is in bytes, not characters, and does not include null terminator @@ -1884,6 +1885,8 @@ if (!GetTokenInformation(handle, typ, &dwordbuf, bufSize, &retLength)) return PyWin_SetAPIError("GetTokenInformation"); return PyLong_FromUnsignedLong(dwordbuf); + default: + break; } PyObject *ret = NULL; @@ -3339,12 +3342,14 @@ if (PyWinObject_AsHANDLE(obExistingTokenHandle, &ExistingTokenHandle)) if (PyWinObject_AsSID_AND_ATTRIBUTESArray(obSidsToDisable, &SidsToDisable, &DisableSidCount)) if (PyWinObject_AsSID_AND_ATTRIBUTESArray(obSidsToRestrict, &SidsToRestrict, &RestrictedSidCount)) - if (PyWinObject_AsLUID_AND_ATTRIBUTESArray(obPrivilegesToDelete, &PrivilegesToDelete, &DeletePrivilegeCount)) + if (PyWinObject_AsLUID_AND_ATTRIBUTESArray(obPrivilegesToDelete, &PrivilegesToDelete, &DeletePrivilegeCount)){ if ((*pfnCreateRestrictedToken)(ExistingTokenHandle,Flags,DisableSidCount,SidsToDisable, - DeletePrivilegeCount,PrivilegesToDelete,RestrictedSidCount,SidsToRestrict,&NewTokenHandle)) + DeletePrivilegeCount,PrivilegesToDelete,RestrictedSidCount,SidsToRestrict,&NewTokenHandle)){ ret=PyWinObject_FromHANDLE(NewTokenHandle); - else + }else{ PyWin_SetAPIError("CreateRestrictedToken",GetLastError()); + } + } if (SidsToDisable!=NULL) free(SidsToDisable); if (PrivilegesToDelete!=NULL) @@ -3563,9 +3568,9 @@ return FALSE; } static const BOOL none_ok = TRUE; // NULL seems OK anywhere - if (!PyWinObject_AsWCHAR(obUser, &pAuthData->User, none_ok, &pAuthData->UserLength) || \ - !PyWinObject_AsWCHAR(obDomain, &pAuthData->Domain, none_ok, &pAuthData->DomainLength) || \ - !PyWinObject_AsWCHAR(obPW, &pAuthData->Password, none_ok, &pAuthData->PasswordLength)) { + if (!PyWinObject_AsWCHAR(obUser, (WCHAR**)&pAuthData->User, none_ok, &pAuthData->UserLength) || \ + !PyWinObject_AsWCHAR(obDomain, (WCHAR**)&pAuthData->Domain, none_ok, &pAuthData->DomainLength) || \ + !PyWinObject_AsWCHAR(obPW, (WCHAR**)&pAuthData->Password, none_ok, &pAuthData->PasswordLength)) { PyErr_Clear(); PyErr_SetString(PyExc_TypeError, err_msg); return FALSE; @@ -3579,11 +3584,11 @@ if (!pAuthData) return; if (pAuthData->User) - PyWinObject_FreeWCHAR(pAuthData->User); + PyWinObject_FreeWCHAR((WCHAR*)pAuthData->User); if (pAuthData->Domain) - PyWinObject_FreeWCHAR(pAuthData->Domain); + PyWinObject_FreeWCHAR((WCHAR*)pAuthData->Domain); if (pAuthData->Password) - PyWinObject_FreeWCHAR(pAuthData->Password); + PyWinObject_FreeWCHAR((WCHAR*)pAuthData->Password); } %} diff -urN pywin32-220-orig/win32/src/win32service.i pywin32-220/win32/src/win32service.i --- pywin32-220-orig/win32/src/win32service.i 2012-09-24 10:17:38 +0800 +++ pywin32-220/win32/src/win32service.i 2017-03-28 09:11:10 +0800 @@ -3,9 +3,18 @@ %module win32service // An interface to the Windows NT Service API +%{ +#ifndef _MSC_VER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 // for SERVICE_* +#endif +%} + %include "typemaps.i" %include "pywin32.i" +%typedef SERVICE_STATUS SERVICE_STATUS; + %{ #undef PyHANDLE #include "PyWinObjects.h" @@ -24,6 +33,13 @@ // according to msdn, 256 is limit for service names and service display names #define MAX_SERVICE_NAME_LEN 256 +#ifndef _MSC_VER +#define SERVICE_ACCEPT_PRESHUTDOWN 0x00000100 +#define SERVICE_CONTROL_PRESHUTDOWN 0x0000000F +#define SERVICE_SID_TYPE_NONE 0x00000000 +#define SERVICE_SID_TYPE_RESTRICTED 0x00000003 +#define SERVICE_SID_TYPE_UNRESTRICTED 0x00000001 +#endif %} %init %{ diff -urN pywin32-220-orig/win32/src/win32tsmodule.cpp pywin32-220/win32/src/win32tsmodule.cpp --- pywin32-220-orig/win32/src/win32tsmodule.cpp 2014-04-01 15:16:30 +0800 +++ pywin32-220/win32/src/win32tsmodule.cpp 2017-03-28 09:11:10 +0800 @@ -96,7 +96,7 @@ &WTSConfigClass)) // @pyparm int|ConfigClass||Type of information to be returned, win32ts.WTSUserConfig* return NULL; if (PyWinObject_AsWCHAR(obServerName, &ServerName, TRUE) - &&PyWinObject_AsWCHAR(obUserName, &UserName, FALSE)) + && PyWinObject_AsWCHAR(obUserName, &UserName, FALSE)){ if (!WTSQueryUserConfig(ServerName, UserName, WTSConfigClass, &buf, &bufsize)) PyWin_SetAPIError("WTSQueryUserConfig"); else @@ -128,6 +128,7 @@ default: PyErr_SetString(PyExc_NotImplementedError,"Config class not supported yet"); } + } PyWinObject_FreeWCHAR(ServerName); PyWinObject_FreeWCHAR(UserName);