--- ./PC/_winreg.c.MINGW 2010-06-10 21:39:43.000000000 +0300 +++ ./PC/_winreg.c 2010-06-10 21:40:55.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); @@ -1087,6 +1099,15 @@ static PyObject * PyDeleteKeyEx(PyObject *self, PyObject *args) { +#ifndef KEY_WOW64_64KEY +/* KEY_WOW64_64KEY is defined for _WIN32_WINNT >= 0x0502, + i.e. Windows Server 2003 with SP1, Windows XP with SP2 + and not supported on w2k + */ + PyErr_SetString(PyExc_NotImplementedError, + "not implemented on this platform"); + return NULL; +#else /*def KEY_WOW64_64KEY*/ HKEY hKey; PyObject *obKey; HMODULE hMod; @@ -1122,6 +1143,7 @@ return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); Py_INCREF(Py_None); return Py_None; +#endif } static PyObject * --- ./PC/msvcrtmodule.c.MINGW 2010-09-07 00:03:53.000000000 +0300 +++ ./PC/msvcrtmodule.c 2010-09-07 00:04:00.000000000 +0300 @@ -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 @@ -346,6 +371,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/test_os.py.MINGW 2011-01-12 01:45:39.000000000 +0200 +++ ./Lib/test/test_os.py 2011-01-12 23:50:13.000000000 +0200 @@ -324,7 +324,11 @@ def test_large_time(self): t1 = 5000000000 # some day in 2128 - os.utime(self.fname, (t1, t1)) + try: + #Note fail if time_t is 32 bit + os.utime(self.fname, (t1, t1)) + except OverflowError: + self.skipTest("requires at least 64-bit time_t") self.assertEqual(os.stat(self.fname).st_mtime, t1) def test_1686475(self): --- ./Lib/test/regrtest.py.MINGW 2011-01-12 01:38:30.000000000 +0200 +++ ./Lib/test/regrtest.py 2011-01-12 01:38:45.000000000 +0200 @@ -388,7 +388,7 @@ found_garbage = [] if single: - filename = os.path.join(TEMPDIR, 'pynexttest') + filename = os.path.join(tempfile.gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next_test = fp.read().strip() @@ -1522,8 +1522,7 @@ # to keep the test files in a subfolder. It eases the cleanup of leftover # files using command "make distclean". if sysconfig.is_python_build(): - TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build') - TEMPDIR = os.path.abspath(TEMPDIR) + TEMPDIR = os.path.abspath('build') if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) --- ./Lib/test/test_curses.py.MINGW 2010-08-09 00:03:48.000000000 +0300 +++ ./Lib/test/test_curses.py 2010-08-09 00:05:38.000000000 +0300 @@ -167,11 +167,16 @@ curses.delay_output(1) curses.echo() ; curses.echo(1) - f = tempfile.TemporaryFile() + fx = tempfile.TemporaryFile() + # cf tempfile.py TemporaryFile vs NamedTemporaryFile + if os.name != 'posix' or os.sys.platform == 'cygwin': + f = fx.file + else: + f = fx stdscr.putwin(f) f.seek(0) curses.getwin(f) - f.close() + fx.close() curses.halfdelay(1) curses.intrflush(1) --- ./Lib/test/test_sundry.py.MINGW 2010-08-08 20:37:33.000000000 +0300 +++ ./Lib/test/test_sundry.py 2010-08-08 20:37:59.000000000 +0300 @@ -27,7 +27,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/distutils/command/build_ext.py.MINGW 2010-12-22 00:31:27.000000000 +0200 +++ ./Lib/distutils/command/build_ext.py 2010-12-22 00:31:31.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_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-11-22 02:08:34.000000000 +0200 +++ ./Lib/distutils/tests/test_sysconfig.py 2010-11-22 02:08:42.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-11-22 02:06:21.000000000 +0200 +++ ./Lib/distutils/tests/test_build_ext.py 2010-11-22 02:06:28.000000000 +0200 @@ -59,6 +59,9 @@ # To further add to the fun, we can't just add library_dirs to the # Extension() instance because that doesn't get plumbed through to the # final compiler command. + #NOTE: [py3k svn r85559] First (uncontroversial) part of issue 9807, barry.warsaw, 2010-10-16 : + #- new _fixup_command is bogus, so we will use own work-around + #- for mingw the line may contain " or sys.version.find('GCC') >= 0" in addition if (sysconfig.get_config_var('Py_ENABLE_SHARED') and not sys.platform.startswith('win')): runshared = sysconfig.get_config_var('RUNSHARED') @@ -91,6 +94,11 @@ 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" + #NOTE: [py3k svn r85559] First (uncontroversial) part of issue 9807, barry.warsaw, 2010-10-16 : + # new _fixup_command is bogus, so we will use own work-around + cmd.library_dirs.insert(0, test_support.SAVEDCWD) cmd.run() finally: sys.stdout = old_stdout @@ -284,6 +292,12 @@ # 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) + #NOTE: [py3k svn r85559] First (uncontroversial) part of issue 9807, barry.warsaw, 2010-10-16 : + # new _fixup_command is bogus, so we will use own work-around + 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 2010-11-22 02:07:35.000000000 +0200 +++ ./Lib/distutils/tests/test_config_cmd.py 2010-11-22 02:07:51.000000000 +0200 @@ -37,6 +37,7 @@ self.assertEqual(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-07-01 22:49:25.000000000 +0300 +++ ./Lib/distutils/unixccompiler.py 2010-07-01 22:49:34.000000000 +0300 @@ -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-11-11 22:21:45.000000000 +0200 +++ ./Lib/distutils/cygwinccompiler.py 2010-11-11 22:21:56.000000000 +0200 @@ -60,6 +60,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] @@ -77,6 +89,8 @@ return ['msvcr90'] else: raise ValueError("Unknown MS Compiler version %s " % msc_ver) + else: + return [] class CygwinCCompiler (UnixCCompiler): @@ -85,6 +99,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" @@ -103,6 +120,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" % @@ -127,6 +148,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', @@ -271,12 +295,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-11-11 22:23:38.000000000 +0200 +++ ./Lib/distutils/sysconfig.py 2010-11-11 22:23:44.000000000 +0200 @@ -72,19 +72,21 @@ 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: - buildir = os.path.dirname(sys.executable) + # NOTE: sysconfig.py-20091210 + # 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: - # python.h is located in the buildir - inc_dir = buildir + return base else: - # the source dir is relative to the buildir - srcdir = os.path.abspath(os.path.join(buildir, - get_config_var('srcdir'))) - # Include is located in the srcdir - inc_dir = os.path.join(srcdir, "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") @@ -147,11 +149,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'] @@ -172,6 +185,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( @@ -180,7 +199,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 @@ -188,7 +208,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 @@ -436,6 +457,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-11-11 22:28:29.000000000 +0200 +++ ./Lib/distutils/ccompiler.py 2010-11-11 22:28:40.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', @@ -968,6 +978,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-11-11 22:30:01.000000000 +0200 +++ ./Lib/sysconfig.py 2010-11-11 22:32:41.000000000 +0200 @@ -128,8 +128,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: @@ -368,7 +373,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 @@ -430,9 +436,19 @@ _CONFIG_VARS['platbase'] = _EXEC_PREFIX _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) # Setting 'userbase' is done below the call to the @@ -447,7 +463,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 try: cwd = os.getcwd() --- ./Lib/ctypes/test/test_functions.py.MINGW 2009-07-05 18:13:39.000000000 +0300 +++ ./Lib/ctypes/test/test_functions.py 2010-06-26 10:33:33.000000000 +0300 @@ -358,6 +358,10 @@ s2h = windll.s_ret_2h_func(S2H(99, 88)) self.assertEqual((s2h.x, s2h.y), (99*2, 88*3)) + # This is known cdecl incompatibility between GCC + # and MSVC. It is addressed in GCC issue #36834. + # Python libffi detect it and complain. + @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)') def test_struct_return_8H(self): class S8I(Structure): _fields_ = [("a", 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 2010-06-26 13:40:30.000000000 +0300 @@ -1,6 +1,7 @@ import unittest from ctypes import * import _ctypes_test +import sys dll = CDLL(_ctypes_test.__file__) @@ -170,6 +171,10 @@ s2h = dll.ret_2h_func(self.wrap(inp)) self.assertEqual((s2h.x, s2h.y), (99*2, 88*3)) + # This is known cdecl incompatibility between GCC + # and MSVC. It is addressed in GCC issue #36834. + # Python libffi detect it and complain. + @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)') def test_struct_return_8H(self): class S8I(Structure): _fields_ = [("a", c_int), --- ./Lib/ctypes/util.py.MINGW 2010-09-15 22:58:56.000000000 +0300 +++ ./Lib/ctypes/util.py 2010-09-15 22:59:09.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, ,