diff --git a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch index af17650f64..c6b13c0f36 100644 --- a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch +++ b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch @@ -1,414 +1,797 @@ -diff -aur 000/setup.py 001/setup.py ---- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 -+++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 -@@ -264,16 +264,7 @@ - MSVCCompiler.link = monkeypatched_link +--- pywin32-b301-orig/setup.py 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/setup.py 2021-10-05 23:54:56 +0800 +@@ -185,8 +185,11 @@ + # the manifest - even without a reference to the CRT assembly - is enough + # to prevent the extension from loading. For more details, see + # http://bugs.python.org/issue7833 +-from distutils.msvc9compiler import MSVCCompiler +-MSVCCompiler._orig_spawn = MSVCCompiler.spawn ++if 'MSC' in sys.version: ++ from distutils.msvc9compiler import MSVCCompiler ++ MSVCCompiler._orig_spawn = MSVCCompiler.spawn ++else: ++ from distutils.cygwinccompiler import Mingw32CCompiler + + # We need to override this method for versions where issue7833 *has* landed + # (ie, 2.7 and 3.2+) +@@ -204,7 +207,8 @@ + return orig_manifest, rid + return None + +-MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info ++if 'MSC' in sys.version: ++ MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info + + def monkeypatched_spawn(self, cmd): + is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"') +@@ -237,10 +241,20 @@ + shutil.copyfile(mfname, mfname + ".orig") + break + +-MSVCCompiler.spawn = monkeypatched_spawn ++if 'MSC' in sys.version: ++ MSVCCompiler.spawn = monkeypatched_spawn ++else: ++ from distutils.spawn import spawn -sdk_info = find_platform_sdk_dir() --if not sdk_info: -- print() -- print("It looks like you are trying to build pywin32 in an environment without") -- print("the necessary tools installed. It's much easier to grab binaries!") -- print() -- print("Please read the docstring at the top of this file, or read README.md") -- print("for more information.") -- print() -- raise RuntimeError("Can't find the Windows SDK") -+sdk_info = { 'include': '', 'lib': '' } - - class WinExt (Extension): - # Base class for all win32 extensions, with some predefined -@@ -305,11 +296,20 @@ ++if 'MSC' in sys.version: ++ sdk_info = find_platform_sdk_dir() ++else: ++ if "SDKDIR" in os.environ: ++ sdk_info = os.environ.get("SDKDIR") ++ else: ++ sdk_info = "." ++ + if not sdk_info: + print() + print("It looks like you are trying to build pywin32 in an environment without") +@@ -289,7 +303,8 @@ extra_link_args = extra_link_args or [] if export_symbol_file: - extra_link_args.append("/DEF:" + export_symbol_file) -+ extra_link_args.append(export_symbol_file) ++ if 'MSC' in sys.version: ++ extra_link_args.append("/DEF:" + export_symbol_file) # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. - define_macros = define_macros or [] -+ define_macros.append(("NTDDI_VERSION", 0x06000000)) -+ define_macros.append(("_WIN32_WINNT", 0x0600)) -+ define_macros.append(("USE_COM_CONTEXT_DEF", None)) -+ define_macros.append(("NO_PYCOM_IDISPATCHEX", None)) -+ define_macros.append(("__in", "")) -+ define_macros.append(("__in_opt", "")) -+ define_macros.append(("__out", "")) -+ define_macros.append(("__deref_out_ecount_full(x)", "")) -+ define_macros.append(("_Check_return_", "")) - define_macros.append(("DISTUTILS_BUILD", None)) - define_macros.append(("_CRT_SECURE_NO_WARNINGS", None)) - self.pch_header = pch_header -@@ -638,7 +632,7 @@ +@@ -323,7 +338,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 [] - def finalize_options(self): - build_ext.finalize_options(self) -- self.windows_h_version = None -+ self.windows_h_version = 0x0600 - # 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) -@@ -865,7 +868,8 @@ - log.debug("Looked for %s in %s", lib, look_dirs) - return "No library '%s'" % lib - self.found_libraries[lib.lower()] = found -- patched_libs.append(os.path.splitext(os.path.basename(found))[0]) -+ lib_name = re.sub(r'^lib(.*)\.a', r'\1', os.path.basename(found)) -+ patched_libs.append(os.path.splitext(lib_name)[0]) +@@ -383,6 +398,47 @@ + if found_mfc: + break - if ext.platforms and self.plat_name not in ext.platforms: - return "Only available on platforms %s" % (ext.platforms,) -@@ -975,6 +979,9 @@ - if not self.compiler.initialized: - self.compiler.initialize() - -+ if self.mingw32: -+ self.compiler.shared_lib_extension = '.dll' ++ else: ++ # Set our C++ standard ++ self.extra_compile_args.append("-std=c++14") ++ self.extra_compile_args.append("-fpermissive") + - self._fixup_sdk_dirs() - - # Here we hack a "pywin32" directory (one of 'win32', 'win32com', -@@ -1226,7 +1233,7 @@ - # XXX This has to be changed for mingw32 - # Get the .lib files we need. This is limited to pywintypes, - # pythoncom and win32ui - but the first 2 have special names -- extra = self.debug and "_d.lib" or ".lib" -+ extra = self.debug and "_d.def" or ".def" - if ext.name in ("pywintypes", "pythoncom"): - # The import libraries are created as PyWinTypes23.lib, but - # are expected to be pywintypes.lib. -@@ -1551,7 +1549,7 @@ ++ # MinGW-w64 doesn't define these ++ self.extra_compile_args.append("-D__WIN32__") ++ # Extra compile args ++ if '64 bit' in sys.version: ++ self.extra_compile_args.append("-D_M_X64") ++ self.extra_compile_args.append("-D_AMD64_") ++ else: ++ self.extra_compile_args.append("-D_M_IX86") ++ self.extra_compile_args.append("-D_X86_") ++ ++ # 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)) ++ ++ if '64 bit' in sys.version: ++ self.extra_link_args.append("-m64") ++ else: ++ self.extra_link_args.append("-m32") ++ ++ # 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") ++ + self.extra_compile_args.append("-DUNICODE") + self.extra_compile_args.append("-D_UNICODE") + self.extra_compile_args.append("-DWINNT") +@@ -390,7 +446,20 @@ + class WinExt_pythonwin(WinExt): + def __init__ (self, name, **kw): + 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']) ++ ++ kw["libraries"] = kw.get("libraries", "") + " mfc100u" ++ if name == 'win32ui': ++ kw["libraries"] = kw.get("libraries", "") + " winspool" ++ elif name == 'win32uiole': ++ kw["libraries"] = kw.get("libraries", "") + " win32ui pythoncom" ++ elif name == 'dde': ++ kw["libraries"] = kw.get("libraries", "") + " win32ui" ++ kw["libraries"] = kw.get("libraries", "") + " pywintypes" + + WinExt.__init__(self, name, **kw) + def get_pywin32_dir(self): +@@ -400,7 +469,7 @@ + def finalize_options(self, build_ext): + WinExt_pythonwin.finalize_options(self, build_ext) + +- if build_ext.mingw32: ++ if 'GCC' in sys.version: + self.extra_link_args.append('-mwindows') + else: + self.extra_link_args.append('/SUBSYSTEM:WINDOWS') +@@ -410,6 +479,9 @@ + + class WinExt_win32(WinExt): + def __init__ (self, name, **kw): ++ if 'GCC' in sys.version: ++ if name not in ['_win32sysloader']: ++ kw["libraries"] = kw.get("libraries", "") + " pywintypes" + WinExt.__init__(self, name, **kw) + def get_pywin32_dir(self): + return "win32" +@@ -418,7 +490,7 @@ + def finalize_options(self, build_ext): + WinExt_win32.finalize_options(self, build_ext) + +- if build_ext.mingw32: ++ if 'GCC' in sys.version: + self.extra_link_args.append('-mconsole') + self.extra_link_args.append('-municode') + else: +@@ -433,6 +505,8 @@ + class WinExt_win32com(WinExt): + def __init__ (self, name, **kw): + kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32" ++ if 'GCC' in sys.version: ++ kw["libraries"] = kw.get("libraries", "") + " uuid pythoncom pywintypes" + + # COM extensions require later windows headers. + if not kw.get("windows_h_version"): +@@ -1187,6 +1261,404 @@ + + 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 '64 bit' in sys.version: ++ amd64_dir = "/amd64" ++ x64_dir = "/x64" ++ else: ++ amd64_dir = "" ++ x64_dir = "" ++ # Windows SDK & Exchange SDK custom dirs ++ self.include_dirs.append(sdk_info + '/include') ++ self.library_dirs.append(sdk_info + '/lib' + x64_dir) ++ # VC++ dirs ++ self.include_dirs.append(sdk_info + '/atlmfc/include') ++ self.library_dirs.append(sdk_info + '/atlmfc/lib' + amd64_dir) ++ ++ self.excluded_extensions = [] # list of (ext, why) ++ self.swig_cpp = True ++ ++ def _why_cant_build_extension(self, ext): ++ # Return None, or a reason it can't be built. ++ if ext.name in ["exchange", "exchdapi"]: ++ return "No library for utility functions available." ++ ++ # Stubs not present; adsiid, bits, ntquery ++ if ext.name in ['adsi', 'bits', 'ifilter']: ++ return "No library for utility functions available." ++ ++ # Comment out below to enable Pythonwin extensions ++ 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 in 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_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, ++ # 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) ++ ++ # Search the MFC dll. ++ try: ++ target_dir = os.path.join(self.build_lib, "pythonwin") ++ mfc_files = ["libmfc100u.dll"] ++ ++ plat_dir = "x86" ++ if '64 bit' in sys.version: ++ plat_dir = "x64" ++ ++ # Locate the redist directory. ++ target_file = os.path.join(target_dir, "Pythonwin.exe") ++ if os.path.exists(target_file): ++ mfcdll_dir = os.path.join(sdk_info, "redist", plat_dir) ++ 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) as exc: ++ if os.path.exists(target_file): ++ print("Cannot find the requested 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 exe '%s'", ext.name) ++ log.info("building '%s' executable", ext.name) ++ ++ # 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) ++ 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) ++ ++ 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) ++ ++ # 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: ++ print("") ++ print("WARNING: building of extension '%s' failed" % (ext.name)) ++ print("") ++ return ++ ++ 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 nothing. ++ ++ if name == "pywintypes": ++ return "pywintypes%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) ++ elif name == "pythoncom": ++ return "pythoncom%d%d%s" % (sys.version_info[0], sys.version_info[1], extra_dll) ++ elif name in ['perfmondata', 'PyISAPI_loader']: ++ return name + extra_dll ++ elif name.endswith("win32.pythonservice"): ++ return "win32/pythonservice" + extra_exe ++ elif name.endswith("pythonwin.Pythonwin"): ++ return "pythonwin/Pythonwin" + 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("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 = {} ++ ++ target_ext = '.cpp' ++ for source in sources: ++ (base, sext) = os.path.splitext(source) ++ if sext == ".i": ++ 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++"] ++ swig_cmd.append("-dnone",) # we never use the .doc files. ++ swig_cmd.extend(self.current_extension.extra_swig_commands) ++ ++ if '64 bit' in sys.version: ++ 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)) ++ ++ # can remove once edklib is no longer used for 32-bit builds ++ if source == "com/win32comext/mapi/src/exchange.i": ++ rebuild = True ++ ++ 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) +@@ -1205,7 +1677,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.install_scripts, "pywin32_postinstall.py") ++ if 'MSC' in sys.version: ++ filename = os.path.join(self.install_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...") +@@ -1219,23 +1694,30 @@ + ]) + + 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"] ++ if 'MSC' in sys.version: ++ _cpp_extensions = base_compiler._cpp_extensions + [".CPP"] + src_extensions = base_compiler.src_extensions + [".CPP"] + + def link(self, +@@ -1248,7 +1730,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, +@@ -1297,7 +1779,7 @@ + return (e, b) + + sources = sorted(sources, key=key_reverse_mc) +- return msvccompiler.MSVCCompiler.compile(self, sources, **kwargs) ++ return base_compiler.compile(self, sources, **kwargs) + + ################################################################ + +@@ -1314,6 +1796,12 @@ + + ################################################################ + ++pywintypes_lib = "" ++win32file_dep = "" ++if 'GCC' in sys.version: ++ pywintypes_lib = "pywintypes" ++ win32file_dep = "ws2_32 mswsock" ++ + pywintypes = WinExt_system32('pywintypes', + sources = [ + "win32/src/PyACL.cpp", +@@ -1338,6 +1826,7 @@ + ], + extra_compile_args = ['-DBUILD_PYWINTYPES'], + libraries = "advapi32 user32 ole32 oleaut32", ++ implib_name = pywintypes_lib, + pch_header = "PyWinTypes.h", + ) + +@@ -1371,8 +1860,8 @@ + """), + ("timer", "user32", None, "win32/src/timermodule.cpp"), + ("win2kras", "rasapi32", 0x0500, "win32/src/win2krasmodule.cpp"), +- ("win32cred", "AdvAPI32 credui", 0x0501, 'win32/src/win32credmodule.cpp'), +- ("win32crypt", "Crypt32 Advapi32", 0x0500, """ ++ ("win32cred", "advapi32 credui", 0x0501, 'win32/src/win32credmodule.cpp'), ++ ("win32crypt", "advapi32 crypt32", 0x0500, """ + win32/src/win32crypt/win32cryptmodule.cpp + win32/src/win32crypt/win32crypt_structs.cpp + win32/src/win32crypt/PyCERTSTORE.cpp +@@ -1383,7 +1872,7 @@ win32/src/win32crypt/PyCRYPTPROV.cpp win32/src/win32crypt/PyCTL_CONTEXT.cpp """), -- ("win32file", "", None, 0x0500, """ -+ ("win32file", "ws2_32 mswsock", None, 0x0500, """ +- ("win32file", "", 0x0500, """ ++ ("win32file", win32file_dep, 0x0500, """ win32/src/win32file.i win32/src/win32file_comm.cpp """), -@@ -1813,7 +1813,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 -diff -aur 000/win32/src/odbc.cpp 001/win32/src/odbc.cpp ---- 000/win32/src/odbc.cpp 2015-04-09 21:00:49.053401800 -0300 -+++ 001/win32/src/odbc.cpp 2015-04-09 21:02:02.366025800 -0300 -@@ -93,8 +93,8 @@ - static cursorObject *cursor(PyObject *o) { return (cursorObject *)o; } +@@ -1403,7 +1892,7 @@ + ("win32pipe", "", None, 'win32/src/win32pipe.i win32/src/win32popen.cpp'), + ("win32print", "winspool user32 gdi32", 0x0500, "win32/src/win32print/win32print.cpp"), + ("win32process", "advapi32 user32", 0x0500, "win32/src/win32process.i"), +- ("win32profile", "Userenv", None, 'win32/src/win32profilemodule.cpp'), ++ ("win32profile", "userenv", None, 'win32/src/win32profilemodule.cpp'), + ("win32ras", "rasapi32 user32", 0x0500, "win32/src/win32rasmodule.cpp"), + ("win32security", "advapi32 user32 netapi32", 0x0500, """ + win32/src/win32security.i +@@ -1424,7 +1913,7 @@ + win32/src/win32inet_winhttp.cpp + """), + ("win32console", "kernel32", 0x0501, "win32/src/win32consolemodule.cpp"), +- ("win32ts", "WtsApi32", 0x0501, "win32/src/win32tsmodule.cpp"), ++ ("win32ts", "wtsapi32", 0x0501, "win32/src/win32tsmodule.cpp"), + ("_win32sysloader", "", 0x0501, "win32/src/_win32sysloader.cpp"), + ("win32transaction", "kernel32", 0x0501, "win32/src/win32transactionmodule.cpp"), - static void cursorDealloc(PyObject *self); --PyMethodDef cursorMethods[]; --PyMemberDef cursorMembers[]; -+extern PyMethodDef cursorMethods[8]; -+extern PyMemberDef cursorMembers[3]; - - static PyTypeObject Cursor_Type = { - PYWIN_OBJECT_HEAD "odbccur", /*tp_name */ -@@ -137,8 +137,8 @@ - }; - - static void connectionDealloc(PyObject *self); --PyMethodDef connectionMethods[]; --PyMemberDef connectionMembers[]; -+extern PyMethodDef connectionMethods[6]; -+extern PyMemberDef connectionMembers[2]; - static PyTypeObject Connection_Type = { - PYWIN_OBJECT_HEAD "odbcconn", /*tp_name */ - sizeof(connectionObject), /*tp_basicsize */ -diff -aur 000/win32/src/PerfMon/perfmondata.cpp 001/win32/src/PerfMon/perfmondata.cpp ---- 000/win32/src/PerfMon/perfmondata.cpp 2015-04-09 21:00:48.772153700 -0300 -+++ 001/win32/src/PerfMon/perfmondata.cpp 2015-04-09 21:02:02.366025800 -0300 -@@ -93,9 +93,9 @@ - // these are used to insure that the data collection functions - // accessed by Perflib will have the correct calling format. - // --PM_OPEN_PROC OpenPerformanceData; --PM_COLLECT_PROC CollectPerformanceData; --PM_CLOSE_PROC ClosePerformanceData; -+extern "C" PM_OPEN_PROC OpenPerformanceData; -+extern "C" PM_COLLECT_PROC CollectPerformanceData; -+extern "C" PM_CLOSE_PROC ClosePerformanceData; - - TCHAR szFullModulePath[MAX_PATH]; - TCHAR szModuleName[MAX_PATH]; // will point into the buffer above. -@@ -414,7 +414,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 -aur 000/win32/src/PySecurityObjects.h 001/win32/src/PySecurityObjects.h ---- 000/win32/src/PySecurityObjects.h 2015-04-09 21:00:48.850278300 -0300 -+++ 001/win32/src/PySecurityObjects.h 2015-04-09 21:01:55.881645000 -0300 -@@ -118,7 +118,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; -@@ -155,7 +155,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 -aur 000/win32/src/PyWinObjects.h 001/win32/src/PyWinObjects.h ---- 000/win32/src/PyWinObjects.h 2015-04-09 21:00:48.881528000 -0300 -+++ 001/win32/src/PyWinObjects.h 2015-04-09 21:01:55.881645000 -0300 -@@ -49,7 +49,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 -aur 000/win32/src/PyWinTypesmodule.cpp 001/win32/src/PyWinTypesmodule.cpp ---- 000/win32/src/PyWinTypesmodule.cpp 2015-04-09 21:00:48.990903200 -0300 -+++ 001/win32/src/PyWinTypesmodule.cpp 2015-04-09 21:01:55.897264900 -0300 -@@ -1119,7 +1119,7 @@ - // Function to format a python traceback into a character string. - #define GPEM_ERROR(what) \ - { \ -- errorMsg = ""; \ -+ errorMsg = ""; \ - goto done; \ - } - PYWINTYPES_EXPORT char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) ---- 000/win32/src/win32crypt/win32cryptmodule.cpp 2015-04-09 21:00:49.194027800 -0300 -+++ 001/win32/src/win32crypt/win32cryptmodule.cpp 2015-04-09 21:02:02.397275800 -0300 -@@ -581,44 +581,37 @@ - pvPara = (void *)&cssrp; - } - 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: { -+ if (StoreProvider == CERT_STORE_PROV_PHYSICAL || -+ StoreProvider == CERT_STORE_PROV_FILENAME || -+ StoreProvider == CERT_STORE_PROV_SYSTEM || -+ StoreProvider == CERT_STORE_PROV_SYSTEM_REGISTRY || -+ StoreProvider == CERT_STORE_PROV_LDAP) { - if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) - return NULL; - free_wchar = TRUE; -- break; -- } -- case CERT_STORE_PROV_REG: { -+ } -+ else if (StoreProvider == CERT_STORE_PROV_REG) { - if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) - return NULL; -- break; -- } -- case CERT_STORE_PROV_FILE: { -+ } -+ else if (StoreProvider == CERT_STORE_PROV_FILE) { - if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) - return NULL; -- break; -- } -- case CERT_STORE_PROV_SERIALIZED: -- case CERT_STORE_PROV_PKCS7: { -+ } -+ else if (StoreProvider == CERT_STORE_PROV_SERIALIZED || -+ StoreProvider == 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: { -+ } -+ else if (StoreProvider == 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"); -- break; -- } -- default: { -+ } -+ else { - PyErr_SetString(PyExc_NotImplementedError, "Specified store provider type not supported"); - return NULL; -- } - } - } - -diff -aur 000/win32/src/win32evtlog.i 001/win32/src/win32evtlog.i ---- 000/win32/src/win32evtlog.i 2015-04-09 21:00:49.256528100 -0300 -+++ 001/win32/src/win32evtlog.i 2015-04-09 21:02:02.397275800 -0300 -@@ -1206,6 +1206,14 @@ +@@ -1448,7 +1937,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", +@@ -1486,7 +1975,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, + ), + ] +@@ -1522,6 +2011,13 @@ + 'win32com' : 'com/win32com/src', } - PyCFunction pfnPyEvtUpdateBookmark = (PyCFunction) PyEvtUpdateBookmark; -+#ifndef EVT_VARIANT_TYPE_ARRAY -+#define EVT_VARIANT_TYPE_ARRAY 128 -+#endif ++pythoncom_lib = pythoncom_dep = "" ++win32ui_lib = "" ++if 'GCC' in sys.version: ++ pythoncom_lib = "pythoncom" ++ pythoncom_dep = " uuid pywintypes" ++ win32ui_lib = "win32ui" + -+#ifndef EVT_VARIANT_TYPE_MASK -+#define EVT_VARIANT_TYPE_MASK 0x7F -+#endif + # The COM modules. + pythoncom = WinExt_system32('pythoncom', + sources=(""" +@@ -1592,9 +2088,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, +@@ -1602,7 +2099,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 +@@ -1869,7 +2366,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 +@@ -2015,6 +2512,7 @@ + "Pythonwin/Win32uiHostGlue.h", + "Pythonwin/win32win.h", + ], ++ implib_name=win32ui_lib, + optional_headers=['afxres.h']), + WinExt_pythonwin("win32uiole", + sources = [ +@@ -2079,9 +2577,9 @@ + + W32_exe_files = [ + WinExt_win32_subsys_con("pythonservice", +- sources=[os.path.join("win32", "src", s) for s in +- "PythonService.cpp PythonService.rc".split()], +- libraries = "user32 advapi32 ole32 shell32"), ++ sources=[os.path.join("win32", "src", s) for s in ++ "PythonService.cpp PythonService.rc".split()], ++ libraries = "user32 advapi32 ole32 shell32"), + WinExt_pythonwin_subsys_win("Pythonwin", + sources = [ + "Pythonwin/pythonwin.cpp", +@@ -2247,6 +2745,9 @@ + ext_modules = win32_extensions + com_extensions + pythonwin_extensions + \ + other_extensions + ++if 'GCC' in sys.version: ++ my_build_ext = mingw_build_ext + - PyObject *PyList_FromEVT_VARIANTArray(PEVT_VARIANT val) - { - if ((val->Type & EVT_VARIANT_TYPE_ARRAY) == 0) { -diff -aur 000/win32/src/win32file_comm.cpp 001/win32/src/win32file_comm.cpp ---- 000/win32/src/win32file_comm.cpp 2015-04-09 21:00:49.490903600 -0300 -+++ 001/win32/src/win32file_comm.cpp 2015-04-09 21:02:02.412900800 -0300 -@@ -163,7 +163,7 @@ - PyDCB::~PyDCB(void) {} - - #define GET_BITFIELD_ENTRY(bitfield_name) \ -- else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); } -+ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.bitfield_name); } - - PyObject *PyDCB::getattro(PyObject *self, PyObject *obname) - { -@@ -198,7 +198,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; \ - } - -@@ -362,7 +362,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); } -+ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.bitfield_name); } - - PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname) - { -@@ -391,7 +391,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 -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i ---- 000/win32/src/win32inet.i 2015-04-09 21:00:49.569028200 -0300 -+++ 001/win32/src/win32inet.i 2015-04-09 21:02:02.428526500 -0300 -@@ -7,6 +7,22 @@ - #include "Windows.h" - #include "WinInet.h" - #undef BOOLAPI // wininet.h defines this! -+ -+#ifndef INTERNET_OPTION_CODEPAGE_PATH -+#define INTERNET_OPTION_CODEPAGE_PATH 100 -+#endif -+ -+#ifndef INTERNET_OPTION_CODEPAGE_EXTRA -+#define INTERNET_OPTION_CODEPAGE_EXTRA 101 -+#endif -+ -+#ifndef INTERNET_OPTION_IDN -+#define INTERNET_OPTION_IDN 102 -+#endif -+ -+#ifndef INTERNET_OPTION_HTTP_DECODING -+#define INTERNET_OPTION_HTTP_DECODING 65 -+#endif - %} - - %include "typemaps.i" -diff -aur 000/win32/src/win32pdhmodule.cpp 001/win32/src/win32pdhmodule.cpp ---- 000/win32/src/win32pdhmodule.cpp 2015-04-09 21:00:49.662779100 -0300 -+++ 001/win32/src/win32pdhmodule.cpp 2015-04-09 21:02:02.444150800 -0300 -@@ -1005,7 +1005,7 @@ - { \ - if (i < seqLen) { \ - PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \ -- myCfg.cfg.##r = PyObject_IsTrue(subItem); \ -+ myCfg.cfg.r = PyObject_IsTrue(subItem); \ - } \ - } - -diff -aur 000/win32/src/win32service.i 001/win32/src/win32service.i ---- 000/win32/src/win32service.i 2015-04-09 21:00:49.990904900 -0300 -+++ 001/win32/src/win32service.i 2015-04-09 21:02:02.475400700 -0300 -@@ -57,6 +57,13 @@ - if (fp!=NULL) - fpEnumServicesStatusEx=(EnumServicesStatusExfunc)fp; - } -+#ifndef SERVICE_CONTROL_PRESHUTDOWN -+#define SERVICE_CONTROL_PRESHUTDOWN 0x0000000F -+#endif -+ -+#ifndef SERVICE_ACCEPT_PRESHUTDOWN -+#define SERVICE_ACCEPT_PRESHUTDOWN 0x00000100 -+#endif - %} - - %{ ---- 000/com/win32comext/mapi/src/mapi_headers/mapidefs.h 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/mapi_headers/mapidefs.h 2020-06-19 16:10:51.180079900 +0300 -@@ -2728,5 +2728,4 @@ - #endif - - #endif /* MAPIDEFS_H */ -- - ---- 000/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2020-06-19 16:11:57.872096400 +0300 -@@ -216,5 +216,4 @@ - #endif - - #endif /* MAPICODE_H */ -- - ---- 000/com/win32comext/mapi/src/mapi_headers/MSPST.h 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/mapi_headers/MSPST.h 2020-06-19 16:12:52.572096500 +0300 -@@ -97,5 +97,4 @@ - 0xd9, 0x6e, 0x00, 0x00 } - - #endif /* _MSPST_H_ */ -- - ---- 000/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2020-06-20 13:20:38.548390500 +0300 -@@ -631,5 +631,4 @@ - - #endif /* MAPIFORM_H */ - -- - ---- 000/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2020-06-20 13:17:46.660390600 +0300 -@@ -6,6 +6,10 @@ - #include "PyMAPIUtil.h" - #include "PyIMAPIAdviseSink.h" - -+#ifdef __MINGW32__ -+#define __FUNCSIG__ __PRETTY_FUNCTION__ -+#endif -+ - // @doc - This file contains autoduck documentation - // --------------------------------------------------- - // + cmdclass = { 'install': my_install, + 'build': my_build, + 'build_ext': my_build_ext, diff --git a/mingw-w64-python-pywin32/002-com-extensions-fix.patch b/mingw-w64-python-pywin32/002-com-extensions-fix.patch new file mode 100644 index 0000000000..f43e03d8c4 --- /dev/null +++ b/mingw-w64-python-pywin32/002-com-extensions-fix.patch @@ -0,0 +1,1324 @@ +diff -Naur pywin32-b301-orig/com/win32com/src/ErrorUtils.cpp pywin32-b301/com/win32com/src/ErrorUtils.cpp +--- pywin32-b301-orig/com/win32com/src/ErrorUtils.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/ErrorUtils.cpp 2021-10-05 18:46:00 +0800 +@@ -1108,18 +1108,18 @@ + } + + 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 -Naur pywin32-b301-orig/com/win32com/src/PyIUnknown.cpp pywin32-b301/com/win32com/src/PyIUnknown.cpp +--- pywin32-b301-orig/com/win32com/src/PyIUnknown.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/PyIUnknown.cpp 2021-10-05 18:46:34 +0800 +@@ -31,7 +31,11 @@ + { + // @comm The repr of this object displays both the object's address, and its attached IUnknown's address + char buf[256]; ++#ifdef _MSC_VER + _snprintf(buf, 256, "<%hs at 0x%0lp with obj at 0x%0lp>", ob_type->tp_name, this, m_obj); ++#else ++ _snprintf(buf, 256, "<%s at 0x%p with obj at 0x%p>", ob_type->tp_name, this, m_obj); ++#endif + #if (PY_VERSION_HEX < 0x03000000) + return PyString_FromString(buf); + #else +@@ -87,7 +91,7 @@ + } + } + +- /* successful QI; need to release it ++ // successful QI; need to release it + pdisp->Release(); + } + } +diff -Naur pywin32-b301-orig/com/win32com/src/dllmain.cpp pywin32-b301/com/win32com/src/dllmain.cpp +--- pywin32-b301-orig/com/win32com/src/dllmain.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/dllmain.cpp 2021-10-05 18:45:36 +0800 +@@ -133,7 +133,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 +@@ -309,7 +309,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 -Naur pywin32-b301-orig/com/win32com/src/include/PythonCOM.h pywin32-b301/com/win32com/src/include/PythonCOM.h +--- pywin32-b301-orig/com/win32com/src/include/PythonCOM.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/include/PythonCOM.h 2021-10-06 00:17:04 +0800 +@@ -110,11 +110,50 @@ + + #ifdef __MINGW32__ + // Special Mingw32 considerations. +-#define NO_PYCOM_ENUMSTATPROPSTG ++#undef _WIN32_WINNT ++#define _WIN32_WINNT 0x0601 ++#undef _WIN32_IE ++#define _WIN32_IE 0x0701 ++ + #define __try try +-#define __except catch ++#define __except(filter) catch(...) + #include + ++#ifdef BUILD_PYTHONCOM ++ ++#include ++#include ++ ++#else ++ ++#include ++#include ++#include ++ ++// adsi ++DEFINE_GUID(IID_IDataObject, 0x0000010e, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); ++DEFINE_GUID(IID_IEnumVARIANT, 0x00020404, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); ++ ++// 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_IOleWindow, 0x00000114, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); ++ ++// axscript ++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); ++DEFINE_GUID(IID_IDispatch, 0x00020400, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); ++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); ++ ++#endif ++ + #endif // __MINGW32__ + + #include // Standard Win32 Types +@@ -426,9 +465,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); } ++ 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); \ +diff -Naur pywin32-b301-orig/com/win32com/src/include/PythonCOMServer.h pywin32-b301/com/win32com/src/include/PythonCOMServer.h +--- pywin32-b301-orig/com/win32com/src/include/PythonCOMServer.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/include/PythonCOMServer.h 2021-10-06 00:17:48 +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, \ ++ static HRESULT PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *unkBase, void **ppResult, \ + REFIID iid) \ + { \ + if (ppResult == NULL) \ +@@ -46,7 +46,7 @@ + virtual IID GetIID(void) { return theIID; } \ + virtual void *ThisAsIID(IID iid) \ + { \ +- if (this == NULL) \ ++ if (this->ThisAsIID(iid) == NULL) \ + return NULL; \ + if (iid == theIID) \ + return (IInterface *)this; \ +@@ -134,7 +134,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, ++ static HRESULT PyGatewayConstruct(PyObject *pPyInstance, PyGatewayBase *gatewayBase, void **ppResult, + REFIID iid) + { + if (ppResult == NULL) +diff -Naur pywin32-b301-orig/com/win32com/src/include/stdafx.h pywin32-b301/com/win32com/src/include/stdafx.h +--- pywin32-b301-orig/com/win32com/src/include/stdafx.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32com/src/include/stdafx.h 2021-10-06 00:18:13 +0800 +@@ -7,6 +7,7 @@ + // so we dont lose all the constants etc that come with DCOM + // + #define _WIN32_DCOM ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x0501 // we use some of these features. + + // objidl.h checks for this to define IContext and IEnumContextProps +diff -Naur pywin32-b301-orig/com/win32comext/adsi/src/PyADSIUtil.cpp pywin32-b301/com/win32comext/adsi/src/PyADSIUtil.cpp +--- pywin32-b301-orig/com/win32comext/adsi/src/PyADSIUtil.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/adsi/src/PyADSIUtil.cpp 2021-10-05 18:50:13 +0800 +@@ -315,7 +315,7 @@ + static void deallocFunc(PyObject *ob) { delete (PyADS_OBJECT_INFO *)ob; } + + static struct PyMemberDef memberlist[]; +- static PyTypeObject PyADS_OBJECT_INFO::Type; ++ static PyTypeObject Type; + + protected: + PyObject *obRDN, *obObjectDN, *obParentDN, *obClassName; +@@ -473,7 +473,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; +diff -Naur pywin32-b301-orig/com/win32comext/adsi/src/PyIDirectoryObject.i pywin32-b301/com/win32comext/adsi/src/PyIDirectoryObject.i +--- pywin32-b301-orig/com/win32comext/adsi/src/PyIDirectoryObject.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/adsi/src/PyIDirectoryObject.i 2021-10-05 18:50:42 +0800 +@@ -120,17 +120,17 @@ + if (!PyArg_ParseTuple(args, "OO:CreateDSObject", &obName, &obAttr)) + return NULL; + +- WCHAR *szName= NULL; +- if (!PyWinObject_AsWCHAR(obName, &szName, FALSE)) +- return NULL; ++ WCHAR *szName= NULL; ++ if (!PyWinObject_AsWCHAR(obName, &szName, FALSE)) ++ return NULL; + + PADS_ATTR_INFO attr; + DWORD cattr; + if (!PyADSIObject_AsADS_ATTR_INFOs(obAttr, &attr, &cattr)) { +- PyWinObject_FreeWCHAR(szName); ++ PyWinObject_FreeWCHAR(szName); + return NULL; +- } +- IDispatch *pRet = NULL; ++ } ++ IDispatch *pRet = NULL; + + Py_BEGIN_ALLOW_THREADS + _result = (HRESULT )_swig_self->CreateDSObject(szName, attr, cattr, &pRet); +diff -Naur pywin32-b301-orig/com/win32comext/adsi/src/PyIDirectorySearch.i pywin32-b301/com/win32comext/adsi/src/PyIDirectorySearch.i +--- pywin32-b301-orig/com/win32comext/adsi/src/PyIDirectorySearch.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/adsi/src/PyIDirectorySearch.i 2021-10-05 18:51:12 +0800 +@@ -81,9 +81,9 @@ + // @pyparm [, ...]|attrNames|| + if (!PyArg_ParseTuple(args, "OO", &obFilter, &obNames)) + return NULL; +- WCHAR *szFilter = NULL; +- if (!PyWinObject_AsWCHAR(obFilter, &szFilter, FALSE)) +- return NULL; ++ WCHAR *szFilter = NULL; ++ if (!PyWinObject_AsWCHAR(obFilter, &szFilter, FALSE)) ++ return NULL; + + WCHAR **names = NULL; + DWORD cnames = -1; +@@ -94,7 +94,7 @@ + } + + HRESULT _result; +- ADS_SEARCH_HANDLE handle; ++ ADS_SEARCH_HANDLE handle; + + Py_BEGIN_ALLOW_THREADS + _result = (HRESULT )_swig_self->ExecuteSearch(szFilter, names, cnames, &handle); +@@ -106,7 +106,7 @@ + ret = PyLong_FromSsize_t((Py_ssize_t)handle); + } + PyADSI_FreeNames(names, cnames); +- PyWinObject_FreeWCHAR(szFilter); ++ PyWinObject_FreeWCHAR(szFilter); + return ret; + } + +diff -Naur pywin32-b301-orig/com/win32comext/adsi/src/adsilib.i pywin32-b301/com/win32comext/adsi/src/adsilib.i +--- pywin32-b301-orig/com/win32comext/adsi/src/adsilib.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/adsi/src/adsilib.i 2021-10-05 18:49:35 +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 -Naur pywin32-b301-orig/com/win32comext/authorization/src/PyGSecurityInformation.h pywin32-b301/com/win32comext/authorization/src/PyGSecurityInformation.h +--- pywin32-b301-orig/com/win32comext/authorization/src/PyGSecurityInformation.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/authorization/src/PyGSecurityInformation.h 2021-10-05 18:51:42 +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 -Naur pywin32-b301-orig/com/win32comext/axcontrol/src/PyIViewObject.cpp pywin32-b301/com/win32comext/axcontrol/src/PyIViewObject.cpp +--- pywin32-b301-orig/com/win32comext/axcontrol/src/PyIViewObject.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/axcontrol/src/PyIViewObject.cpp 2021-10-05 18:52:25 +0800 +@@ -256,7 +256,7 @@ + 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); +diff -Naur pywin32-b301-orig/com/win32comext/bits/src/bits_pch.h pywin32-b301/com/win32comext/bits/src/bits_pch.h +--- pywin32-b301-orig/com/win32comext/bits/src/bits_pch.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/bits/src/bits_pch.h 2021-10-05 18:53:07 +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 -Naur pywin32-b301-orig/com/win32comext/ifilter/src/stdafx.h pywin32-b301/com/win32comext/ifilter/src/stdafx.h +--- pywin32-b301-orig/com/win32comext/ifilter/src/stdafx.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/ifilter/src/stdafx.h 2021-10-05 18:53:41 +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 -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIAddrBook.i pywin32-b301/com/win32comext/mapi/src/PyIAddrBook.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIAddrBook.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIAddrBook.i 2021-10-05 19:00:14 +0800 +@@ -39,14 +39,14 @@ + // @pyswig |OpenEntry|Opens a folder or message and returns an interface object for further access. + PyObject *PyIAddrBook::OpenEntry(PyObject *self, PyObject *args) + { +- HRESULT _result; +- char * entryString; ++ HRESULT _result; ++ char * entryString; + int entryStrLen; +- IID iid; ++ IID iid; + IID *pIID; +- PyObject * objIID = 0; +- unsigned long flags; +- IUnknown * pUnk = NULL; ++ PyObject * objIID = 0; ++ unsigned long flags; ++ IUnknown * pUnk = NULL; + ULONG resType; + PyObject *obEntry; + +@@ -55,8 +55,8 @@ + // @pyparm string|entryId||The entryID of the object + // @pyparm |iid||The IID of the object to return, or None for the default IID + // @pyparm int|flags||Bitmask of flags that controls how the object is opened. +- if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) +- return NULL; ++ if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) ++ return NULL; + if (obEntry==Py_None) { + entryString = NULL; + entryStrLen = 0; +@@ -75,12 +75,12 @@ + return NULL; + } + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); ++ _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); + Py_END_ALLOW_THREADS +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } +- return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } ++ return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); + } + %} + +@@ -101,17 +101,17 @@ + IAddrBook *_swig_self; + PyObject *obE1, *obE2; + if ((_swig_self=GetI(self))==NULL) return NULL; +- if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", ++ if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", + &obE1, // @pyparm string|entryId||The first entry ID to be compared + &obE2, // @pyparm string|entryId||The second entry ID to be compared + &flags)) // @pyparm int|flags|0|Reserved - must be zero. +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE1, (char **)&peid1, FALSE, &cb1)) +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE2, (char **)&peid2, FALSE, &cb2)) +- goto done; ++ goto done; + + Py_BEGIN_ALLOW_THREADS + hr=_swig_self->CompareEntryIDs(cb1, peid1, cb2, peid2, flags, &ulResult); +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIConverterSession.i pywin32-b301/com/win32comext/mapi/src/PyIConverterSession.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIConverterSession.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIConverterSession.i 2021-10-05 19:01:11 +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; +@@ -90,12 +93,6 @@ + result = Py_None; + } + +-done: +- if (pStream) +- pStream->Release(); +- if (pMsg) +- pMsg->Release(); +- + return result; + } + +@@ -117,9 +114,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; +@@ -135,12 +135,6 @@ + result = Py_None; + } + +-done: +- if (pStream) +- pStream->Release(); +- if (pMsg) +- pMsg->Release(); +- + return result; + } + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp pywin32-b301/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2021-10-05 23:03:48 +0800 +@@ -6,6 +6,10 @@ + #include "PyMAPIUtil.h" + #include "PyIMAPIAdviseSink.h" + ++#ifdef __MINGW32__ ++#define __FUNCSIG__ __PRETTY_FUNCTION__ ++#endif ++ + // @doc - This file contains autoduck documentation + // --------------------------------------------------- + // +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIContainer.i pywin32-b301/com/win32comext/mapi/src/PyIMAPIContainer.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIContainer.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMAPIContainer.i 2021-10-05 19:01:54 +0800 +@@ -30,24 +30,24 @@ + // @pyswig |OpenEntry|Opens an object and returns an interface object for further access. + PyObject *PyIMAPIContainer::OpenEntry(PyObject *self, PyObject *args) + { +- HRESULT _result; +- char * entryString; ++ HRESULT _result; ++ char * entryString; + int entryStrLen; +- IID iid; ++ IID iid; + IID *pIID; +- PyObject * objIID = 0; +- unsigned long flags; +- IUnknown * pUnk = NULL; ++ PyObject * objIID = 0; ++ unsigned long flags; ++ IUnknown * pUnk = NULL; + ULONG resType; + PyObject *obEntry; + + IMAPIContainer *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; +- // @pyparm string|entryId||The EntryID to open. +- // @pyparm |iid||The IID of the returned interface, or None for the default interface. +- // @pyparm int|flags||Flags for the call. May include MAPI_BEST_ACCESS, MAPI_DEFERRED_ERRORS, MAPI_MODIFY and possibly others (see the MAPI documentation) +- if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) +- return NULL; ++ // @pyparm string|entryId||The EntryID to open. ++ // @pyparm |iid||The IID of the returned interface, or None for the default interface. ++ // @pyparm int|flags||Flags for the call. May include MAPI_BEST_ACCESS, MAPI_DEFERRED_ERRORS, MAPI_MODIFY and possibly others (see the MAPI documentation) ++ if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) ++ return NULL; + if (obEntry==Py_None) { + entryString = NULL; + entryStrLen = 0; +@@ -66,12 +66,12 @@ + return NULL; + } + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); ++ _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); + Py_END_ALLOW_THREADS +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } +- return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } ++ return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); + } + + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIFolder.i pywin32-b301/com/win32comext/mapi/src/PyIMAPIFolder.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIFolder.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMAPIFolder.i 2021-10-05 19:02:34 +0800 +@@ -43,10 +43,10 @@ + IMAPIFolder *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"l|l:GetLastError", ++ if(!PyArg_ParseTuple(args,"l|l:GetLastError", + &hr, // @pyparm int|hr||Contains the error code generated in the previous method call. + &flags)) // @pyparm int|flags||Indicates for format for the output. +- return NULL; ++ return NULL; + + Py_BEGIN_ALLOW_THREADS + hRes = _swig_self->GetLastError(hr, flags, &me); +@@ -156,12 +156,12 @@ + IMAPIFolder *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"OOO|l:DeleteFolder", ++ if(!PyArg_ParseTuple(args,"OOO|l:DeleteFolder", + &obEntryId, // @pyparm string|entryId||The EntryID of the subfolder to delete. + &obUIParam, // @pyparm long|uiParam||Handle of the parent window of the progress indicator. + &obProgress, // @pyparm |progress||A progress object, or None + &flags)) +- return NULL; ++ return NULL; + if (PyString_Check(obEntryId)) { + eid = (LPENTRYID)PyString_AsString(obEntryId); + cbEID = PyString_Size(obEntryId); +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIProp.i pywin32-b301/com/win32comext/mapi/src/PyIMAPIProp.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPIProp.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMAPIProp.i 2021-10-05 19:03:10 +0800 +@@ -36,29 +36,29 @@ + + // @pyswig int, [items, ]|GetProps|Returns a list of property values. + PyObject *PyIMAPIProp::GetProps(PyObject *self, PyObject *args) { +- PyObject * _resultobj; +- HRESULT _result; +- SPropTagArray * _arg0 = NULL; +- unsigned long _arg1=0; +- PyObject * _obj0 = 0; ++ PyObject * _resultobj; ++ HRESULT _result; ++ SPropTagArray * _arg0 = NULL; ++ unsigned long _arg1=0; ++ PyObject * _obj0 = 0; + + IMAPIProp *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + // @pyparm |propList||The list of properties + // @pyparm int|flags|0| +- if(!PyArg_ParseTuple(args,"O|l:GetProps",&_obj0,&_arg1)) +- return NULL; ++ if(!PyArg_ParseTuple(args,"O|l:GetProps",&_obj0,&_arg1)) ++ return NULL; + if (!PyMAPIObject_AsSPropTagArray(_obj0, &_arg0)) + return NULL; + ULONG numValues; + SPropValue *pv; + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->GetProps(_arg0,_arg1, &numValues, &pv); ++ _result = (HRESULT )_swig_self->GetProps(_arg0,_arg1, &numValues, &pv); + Py_END_ALLOW_THREADS + PyMAPIObject_FreeSPropTagArray(_arg0); +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } + + _resultobj = PyTuple_New(numValues); + if (_resultobj==NULL) { +@@ -86,7 +86,7 @@ + PyObject *PyIMAPIProp::DeleteProps(PyObject *self, PyObject *args) + { + PyObject *obs; +- SPropTagArray * _arg0; ++ SPropTagArray * _arg0; + HRESULT hr; + IMAPIProp *pMAPIProp; + PyObject *obWantProblems = Py_False; +@@ -94,7 +94,7 @@ + if ((pMAPIProp=GetI(self))==NULL) return NULL; + // @pyparm |propList||The list of properties + // @pyparm bool|wantProblems|False|Return detailed error information +- if(!PyArg_ParseTuple(args,"O|O:DeleteProps",&obs, &obWantProblems)) ++ if(!PyArg_ParseTuple(args,"O|O:DeleteProps",&obs, &obWantProblems)) + return NULL; + int wantProblems = PyObject_IsTrue(obWantProblems); + if (wantProblems == -1) +@@ -128,7 +128,7 @@ + if ((pMAPIProp=GetI(self))==NULL) return NULL; + // @pyparm [, ]|propList||The list of properties + // @pyparm bool|wantProblems|False|Return detailed error information +- if(!PyArg_ParseTuple(args,"O|O:SetProps",&obs, &obWantProblems)) ++ if(!PyArg_ParseTuple(args,"O|O:SetProps",&obs, &obWantProblems)) + return NULL; + if (!PySequence_Check(obs)) { + PyErr_SetString(PyExc_TypeError, "Properties must be a sequence of tuples"); +@@ -183,7 +183,7 @@ + // @pyparm |dest||The destination object + // @pyparm int|flags||flags + // @pyparm bool|wantProblems|False|Return detailed error information +- if(!PyArg_ParseTuple(args,"OOlzOOl|O:CopyTo",&obIIDExclude, &obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems)) ++ if(!PyArg_ParseTuple(args,"OOlzOOl|O:CopyTo",&obIIDExclude, &obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems)) + return NULL; + int wantProblems = PyObject_IsTrue(obWantProblems); + if (wantProblems == -1) +@@ -264,7 +264,7 @@ + // @pyparm |dest||The destination object + // @pyparm int|flags||flags + // @pyparm bool|wantProblems|False|Return detailed error information +- if(!PyArg_ParseTuple(args,"OlzOOl|O:CopyProps",&obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems)) ++ if(!PyArg_ParseTuple(args,"OlzOOl|O:CopyProps",&obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems)) + return NULL; + int wantProblems = PyObject_IsTrue(obWantProblems); + if (wantProblems == -1) +@@ -314,7 +314,7 @@ + // @pyparm |iid||The IID of the resulting interface. + // @pyparm int|interfaceOptions||Data that relates to the interface identified by the lpiid parameter. + // @pyparm int|flags||flags +- if(!PyArg_ParseTuple(args,"kOll:OpenProperty",&propTag, &obIID, &interfaceOptions, &flags)) ++ if(!PyArg_ParseTuple(args,"kOll:OpenProperty",&propTag, &obIID, &interfaceOptions, &flags)) + return NULL; + // IID. + if (!PyWinObject_AsIID(obIID, &iid)) +@@ -418,10 +418,10 @@ + IMAPIProp *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"l|l:GetLastError", ++ if(!PyArg_ParseTuple(args,"l|l:GetLastError", + &hr, // @pyparm int|hr||Contains the error code generated in the previous method call. + &flags)) // @pyparm int|flags||Indicates for format for the output. +- return NULL; ++ return NULL; + + Py_BEGIN_ALLOW_THREADS + hRes = _swig_self->GetLastError(hr, flags, &me); +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPISession.i pywin32-b301/com/win32comext/mapi/src/PyIMAPISession.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMAPISession.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMAPISession.i 2021-10-05 19:04:14 +0800 +@@ -32,14 +32,14 @@ + // @pyswig |OpenEntry|Opens an object and returns an interface object for further access. + PyObject *PyIMAPISession::OpenEntry(PyObject *self, PyObject *args) + { +- HRESULT _result; +- char *entryString; ++ HRESULT _result; ++ char *entryString; + int entryStrLen; +- IID iid; ++ IID iid; + IID *pIID; +- PyObject * objIID = 0; +- unsigned long flags; +- IUnknown * pUnk = NULL; ++ PyObject * objIID = 0; ++ unsigned long flags; ++ IUnknown * pUnk = NULL; + ULONG resType; + PyObject *obEntry; + +@@ -48,8 +48,8 @@ + // @pyparm string|entryId||The EntryID to open. + // @pyparm |iid||The IID of the returned interface, or None for the default interface. + // @pyparm int|flags||Flags for the call. May include MAPI_BEST_ACCESS, MAPI_DEFERRED_ERRORS, MAPI_MODIFY and possibly others (see the MAPI documentation) +- if(!PyArg_ParseTuple(args,"OOl:OpenEntry", &obEntry, &objIID, &flags)) +- return NULL; ++ if(!PyArg_ParseTuple(args,"OOl:OpenEntry", &obEntry, &objIID, &flags)) ++ return NULL; + if (obEntry==Py_None) { + entryString = NULL; + entryStrLen = 0; +@@ -68,11 +68,11 @@ + return NULL; + } + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); ++ _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); + Py_END_ALLOW_THREADS +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } + return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); + } + %} +@@ -82,24 +82,24 @@ + // @pyswig |OpenMsgStore|Opens a message store. + PyObject *PyIMAPISession::OpenMsgStore(PyObject *self, PyObject *args) + { +- HRESULT _result; +- char * entryString; ++ HRESULT _result; ++ char * entryString; + int entryStrLen; +- IID iid; ++ IID iid; + IID *pIID; +- PyObject * objIID = 0; +- unsigned long ulParm; +- unsigned long flags; +- IMsgStore * pMS = NULL; ++ PyObject * objIID = 0; ++ unsigned long ulParm; ++ unsigned long flags; ++ IMsgStore * pMS = NULL; + + IMAPISession *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; +- // @pyparm int|uiParam||Handle to the parent window for dialogs. +- // @pyparm string|entryId||The entry ID of the message store to open. +- // @pyparm |iid||The IID of the interface returned, or None +- // @pyparm int|flags||Options for the call. +- if(!PyArg_ParseTuple(args,"ls#Ol:OpenMsgStore",&ulParm,&entryString,&entryStrLen, &objIID,&flags)) +- return NULL; ++ // @pyparm int|uiParam||Handle to the parent window for dialogs. ++ // @pyparm string|entryId||The entry ID of the message store to open. ++ // @pyparm |iid||The IID of the interface returned, or None ++ // @pyparm int|flags||Options for the call. ++ if(!PyArg_ParseTuple(args,"ls#Ol:OpenMsgStore",&ulParm,&entryString,&entryStrLen, &objIID,&flags)) ++ return NULL; + if (objIID==Py_None) + pIID = NULL; + else { +@@ -108,13 +108,13 @@ + return NULL; + } + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->OpenMsgStore(ulParm, entryStrLen,(ENTRYID *)entryString,pIID,flags,&pMS); ++ _result = (HRESULT )_swig_self->OpenMsgStore(ulParm, entryStrLen,(ENTRYID *)entryString,pIID,flags,&pMS); + Py_END_ALLOW_THREADS +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } +- // @comm The result is the interface specified by the IID, or IID_IMsgStore if None is used. +- return PyCom_PyObjectFromIUnknown(pMS, pIID ? *pIID : IID_IMsgStore, FALSE /*bAddRef*/ ); ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } ++ // @comm The result is the interface specified by the IID, or IID_IMsgStore if None is used. ++ return PyCom_PyObjectFromIUnknown(pMS, pIID ? *pIID : IID_IMsgStore, FALSE /*bAddRef*/ ); + } + %} + +@@ -128,8 +128,8 @@ + LPENTRYID peid; + IMAPISession *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; +- if(!PyArg_ParseTuple(args,":QueryIdentity")) +- return NULL; ++ if(!PyArg_ParseTuple(args,":QueryIdentity")) ++ return NULL; + + HRESULT _result; + Py_BEGIN_ALLOW_THREADS +@@ -139,8 +139,8 @@ + if (_result==S_OK) + rc = PyString_FromStringAndSize((char *)peid, cb); + else if (FAILED(_result)) { +- rc = OleSetOleError(_result); +- } else { ++ rc = OleSetOleError(_result); ++ } else { + rc = Py_None; + Py_INCREF(Py_None); + } +@@ -220,17 +220,17 @@ + IMAPISession *_swig_self; + PyObject *obE1, *obE2; + if ((_swig_self=GetI(self))==NULL) return NULL; +- if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", ++ if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", + &obE1, // @pyparm string|entryId||The first entry ID to be compared + &obE2, // @pyparm string|entryId||The second entry ID to be compared + &flags)) // @pyparm int|flags|0|Reserved - must be zero. +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE1, (char **)&peid1, FALSE, &cb1)) +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE2, (char **)&peid2, FALSE, &cb2)) +- goto done; ++ goto done; + + Py_BEGIN_ALLOW_THREADS + hr=_swig_self->CompareEntryIDs(cb1, peid1, cb2, peid2, flags, &ulResult); +@@ -260,10 +260,10 @@ + IMAPISession *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"l|l:GetLastError", ++ if(!PyArg_ParseTuple(args,"l|l:GetLastError", + &hr, // @pyparm int|hr||Contains the error code generated in the previous method call. + &flags)) // @pyparm int|flags||Indicates for format for the output. +- return NULL; ++ return NULL; + + Py_BEGIN_ALLOW_THREADS + hRes = _swig_self->GetLastError(hr, flags, &me); +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/PyIMsgStore.i pywin32-b301/com/win32comext/mapi/src/PyIMsgStore.i +--- pywin32-b301-orig/com/win32comext/mapi/src/PyIMsgStore.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/PyIMsgStore.i 2021-10-05 19:04:49 +0800 +@@ -33,14 +33,14 @@ + // @pyswig |OpenEntry|Opens a folder or message and returns an interface object for further access. + PyObject *PyIMsgStore::OpenEntry(PyObject *self, PyObject *args) + { +- HRESULT _result; +- char * entryString; ++ HRESULT _result; ++ char * entryString; + int entryStrLen; +- IID iid; ++ IID iid; + IID *pIID; +- PyObject * objIID = 0; +- unsigned long flags; +- IUnknown * pUnk = NULL; ++ PyObject * objIID = 0; ++ unsigned long flags; ++ IUnknown * pUnk = NULL; + ULONG resType; + PyObject *obEntry; + +@@ -49,8 +49,8 @@ + // @pyparm string|entryId||The entryID of the object + // @pyparm |iid||The IID of the object to return, or None for the default IID + // @pyparm int|flags||Bitmask of flags that controls how the object is opened. +- if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) +- return NULL; ++ if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags)) ++ return NULL; + if (obEntry==Py_None) { + entryString = NULL; + entryStrLen = 0; +@@ -69,12 +69,12 @@ + return NULL; + } + Py_BEGIN_ALLOW_THREADS +- _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); ++ _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk); + Py_END_ALLOW_THREADS +- if (FAILED(_result)) { +- return OleSetOleError(_result); +- } +- return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); ++ if (FAILED(_result)) { ++ return OleSetOleError(_result); ++ } ++ return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/); + } + + %} +@@ -144,17 +144,17 @@ + IMsgStore *_swig_self; + PyObject *obE1, *obE2; + if ((_swig_self=GetI(self))==NULL) return NULL; +- if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", ++ if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs", + &obE1, // @pyparm string|entryId||The first entry ID to be compared + &obE2, // @pyparm string|entryId||The second entry ID to be compared + &flags)) // @pyparm int|flags|0|Reserved - must be zero. +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE1, (char **)&peid1, FALSE, &cb1)) +- goto done; ++ goto done; + + if (!PyWinObject_AsString(obE2, (char **)&peid2, FALSE, &cb2)) +- goto done; ++ goto done; + + Py_BEGIN_ALLOW_THREADS + hr=_swig_self->CompareEntryIDs(cb1, peid1, cb2, peid2, flags, &ulResult); +@@ -182,10 +182,10 @@ + IMsgStore *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"l|l:GetLastError", ++ if(!PyArg_ParseTuple(args,"l|l:GetLastError", + &hr, // @pyparm int|hr||Contains the error code generated in the previous method call. + &flags)) // @pyparm int|flags||Indicates for format for the output. +- return NULL; ++ return NULL; + + Py_BEGIN_ALLOW_THREADS + hRes = _swig_self->GetLastError(hr, flags, &me); +@@ -255,11 +255,11 @@ + IMsgStore *_swig_self; + if ((_swig_self=GetI(self))==NULL) return NULL; + +- if(!PyArg_ParseTuple(args,"OkO:Advise", ++ if(!PyArg_ParseTuple(args,"OkO:Advise", + &obEntryId, // @pyparm string|entryId||entry identifier of the folder or message about which notifications should be generated, or None + &ulEventMask, // @pyparm int|eventMask||A mask of values that indicate the types of notification events. + &obAdviseSink)) // @pyparm |adviseSink||An advise sink. +- return NULL; ++ return NULL; + if (obEntryId == Py_None) + { + eid = NULL; +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi.i pywin32-b301/com/win32comext/mapi/src/mapi.i +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi.i 2021-10-05 18:58:11 +0800 +@@ -24,6 +24,10 @@ + %include "mapilib.i" + + %{ ++#ifndef _MSC_VER ++#define USES_IID_IMsgServiceAdmin2 ++#endif ++ + #include "mapiaux.h" + + #include "PythonCOMServer.h" +@@ -620,9 +624,9 @@ + return NULL; + + if (!PyWinObject_AsMAPIStr(obProfileName, &lpszProfileName, ulFlags & MAPI_UNICODE, FALSE)) +- goto done; ++ PyWinObject_FreeString(lpszProfileName); + if (!PyWinObject_AsMAPIStr(obPassword, &lpszPassword, ulFlags & MAPI_UNICODE, TRUE)) +- goto done; ++ PyWinObject_FreeString(lpszPassword); + + Py_BEGIN_ALLOW_THREADS + hRes = ::MAPILogonEx(ulUIParam, lpszProfileName, lpszPassword, ulFlags, &lpSession); +@@ -633,10 +637,6 @@ + else + MAKE_OUTPUT_INTERFACE(&lpSession, result, IID_IMAPISession); + +-done: +- PyWinObject_FreeString(lpszProfileName); +- PyWinObject_FreeString(lpszPassword); +- + return result; + } + %} +@@ -778,7 +778,7 @@ + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return OleSetOleError(hr); +- return PyInt_FromLong((long)pSession); ++ return PyLong_FromLong((LONG_PTR)pSession); + } + %} + // @pyswig |CloseIMsgSession| +@@ -786,7 +786,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; +@@ -810,7 +810,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|| +@@ -934,7 +934,7 @@ + else if (strncmp(c,"\\pntext",7)==0) {c+=7; while (c|OpenStreamOnFileW|Allocates and initializes an OLE IStream object to access the contents of a file. + %native(OpenStreamOnFileW) PyOpenStreamOnFileW; + %{ +@@ -1112,6 +1109,7 @@ + return PyCom_PyObjectFromIUnknown(pStream, IID_IStream, FALSE); + } + %} ++#endif + + // @pyswig item|HrGetOneProp|Retrieves the value of a single property from an IMAPIProp object. + %native(HrGetOneProp) PyHrGetOneProp; +@@ -1131,7 +1129,7 @@ + return NULL; + + if (!PyCom_InterfaceFromPyObject(obProp, IID_IMAPIProp, (void **)&pProp, FALSE)) +- goto done; ++ if (pProp) pProp->Release(); + + { + PY_INTERFACE_PRECALL; +@@ -1141,10 +1139,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 +@@ -1153,15 +1151,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%uX", PROP_TYPE(pPV->ulPropTag)); + PyErr_SetString(PyExc_TypeError, buf); + Py_DECREF(ret); + ret = NULL; + } +-done: +- if (pProp) pProp->Release(); +- MAPIFreeBuffer(pPV); +- ++ + return ret; + } + %} +@@ -1174,6 +1169,7 @@ + HRESULT hRes; + PyObject *obProp; + PyObject *obPropValue; ++ ULONG propTag; + IMAPIProp *pProp = NULL; + PyObject *ret = NULL; + SPropValue *pPV = NULL; +@@ -1184,14 +1180,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; +@@ -1201,13 +1197,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 -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/EdkMdb.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/EdkMdb.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/EdkMdb.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/EdkMdb.h 2021-10-06 01:01:15 +0800 +@@ -78,7 +78,7 @@ + #define PR_PROFILE_RECONNECT_INTERVAL PROP_TAG( PT_LONG, pidProfileMin+0x1a) // dup tag of PR_USER_NAME + #define PR_PROFILE_SERVER_VERSION PROP_TAG( PT_LONG, pidProfileMin+0x1b) + +-/* SE 233155 - MarkH: EMSABP DCR /* ++/* SE 233155 - MarkH: EMSABP DCR */ + /* Properties in the abp section - I got these values from AlecDun (Outlook team) */ + #define PR_PROFILE_ABP_ALLOW_RECONNECT PROP_TAG( PT_LONG, pidProfileMin+0x39) + #define PR_PROFILE_ABP_MTHREAD_TIMEOUT_SECS PROP_TAG( PT_LONG, pidProfileMin+0x3A) +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapilib.i pywin32-b301/com/win32comext/mapi/src/mapilib.i +--- pywin32-b301-orig/com/win32comext/mapi/src/mapilib.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapilib.i 2021-10-05 18:58:27 +0800 +@@ -7,6 +7,29 @@ + 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 -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapiutil.cpp pywin32-b301/com/win32comext/mapi/src/mapiutil.cpp +--- pywin32-b301-orig/com/win32comext/mapi/src/mapiutil.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapiutil.cpp 2021-10-05 18:58:55 +0800 +@@ -350,7 +350,7 @@ + + default: { + char buf[128]; +- sprintf(buf, "Unsupported MAPI property type 0x%X", PROP_TYPE(pv->ulPropTag)); ++ sprintf(buf, "Unsupported MAPI property type 0x%uX", PROP_TYPE(pv->ulPropTag)); + PyErr_SetString(PyExc_TypeError, buf); + ok = FALSE; + } +@@ -511,7 +511,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%uX", __FILE__, PROP_TYPE(pv->ulPropTag)); + /* Dont set exception, as this prevents otherwise valid props from + being returned + */ +diff -Naur pywin32-b301-orig/com/win32comext/propsys/src/PyPROPVARIANT.cpp pywin32-b301/com/win32comext/propsys/src/PyPROPVARIANT.cpp +--- pywin32-b301-orig/com/win32comext/propsys/src/PyPROPVARIANT.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/propsys/src/PyPROPVARIANT.cpp 2021-10-05 19:05:33 +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 -Naur pywin32-b301-orig/com/win32comext/propsys/src/propsys.cpp pywin32-b301/com/win32comext/propsys/src/propsys.cpp +--- pywin32-b301-orig/com/win32comext/propsys/src/propsys.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/propsys/src/propsys.cpp 2021-10-05 19:05:17 +0800 +@@ -38,6 +38,22 @@ + #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 *ppropvar, ++ SERIALIZEDPROPERTYVALUE **ppProp, ++ ULONG *pcb ++); ++ ++PSSTDAPI StgDeserializePropVariant( ++ const SERIALIZEDPROPERTYVALUE *pprop, ++ ULONG cbMax, ++ PROPVARIANT *ppropvar ++); ++#endif ++ + #define CHECK_PFN(fname) \ + if (pfn##fname == NULL) \ + return PyErr_Format(PyExc_NotImplementedError, "%s is not available on this platform", #fname); +diff -Naur pywin32-b301-orig/com/win32comext/shell/src/shell_pch.h pywin32-b301/com/win32comext/shell/src/shell_pch.h +--- pywin32-b301-orig/com/win32comext/shell/src/shell_pch.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/shell/src/shell_pch.h 2021-10-05 19:05:57 +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 -Naur pywin32-b301-orig/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp pywin32-b301/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp +--- pywin32-b301-orig/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp 2021-10-05 19:07:04 +0800 +@@ -488,7 +488,7 @@ + else + // Task Scheduler won't take an empty string for data anymore ?????? + if (data_len == 0) +- workitem_data = NULL; ++ workitem_data = NULL; + + HRESULT hr; + PY_INTERFACE_PRECALL; diff --git a/mingw-w64-python-pywin32/002-dependency-fixes.patch b/mingw-w64-python-pywin32/002-dependency-fixes.patch deleted file mode 100644 index e9a9eac66e..0000000000 --- a/mingw-w64-python-pywin32/002-dependency-fixes.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff -aur 000/setup.py 001/setup.py ---- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 -+++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 -@@ -100,7 +100,7 @@ - - # some modules need a static CRT to avoid problems caused by them having a - # manifest. --static_crt_modules = ["winxpgui"] -+static_crt_modules = [] - - - from distutils.dep_util import newer_group -@@ -476,6 +476,7 @@ - - class WinExt_win32(WinExt): - def __init__ (self, name, **kw): -+ kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32 pywintypes" - WinExt.__init__(self, name, **kw) - def get_pywin32_dir(self): - return "win32" -@@ -499,7 +500,7 @@ - # itself - thus, output is "win32comext" - class WinExt_win32com(WinExt): - def __init__ (self, name, **kw): -- kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32" -+ kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32 uuid pywintypes pythoncom" - - # COM extensions require later windows headers. - if not kw.get("windows_h_version"): -@@ -1500,6 +1504,10 @@ - "win32/src/PySecurityObjects.h", - ], - extra_compile_args = ['-DBUILD_PYWINTYPES'], -+ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpywintypes.dll.a' % ( -+ sys.version_info.major, -+ sys.version_info.minor, -+ )], - libraries = "advapi32 user32 ole32 oleaut32", - pch_header = "PyWinTypes.h", - ) -@@ -1764,9 +1762,13 @@ - %(win32com)s/include\\PyIEnumContextProps.h %(win32com)s/include\\PyIClientSecurity.h - %(win32com)s/include\\PyIServerSecurity.h - """ % dirs).split(), -- libraries = "oleaut32 ole32 user32 urlmon", -- export_symbol_file = 'com/win32com/src/PythonCOM.def', -+ libraries = "oleaut32 ole32 user32 urlmon uuid pywintypes", -+ # export_symbol_file = 'com/win32com/src/PythonCOM.def', - extra_compile_args = ['-DBUILD_PYTHONCOM'], -+ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpythoncom.dll.a' % ( -+ sys.version_info.major, -+ sys.version_info.minor, -+ )], - pch_header = "stdafx.h", - windows_h_version = 0x500, - base_address = dll_base_address, diff --git a/mingw-w64-python-pywin32/003-seh.patch b/mingw-w64-python-pywin32/003-seh.patch deleted file mode 100644 index eb0cdfdf70..0000000000 --- a/mingw-w64-python-pywin32/003-seh.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- 000/win32/src/win32apimodule.cpp 2019-07-18 09:05:08.224088200 +0300 -+++ 001/win32/src/win32apimodule.cpp 2018-09-28 09:32:03.000000000 +0300 -@@ -707,7 +707,7 @@ static PyObject *PyFindCloseChangeNotification(PyObject *self, PyObject *args) - } - - // @pymethod string|win32api|FormatMessage|Returns an error message from the system error file. --static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) -+__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) - { - int errCode = 0; - // @pyparm int|errCode|0|The error code to return the message for, If this value is 0, then GetLastError() is -@@ -795,6 +795,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) - { - baccessviolation = TRUE; - } -+ __except_end - PyW32_END_ALLOW_THREADS - } - -@@ -819,7 +818,7 @@ cleanup: - } - - // @pymethod |win32api|FormatMessageW|Returns an error message from the system error file. --static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) -+__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) - { - int errCode = 0; - // Accept just the error code -@@ -902,6 +913,7 @@ static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) - { - baccessviolation = TRUE; - } -+ __except_end - PyW32_END_ALLOW_THREADS - } - -@@ -5555,7 +5553,7 @@ static PyObject *PyApply(PyObject *self, PyObject *args) - Py_XDECREF(exc_type); - Py_XDECREF(exc_value); - ret = NULL; -- } -+ } __except_end - return ret; - // @comm Calls the specified function in a manner similar to - // the built-in function apply(), but allows Win32 exceptions ---- 000/com/win32com/src/include/PythonCOM.h 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32com/src/include/PythonCOM.h 2020-06-20 13:10:05.609363700 +0300 -@@ -111,8 +111,6 @@ - #ifdef __MINGW32__ - // Special Mingw32 considerations. - #define NO_PYCOM_ENUMSTATPROPSTG --#define __try try --#define __except catch - #include - - #endif // __MINGW32__ ---- 000/com/win32comext/mapi/src/mapi.i 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/mapi/src/mapi.i 2020-06-20 13:10:05.609363700 +0300 -@@ -129,6 +129,7 @@ - PyWin_SetAPIError("MAPIUninitialize", ERROR_INVALID_HANDLE); - rc = NULL; - } -+ __except_end - return rc; - } - ---- 000/com/win32comext/shell/src/shell.cpp 2020-06-13 08:39:03.000000000 +0300 -+++ 001/com/win32comext/shell/src/shell.cpp 2020-06-20 14:15:11.188333200 +0300 -@@ -258,16 +258,13 @@ - pidl = _ILNext(pidl); - } - } --#if defined(__MINGW32__) || defined(MAINWIN) -- catch (...) --#else - __except (EXCEPTION_EXECUTE_HANDLER) --#endif - { - Py_DECREF(ret); - PyErr_SetString(PyExc_ValueError, "This string is an invalid PIDL (win32 exception unpacking)"); - ret = NULL; - } -+ __except_end - if (bFreeSystemPIDL) - CoTaskMemFree((void *)pidl_free); - return ret; diff --git a/mingw-w64-python-pywin32/003-win32-extensions-fix.patch b/mingw-w64-python-pywin32/003-win32-extensions-fix.patch new file mode 100644 index 0000000000..0df6680475 --- /dev/null +++ b/mingw-w64-python-pywin32/003-win32-extensions-fix.patch @@ -0,0 +1,945 @@ +diff -Naur pywin32-b301-orig/win32/src/PerfMon/PyPerfMsgs.mc pywin32-b301/win32/src/PerfMon/PyPerfMsgs.mc +--- pywin32-b301-orig/win32/src/PerfMon/PyPerfMsgs.mc 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PerfMon/PyPerfMsgs.mc 2021-10-05 19:11:03 +0800 +@@ -85,4 +85,5 @@ + The collection DLL and application have mismatched structure sizes. The versions are probably not in synch. + . + ;// +-;#endif // _PYPERFMSG_H_ +\ No newline at end of file ++;#endif // _PYPERFMSG_H_ ++ +diff -Naur pywin32-b301-orig/win32/src/PerfMon/perfmondata.cpp pywin32-b301/win32/src/PerfMon/perfmondata.cpp +--- pywin32-b301-orig/win32/src/PerfMon/perfmondata.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PerfMon/perfmondata.cpp 2021-10-05 19:10:41 +0800 +@@ -414,7 +414,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 -Naur pywin32-b301-orig/win32/src/PyDEVMODE.cpp pywin32-b301/win32/src/PyDEVMODE.cpp +--- pywin32-b301-orig/win32/src/PyDEVMODE.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PyDEVMODE.cpp 2021-10-05 19:15:03 +0800 +@@ -759,6 +759,7 @@ + BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODEW *ppDEVMODE, BOOL bNoneOk) + { + if (ob == Py_None) ++ { + if (bNoneOk) { + *ppDEVMODE = NULL; + return TRUE; +@@ -767,6 +768,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 -Naur pywin32-b301-orig/win32/src/PySecurityObjects.h pywin32-b301/win32/src/PySecurityObjects.h +--- pywin32-b301-orig/win32/src/PySecurityObjects.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PySecurityObjects.h 2021-10-05 19:15:23 +0800 +@@ -118,7 +118,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; +@@ -155,7 +155,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 -Naur pywin32-b301-orig/win32/src/PyWinTypes.h pywin32-b301/win32/src/PyWinTypes.h +--- pywin32-b301-orig/win32/src/PyWinTypes.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PyWinTypes.h 2021-10-05 19:17:46 +0800 +@@ -28,6 +28,18 @@ + #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. + // Creates and initializes local variables called 'module' and 'dict'. +diff -Naur pywin32-b301-orig/win32/src/PyWinTypesmodule.cpp pywin32-b301/win32/src/PyWinTypesmodule.cpp +--- pywin32-b301-orig/win32/src/PyWinTypesmodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PyWinTypesmodule.cpp 2021-10-05 19:18:17 +0800 +@@ -1128,11 +1128,19 @@ + } + + // 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 + PYWINTYPES_EXPORT char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) + { + // Sleep (30000); // Time enough to attach the debugger (barely) +diff -Naur pywin32-b301-orig/win32/src/PythonService.cpp pywin32-b301/win32/src/PythonService.cpp +--- pywin32-b301-orig/win32/src/PythonService.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PythonService.cpp 2021-10-05 19:16:12 +0800 +@@ -881,6 +881,7 @@ + ReportPythonError(E_PYS_NOT_CONTROL_HANDLER); + // else no instance - an error has already been reported. + if (!bServiceDebug) ++ { + if (g_RegisterServiceCtrlHandlerEx) { + // Use 2K/XP extended registration if available + pe->sshStatusHandle = g_RegisterServiceCtrlHandlerEx(lpszArgv[0], service_ctrl_ex, pe); +@@ -889,6 +890,7 @@ + // Otherwise fall back to NT + pe->sshStatusHandle = RegisterServiceCtrlHandler(lpszArgv[0], service_ctrl); + } ++ } + } + // No instance - we can't start. + if (!instance) { +@@ -1156,7 +1158,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 %ld\n", errCode); + // Just incase the error was caused by this EXE not being registered + #ifndef BUILD_FREEZE + RegisterPythonServiceExe(); +@@ -1312,13 +1314,13 @@ + // Register the EXE. + // This writes an entry to the Python registry and also + // to the EventLog so I can stick in messages. +-static BOOL RegisterPythonServiceExe(void) ++BOOL RegisterPythonServiceExe(void) + { + printf("Registering the Python Service Manager...\n"); + 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 %ld)\n", GetLastError()); + return FALSE; + } + assert(Py_IsInitialized()); +@@ -1337,7 +1339,7 @@ + wsprintf(keyBuf, _T("Software\\Python\\PythonService\\%hs"), szVerString); + DWORD rc; + 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 %ld\n", rc); + return FALSE; + } + // don't bother registering in the event log - do it when we write a log entry. +@@ -1373,7 +1375,7 @@ + + TCHAR cvtBuf[20]; + wsprintf(cvtBuf, L"%d", errCode); +- LPTSTR lpszStrings[] = {cvtBuf, buf, L'\0'}; ++ LPTSTR lpszStrings[] = {cvtBuf, buf, _T('\0')}; + ReportError(msgCode, (LPCTSTR *)lpszStrings); + } + +diff -Naur pywin32-b301-orig/win32/src/PythonServiceMessages.mc pywin32-b301/win32/src/PythonServiceMessages.mc +--- pywin32-b301-orig/win32/src/PythonServiceMessages.mc 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/PythonServiceMessages.mc 2021-10-05 19:16:31 +0800 +@@ -137,7 +137,7 @@ + Severity=Error + SymbolicName=E_UNUSED2 + Language=English +- ++Unknown error. + . + + MessageId=0x8 +diff -Naur pywin32-b301-orig/win32/src/_winxptheme.i pywin32-b301/win32/src/_winxptheme.i +--- pywin32-b301-orig/win32/src/_winxptheme.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/_winxptheme.i 2021-10-05 19:13:49 +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 -Naur pywin32-b301-orig/win32/src/odbc.cpp pywin32-b301/win32/src/odbc.cpp +--- pywin32-b301-orig/win32/src/odbc.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/odbc.cpp 2021-10-05 19:14:45 +0800 +@@ -93,8 +93,8 @@ + static cursorObject *cursor(PyObject *o) { return (cursorObject *)o; } + + static void cursorDealloc(PyObject *self); +-PyMethodDef cursorMethods[]; +-PyMemberDef cursorMembers[]; ++extern PyMethodDef cursorMethods[]; ++extern PyMemberDef cursorMembers[]; + + static PyTypeObject Cursor_Type = { + PYWIN_OBJECT_HEAD "odbccur", /*tp_name */ +@@ -137,8 +137,8 @@ + }; + + static void connectionDealloc(PyObject *self); +-PyMethodDef connectionMethods[]; +-PyMemberDef connectionMembers[]; ++extern PyMethodDef connectionMethods[]; ++extern PyMemberDef connectionMembers[]; + static PyTypeObject Connection_Type = { + PYWIN_OBJECT_HEAD "odbcconn", /*tp_name */ + sizeof(connectionObject), /*tp_basicsize */ +@@ -379,7 +379,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. */ +@@ -387,7 +387,7 @@ + {"close", odbcClose, 1}, /* @pymeth close|Closes the connection. */ + {0, 0}}; + +-static PyMemberDef connectionMembers[] = {{"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY}, ++struct PyMemberDef connectionMembers[] = {{"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY}, + {NULL}}; + + static void connectionDealloc(PyObject *self) +@@ -1422,7 +1422,7 @@ + } + + /* @object cursor|An object representing an ODBC cursor. */ +-static PyMethodDef cursorMethods[] = { ++struct 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 */ +@@ -1432,7 +1432,7 @@ + {"setoutputsize", odbcCurSetOutputSize, 1}, /* @pymeth setoutputsize| */ + {0, 0}}; + +-static PyMemberDef cursorMembers[] = {{"description", T_OBJECT, offsetof(cursorObject, description), READONLY}, ++struct PyMemberDef cursorMembers[] = {{"description", T_OBJECT, offsetof(cursorObject, description), READONLY}, + {"error", T_OBJECT, offsetof(cursorObject, cursorError), READONLY}, + {NULL}}; + +diff -Naur pywin32-b301-orig/win32/src/win32api_display.cpp pywin32-b301/win32/src/win32api_display.cpp +--- pywin32-b301-orig/win32/src/win32api_display.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32api_display.cpp 2021-10-05 19:18:33 +0800 +@@ -134,28 +134,36 @@ + return NULL; + + 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 (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 (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 (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); + } +@@ -243,6 +251,7 @@ + BOOL PyWinObject_AsDISPLAY_DEVICE(PyObject *ob, PDISPLAY_DEVICE *ppDISPLAY_DEVICE, BOOL bNoneOk) + { + if (ob == Py_None) ++ { + if (bNoneOk) { + *ppDISPLAY_DEVICE = NULL; + return TRUE; +@@ -251,6 +260,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 -Naur pywin32-b301-orig/win32/src/win32apimodule.cpp pywin32-b301/win32/src/win32apimodule.cpp +--- pywin32-b301-orig/win32/src/win32apimodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32apimodule.cpp 2021-10-05 19:19:01 +0800 +@@ -5592,8 +5592,8 @@ + } + PyThreadState *stateSave = PyThreadState_Swap(NULL); + PyThreadState_Swap(stateSave); +- _try { ret = PyObject_CallObject(obFunc, obArgs); } +- _except(PyApplyExceptionFilter(GetExceptionCode(), GetExceptionInformation(), obHandler, &exc_type, &exc_value)) ++ __try { ret = PyObject_CallObject(obFunc, obArgs); } ++ __except(PyApplyExceptionFilter(GetExceptionCode(), GetExceptionInformation(), obHandler, &exc_type, &exc_value)) + { + // Do my best to restore the thread state to a sane spot. + PyThreadState *stateCur = PyThreadState_Swap(NULL); +diff -Naur pywin32-b301-orig/win32/src/win32consolemodule.cpp pywin32-b301/win32/src/win32consolemodule.cpp +--- pywin32-b301-orig/win32/src/win32consolemodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32consolemodule.cpp 2021-10-05 19:19:23 +0800 +@@ -1,4 +1,5 @@ + // @doc ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x501 + #include "PyWinTypes.h" + #include "PyWinObjects.h" +@@ -1296,6 +1297,7 @@ + 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 +1305,7 @@ + Py_INCREF(Py_None); + return Py_None; + } ++ } + return NULL; + } + +@@ -1814,12 +1817,14 @@ + CHECK_PFN(AddConsoleAlias); + if (PyWinObject_AsWCHAR(obsource, &source, 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 -Naur pywin32-b301-orig/win32/src/win32credmodule.cpp pywin32-b301/win32/src/win32credmodule.cpp +--- pywin32-b301-orig/win32/src/win32credmodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32credmodule.cpp 2021-10-05 19:21:29 +0800 +@@ -1,4 +1,5 @@ + // @doc ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x501 // Credentials functions only available on WinXP + #include "PyWinTypes.h" + #include "PyWinObjects.h" +diff -Naur pywin32-b301-orig/win32/src/win32crypt/win32cryptmodule.cpp pywin32-b301/win32/src/win32crypt/win32cryptmodule.cpp +--- pywin32-b301-orig/win32/src/win32crypt/win32cryptmodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32crypt/win32cryptmodule.cpp 2021-10-05 19:12:21 +0800 +@@ -1,4 +1,5 @@ + // @doc ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x502 + #include "win32crypt.h" + +@@ -486,7 +487,7 @@ + CertEnumSystemStore(dwFlags, pvSystemStoreLocationPara, ret, CertEnumSystemStoreCallback); + Py_END_ALLOW_THREADS + +- if (!bsuccess) ++ if (!bsuccess) + { + Py_DECREF(ret); + ret = NULL; +@@ -582,6 +583,7 @@ + pvPara = (void *)&cssrp; + } + else { ++#ifdef _MSC_VER + switch ((ULONG_PTR)StoreProvider) { + case CERT_STORE_PROV_PHYSICAL: + case CERT_STORE_PROV_FILENAME: +@@ -623,6 +625,41 @@ + return NULL; + } + } ++#else ++ if (StoreProvider == CERT_STORE_PROV_PHYSICAL) ++ if (StoreProvider == CERT_STORE_PROV_FILENAME) ++ if (StoreProvider == CERT_STORE_PROV_SYSTEM) ++ if (StoreProvider == CERT_STORE_PROV_SYSTEM_REGISTRY) ++ if (StoreProvider == CERT_STORE_PROV_LDAP) { ++ if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) ++ return NULL; ++ free_wchar = TRUE; ++ } ++ if (StoreProvider == CERT_STORE_PROV_REG) { ++ if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) ++ return NULL; ++ } ++ if (StoreProvider == CERT_STORE_PROV_FILE) { ++ if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) ++ return NULL; ++ } ++ if (StoreProvider == CERT_STORE_PROV_SERIALIZED) ++ if (StoreProvider == CERT_STORE_PROV_PKCS7) { ++ if (!pybuf.init(obpvPara)) ++ return NULL; ++ crypt_data_blob.pbData = (BYTE*)pybuf.ptr(); ++ crypt_data_blob.cbData = pybuf.len(); ++ pvPara = (void *)&crypt_data_blob; ++ } ++ if (StoreProvider == 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"); ++ } ++ ++ PyErr_SetString(PyExc_NotImplementedError, "Specified store provider type not supported"); ++ return NULL; ++#endif + } + + Py_BEGIN_ALLOW_THREADS hcertstore = CertOpenStore(StoreProvider, dwEncodingType, hcryptprov, dwFlags, pvPara); +diff -Naur pywin32-b301-orig/win32/src/win32dynamicdialog.cpp pywin32-b301/win32/src/win32dynamicdialog.cpp +--- pywin32-b301-orig/win32/src/win32dynamicdialog.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32dynamicdialog.cpp 2021-10-05 19:21:51 +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) { +diff -Naur pywin32-b301-orig/win32/src/win32event.i pywin32-b301/win32/src/win32event.i +--- pywin32-b301-orig/win32/src/win32event.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32event.i 2021-10-05 19:22:21 +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 -Naur pywin32-b301-orig/win32/src/win32evtlog.i pywin32-b301/win32/src/win32evtlog.i +--- pywin32-b301-orig/win32/src/win32evtlog.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32evtlog.i 2021-10-05 19:22:37 +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 -Naur pywin32-b301-orig/win32/src/win32file.i pywin32-b301/win32/src/win32file.i +--- pywin32-b301-orig/win32/src/win32file.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32file.i 2021-10-05 19:23:09 +0800 +@@ -73,6 +73,9 @@ + %include "typemaps.i" + %include "pywin32.i" + ++%typedef DCB DCB; ++%typedef COMMTIMEOUTS COMMTIMEOUTS; ++ + %{ + + #include "datetime.h" // python's datetime header. +@@ -753,8 +756,8 @@ + &obHandle, &obCreationTime, &obLastAccessTime, &obLastWriteTime, &UTCTimes)) + return NULL; + +- if (!PyWinObject_AsHANDLE(obHandle, &hHandle)) +- return NULL; ++ if (!PyWinObject_AsHANDLE(obHandle, &hHandle)) ++ return NULL; + if (obCreationTime != Py_None){ + if (!PyWinObject_AsFILETIME(obCreationTime, &FileTime)) + return NULL; +diff -Naur pywin32-b301-orig/win32/src/win32file_comm.cpp pywin32-b301/win32/src/win32file_comm.cpp +--- pywin32-b301-orig/win32/src/win32file_comm.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32file_comm.cpp 2021-10-05 19:24:16 +0800 +@@ -163,7 +163,7 @@ + PyDCB::~PyDCB(void) {} + + #define GET_BITFIELD_ENTRY(bitfield_name) \ +- else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); } ++ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.bitfield_name); } + + PyObject *PyDCB::getattro(PyObject *self, PyObject *obname) + { +@@ -198,7 +198,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; \ + } + +@@ -362,7 +362,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); } ++ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.bitfield_name); } + + PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname) + { +@@ -391,7 +391,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 -Naur pywin32-b301-orig/win32/src/win32gui.i pywin32-b301/win32/src/win32gui.i +--- pywin32-b301-orig/win32/src/win32gui.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32gui.i 2021-10-05 19:25:22 +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) { +@@ -1766,9 +1779,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; +@@ -7587,13 +7600,13 @@ + "structure says it has %d bytes, but %d was provided", + (int)struct_bytes, (int)pybuf.len()); + // @pyseeapi RegisterDeviceNotification +- HDEVNOTIFY not; ++ HDEVNOTIFY notify; + Py_BEGIN_ALLOW_THREADS +- not = RegisterDeviceNotification(handle, pybuf.ptr(), flags); ++ notify = RegisterDeviceNotification(handle, pybuf.ptr(), 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 -Naur pywin32-b301-orig/win32/src/win32inet.i pywin32-b301/win32/src/win32inet.i +--- pywin32-b301-orig/win32/src/win32inet.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32inet.i 2021-10-05 19:25:44 +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 -Naur pywin32-b301-orig/win32/src/win32net/win32netmisc.cpp pywin32-b301/win32/src/win32net/win32netmisc.cpp +--- pywin32-b301-orig/win32/src/win32net/win32netmisc.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32net/win32netmisc.cpp 2021-10-05 19:12:53 +0800 +@@ -1417,7 +1417,8 @@ + + #if WINVER >= 0x0500 + +-extern "C" NetValidateNamefunc pfnNetValidateName = NULL; ++extern "C" NetValidateNamefunc pfnNetValidateName; ++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 +@@ -1460,8 +1461,10 @@ + return ret; + } + +-extern "C" NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy = NULL; +-extern "C" NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree = NULL; ++extern "C" NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy; ++NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy = NULL; ++extern "C" NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree; ++NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree = NULL; + + static void PyObject_CleanupAUTH_INPUT(NET_VALIDATE_AUTHENTICATION_INPUT_ARG *p) + { +diff -Naur pywin32-b301-orig/win32/src/win32pdhmodule.cpp pywin32-b301/win32/src/win32pdhmodule.cpp +--- pywin32-b301-orig/win32/src/win32pdhmodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32pdhmodule.cpp 2021-10-05 19:26:15 +0800 +@@ -1003,7 +1003,7 @@ + { \ + if (i < seqLen) { \ + PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \ +- myCfg.cfg.##r = PyObject_IsTrue(subItem); \ ++ myCfg.cfg.r = PyObject_IsTrue(subItem); \ + } \ + } + +diff -Naur pywin32-b301-orig/win32/src/win32print/win32print.cpp pywin32-b301/win32/src/win32print/win32print.cpp +--- pywin32-b301-orig/win32/src/win32print/win32print.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32print/win32print.cpp 2021-10-05 19:13:26 +0800 +@@ -335,6 +335,7 @@ + + *pbuf = NULL; + if (level == 0) ++ { + if (obinfo == Py_None) + return TRUE; + else { +@@ -346,6 +347,7 @@ + } + return TRUE; + } ++ } + + if (!PyDict_Check(obinfo)) { + PyErr_Format(PyExc_TypeError, "PRINTER_INFO_%d must be a dictionary", level); +@@ -2454,12 +2456,14 @@ + if (PyArg_ParseTuple(args, "OOO:DeletePrinterDriver", &observername, &obenvironment, &obdrivername) && + 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); +@@ -2489,12 +2493,14 @@ + &versionflag) && + 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 -Naur pywin32-b301-orig/win32/src/win32process.i pywin32-b301/win32/src/win32process.i +--- pywin32-b301-orig/win32/src/win32process.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32process.i 2021-10-05 19:26:42 +0800 +@@ -1621,6 +1621,7 @@ + $target = PyWinLong_FromVoidPtr($source); + } + ++%typedef ULONG_PTR ULONG_PTR; + + // @pyswig long|VirtualAllocEx| + LONG_VOIDPTR VirtualAllocEx( +diff -Naur pywin32-b301-orig/win32/src/win32security.i pywin32-b301/win32/src/win32security.i +--- pywin32-b301-orig/win32/src/win32security.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32security.i 2021-10-05 19:27:41 +0800 +@@ -5,6 +5,7 @@ + %module win32security // An interface to the win32 security API's + + %{ ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x0600 // Vista! + %} + +@@ -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; +@@ -114,8 +115,8 @@ + HMODULE loadmodule(WCHAR *dllname) + { + HMODULE hmodule = GetModuleHandle(dllname); +- if (hmodule==NULL) +- hmodule = LoadLibrary(dllname); ++ if (hmodule==NULL) ++ hmodule = LoadLibrary(dllname); + return hmodule; + } + +@@ -3339,12 +3340,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) +diff -Naur pywin32-b301-orig/win32/src/win32service.i pywin32-b301/win32/src/win32service.i +--- pywin32-b301-orig/win32/src/win32service.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32service.i 2021-10-05 19:28:03 +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 -Naur pywin32-b301-orig/win32/src/win32tsmodule.cpp pywin32-b301/win32/src/win32tsmodule.cpp +--- pywin32-b301-orig/win32/src/win32tsmodule.cpp 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/win32/src/win32tsmodule.cpp 2021-10-05 19:28:24 +0800 +@@ -1,4 +1,5 @@ + // @doc ++#undef _WIN32_WINNT + #define _WIN32_WINNT 0x501 + #include "PyWinTypes.h" + #include "PyWinObjects.h" +@@ -96,6 +97,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)) ++ { + if (!WTSQueryUserConfig(ServerName, UserName, WTSConfigClass, &buf, &bufsize)) + PyWin_SetAPIError("WTSQueryUserConfig"); + else +@@ -137,6 +139,7 @@ + default: + PyErr_SetString(PyExc_NotImplementedError, "Config class not supported yet"); + } ++ } + + PyWinObject_FreeWCHAR(ServerName); + PyWinObject_FreeWCHAR(UserName); diff --git a/mingw-w64-python-pywin32/004-disable-modules.patch b/mingw-w64-python-pywin32/004-disable-modules.patch deleted file mode 100644 index 927524174e..0000000000 --- a/mingw-w64-python-pywin32/004-disable-modules.patch +++ /dev/null @@ -1,89 +0,0 @@ ---- 000/setup.py 2020-06-20 14:41:31.583265800 +0300 -+++ 001/setup.py 2020-06-20 17:41:06.998916300 +0300 -@@ -1006,12 +1009,12 @@ - # need at this stage. - if sys.version_info > (2, 7) and sys.version_info < (3, 3): - # only stuff built with msvc9 needs this loader. -- self._build_pycom_loader() -- self._build_scintilla() -+ #self._build_pycom_loader() -+ pass -+ #self._build_scintilla() - # Copy cpp lib files needed to create Python COM extensions -- clib_files = (['win32', 'pywintypes%s.lib'], -- ['win32com', 'pythoncom%s.lib'], -- ['win32com', 'axscript%s.lib']) -+ clib_files = (['win32', 'pywintypes%s.def'], -+ ['win32com', 'pythoncom%s.def']) - 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): -@@ -1041,20 +1041,6 @@ - mfc_version = "vc140" - mfc_libraries = ["mfc140u.dll", "mfcm140u.dll"] - -- mfc_contents = self.lookupMfcInVisualStudio(mfc_version, mfc_libraries) -- if not mfc_contents: -- print("Can't find MFC contents in VisualStudio. Looking into WinSxS now..") -- mfc_contents = self.lookupMfcInWinSxS(mfc_version, mfc_libraries) -- -- if not mfc_contents: -- raise RuntimeError("No MFC files found!") -- -- for mfc_content in mfc_contents: -- shutil.copyfile(mfc_content, -- os.path.join(target_dir, os.path.split(mfc_content)[1]), -- ) -- -- - def build_exefile(self, ext): - sources = ext.sources - if sources is None or type(sources) not in (list, tuple): -@@ -1917,6 +1920,6 @@ - """ % dirs).split(), - depends=["%(internet)s/internet_pch.h" % dirs]), -- WinExt_win32com('mapi', libraries="advapi32", pch_header="PythonCOM.h", -+ WinExt_win32com('mapi', libraries="advapi32 SKIP", pch_header="PythonCOM.h", - include_dirs=["%(mapi)s/mapi_headers" % dirs], - sources=(""" - %(mapi)s/mapi.i %(mapi)s/mapi.cpp -@@ -2041,6 +2045,6 @@ - """ % dirs).split()), - -- WinExt_win32com('propsys', libraries='propsys', delay_load_libraries='shell32', -+ WinExt_win32com('propsys', libraries='propsys SKIP', delay_load_libraries='shell32', - unicode_mode=True, - sources=(""" - %(propsys)s/propsys.cpp -@@ -2122,6 +2127,7 @@ - - pythonwin_extensions = [ - WinExt_pythonwin("win32ui", -+ libraries="SKIP", - sources = [ - "Pythonwin/dbgthread.cpp", - "Pythonwin/dibapi.cpp", -@@ -2225,6 +2231,7 @@ - ], - optional_headers=['afxres.h']), - WinExt_pythonwin("win32uiole", -+ libraries="SKIP", - sources = [ - "Pythonwin/stdafxole.cpp", - "Pythonwin/win32oleDlgInsert.cpp", -@@ -2242,6 +2249,7 @@ - windows_h_version = 0x500, - optional_headers=['afxres.h']), - WinExt_pythonwin("dde", -+ libraries="SKIP", - sources = [ - "Pythonwin/stddde.cpp", - "Pythonwin/ddetopic.cpp", -@@ -2292,6 +2300,7 @@ - unicode_mode = True, - libraries = "user32 advapi32 ole32 shell32 pywintypes"), - WinExt_pythonwin_subsys_win("Pythonwin", -+ libraries="SKIP", - sources = [ - "Pythonwin/pythonwin.cpp", - "Pythonwin/pythonwin.rc", diff --git a/mingw-w64-python-pywin32/004-isapi-fix.patch b/mingw-w64-python-pywin32/004-isapi-fix.patch new file mode 100644 index 0000000000..5c0de8f565 --- /dev/null +++ b/mingw-w64-python-pywin32/004-isapi-fix.patch @@ -0,0 +1,26 @@ +diff -Naur pywin32-b301-orig/isapi/src/PythonEng.h pywin32-b301/isapi/src/PythonEng.h +--- pywin32-b301-orig/isapi/src/PythonEng.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/isapi/src/PythonEng.h 2021-10-05 19:07:38 +0800 +@@ -63,7 +63,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 -Naur pywin32-b301-orig/isapi/src/StdAfx.h pywin32-b301/isapi/src/StdAfx.h +--- pywin32-b301-orig/isapi/src/StdAfx.h 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/isapi/src/StdAfx.h 2021-10-05 19:08:26 +0800 +@@ -51,6 +51,10 @@ + typedef int Py_ssize_t; + #endif + ++#ifndef _MSC_VER ++#define HSE_REQ_SET_FLUSH_FLAG (HSE_REQ_END_RESERVED+43) ++#endif ++ + // ***** py3k support ***** + // Note that when built for py3k, 'UNICODE' is defined, which conveniently + // means TCHAR is the same size as the native unicode object in all versions. diff --git a/mingw-w64-python-pywin32/005-swig-fix.patch b/mingw-w64-python-pywin32/005-swig-fix.patch new file mode 100644 index 0000000000..78d45ec5d8 --- /dev/null +++ b/mingw-w64-python-pywin32/005-swig-fix.patch @@ -0,0 +1,122 @@ +diff -Naur pywin32-b301-orig/SWIG/swig_lib/python/pythoncom.i pywin32-b301/SWIG/swig_lib/python/pythoncom.i +--- pywin32-b301-orig/SWIG/swig_lib/python/pythoncom.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/SWIG/swig_lib/python/pythoncom.i 2021-10-05 19:09:14 +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 -Naur pywin32-b301-orig/SWIG/swig_lib/python/pywintypes.i pywin32-b301/SWIG/swig_lib/python/pywintypes.i +--- pywin32-b301-orig/SWIG/swig_lib/python/pywintypes.i 2021-05-30 16:31:38 +0800 ++++ pywin32-b301/SWIG/swig_lib/python/pywintypes.i 2021-10-05 19:10:04 +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 --git a/mingw-w64-python-pywin32/006-mapi-headers-fix.patch b/mingw-w64-python-pywin32/006-mapi-headers-fix.patch new file mode 100644 index 0000000000..d9be2f7d34 --- /dev/null +++ b/mingw-w64-python-pywin32/006-mapi-headers-fix.patch @@ -0,0 +1,76 @@ +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPI.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPI.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPI.h 2021-10-06 01:38:35 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPI.h 2021-10-06 01:42:20 +0800 +@@ -20,6 +20,13 @@ + #pragma once + #endif + ++#ifndef _MSC_VER ++#define __in ++#define __in_opt ++#define __out ++#define __deref_out_ecount_full(x) ++#endif ++ + /* + * Types. + */ +@@ -160,7 +167,7 @@ + + /* #define MAPI_LOGON_UI 0x00000001 Display logon UI */ + /* #define MAPI_NEW_SESSION 0x00000002 Don't use shared session */ +-/* #define MAPI_LONG_MSGID 0x00004000 /* allow 512 char returned ID */ ++/* #define MAPI_LONG_MSGID 0x00004000 allow 512 char returned ID */ + + /* MAPIAddress() flags. */ + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPICode.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPICode.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2021-10-06 01:38:35 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2021-10-06 01:41:52 +0800 +@@ -216,5 +216,4 @@ + #endif + + #endif /* MAPICODE_H */ +- + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPIDefS.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPIDefS.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPIDefS.h 2021-10-06 01:38:35 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPIDefS.h 2021-10-06 01:42:30 +0800 +@@ -51,6 +51,13 @@ + #include + #endif + ++#ifndef _MSC_VER ++#define __in ++#define __in_opt ++#define __out ++#define __deref_out_ecount_full(x) ++#endif ++ + /* Array dimension for structures with variable-sized arrays at the end. */ + + #ifndef MAPI_DIM +@@ -2728,5 +2735,4 @@ + #endif + + #endif /* MAPIDEFS_H */ +- + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPIForm.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPIForm.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2021-10-06 01:38:35 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2021-10-06 01:42:36 +0800 +@@ -631,5 +631,4 @@ + + #endif /* MAPIFORM_H */ + +- + +diff -Naur pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MSPST.h pywin32-b301/com/win32comext/mapi/src/mapi_headers/MSPST.h +--- pywin32-b301-orig/com/win32comext/mapi/src/mapi_headers/MSPST.h 2021-10-06 01:38:35 +0800 ++++ pywin32-b301/com/win32comext/mapi/src/mapi_headers/MSPST.h 2021-10-06 01:42:42 +0800 +@@ -97,5 +97,4 @@ + 0xd9, 0x6e, 0x00, 0x00 } + + #endif /* _MSPST_H_ */ +- + diff --git a/mingw-w64-python-pywin32/PKGBUILD b/mingw-w64-python-pywin32/PKGBUILD index 65a9f4018a..088ee22cdc 100644 --- a/mingw-w64-python-pywin32/PKGBUILD +++ b/mingw-w64-python-pywin32/PKGBUILD @@ -1,6 +1,7 @@ # Maintainer: Ray Donnelly # Maintainer: Joan Karadimov # Contributor: Renato Silva +# Contributor: Raed Rizqie _realname='pywin32' pkgbase=mingw-w64-python-${_realname} @@ -10,36 +11,37 @@ pkgdesc='Python for Windows Extensions (mingw-w64)' license=('PSF') arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64') -pkgver=228 +pkgver=301 pkgrel=1 makedepends=( ${MINGW_PACKAGE_PREFIX}-python ${MINGW_PACKAGE_PREFIX}-python-setuptools rsync) source=("https://github.com/mhammond/${_realname}/archive/b${pkgver}.zip" - setup.cfg seh.h - minmax.h 001-compile-and-setup-fixes.patch - 002-dependency-fixes.patch - 003-seh.patch - 004-disable-modules.patch) -sha256sums=('524a40b85bd0d0bd52a5bcce7ccb236ae46a336975df5452b336d813f4b64a6d' - '74033ac90498a63b579b4dd8c5948b2ea1a9de63aa57f3d4e4e44bb0f549520b' + 002-com-extensions-fix.patch + 003-win32-extensions-fix.patch + 004-isapi-fix.patch + 005-swig-fix.patch + 006-mapi-headers-fix.patch) +sha256sums=('b55811d60112aea58c58bbed2ffd92f7be6727cb2400764755c7e6cd9789d210' '03f8c0372059bb5b1933d77309101c67fa08504b42a6fce1186ed9a29e0c271f' - '17eb1454e8955771af57209a49439f7cf26a885767a8e707f6c77e3c3ccd479f' - 'a6dc5c309148b85cd0b2e90f673d998528747e9fceab43d246bbe17ee7a4c8ad' - 'fcc23eaaff99160147db4dd48cf951b6db62adb8287807e7a281c032902c4f98' - '109a3ece2cfa359b6e68aebbcc74db4b7e80eda0be3d9c6bed88a7d099c70d37' - 'e8c32de54fe2a375b0331fae36efaa4400518386d03ee429da13e1846b4c2e08') + '0d0406f36f0d203e69a7cb489f83428a2546c417e56e2147ddf2f73256d14af7' + 'fb941a9f0e0c929c8596cba7f0a1fcc9ee6c1f642aa727f5b50c0dde2006dace' + '851d01864eea19d668e748214cb2ed19164c34f9a2db470e9b393a33559e7f26' + '495735237e62d9cd829671a20e28896b4055ab3c017b06a12f3a56cfcfa5e9bd' + '076cc45da1e5c44ee5530e72766a6aeac222b3db4117043761de5f1ac18f8aeb' + '65da9bd818544422446b2f41ef6ab2d52a9dba5c21402a499ac89c3049d09324') prepare() { cd "${srcdir}/${_realname}-b${pkgver}" patch -p1 < "${startdir}"/001-compile-and-setup-fixes.patch - patch -p1 < "${startdir}"/002-dependency-fixes.patch - patch -p1 < "${startdir}"/003-seh.patch - patch -p1 < "${startdir}"/004-disable-modules.patch - cp "${startdir}"/setup.cfg setup.cfg + patch -p1 < "${startdir}"/002-com-extensions-fix.patch + patch -p1 < "${startdir}"/003-win32-extensions-fix.patch + patch -p1 < "${startdir}"/004-isapi-fix.patch + patch -p1 < "${startdir}"/005-swig-fix.patch + patch -p1 < "${startdir}"/006-mapi-headers-fix.patch } build() { @@ -47,10 +49,9 @@ build() { rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-python-${CARCH}-${_realname}-${pkgver}" cd "${srcdir}/build-python-${CARCH}-${_realname}-${pkgver}" - CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive -include ../seh.h -include ../minmax.h -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS" \ LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ - ${MINGW_PREFIX}/bin/python setup.py build + ${MINGW_PREFIX}/bin/python setup.py build --skip-verstamp } package() { diff --git a/mingw-w64-python-pywin32/minmax.h b/mingw-w64-python-pywin32/minmax.h deleted file mode 100644 index df1bf85ef1..0000000000 --- a/mingw-w64-python-pywin32/minmax.h +++ /dev/null @@ -1,2 +0,0 @@ -#define min(a, b) (((a)<(b))?(a):(b)) -#define max(a, b) (((a)>(b))?(a):(b)) diff --git a/mingw-w64-python-pywin32/setup.cfg b/mingw-w64-python-pywin32/setup.cfg deleted file mode 100644 index 68ed37fbd5..0000000000 --- a/mingw-w64-python-pywin32/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[build] -compiler=mingw32