--- ./PC/_winreg.c.MINGW 2009-06-11 00:08:17.000000000 +0300 +++ ./PC/_winreg.c 2009-06-10 22:03:53.000000000 +0300 @@ -17,6 +17,18 @@ #include "malloc.h" /* for alloca */ #include "windows.h" +#if defined(__MINGW32__) +_CRTIMP size_t __cdecl __MINGW_NOTHROW _mbstrlen(const char *s); +#endif + +#if !defined(REG_LEGAL_CHANGE_FILTER) +#define REG_LEGAL_CHANGE_FILTER \ + (REG_NOTIFY_CHANGE_NAME |\ + REG_NOTIFY_CHANGE_ATTRIBUTES |\ + REG_NOTIFY_CHANGE_LAST_SET |\ + REG_NOTIFY_CHANGE_SECURITY) +#endif + static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); static PyObject *PyHKEY_FromHKEY(HKEY h); static BOOL PyHKEY_Close(PyObject *obHandle); --- ./PC/msvcrtmodule.c.MINGW 2010-02-18 22:16:40.000000000 +0200 +++ ./PC/msvcrtmodule.c 2010-02-18 21:54:38.000000000 +0200 @@ -22,6 +22,31 @@ #include #include +#if defined(__MINGW32__) +#if __MSVCRT_VERSION__ >= 0x0700 +# define _WCONIO_DEFINED +/* NOTE: Up to version ?.?? mingw don't define functions + * listed below. Also it require module to be linked with + * ms-vcrt at least verion 7. + * To build with different runtimes see: + * http://www.mingw.org/wiki/HOWTO_Use_the_GCC_specs_file + * + * Also note that NT5.1(XP), shiped with msvcrt version 7.0, + * contain all those functions, but library name is msvcrt.dll. + * So if you like module to run on w2k as is you must define + * appropriate __MSVCRT_VERSION__ . + * If you like those functions even on w2k you must link + * with appropriate runtime and to pack it in distributions. + * This is what MSVC build do - it is build and packed + * with version 9.0 of Microsoft C-runtime. + */ +_CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwch (void); +_CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwche (void); +_CRTIMP wint_t __cdecl __MINGW_NOTHROW _putwch (wchar_t); +_CRTIMP wint_t __cdecl __MINGW_NOTHROW _ungetwch(wint_t); +#endif /* __MSVCRT_VERSION__ >= 0x0700 */ +#endif + #ifdef _MSC_VER #if _MSC_VER >= 1500 && _MSC_VER < 1600 #include @@ -343,6 +368,7 @@ if (!PyArg_ParseTuple(args, "u:ungetwch", &ch)) return NULL; + /* FIXME: why _ungetch is called instead _ungetwch */ if (_ungetch(ch) == EOF) return PyErr_SetFromErrno(PyExc_IOError); Py_INCREF(Py_None); --- ./Lib/test/regrtest.py.MINGW 2010-03-06 23:51:50.000000000 +0200 +++ ./Lib/test/regrtest.py 2010-03-06 23:52:09.000000000 +0200 @@ -388,7 +388,8 @@ found_garbage = [] if single: - filename = 'pynexttest' + from tempfile import gettempdir + filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next_test = fp.read().strip() --- ./Lib/test/test_sundry.py.MINGW 2009-04-29 22:49:56.000000000 +0300 +++ ./Lib/test/test_sundry.py 2010-02-24 00:50:10.000000000 +0200 @@ -29,7 +29,11 @@ import distutils.command.bdist_dumb if sys.platform.startswith('win'): - import distutils.command.bdist_msi + try: + import distutils.command.bdist_msi # if msi module is not build + except ImportError: + if test_support.verbose: + print "skipping bdist_msi" import distutils.command.bdist import distutils.command.bdist_rpm import distutils.command.bdist_wininst --- ./Lib/test/test_unittest.py.MINGW 2010-03-11 23:52:04.000000000 +0200 +++ ./Lib/test/test_unittest.py 2010-03-11 23:18:56.000000000 +0200 @@ -3664,6 +3664,11 @@ loader = unittest.TestLoader() loader._top_level_dir = '/foo' + #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ... + #NOTE: Its fail on platforms without root directory support(like windows) + #where temp and current working directories may stay on different drivers. + old_wd = os.getcwd() + os.chdir(test_support.SAVEDCWD) name = loader._get_name_from_path('/foo/bar/baz.py') self.assertEqual(name, 'bar.baz') @@ -3673,6 +3678,7 @@ with self.assertRaises(AssertionError): loader._get_name_from_path('/bar/baz.py') + os.chdir(old_wd) def test_find_tests(self): loader = unittest.TestLoader() @@ -3708,7 +3714,13 @@ loader.loadTestsFromModule = lambda module: module + ' tests' loader._top_level_dir = '/foo' + #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ... + #NOTE: Its fail on platforms without root directory support(like windows) + #where temp and current working directories may stay on different drivers. + old_wd = os.getcwd() + os.chdir(test_support.SAVEDCWD) suite = list(loader._find_tests('/foo', 'test*.py')) + os.chdir(old_wd) expected = [name + ' module tests' for name in ('test1', 'test2')] @@ -3769,7 +3781,13 @@ loader._top_level_dir = '/foo' # this time no '.py' on the pattern so that it can match # a test package + #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ... + #NOTE: Its fail on platforms without root directory support(like windows) + #where temp and current working directories may stay on different drivers. + old_wd = os.getcwd() + os.chdir(test_support.SAVEDCWD) suite = list(loader._find_tests('/foo', 'test*')) + os.chdir(old_wd) # We should have loaded tests from the test_directory package by calling load_tests # and directly from the test_directory2 package --- ./Lib/distutils/command/build_ext.py.MINGW 2010-03-05 23:51:59.000000000 +0200 +++ ./Lib/distutils/command/build_ext.py 2010-03-05 23:58:21.000000000 +0200 @@ -19,7 +19,8 @@ from distutils.util import get_platform from distutils import log -if os.name == 'nt': +# GCC(mingw): os.name is "nt" but build system is posix +if os.name == 'nt' and sys.version.find('GCC') < 0: from distutils.msvccompiler import get_build_version MSVC_VERSION = int(get_build_version()) @@ -180,7 +181,8 @@ # for extensions under windows use different directories # for Release and Debug builds. # also Python's library directory must be appended to library_dirs - if os.name == 'nt': + # GCC(mingw): os.name is "nt" but build system is posix + if os.name == 'nt' and sys.version.find('GCC') < 0: # the 'libs' directory is for binary installs - we assume that # must be the *native* platform. But we don't really support # cross-compiling via a binary install anyway, so we let it go. @@ -222,7 +224,8 @@ # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs - if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': + if (sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' + or (sys.platform == 'win32' and sys.version.find('GCC') >= 0)): if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", @@ -700,6 +703,34 @@ # pyconfig.h that MSVC groks. The other Windows compilers all seem # to need it mentioned explicitly, though, so that's what we do. # Append '_d' to the python import library on debug builds. + + # FIXME: What is purpose of code below ? + # The posix build system khow requred libraries to build a module. + # The libraries are stored in config(Makefile) variables BLDLIBRARY, + # MODLIBS and SHLIBS. Note that some variables may contain linker + # flags. + # NOTE: For now we will check only GCC(mingw) compiler as is clear + # that we build for windows platfrom. + # The code for GCC(mingw) is not correct but this is distutils + # limitation - we has to pass variables to the linker as is + # instead only library names. + if self.compiler.compiler_type == 'mingw32': + from distutils import sysconfig + template = "python%s" + if self.debug: + template = template + '_d' + extra = [(template % (sysconfig.get_config_var('VERSION')))] + for lib in sysconfig.get_config_var('BLDLIBRARY').split(): + if lib.startswith('-l'): + extra.append(lib[2:]) + for lib in sysconfig.get_config_var('MODLIBS').split(): + if lib.startswith('-l'): + extra.append(lib[2:]) + for lib in sysconfig.get_config_var('SHLIBS').split(): + if lib.startswith('-l'): + extra.append(lib[2:]) + return ext.libraries + extra + if sys.platform == "win32": from distutils.msvccompiler import MSVCCompiler if not isinstance(self.compiler, MSVCCompiler): --- ./Lib/distutils/tests/test_msvc9compiler.py.MINGW 2009-12-23 11:38:45.000000000 +0200 +++ ./Lib/distutils/tests/test_msvc9compiler.py 2009-12-27 12:36:38.000000000 +0200 @@ -109,7 +109,11 @@ self.assertTrue('Desktop' in keys) def test_remove_visual_c_ref(self): - from distutils.msvc9compiler import MSVCCompiler + try: + from distutils.msvc9compiler import MSVCCompiler + except DistutilsPlatformError: + # FIXME: this test is only for MSVC X.Y(?) or above + raise unittest.SkipTest, "manifest not supported" tempdir = self.mkdtemp() manifest = os.path.join(tempdir, 'manifest') f = open(manifest, 'w') --- ./Lib/distutils/tests/test_unixccompiler.py.MINGW 2010-03-05 22:31:41.000000000 +0200 +++ ./Lib/distutils/tests/test_unixccompiler.py 2010-03-07 00:39:47.000000000 +0200 @@ -119,7 +119,7 @@ def gcv(v): return 'xxx' sysconfig.get_config_var = gcv - self.assertEqual(self.cc.rpath_foo(), '-R/foo') + self.assertEqual(self.cc.rpath_foo(), '-blibpath:/foo') def test_suite(): --- ./Lib/distutils/tests/test_bdist_msi.py.MINGW 2010-02-10 23:26:43.000000000 +0200 +++ ./Lib/distutils/tests/test_bdist_msi.py 2010-03-05 22:31:41.000000000 +0200 @@ -11,6 +11,7 @@ support.LoggingSilencer, unittest.TestCase): + @unittest.skip("Require bdist_msi") def test_minial(self): # minimal test XXX need more tests from distutils.command.bdist_msi import bdist_msi --- ./Lib/distutils/tests/test_sysconfig.py.MINGW 2010-02-10 23:05:26.000000000 +0200 +++ ./Lib/distutils/tests/test_sysconfig.py 2010-02-21 21:41:57.000000000 +0200 @@ -43,9 +43,15 @@ # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. + #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ... + #NOTE: Its fail on platforms without root directory support(like windows) + #where temp and current working directories may stay on different drivers. + old_wd = os.getcwd() + os.chdir(SAVEDCWD) self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h) + os.chdir(old_wd) def test_parse_makefile_base(self): self.makefile = test.test_support.TESTFN --- ./Lib/distutils/tests/test_build_ext.py.MINGW 2010-03-06 23:38:31.000000000 +0200 +++ ./Lib/distutils/tests/test_build_ext.py 2010-03-06 23:38:53.000000000 +0200 @@ -61,6 +61,9 @@ sys.stdout = StringIO() try: cmd.ensure_finalized() + #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ... + #Without current working dir: "...cannot find -lpython27" + cmd.library_dirs.insert(0, test_support.SAVEDCWD) cmd.run() finally: sys.stdout = old_stdout @@ -261,6 +264,10 @@ # returns wrong result with --inplace other_tmp_dir = os.path.realpath(self.mkdtemp()) old_wd = os.getcwd() + #Without current working dir: "...cannot find -lpython27" + #NOTE: After issue #7712(r78136) test cannot use old_wd ! + #cmd.library_dirs.insert(0, old_wd) + cmd.library_dirs.insert(0, test_support.SAVEDCWD) os.chdir(other_tmp_dir) try: cmd.inplace = 1 --- ./Lib/distutils/tests/test_config_cmd.py.MINGW 2009-07-05 18:00:54.000000000 +0300 +++ ./Lib/distutils/tests/test_config_cmd.py 2009-07-05 17:42:40.000000000 +0300 @@ -37,6 +37,7 @@ self.assertEquals(len(self._logs), numlines+1) def test_search_cpp(self): + # TODO: mingw host ? if sys.platform == 'win32': return pkg_dir, dist = self.create_dist() --- ./Lib/distutils/unixccompiler.py.MINGW 2010-03-05 23:35:39.000000000 +0200 +++ ./Lib/distutils/unixccompiler.py 2010-03-05 23:35:44.000000000 +0200 @@ -292,6 +292,8 @@ return ["+s", "-L" + dir] elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": return ["-rpath", dir] + elif sys.platform[:3] == "aix": + return "-blibpath:" + dir elif self._is_gcc(compiler): return "-Wl,-R" + dir else: --- ./Lib/distutils/cygwinccompiler.py.MINGW 2010-03-05 22:59:56.000000000 +0200 +++ ./Lib/distutils/cygwinccompiler.py 2010-03-05 23:00:45.000000000 +0200 @@ -66,6 +66,18 @@ """Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """ + # FIXME: next code is from issue870382 + # MS C-runtime libraries never support backward compatibility. + # Linking to a different library without to specify correct runtime + # version for the headers will link renamed functions to msvcrt. + # See issue3308: this piece of code is python problem even + # with correct w32api headers. + # Issue: for MSVC compiler we can get the version and from version + # to determine mcvcrt as code below. But what about if python is + # build with GCC compiler? + # Output of sys.version is information for python build on first + # line, on the next line is information for the compiler and the + # output lack information for the C-runtime. msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] @@ -83,6 +95,8 @@ return ['msvcr90'] else: raise ValueError("Unknown MS Compiler version %s " % msc_ver) + else: + return [] class CygwinCCompiler (UnixCCompiler): @@ -91,6 +105,9 @@ obj_extension = ".o" static_lib_extension = ".a" shared_lib_extension = ".dll" + # FIXME: dylib_... = ".dll.a" is not enought for binutils + # loader on win32 platform !!! + dylib_lib_extension = ".dll.a" static_lib_format = "lib%s%s" shared_lib_format = "%s%s" exe_extension = ".exe" @@ -109,6 +126,10 @@ "Compiling may fail because of undefined preprocessor macros." % details) + # Next line of code is problem for cross-compiled enviroment: + # NOTE: GCC cross-compiler is prefixed by the -- + # and by default binaries are installed in same directory + # as native compiler. self.gcc_version, self.ld_version, self.dllwrap_version = \ get_versions() self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" % @@ -133,6 +154,9 @@ else: shared_option = "-mdll -static" + # FIXME: + # Hard-code may override unix-compiler settings and isn't + # possible to use Makefile variables to pass correct flags ! # Hard-code GCC because that's what this is all about. # XXX optimization, warnings etc. should be customizable. self.set_executables(compiler='gcc -mcygwin -O -Wall', @@ -277,12 +301,20 @@ if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: - # use normcase to make sure '.rc' is really '.rc' and not '.RC' - (base, ext) = os.path.splitext (os.path.normcase(src_name)) + # FIXME: "bogus checks for suffix" - as example the commented + # by #BOGUS# code break valid assembler suffix ".S" ! + #BOGUS## use normcase to make sure '.rc' is really '.rc' and not '.RC' + #BOGUS#base, ext = os.path.splitext(os.path.normcase(src_name)) + base, ext = os.path.splitext (src_name) + ext_normcase = os.path.normcase(ext) + if ext_normcase in ['.rc','.res']: + ext = ext_normcase if ext not in (self.src_extensions + ['.rc','.res']): raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % \ (ext, src_name) + base = os.path.splitdrive(base)[1] # Chop off the drive + base = base[os.path.isabs(base):] # If abs, chop off leading / if strip_dir: base = os.path.basename (base) if ext == '.res' or ext == '.rc': --- ./Lib/distutils/sysconfig.py.MINGW 2010-03-05 23:51:59.000000000 +0200 +++ ./Lib/distutils/sysconfig.py 2010-03-06 02:55:42.000000000 +0200 @@ -71,16 +71,20 @@ """ if prefix is None: prefix = plat_specific and EXEC_PREFIX or PREFIX - if os.name == "posix": + # GCC(mingw): os.name is "nt" but build system is posix + if os.name == "posix" or sys.version.find('GCC') >= 0: if python_build: + # Assume the executable is in the build directory. The + # pyconfig.h file should be in the same directory. Since + # the build directory may not be the source directory, we + # must use "srcdir" from the makefile to find the "Include" + # directory. base = os.path.dirname(os.path.abspath(sys.executable)) if plat_specific: - inc_dir = base + return base else: - inc_dir = os.path.join(base, "Include") - if not os.path.exists(inc_dir): - inc_dir = os.path.join(os.path.dirname(base), "Include") - return inc_dir + incdir = os.path.join(get_config_var('srcdir'), 'Include') + return os.path.normpath(incdir) return os.path.join(prefix, "include", "python" + get_python_version()) elif os.name == "nt": return os.path.join(prefix, "include") @@ -160,11 +164,22 @@ Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. + + NOTE (known limitation of python build/install system): + In cross-build environment make macros like CC and LDSHARED + contain cross-compiler/linker instead of host compiler/linker. """ + posix_build = None if compiler.compiler_type == "unix": - (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \ + posix_build = True + elif compiler.compiler_type == "mingw32": + # GCC(mingw): if build system is posix + if sys.version.find('GCC') >= 0: + posix_build = True + if posix_build == True: + (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', - 'CCSHARED', 'LDSHARED', 'SO') + 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: cc = os.environ['CC'] @@ -185,6 +200,12 @@ cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] + if 'AR' in os.environ: + ar = os.environ['AR'] + if 'ARFLAGS' in os.environ: + archiver = ar + ' ' + os.environ['ARFLAGS'] + else: + archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( @@ -193,7 +214,8 @@ compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, - linker_exe=cc) + linker_exe=cc, + archiver=archiver) compiler.shared_lib_extension = so_ext @@ -201,7 +223,8 @@ def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: - if os.name == "nt": + # GCC(mingw): os.name is "nt" but build system is posix + if os.name == "nt" and sys.version.find('GCC') < 0: inc_dir = os.path.join(project_base, "PC") else: inc_dir = project_base @@ -444,6 +467,11 @@ def _init_nt(): """Initialize the module as appropriate for NT""" + if sys.version.find('GCC') >= 0: + # GCC(mingw) use posix build system + # FIXME: may be modification has to be in get_config_vars ? + _init_posix() + return g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) --- ./Lib/distutils/ccompiler.py.MINGW 2010-01-23 13:04:39.000000000 +0200 +++ ./Lib/distutils/ccompiler.py 2010-03-07 00:43:19.000000000 +0200 @@ -25,8 +25,18 @@ Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. + + NOTE (known limitation of python build/install system): + In cross-build environment make macros like CC and LDSHARED + contain cross-compiler/linker instead of host compiler/linker. """ + posix_build = None if compiler.compiler_type == "unix": + posix_build = True + elif compiler.compiler_type == "mingw32": + if sys.version.find('GCC') >= 0: + posix_build = True + if posix_build == True: (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ _sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', @@ -966,6 +976,8 @@ osname = os.name if platform is None: platform = sys.platform + if osname == "nt" and sys.version.find('GCC') >= 0: + return 'mingw32' for pattern, compiler in _default_compilers: if re.match(pattern, platform) is not None or \ re.match(pattern, osname) is not None: --- ./Lib/sysconfig.py.MINGW 2010-03-11 23:46:54.000000000 +0200 +++ ./Lib/sysconfig.py 2010-03-11 23:18:57.000000000 +0200 @@ -110,8 +110,13 @@ if _PYTHON_BUILD: for scheme in ('posix_prefix', 'posix_home'): - _INSTALL_SCHEMES[scheme]['include'] = '{projectbase}/Include' - _INSTALL_SCHEMES[scheme]['platinclude'] = '{srcdir}' + _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include' + _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}' + + # GCC(mingw) use posix build system + if os.name == "nt" and sys.version.find('GCC') >= 0: + _INSTALL_SCHEMES['nt']['include'] = '{srcdir}/Include' + _INSTALL_SCHEMES['nt']['platinclude'] = '{projectbase}' def _subst_vars(s, local_vars): try: @@ -338,7 +343,8 @@ def get_config_h_filename(): """Returns the path of pyconfig.h.""" if _PYTHON_BUILD: - if os.name == "nt": + # GCC(mingw): os.name is "nt" but build system is posix + if os.name == "nt" and sys.version.find('GCC') < 0: inc_dir = os.path.join(_PROJECT_BASE, "PC") else: inc_dir = _PROJECT_BASE @@ -401,9 +407,19 @@ _CONFIG_VARS['userbase'] = _getuserbase() _CONFIG_VARS['projectbase'] = _PROJECT_BASE - if os.name in ('nt', 'os2'): - _init_non_posix(_CONFIG_VARS) + # GCC(mingw) use posix build system + posix_build = None if os.name == 'posix': + posix_build = True + else: + if os.name in ('nt', 'os2'): + if sys.version.find('GCC') >= 0: + posix_build = True + else: + posix_build = False + if posix_build == False: + _init_non_posix(_CONFIG_VARS) + if posix_build == True: _init_posix(_CONFIG_VARS) if 'srcdir' not in _CONFIG_VARS: @@ -413,7 +429,7 @@ # Normally it is relative to the build directory. However, during # testing, for example, we might be running a non-installed python # from a different directory. - if _PYTHON_BUILD and os.name == "posix": + if _PYTHON_BUILD and posix_build == True: base = _PROJECT_BASE if (not os.path.isabs(_CONFIG_VARS['srcdir']) and base != os.getcwd()): --- ./Lib/ctypes/test/test_functions.py.MINGW 2009-07-05 18:13:39.000000000 +0300 +++ ./Lib/ctypes/test/test_functions.py 2009-07-22 00:22:31.000000000 +0300 @@ -359,6 +359,11 @@ self.assertEqual((s2h.x, s2h.y), (99*2, 88*3)) def test_struct_return_8H(self): + if sys.platform == "win32" and sys.version.find("GCC") >= 0: + # This is known cdecl incompatibility between GCC + # and MSVC. It is addressed in GCC issue #36834. + # Python libffi detect it and complain. + return class S8I(Structure): _fields_ = [("a", c_int), ("b", c_int), --- ./Lib/ctypes/test/test_as_parameter.py.MINGW 2009-07-05 18:12:23.000000000 +0300 +++ ./Lib/ctypes/test/test_as_parameter.py 2009-07-22 00:19:35.000000000 +0300 @@ -1,6 +1,7 @@ import unittest from ctypes import * import _ctypes_test +import sys dll = CDLL(_ctypes_test.__file__) @@ -171,6 +172,11 @@ self.assertEqual((s2h.x, s2h.y), (99*2, 88*3)) def test_struct_return_8H(self): + if sys.platform == "win32" and sys.version.find("GCC") >= 0: + # This is known cdecl incompatibility between GCC + # and MSVC. It is addressed in GCC issue #36834. + # Python libffi detect it and complain. + return class S8I(Structure): _fields_ = [("a", c_int), ("b", c_int), --- ./Lib/ctypes/util.py.MINGW 2009-10-23 21:41:00.000000000 +0300 +++ ./Lib/ctypes/util.py 2009-10-23 21:29:17.000000000 +0300 @@ -7,6 +7,11 @@ if os.name == "nt": def _get_build_version(): + #*********************************************************** + # NOTE: As example for GCC(mingw) build sys.version return: + # '2.7a0 (trunk:M, ,