[Python-checkins] r80884 - in python/branches/py3k-jit: Demo/pdist/FSProxy.py Doc/library/numbers.rst Doc/library/tarfile.rst Doc/library/urllib.request.rst Doc/whatsnew/3.2.rst Lib/asyncore.py Lib/ctypes/test/test_win32.py Lib/decimal.py Lib/distutils/command/install.py Lib/distutils/file_util.py Lib/distutils/util.py Lib/email/test/data/audiotest.au Lib/email/test/test_email.py Lib/gzip.py Lib/platform.py Lib/profile.py Lib/pydoc.py Lib/shutil.py Lib/tarfile.py Lib/test/audiotest.au Lib/test/regrtest.py Lib/test/support.py Lib/test/test_asyncore.py Lib/test/test_builtin.py Lib/test/test_decimal.py Lib/test/test_dictviews.py Lib/test/test_frozen.py Lib/test/test_ftplib.py Lib/test/test_gdb.py Lib/test/test_ossaudiodev.py Lib/test/test_reprlib.py Lib/test/test_select.py Lib/test/test_shutil.py Lib/test/test_smtplib.py Lib/test/test_socket.py Lib/test/test_ssl.py Lib/test/test_strptime.py Lib/test/test_tarfile.py Lib/test/test_tempfile.py Lib/test/test_urllib2.py Lib/test/test_uuid.py Lib/urllib/request.py Lib/uuid.py Mac/Makefile.in Misc/NEWS Modules/_ctypes/callproc.c Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/libffi_msvc/README Modules/_ctypes/libffi_msvc/README.ctypes Modules/_ctypes/libffi_msvc/ffi.c Modules/_ctypes/libffi_msvc/ffi.h Modules/_ctypes/libffi_msvc/ffi_common.h Modules/_ctypes/libffi_msvc/fficonfig.h Modules/_ctypes/libffi_msvc/ffitarget.h Modules/_ctypes/libffi_msvc/prep_cif.c Modules/_ctypes/libffi_msvc/types.c Modules/_ctypes/libffi_msvc/win32.c Modules/_ctypes/libffi_msvc/win64.asm Modules/_io/fileio.c Modules/_ssl.c Modules/posixmodule.c PCbuild/_ctypes.vcproj Tools/scripts/serve.py Tools/webchecker/wcgui.py Tools/webchecker/websucker.py configure configure.in setup.py

collin.winter python-checkins at python.org
Thu May 6 23:49:29 CEST 2010


Author: collin.winter
Date: Thu May  6 23:49:27 2010
New Revision: 80884

Log:
Merged revisions 80740,80750-80751,80755,80757,80760,80764,80767,80771-80773,80775,80778,80781,80783,80786,80790,80795,80798,80803,80805-80806,80824,80828,80833-80834,80836,80840,80842,80846,80851,80855,80859,80871,80876,80881,80883 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r80740 | benjamin.peterson | 2010-05-03 17:36:36 -0700 (Mon, 03 May 2010) | 10 lines
  
  Blocked revisions 80738 via svnmerge
  
  ........
    r80738 | brett.cannon | 2010-05-03 19:30:17 -0500 (Mon, 03 May 2010) | 4 lines
    
    Remove a redundant string length check and variable assignment.
    
    Found with Clang's static analyzer.
  ........
................
  r80750 | alexandre.vassalotti | 2010-05-03 20:26:10 -0700 (Mon, 03 May 2010) | 8 lines
  
  Blocked revisions 80749 via svnmerge
  
  ........
    r80749 | alexandre.vassalotti | 2010-05-03 20:21:51 -0700 (Mon, 03 May 2010) | 2 lines
    
    Issue #8404: Fix set operations on dictionary views.
  ........
................
  r80751 | alexandre.vassalotti | 2010-05-03 20:41:49 -0700 (Mon, 03 May 2010) | 4 lines
  
  Forward port unit tests for set operation and repr.
  
  Patch by Alexander Belopolsky.
................
  r80755 | mark.dickinson | 2010-05-04 07:35:33 -0700 (Tue, 04 May 2010) | 17 lines
  
  Merged revisions 80753 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80753 | mark.dickinson | 2010-05-04 15:25:50 +0100 (Tue, 04 May 2010) | 10 lines
    
    Issue #8567: Fix incorrect precedence of signals in Decimal module.
    
    When a Decimal operation raises multiple signals and more than one of
    those signals is trapped, the specification determines the order in
    which the signals should be handled.  In many cases this order wasn't
    being followed, leading to the wrong Python exception being raised.
    This commit fixes those cases, and adds extra tests.  The tests are
    only enabled when EXTENDEDERRORTESTS is True, since they involve
    rerunning each Decimal testcase several times.
  ........
................
  r80757 | r.david.murray | 2010-05-04 09:17:50 -0700 (Tue, 04 May 2010) | 12 lines
  
  Recorded merge of revisions 80458 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  Sean merged this in r84059.
  
  ........
    r80458 | sean.reifschneider | 2010-04-25 02:31:23 -0400 (Sun, 25 Apr 2010) | 3 lines
    
    Fixing obscure syslog corner-case when sys.argv = None, syslog() would call
    openlog() for every logged message.
  ........
................
  r80760 | mark.dickinson | 2010-05-04 09:50:06 -0700 (Tue, 04 May 2010) | 18 lines
  
  Blocked revisions 80758-80759 via svnmerge
  
  ........
    r80758 | mark.dickinson | 2010-05-04 17:18:25 +0100 (Tue, 04 May 2010) | 9 lines
    
    Issue #1533: fix inconsistency in range function argument processing:
    any non-float non-integer argument is now converted to an integer (if
    possible) using its __int__ method.  Previously, only small arguments
    were treated this way; larger arguments (those whose __int__ was
    outside the range of a C long) would produce a TypeError.
    
    Patch by Alexander Belopolsky (with minor modifications).
  ........
    r80759 | mark.dickinson | 2010-05-04 17:19:06 +0100 (Tue, 04 May 2010) | 1 line
    
    Fix trailing whitespace.
  ........
................
  r80764 | mark.dickinson | 2010-05-04 11:47:04 -0700 (Tue, 04 May 2010) | 10 lines
  
  Merged revisions 80762 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80762 | mark.dickinson | 2010-05-04 19:45:27 +0100 (Tue, 04 May 2010) | 3 lines
    
    Fix test_gzip failure on OS X.  The failure was a result of trying to fflush
    a file that wasn't open for writing.  Patch by Antoine Pitrou.
  ........
................
  r80767 | thomas.heller | 2010-05-04 12:17:41 -0700 (Tue, 04 May 2010) | 19 lines
  
  Merged revisions 80761,80766 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80761 | thomas.heller | 2010-05-04 20:44:42 +0200 (Di, 04 Mai 2010) | 8 lines
    
    On Windows, ctypes does no longer check the stack before and after
    calling a foreign function.  This allows to use the unmodified libffi
    library.
    
    Remove most files from _ctypes/libffi_msvc, only two include files
    stay (updated from _ctypes/libffi/...).  Other files are used in the
    cross-platform _ctypes/libffi directory.
  ........
    r80766 | thomas.heller | 2010-05-04 21:08:18 +0200 (Di, 04 Mai 2010) | 2 lines
    
    Remove reference to unused source file.
  ........
................
  r80771 | michael.foord | 2010-05-04 15:29:10 -0700 (Tue, 04 May 2010) | 1 line
  
  Fix error handling removing files in test.support.unlink
................
  r80772 | antoine.pitrou | 2010-05-04 16:31:41 -0700 (Tue, 04 May 2010) | 3 lines
  
  Add what's new entry for r80157 and r80071.
................
  r80773 | senthil.kumaran | 2010-05-04 22:32:16 -0700 (Tue, 04 May 2010) | 3 lines
  
  Fix Issue8619 docfix related to urllib.
................
  r80775 | senthil.kumaran | 2010-05-05 00:22:18 -0700 (Wed, 05 May 2010) | 3 lines
  
  Fix issue8619 - Doc fix - code example.
................
  r80778 | victor.stinner | 2010-05-05 05:42:20 -0700 (Wed, 05 May 2010) | 9 lines
  
  Blocked revisions 80777 via svnmerge
  
  ........
    r80777 | victor.stinner | 2010-05-05 14:40:49 +0200 (mer., 05 mai 2010) | 3 lines
    
    Issue #8313: traceback.format_exception_only() encodes unicode message to
    ASCII with backslashreplace error handler if str(value) failed
  ........
................
  r80781 | ronald.oussoren | 2010-05-05 06:20:31 -0700 (Wed, 05 May 2010) | 4 lines
  
  Small update to Mac/Makefile to ensure that we
  install python binaries that support all 
  architectures in a universal build.
................
  r80783 | marc-andre.lemburg | 2010-05-05 06:32:59 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80782 via svnmerge from 
  svn+pythonssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80782 | marc-andre.lemburg | 2010-05-05 15:30:01 +0200 (Wed, 05 May 2010) | 3 lines
    
    Update the NEWS entry for issue #8211.
  ........
................
  r80786 | ronald.oussoren | 2010-05-05 08:32:33 -0700 (Wed, 05 May 2010) | 16 lines
  
  Merged revisions 80784 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80784 | ronald.oussoren | 2010-05-05 16:48:37 +0200 (Wed, 05 May 2010) | 9 lines
    
    The C function used by uuid.uuid4 is broken on
    OSX 10.6 in that after os.fork() the parent and
    child generate the same sequence of UUIDs.
    
    This patch falls back to the the Python implementation
    on OSX 10.6 or later.
    
    Fixes issue #8621.
  ........
................
  r80790 | antoine.pitrou | 2010-05-05 08:57:33 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80789 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80789 | antoine.pitrou | 2010-05-05 17:53:45 +0200 (mer., 05 mai 2010) | 3 lines
    
    Untabify Modules/_ssl.c
  ........
................
  r80795 | barry.warsaw | 2010-05-05 09:18:31 -0700 (Wed, 05 May 2010) | 5 lines
  
  Bug 7755: audiotest.au is arguably copyrighted material, but definitely makes
  Debian unhappy.  The actual contents of the audio clip are unimportant, so
  replace it with something that we know is okay.  Guido likes woodpeckers.
................
  r80798 | antoine.pitrou | 2010-05-05 09:31:07 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80796 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80796 | antoine.pitrou | 2010-05-05 18:27:30 +0200 (mer., 05 mai 2010) | 3 lines
    
    Untabify Modules/_io/fileio.c
  ........
................
  r80803 | antoine.pitrou | 2010-05-05 11:30:22 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80802 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80802 | antoine.pitrou | 2010-05-05 20:29:02 +0200 (mer., 05 mai 2010) | 3 lines
    
    Issue #8600: fix test_gdb failures when gdb issues some spurious warnings.
  ........
................
  r80805 | ronald.oussoren | 2010-05-05 12:11:21 -0700 (Wed, 05 May 2010) | 4 lines
  
  Remove traces of MacOS9 support.
  
  Fix for issue #7908
................
  r80806 | ronald.oussoren | 2010-05-05 12:12:30 -0700 (Wed, 05 May 2010) | 14 lines
  
  Blocked revisions 80804 via svnmerge
  
  ........
    r80804 | ronald.oussoren | 2010-05-05 21:09:31 +0200 (Wed, 05 May 2010) | 8 lines
    
    In a number of places code still revers
    to "sys.platform == 'mac'" and that is 
    dead code because it refers to a platform
    that is no longer supported (and hasn't been
    supported for several releases).
    
    Fixes issue #7908 for the trunk.
  ........
................
  r80824 | victor.stinner | 2010-05-05 14:43:57 -0700 (Wed, 05 May 2010) | 3 lines
  
  Issue #8390: tarfile uses surrogateespace as the default error handler
  (instead of replace in read mode or strict in write mode)
................
  r80828 | mark.dickinson | 2010-05-05 14:54:18 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80826 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80826 | mark.dickinson | 2010-05-05 22:52:39 +0100 (Wed, 05 May 2010) | 1 line
    
    Issue 8628: fix incorrect documentation for numbers.Complex.imag.
  ........
................
  r80833 | tarek.ziade | 2010-05-05 15:27:31 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80830 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80830 | tarek.ziade | 2010-05-06 00:15:31 +0200 (Thu, 06 May 2010) | 1 line
    
    Fixed #4265: shutil.copyfile() was leaking file descriptors when disk fills
  ........
................
  r80834 | mark.dickinson | 2010-05-05 15:31:36 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80832 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80832 | mark.dickinson | 2010-05-05 23:23:58 +0100 (Wed, 05 May 2010) | 2 lines
    
    Issue #8625:  Turn off gcc optimization in debug builds.
  ........
................
  r80836 | mark.dickinson | 2010-05-05 15:39:58 -0700 (Wed, 05 May 2010) | 3 lines
  
  Issue #1533:  Merge added trunk range tests to py3k.  (The fix itself
  doesn't need to be merged.)  Patch by Alexander Belopolsky.
................
  r80840 | tarek.ziade | 2010-05-05 15:43:04 -0700 (Wed, 05 May 2010) | 9 lines
  
  Merged revisions 80837 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80837 | tarek.ziade | 2010-05-06 00:41:25 +0200 (Thu, 06 May 2010) | 1 line
    
    removed non needed lines
  ........
................
  r80842 | mark.dickinson | 2010-05-05 15:44:34 -0700 (Wed, 05 May 2010) | 9 lines
  
  Blocked revisions 80839 via svnmerge
  
  ........
    r80839 | mark.dickinson | 2010-05-05 23:42:51 +0100 (Wed, 05 May 2010) | 3 lines
    
    Issue #1533:  test_range in test_builtin: fix test comment and add test
    for rejection of small floats.  Thanks Alexander Belopolsky.
  ........
................
  r80846 | victor.stinner | 2010-05-05 17:08:46 -0700 (Wed, 05 May 2010) | 20 lines
  
  Recorded merge of revisions 80844-80845 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80844 | victor.stinner | 2010-05-06 01:33:33 +0200 (jeu., 06 mai 2010) | 5 lines
  
    Untabify Modules/posixmodule.c
  
    Run Antoine Pitrou "untabify" script + manual editions (OS/2 and some
    continuation lines).
  ........
    r80845 | victor.stinner | 2010-05-06 02:03:44 +0200 (jeu., 06 mai 2010) | 4 lines
  
    Untabify Modules/posixmodule.c (2)
  
    Fix some more functions by hand
  ........
  
  I rewrote the patch for py3k from scratch using untabify + manual editions
................
  r80851 | r.david.murray | 2010-05-05 18:09:27 -0700 (Wed, 05 May 2010) | 11 lines
  
  Merged revisions 80849 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80849 | r.david.murray | 2010-05-05 20:59:04 -0400 (Wed, 05 May 2010) | 4 lines
    
    Have the serve.py script announce the directory it is
    serving and which port it is serving it on (I can
    never remember the default port number it uses...)
  ........
................
  r80855 | r.david.murray | 2010-05-05 18:41:14 -0700 (Wed, 05 May 2010) | 24 lines
  
  Merged revisions 80800 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  It turns out that email5 (py3k), because it is using unicode for the
  payload, doesn't do the encoding to the output character set until later
  in the process.  Specifically, charset.body_encode no longer does the
  input-to-output charset conversion.  So the if test in the exception
  clause in encoders.encode_7or8bit really is needed in email5.
  
  So, this merge only merges the test, not the removal of the 'if'.
  
  ........
    r80800 | r.david.murray | 2010-05-05 13:31:03 -0400 (Wed, 05 May 2010) | 9 lines
    
    Issue #7472: remove unused code from email.encoders.encode_7or8bit.
    
    Yukihiro Nakadaira noticed a typo in encode_7or8bit that was trying
    to special case iso-2022 codecs.  It turns out that the code in
    question is never used, because whereas it was designed to trigger
    if the payload encoding was eight bit but its output encoding was
    7 bit, in practice the payload is always converted to the 7bit 
    encoding before encode_7or8bit is called.  Patch by Shawat Anand.
  ........
................
  r80859 | brian.curtin | 2010-05-05 20:05:50 -0700 (Wed, 05 May 2010) | 12 lines
  
  Merged revisions 80857 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80857 | brian.curtin | 2010-05-05 21:54:44 -0500 (Wed, 05 May 2010) | 5 lines
    
    Fix #7863. Properly identify Windows 7 and Server 2008 R2.
    
    Removed various unused code and added a way to correctly determine
    server vs. workstation via the registry.
  ........
................
  r80871 | antoine.pitrou | 2010-05-06 07:15:10 -0700 (Thu, 06 May 2010) | 9 lines
  
  Merged revisions 80869 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80869 | antoine.pitrou | 2010-05-06 16:11:23 +0200 (jeu., 06 mai 2010) | 3 lines
    
    `self` doesn't exist here
  ........
................
  r80876 | giampaolo.rodola | 2010-05-06 11:06:30 -0700 (Thu, 06 May 2010) | 9 lines
  
  Merged revisions 80875 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80875 | giampaolo.rodola | 2010-05-06 19:57:06 +0200 (gio, 06 mag 2010) | 1 line
    
    Fix asyncore issues 8573 and 8483: _strerror might throw ValueError; asyncore.__getattr__ cheap inheritance caused confusing error messages when accessing undefined class attributes; added an alias for __str__ which now is used as a fallback for __repr__
  ........
................
  r80881 | giampaolo.rodola | 2010-05-06 13:02:37 -0700 (Thu, 06 May 2010) | 9 lines
  
  Merged revisions 80880 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80880 | giampaolo.rodola | 2010-05-06 21:56:34 +0200 (gio, 06 mag 2010) | 1 line
    
    provides a clearer warning message when cheap inheritance with the underlying socket object is used
  ........
................
  r80883 | giampaolo.rodola | 2010-05-06 13:21:57 -0700 (Thu, 06 May 2010) | 9 lines
  
  Merged revisions 80882 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80882 | giampaolo.rodola | 2010-05-06 22:19:32 +0200 (gio, 06 mag 2010) | 1 line
    
    adds handle_error(self):raise to test modules using asyncore to provide a clearer error message in case something goes wrong
  ........
................


Removed:
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/LICENSE
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README.ctypes
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.c
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi_common.h
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffitarget.h
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/prep_cif.c
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/types.c
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win32.c
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win64.asm
Modified:
   python/branches/py3k-jit/   (props changed)
   python/branches/py3k-jit/Demo/pdist/FSProxy.py
   python/branches/py3k-jit/Doc/library/numbers.rst
   python/branches/py3k-jit/Doc/library/tarfile.rst
   python/branches/py3k-jit/Doc/library/urllib.request.rst
   python/branches/py3k-jit/Doc/whatsnew/3.2.rst
   python/branches/py3k-jit/Lib/asyncore.py
   python/branches/py3k-jit/Lib/ctypes/test/test_win32.py
   python/branches/py3k-jit/Lib/decimal.py
   python/branches/py3k-jit/Lib/distutils/command/install.py
   python/branches/py3k-jit/Lib/distutils/file_util.py
   python/branches/py3k-jit/Lib/distutils/util.py
   python/branches/py3k-jit/Lib/email/test/data/audiotest.au
   python/branches/py3k-jit/Lib/email/test/test_email.py
   python/branches/py3k-jit/Lib/gzip.py
   python/branches/py3k-jit/Lib/platform.py
   python/branches/py3k-jit/Lib/profile.py
   python/branches/py3k-jit/Lib/pydoc.py
   python/branches/py3k-jit/Lib/shutil.py
   python/branches/py3k-jit/Lib/tarfile.py
   python/branches/py3k-jit/Lib/test/audiotest.au
   python/branches/py3k-jit/Lib/test/regrtest.py
   python/branches/py3k-jit/Lib/test/support.py
   python/branches/py3k-jit/Lib/test/test_asyncore.py
   python/branches/py3k-jit/Lib/test/test_builtin.py
   python/branches/py3k-jit/Lib/test/test_decimal.py
   python/branches/py3k-jit/Lib/test/test_dictviews.py
   python/branches/py3k-jit/Lib/test/test_frozen.py
   python/branches/py3k-jit/Lib/test/test_ftplib.py
   python/branches/py3k-jit/Lib/test/test_gdb.py
   python/branches/py3k-jit/Lib/test/test_ossaudiodev.py
   python/branches/py3k-jit/Lib/test/test_reprlib.py
   python/branches/py3k-jit/Lib/test/test_select.py
   python/branches/py3k-jit/Lib/test/test_shutil.py
   python/branches/py3k-jit/Lib/test/test_smtplib.py
   python/branches/py3k-jit/Lib/test/test_socket.py
   python/branches/py3k-jit/Lib/test/test_ssl.py
   python/branches/py3k-jit/Lib/test/test_strptime.py
   python/branches/py3k-jit/Lib/test/test_tarfile.py
   python/branches/py3k-jit/Lib/test/test_tempfile.py
   python/branches/py3k-jit/Lib/test/test_urllib2.py
   python/branches/py3k-jit/Lib/test/test_uuid.py
   python/branches/py3k-jit/Lib/urllib/request.py
   python/branches/py3k-jit/Lib/uuid.py
   python/branches/py3k-jit/Mac/Makefile.in
   python/branches/py3k-jit/Misc/NEWS
   python/branches/py3k-jit/Modules/_ctypes/callproc.c
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.h
   python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/fficonfig.h
   python/branches/py3k-jit/Modules/_io/fileio.c
   python/branches/py3k-jit/Modules/_ssl.c
   python/branches/py3k-jit/Modules/posixmodule.c
   python/branches/py3k-jit/PCbuild/_ctypes.vcproj
   python/branches/py3k-jit/Tools/scripts/serve.py
   python/branches/py3k-jit/Tools/webchecker/wcgui.py
   python/branches/py3k-jit/Tools/webchecker/websucker.py
   python/branches/py3k-jit/configure
   python/branches/py3k-jit/configure.in
   python/branches/py3k-jit/setup.py

Modified: python/branches/py3k-jit/Demo/pdist/FSProxy.py
==============================================================================
--- python/branches/py3k-jit/Demo/pdist/FSProxy.py	(original)
+++ python/branches/py3k-jit/Demo/pdist/FSProxy.py	Thu May  6 23:49:27 2010
@@ -23,12 +23,7 @@
 import time
 import fnmatch
 
-if os.name == 'mac':
-    import macfs
-    maxnamelen = 31
-else:
-    macfs = None
-    maxnamelen = 255
+maxnamelen = 255
 
 skipnames = (os.curdir, os.pardir)
 
@@ -63,16 +58,10 @@
         return ignore
 
     def _hidden(self, name):
-        if os.name == 'mac':
-            return name[0] == '(' and name[-1] == ')'
-        else:
-            return name[0] == '.'
+        return name[0] == '.'
 
     def _hide(self, name):
-        if os.name == 'mac':
-            return '(%s)' % name
-        else:
-            return '.%s' % name
+        return '.%s' % name
 
     def visible(self, name):
         if len(name) > maxnamelen: return 0
@@ -81,18 +70,8 @@
         if self._hidden(name): return 0
         head, tail = os.path.split(name)
         if head or not tail: return 0
-        if macfs:
-            if os.path.exists(name) and not os.path.isdir(name):
-                try:
-                    fs = macfs.FSSpec(name)
-                    c, t = fs.GetCreatorType()
-                    if t != 'TEXT': return 0
-                except macfs.error as msg:
-                    print("***", name, msg)
-                    return 0
-        else:
-            if os.path.islink(name): return 0
-            if '\0' in open(name, 'rb').read(512): return 0
+        if os.path.islink(name): return 0
+        if '\0' in open(name, 'rb').read(512): return 0
         for ign in self._ignore:
             if fnmatch.fnmatch(name, ign): return 0
         return 1

Modified: python/branches/py3k-jit/Doc/library/numbers.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/numbers.rst	(original)
+++ python/branches/py3k-jit/Doc/library/numbers.rst	Thu May  6 23:49:27 2010
@@ -29,11 +29,11 @@
 
    .. attribute:: real
 
-      Abstract. Retrieves the :class:`Real` component of this number.
+      Abstract. Retrieves the real component of this number.
 
    .. attribute:: imag
 
-      Abstract. Retrieves the :class:`Real` component of this number.
+      Abstract. Retrieves the imaginary component of this number.
 
    .. method:: conjugate()
 

Modified: python/branches/py3k-jit/Doc/library/tarfile.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/tarfile.rst	(original)
+++ python/branches/py3k-jit/Doc/library/tarfile.rst	Thu May  6 23:49:27 2010
@@ -218,7 +218,7 @@
 .. versionadded:: 3.2
    Added support for the context manager protocol.
 
-.. class:: TarFile(name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False, ignore_zeros=False, encoding=ENCODING, errors=None, pax_headers=None, debug=0, errorlevel=0)
+.. class:: TarFile(name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False, ignore_zeros=False, encoding=ENCODING, errors='surrogateescape', pax_headers=None, debug=0, errorlevel=0)
 
    All following arguments are optional and can be accessed as instance attributes
    as well.
@@ -267,6 +267,9 @@
    to be handled. The default settings will work for most users.
    See section :ref:`tar-unicode` for in-depth information.
 
+   .. versionchanged:: 3.2
+      Use ``'surrogateescape'`` as the default for the *errors* argument.
+
    The *pax_headers* argument is an optional dictionary of strings which
    will be added as a pax global header if *format* is :const:`PAX_FORMAT`.
 
@@ -449,11 +452,14 @@
    a :class:`TarInfo` object.
 
 
-.. method:: TarInfo.tobuf(format=DEFAULT_FORMAT, encoding=ENCODING, errors='strict')
+.. method:: TarInfo.tobuf(format=DEFAULT_FORMAT, encoding=ENCODING, errors='surrogateescape')
 
    Create a string buffer from a :class:`TarInfo` object. For information on the
    arguments see the constructor of the :class:`TarFile` class.
 
+   .. versionchanged:: 3.2
+      Use ``'surrogateescape'`` as the default for the *errors* argument.
+
 
 A ``TarInfo`` object has the following public data attributes:
 
@@ -701,11 +707,10 @@
 appropriately, this conversion may fail.
 
 The *errors* argument defines how characters are treated that cannot be
-converted. Possible values are listed in section :ref:`codec-base-classes`. In
-read mode the default scheme is ``'replace'``. This avoids unexpected
-:exc:`UnicodeError` exceptions and guarantees that an archive can always be
-read. In write mode the default value for *errors* is ``'strict'``.  This
-ensures that name information is not altered unnoticed.
+converted. Possible values are listed in section :ref:`codec-base-classes`.
+The default scheme is ``'surrogateescape'`` which Python also uses for its
+file system calls, see :ref:`os-filenames`.
 
 In case of writing :const:`PAX_FORMAT` archives, *encoding* is ignored because
-non-ASCII metadata is stored using *UTF-8*.
+non-ASCII metadata is stored using *UTF-8*. Storing surrogate characters is not
+possible and will raise a :exc:`UnicodeEncodeError`.

Modified: python/branches/py3k-jit/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/urllib.request.rst	(original)
+++ python/branches/py3k-jit/Doc/library/urllib.request.rst	Thu May  6 23:49:27 2010
@@ -133,17 +133,17 @@
    of the :class:`FancyURLopener` class and use it to perform their requested
    actions.  To override this functionality, programmers can create a subclass of
    :class:`URLopener` or :class:`FancyURLopener`, then assign an instance of that
-   class to the ``urllib._urlopener`` variable before calling the desired function.
-   For example, applications may want to specify a different
-   :mailheader:`User-Agent` header than :class:`URLopener` defines.  This can be
-   accomplished with the following code::
+   class to the ``urllib.request._urlopener`` variable before calling the
+   desired function.  For example, applications may want to specify a different
+   :mailheader:`User-Agent` header than :class:`URLopener` defines.
+   This can be accomplished with the following code::
 
       import urllib.request
 
       class AppURLopener(urllib.request.FancyURLopener):
           version = "App/1.7"
 
-      urllib._urlopener = AppURLopener()
+      urllib.request._urlopener = AppURLopener()
 
 
 .. function:: urlcleanup()

Modified: python/branches/py3k-jit/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k-jit/Doc/whatsnew/3.2.rst	(original)
+++ python/branches/py3k-jit/Doc/whatsnew/3.2.rst	Thu May  6 23:49:27 2010
@@ -123,6 +123,11 @@
 
   (Contributed by Antoine Pitrou; :issue:`3001`.)
 
+* Regular and recursive locks now accept an optional *timeout* argument
+  to their ``acquire`` method. (Contributed by Antoine Pitrou; :issue:`7316`)
+  Similarly, :meth:`threading.Semaphore.acquire` also gains a *timeout*
+  argument. (Contributed by Torsten Landschoff; :issue:`850728`.)
+
 
 Optimizations
 =============

Modified: python/branches/py3k-jit/Lib/asyncore.py
==============================================================================
--- python/branches/py3k-jit/Lib/asyncore.py	(original)
+++ python/branches/py3k-jit/Lib/asyncore.py	Thu May  6 23:49:27 2010
@@ -50,6 +50,8 @@
 import socket
 import sys
 import time
+import warnings
+
 import os
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
      ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode
@@ -60,10 +62,12 @@
     socket_map = {}
 
 def _strerror(err):
-    res = os.strerror(err)
-    if res == 'Unknown error':
-        res = errorcode[err]
-    return res
+    try:
+        return strerror(err)
+    except (ValueError, OverflowError):
+        if err in errorcode:
+            return errorcode[err]
+        return "Unknown error %s" %err
 
 class ExitNow(Exception):
     pass
@@ -264,6 +268,8 @@
                 status.append(repr(self.addr))
         return '<%s at %#x>' % (' '.join(status), id(self))
 
+    __str__ = __repr__
+
     def add_channel(self, map=None):
         #self.log_info('adding channel %s' % self)
         if map is None:
@@ -395,7 +401,16 @@
     # cheap inheritance, used to pass all other attribute
     # references to the underlying socket object.
     def __getattr__(self, attr):
-        return getattr(self.socket, attr)
+        try:
+            retattr = getattr(self.socket, attr)
+        except AttributeError:
+            raise AttributeError("%s instance has no attribute '%s'"
+                                 %(self.__class__.__name__, attr))
+        else:
+            msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \
+                  "instead" % {'me' : self.__class__.__name__, 'attr' : attr}
+            warnings.warn(msg, DeprecationWarning, stacklevel=2)
+            return retattr
 
     # log and log_info may be overridden to provide more sophisticated
     # logging and warning methods. In general, log is for 'hit' logging

Modified: python/branches/py3k-jit/Lib/ctypes/test/test_win32.py
==============================================================================
--- python/branches/py3k-jit/Lib/ctypes/test/test_win32.py	(original)
+++ python/branches/py3k-jit/Lib/ctypes/test/test_win32.py	Thu May  6 23:49:27 2010
@@ -6,32 +6,6 @@
 
 import _ctypes_test
 
-if sys.platform == "win32" and sizeof(c_void_p) == sizeof(c_int):
-    # Only windows 32-bit has different calling conventions.
-
-    class WindowsTestCase(unittest.TestCase):
-        def test_callconv_1(self):
-            # Testing stdcall function
-
-            IsWindow = windll.user32.IsWindow
-            # ValueError: Procedure probably called with not enough arguments (4 bytes missing)
-            self.assertRaises(ValueError, IsWindow)
-
-            # This one should succeeed...
-            self.assertEqual(0, IsWindow(0))
-
-            # ValueError: Procedure probably called with too many arguments (8 bytes in excess)
-            self.assertRaises(ValueError, IsWindow, 0, 0, 0)
-
-        def test_callconv_2(self):
-            # Calling stdcall function as cdecl
-
-            IsWindow = cdll.user32.IsWindow
-
-            # ValueError: Procedure called with not enough arguments (4 bytes missing)
-            # or wrong calling convention
-            self.assertRaises(ValueError, IsWindow, None)
-
 if sys.platform == "win32":
     class FunctionCallTestCase(unittest.TestCase):
 

Modified: python/branches/py3k-jit/Lib/decimal.py
==============================================================================
--- python/branches/py3k-jit/Lib/decimal.py	(original)
+++ python/branches/py3k-jit/Lib/decimal.py	Thu May  6 23:49:27 2010
@@ -1655,47 +1655,53 @@
         exp_min = len(self._int) + self._exp - context.prec
         if exp_min > Etop:
             # overflow: exp_min > Etop iff self.adjusted() > Emax
+            ans = context._raise_error(Overflow, 'above Emax', self._sign)
             context._raise_error(Inexact)
             context._raise_error(Rounded)
-            return context._raise_error(Overflow, 'above Emax', self._sign)
+            return ans
+
         self_is_subnormal = exp_min < Etiny
         if self_is_subnormal:
-            context._raise_error(Subnormal)
             exp_min = Etiny
 
         # round if self has too many digits
         if self._exp < exp_min:
-            context._raise_error(Rounded)
             digits = len(self._int) + self._exp - exp_min
             if digits < 0:
                 self = _dec_from_triple(self._sign, '1', exp_min-1)
                 digits = 0
-            this_function = getattr(self, self._pick_rounding_function[context.rounding])
-            changed = this_function(digits)
+            rounding_method = self._pick_rounding_function[context.rounding]
+            changed = getattr(self, rounding_method)(digits)
             coeff = self._int[:digits] or '0'
-            if changed == 1:
+            if changed > 0:
                 coeff = str(int(coeff)+1)
-            ans = _dec_from_triple(self._sign, coeff, exp_min)
+                if len(coeff) > context.prec:
+                    coeff = coeff[:-1]
+                    exp_min += 1
+
+            # check whether the rounding pushed the exponent out of range
+            if exp_min > Etop:
+                ans = context._raise_error(Overflow, 'above Emax', self._sign)
+            else:
+                ans = _dec_from_triple(self._sign, coeff, exp_min)
 
+            # raise the appropriate signals, taking care to respect
+            # the precedence described in the specification
+            if changed and self_is_subnormal:
+                context._raise_error(Underflow)
+            if self_is_subnormal:
+                context._raise_error(Subnormal)
             if changed:
                 context._raise_error(Inexact)
-                if self_is_subnormal:
-                    context._raise_error(Underflow)
-                    if not ans:
-                        # raise Clamped on underflow to 0
-                        context._raise_error(Clamped)
-                elif len(ans._int) == context.prec+1:
-                    # we get here only if rescaling rounds the
-                    # cofficient up to exactly 10**context.prec
-                    if ans._exp < Etop:
-                        ans = _dec_from_triple(ans._sign,
-                                                   ans._int[:-1], ans._exp+1)
-                    else:
-                        # Inexact and Rounded have already been raised
-                        ans = context._raise_error(Overflow, 'above Emax',
-                                                   self._sign)
+            context._raise_error(Rounded)
+            if not ans:
+                # raise Clamped on underflow to 0
+                context._raise_error(Clamped)
             return ans
 
+        if self_is_subnormal:
+            context._raise_error(Subnormal)
+
         # fold down if _clamp == 1 and self has too few digits
         if context._clamp == 1 and self._exp > Etop:
             context._raise_error(Clamped)
@@ -2322,6 +2328,7 @@
         # from here on, the result always goes through the call
         # to _fix at the end of this function.
         ans = None
+        exact = False
 
         # crude test to catch cases of extreme overflow/underflow.  If
         # log10(self)*other >= 10**bound and bound >= len(str(Emax))
@@ -2346,6 +2353,7 @@
             ans = self._power_exact(other, context.prec + 1)
             if ans is not None and result_sign == 1:
                 ans = _dec_from_triple(1, ans._int, ans._exp)
+            exact = True
 
         # usual case: inexact result, x**y computed directly as exp(y*log(x))
         if ans is None:
@@ -2368,24 +2376,55 @@
 
             ans = _dec_from_triple(result_sign, str(coeff), exp)
 
-        # the specification says that for non-integer other we need to
-        # raise Inexact, even when the result is actually exact.  In
-        # the same way, we need to raise Underflow here if the result
-        # is subnormal.  (The call to _fix will take care of raising
-        # Rounded and Subnormal, as usual.)
-        if not other._isinteger():
-            context._raise_error(Inexact)
-            # pad with zeros up to length context.prec+1 if necessary
+        # unlike exp, ln and log10, the power function respects the
+        # rounding mode; no need to switch to ROUND_HALF_EVEN here
+
+        # There's a difficulty here when 'other' is not an integer and
+        # the result is exact.  In this case, the specification
+        # requires that the Inexact flag be raised (in spite of
+        # exactness), but since the result is exact _fix won't do this
+        # for us.  (Correspondingly, the Underflow signal should also
+        # be raised for subnormal results.)  We can't directly raise
+        # these signals either before or after calling _fix, since
+        # that would violate the precedence for signals.  So we wrap
+        # the ._fix call in a temporary context, and reraise
+        # afterwards.
+        if exact and not other._isinteger():
+            # pad with zeros up to length context.prec+1 if necessary; this
+            # ensures that the Rounded signal will be raised.
             if len(ans._int) <= context.prec:
-                expdiff = context.prec+1 - len(ans._int)
+                expdiff = context.prec + 1 - len(ans._int)
                 ans = _dec_from_triple(ans._sign, ans._int+'0'*expdiff,
                                        ans._exp-expdiff)
-            if ans.adjusted() < context.Emin:
-                context._raise_error(Underflow)
 
-        # unlike exp, ln and log10, the power function respects the
-        # rounding mode; no need to use ROUND_HALF_EVEN here
-        ans = ans._fix(context)
+            # create a copy of the current context, with cleared flags/traps
+            newcontext = context.copy()
+            newcontext.clear_flags()
+            for exception in _signals:
+                newcontext.traps[exception] = 0
+
+            # round in the new context
+            ans = ans._fix(newcontext)
+
+            # raise Inexact, and if necessary, Underflow
+            newcontext._raise_error(Inexact)
+            if newcontext.flags[Subnormal]:
+                newcontext._raise_error(Underflow)
+
+            # propagate signals to the original context; _fix could
+            # have raised any of Overflow, Underflow, Subnormal,
+            # Inexact, Rounded, Clamped.  Overflow needs the correct
+            # arguments.  Note that the order of the exceptions is
+            # important here.
+            if newcontext.flags[Overflow]:
+                context._raise_error(Overflow, 'above Emax', ans._sign)
+            for exception in Underflow, Subnormal, Inexact, Rounded, Clamped:
+                if newcontext.flags[exception]:
+                    context._raise_error(exception)
+
+        else:
+            ans = ans._fix(context)
+
         return ans
 
     def __rpow__(self, other, context=None):
@@ -2479,14 +2518,15 @@
                                         'quantize result has too many digits for current context')
 
         # raise appropriate flags
+        if ans and ans.adjusted() < context.Emin:
+            context._raise_error(Subnormal)
         if ans._exp > self._exp:
-            context._raise_error(Rounded)
             if ans != self:
                 context._raise_error(Inexact)
-        if ans and ans.adjusted() < context.Emin:
-            context._raise_error(Subnormal)
+            context._raise_error(Rounded)
 
-        # call to fix takes care of any necessary folddown
+        # call to fix takes care of any necessary folddown, and
+        # signals Clamped if necessary
         ans = ans._fix(context)
         return ans
 
@@ -2585,10 +2625,10 @@
             context = getcontext()
         if rounding is None:
             rounding = context.rounding
-        context._raise_error(Rounded)
         ans = self._rescale(0, rounding)
         if ans != self:
             context._raise_error(Inexact)
+        context._raise_error(Rounded)
         return ans
 
     def to_integral_value(self, rounding=None, context=None):
@@ -3469,13 +3509,13 @@
             context._raise_error(Overflow,
                                  'Infinite result from next_toward',
                                  ans._sign)
-            context._raise_error(Rounded)
             context._raise_error(Inexact)
+            context._raise_error(Rounded)
         elif ans.adjusted() < context.Emin:
             context._raise_error(Underflow)
             context._raise_error(Subnormal)
-            context._raise_error(Rounded)
             context._raise_error(Inexact)
+            context._raise_error(Rounded)
             # if precision == 1 then we don't raise Clamped for a
             # result 0E-Etiny.
             if not ans:

Modified: python/branches/py3k-jit/Lib/distutils/command/install.py
==============================================================================
--- python/branches/py3k-jit/Lib/distutils/command/install.py	(original)
+++ python/branches/py3k-jit/Lib/distutils/command/install.py	Thu May  6 23:49:27 2010
@@ -65,20 +65,6 @@
         'scripts': '$userbase/Scripts',
         'data'   : '$userbase',
         },
-    'mac': {
-        'purelib': '$base/Lib/site-packages',
-        'platlib': '$base/Lib/site-packages',
-        'headers': '$base/Include/$dist_name',
-        'scripts': '$base/Scripts',
-        'data'   : '$base',
-        },
-    'mac_user': {
-        'purelib': '$usersite',
-        'platlib': '$usersite',
-        'headers': '$userbase/$py_version_short/include/$dist_name',
-        'scripts': '$userbase/bin',
-        'data'   : '$userbase',
-        },
     'os2': {
         'purelib': '$base/Lib/site-packages',
         'platlib': '$base/Lib/site-packages',

Modified: python/branches/py3k-jit/Lib/distutils/file_util.py
==============================================================================
--- python/branches/py3k-jit/Lib/distutils/file_util.py	(original)
+++ python/branches/py3k-jit/Lib/distutils/file_util.py	Thu May  6 23:49:27 2010
@@ -132,15 +132,6 @@
     if dry_run:
         return (dst, 1)
 
-    # On Mac OS, use the native file copy routine
-    if os.name == 'mac':
-        import macostools
-        try:
-            macostools.copy(src, dst, 0, preserve_times)
-        except os.error as exc:
-            raise DistutilsFileError(
-                  "could not copy '%s' to '%s': %s" % (src, dst, exc.args[-1]))
-
     # If linking (hard or symbolic), use the appropriate system call
     # (Unix only, of course, but that's the caller's responsibility)
     elif link == 'hard':

Modified: python/branches/py3k-jit/Lib/distutils/util.py
==============================================================================
--- python/branches/py3k-jit/Lib/distutils/util.py	(original)
+++ python/branches/py3k-jit/Lib/distutils/util.py	Thu May  6 23:49:27 2010
@@ -91,15 +91,6 @@
             path = path[1:]
         return os.path.join(new_root, path)
 
-    elif os.name == 'mac':
-        if not os.path.isabs(pathname):
-            return os.path.join(new_root, pathname)
-        else:
-            # Chop off volume name from start of path
-            elements = pathname.split(":", 1)
-            pathname = ":" + elements[1]
-            return os.path.join(new_root, pathname)
-
     else:
         raise DistutilsPlatformError("nothing known about "
                                      "platform '%s'" % os.name)

Modified: python/branches/py3k-jit/Lib/email/test/data/audiotest.au
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k-jit/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k-jit/Lib/email/test/test_email.py	(original)
+++ python/branches/py3k-jit/Lib/email/test/test_email.py	Thu May  6 23:49:27 2010
@@ -530,6 +530,13 @@
         msg = MIMEText('hello \xf8 world', _charset='iso-8859-1')
         eq(msg['content-transfer-encoding'], 'quoted-printable')
 
+    def test_encode7or8bit(self):
+        # Make sure a charset whose input character set is 8bit but
+        # whose output character set is 7bit gets a transfer-encoding
+        # of 7bit.
+        eq = self.assertEqual
+        msg = MIMEText('\xca\xb8', _charset='euc-jp')
+        eq(msg['content-transfer-encoding'], '7bit')
 
 
 # Test long header wrapping

Modified: python/branches/py3k-jit/Lib/gzip.py
==============================================================================
--- python/branches/py3k-jit/Lib/gzip.py	(original)
+++ python/branches/py3k-jit/Lib/gzip.py	Thu May  6 23:49:27 2010
@@ -380,7 +380,7 @@
         if self.mode == WRITE:
             # Ensure the compressor's buffer is flushed
             self.fileobj.write(self.compress.flush(zlib_mode))
-        self.fileobj.flush()
+            self.fileobj.flush()
 
     def fileno(self):
         """Invoke the underlying file object's fileno() method.

Modified: python/branches/py3k-jit/Lib/platform.py
==============================================================================
--- python/branches/py3k-jit/Lib/platform.py	(original)
+++ python/branches/py3k-jit/Lib/platform.py	Thu May  6 23:49:27 2010
@@ -601,12 +601,19 @@
             VER_PLATFORM_WIN32_WINDOWS = 1
             VER_PLATFORM_WIN32_NT = 2
             VER_NT_WORKSTATION = 1
+            VER_NT_SERVER = 3
+            REG_SZ = 1
 
     # Find out the registry key and some general version infos
-    maj,min,buildno,plat,csd = GetVersionEx()
+    winver = GetVersionEx()
+    maj,min,buildno,plat,csd = winver
     version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF)
-    if csd[:13] == 'Service Pack ':
-        csd = 'SP' + csd[13:]
+    if hasattr(winver, "service_pack"):
+        if winver.service_pack != "":
+            csd = 'SP%s' % winver.service_pack_major
+    else:
+        if csd[:13] == 'Service Pack ':
+            csd = 'SP' + csd[13:]
 
     if plat == VER_PLATFORM_WIN32_WINDOWS:
         regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion'
@@ -637,23 +644,33 @@
             else:
                 release = 'post2003'
         elif maj == 6:
-            if min == 0:
-                # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx
+            if hasattr(winver, "product_type"):
+                product_type = winver.product_type
+            else:
+                product_type = VER_NT_WORKSTATION
+                # Without an OSVERSIONINFOEX capable sys.getwindowsversion(),
+                # or help from the registry, we cannot properly identify
+                # non-workstation versions.
                 try:
-                    productType = GetVersionEx(1)[8]
-                except TypeError:
-                    # sys.getwindowsversion() doesn't take any arguments, so
-                    # we cannot detect 2008 Server that way.
-                    # XXX Add some other means of detecting 2008 Server ?!
+                    key = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey)
+                    name, type = RegQueryValueEx(key, "ProductName")
+                    # Discard any type that isn't REG_SZ
+                    if type == REG_SZ and name.find("Server") != -1:
+                        product_type = VER_NT_SERVER
+                except WindowsError:
+                    # Use default of VER_NT_WORKSTATION
+                    pass
+
+            if min == 0:
+                if product_type == VER_NT_WORKSTATION:
                     release = 'Vista'
                 else:
-                    if productType == VER_NT_WORKSTATION:
-                        release = 'Vista'
-                    else:
-                        release = '2008Server'
-            #elif min == 1:
-            #    # Windows 7 release candidate uses version 6.1.7100
-            #    release = '7RC'
+                    release = '2008Server'
+            elif min == 1:
+                if product_type == VER_NT_WORKSTATION:
+                    release = '7'
+                else:
+                    release = '2008ServerR2'
             else:
                 release = 'post2008Server'
 
@@ -1147,10 +1164,6 @@
             if not version:
                 version = vendor
 
-        elif os.name == 'mac':
-            release,(version,stage,nonrel),machine = mac_ver()
-            system = 'MacOS'
-
     # System specific extensions
     if system == 'OpenVMS':
         # OpenVMS seems to have release and version mixed up

Modified: python/branches/py3k-jit/Lib/profile.py
==============================================================================
--- python/branches/py3k-jit/Lib/profile.py	(original)
+++ python/branches/py3k-jit/Lib/profile.py	Thu May  6 23:49:27 2010
@@ -92,11 +92,6 @@
     else:
         return prof.print_stats()
 
-if os.name == "mac":
-    import MacOS
-    def _get_time_mac(timer=MacOS.GetTicks):
-        return timer() / 60.0
-
 if hasattr(os, "times"):
     def _get_time_times(timer=os.times):
         t = timer()
@@ -173,10 +168,6 @@
                 self.timer = resgetrusage
                 self.dispatcher = self.trace_dispatch
                 self.get_time = _get_time_resource
-            elif os.name == 'mac':
-                self.timer = MacOS.GetTicks
-                self.dispatcher = self.trace_dispatch_mac
-                self.get_time = _get_time_mac
             elif hasattr(time, 'clock'):
                 self.timer = self.get_time = time.clock
                 self.dispatcher = self.trace_dispatch_i

Modified: python/branches/py3k-jit/Lib/pydoc.py
==============================================================================
--- python/branches/py3k-jit/Lib/pydoc.py	(original)
+++ python/branches/py3k-jit/Lib/pydoc.py	Thu May  6 23:49:27 2010
@@ -2024,7 +2024,7 @@
 
     class DocServer(http.server.HTTPServer):
         def __init__(self, port, callback):
-            host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
+            host = 'localhost'
             self.address = ('', port)
             self.url = 'http://%s:%d/' % (host, port)
             self.callback = callback
@@ -2141,10 +2141,6 @@
             except ImportError: # pre-webbrowser.py compatibility
                 if sys.platform == 'win32':
                     os.system('start "%s"' % url)
-                elif sys.platform == 'mac':
-                    try: import ic
-                    except ImportError: pass
-                    else: ic.launchurl(url)
                 else:
                     rc = os.system('netscape -remote "openURL(%s)" &' % url)
                     if rc: os.system('netscape "%s" &' % url)

Modified: python/branches/py3k-jit/Lib/shutil.py
==============================================================================
--- python/branches/py3k-jit/Lib/shutil.py	(original)
+++ python/branches/py3k-jit/Lib/shutil.py	Thu May  6 23:49:27 2010
@@ -84,8 +84,6 @@
     if _samefile(src, dst):
         raise Error("`%s` and `%s` are the same file" % (src, dst))
 
-    fsrc = None
-    fdst = None
     for fn in [src, dst]:
         try:
             st = os.stat(fn)
@@ -96,15 +94,10 @@
             # XXX What about other special files? (sockets, devices...)
             if stat.S_ISFIFO(st.st_mode):
                 raise SpecialFileError("`%s` is a named pipe" % fn)
-    try:
-        fsrc = open(src, 'rb')
-        fdst = open(dst, 'wb')
-        copyfileobj(fsrc, fdst)
-    finally:
-        if fdst:
-            fdst.close()
-        if fsrc:
-            fsrc.close()
+
+    with open(src, 'rb') as fsrc:
+        with open(dst, 'wb') as fdst:
+            copyfileobj(fsrc, fdst)
 
 def copymode(src, dst):
     """Copy mode bits from src to dst"""

Modified: python/branches/py3k-jit/Lib/tarfile.py
==============================================================================
--- python/branches/py3k-jit/Lib/tarfile.py	(original)
+++ python/branches/py3k-jit/Lib/tarfile.py	Thu May  6 23:49:27 2010
@@ -50,13 +50,6 @@
 import copy
 import re
 
-if sys.platform == 'mac':
-    # This module needs work for MacOS9, especially in the area of pathname
-    # handling. In many places it is assumed a simple substitution of / by the
-    # local os.path.sep is good enough to convert pathnames, but this does not
-    # work with the mac rooted:path:name versus :nonrooted:path:name syntax
-    raise ImportError("tarfile does not work for platform==mac")
-
 try:
     import grp, pwd
 except ImportError:
@@ -985,7 +978,7 @@
 
         return info
 
-    def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="strict"):
+    def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
         """Return a tar header as a string of 512 byte blocks.
         """
         info = self.get_info()
@@ -1497,7 +1490,7 @@
 
     def __init__(self, name=None, mode="r", fileobj=None, format=None,
             tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
-            errors=None, pax_headers=None, debug=None, errorlevel=None):
+            errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None):
         """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
            read from an existing archive, 'a' to append data to an existing
            file or 'w' to create a new file overwriting an existing one. `mode'
@@ -1538,13 +1531,7 @@
             self.ignore_zeros = ignore_zeros
         if encoding is not None:
             self.encoding = encoding
-
-        if errors is not None:
-            self.errors = errors
-        elif mode == "r":
-            self.errors = "replace"
-        else:
-            self.errors = "strict"
+        self.errors = errors
 
         if pax_headers is not None and self.format == PAX_FORMAT:
             self.pax_headers = pax_headers

Modified: python/branches/py3k-jit/Lib/test/audiotest.au
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k-jit/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-jit/Lib/test/regrtest.py	Thu May  6 23:49:27 2010
@@ -1209,34 +1209,6 @@
         test_kqueue
         test_ossaudiodev
         """,
-   'mac':
-        """
-        test_atexit
-        test_bz2
-        test_crypt
-        test_curses
-        test_dbm
-        test_fcntl
-        test_fork1
-        test_epoll
-        test_grp
-        test_ioctl
-        test_largefile
-        test_locale
-        test_kqueue
-        test_mmap
-        test_openpty
-        test_ossaudiodev
-        test_poll
-        test_popen
-        test_posix
-        test_pty
-        test_pwd
-        test_resource
-        test_signal
-        test_sundry
-        test_tarfile
-        """,
     'unixware7':
         """
         test_epoll

Modified: python/branches/py3k-jit/Lib/test/support.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/support.py	(original)
+++ python/branches/py3k-jit/Lib/test/support.py	Thu May  6 23:49:27 2010
@@ -186,7 +186,7 @@
         os.unlink(filename)
     except OSError as error:
         # The filename need not exist.
-        if error.errno != errno.ENOENT:
+        if error.errno not in (errno.ENOENT, errno.ENOTDIR):
             raise
 
 def rmtree(path):
@@ -376,6 +376,7 @@
 # module name.
 TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
 
+
 # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
 # TESTFN_UNICODE is a filename that can be encoded using the
 # file system encoding, but *not* with the default (ascii) encoding

Modified: python/branches/py3k-jit/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_asyncore.py	Thu May  6 23:49:27 2010
@@ -5,6 +5,7 @@
 import socket
 import sys
 import time
+import warnings
 
 from test import support
 from test.support import TESTFN, run_unittest, unlink
@@ -306,6 +307,22 @@
                     'warning: unhandled accept event']
         self.assertEquals(lines, expected)
 
+    def test_issue_8594(self):
+        # XXX - this test is supposed to be removed in next major Python
+        # version
+        d = asyncore.dispatcher(socket.socket())
+        # make sure the error message no longer refers to the socket
+        # object but the dispatcher instance instead
+        self.assertRaisesRegexp(AttributeError, 'dispatcher instance',
+                                getattr, d, 'foo')
+        # cheap inheritance with the underlying socket is supposed
+        # to still work but a DeprecationWarning is expected
+        with warnings.catch_warnings(record=True) as w:
+            warnings.simplefilter("always")
+            family = d.family
+            self.assertEqual(family, socket.AF_INET)
+            self.assertTrue(len(w) == 1)
+            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
 
 
 class dispatcherwithsend_noread(asyncore.dispatcher_with_send):

Modified: python/branches/py3k-jit/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_builtin.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_builtin.py	Thu May  6 23:49:27 2010
@@ -942,8 +942,8 @@
         self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
         """
 
-        # Reject floats when it would require PyLongs to represent.
-        # (smaller floats still accepted, but deprecated)
+        # Reject floats.
+        self.assertRaises(TypeError, range, 1., 1., 1.)
         self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
 
         self.assertRaises(TypeError, range, 0, "spam")
@@ -954,6 +954,46 @@
 
         self.assertRaises(OverflowError, len, range(0, sys.maxsize**10))
 
+        bignum = 2*sys.maxsize
+        smallnum = 42
+
+        # User-defined class with an __index__ method
+        class I:
+            def __init__(self, n):
+                self.n = int(n)
+            def __index__(self):
+                return self.n
+        self.assertEqual(list(range(I(bignum), I(bignum + 1))), [bignum])
+        self.assertEqual(list(range(I(smallnum), I(smallnum + 1))), [smallnum])
+
+        # User-defined class with a failing __index__ method
+        class IX:
+            def __index__(self):
+                raise RuntimeError
+        self.assertRaises(RuntimeError, range, IX())
+
+        # User-defined class with an invalid __index__ method
+        class IN:
+            def __index__(self):
+                return "not a number"
+
+        self.assertRaises(TypeError, range, IN())
+        # Exercise various combinations of bad arguments, to check
+        # refcounting logic
+        self.assertRaises(TypeError, range, 0.0)
+
+        self.assertRaises(TypeError, range, 0, 0.0)
+        self.assertRaises(TypeError, range, 0.0, 0)
+        self.assertRaises(TypeError, range, 0.0, 0.0)
+
+        self.assertRaises(TypeError, range, 0, 0, 1.0)
+        self.assertRaises(TypeError, range, 0, 0.0, 1)
+        self.assertRaises(TypeError, range, 0, 0.0, 1.0)
+        self.assertRaises(TypeError, range, 0.0, 0, 1)
+        self.assertRaises(TypeError, range, 0.0, 0, 1.0)
+        self.assertRaises(TypeError, range, 0.0, 0.0, 1)
+        self.assertRaises(TypeError, range, 0.0, 0.0, 1.0)
+
     def test_input(self):
         self.write_testfile()
         fp = open(TESTFN, 'r')

Modified: python/branches/py3k-jit/Lib/test/test_decimal.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_decimal.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_decimal.py	Thu May  6 23:49:27 2010
@@ -41,6 +41,12 @@
 # Useful Test Constant
 Signals = tuple(getcontext().flags.keys())
 
+# Signals ordered with respect to precedence: when an operation
+# produces multiple signals, signals occurring later in the list
+# should be handled before those occurring earlier in the list.
+OrderedSignals = (Clamped, Rounded, Inexact, Subnormal,
+                  Underflow, Overflow, DivisionByZero, InvalidOperation)
+
 # Tests are built around these assumed context defaults.
 # test_main() restores the original context.
 def init():
@@ -351,6 +357,25 @@
                 else:
                     self.fail("Did not raise %s in %s" % (error, s))
                 self.context.traps[error] = 0
+
+            # as above, but add traps cumulatively, to check precedence
+            ordered_errors = [e for e in OrderedSignals if e in theirexceptions]
+            for error in ordered_errors:
+                self.context.traps[error] = 1
+                try:
+                    funct(*vals)
+                except error:
+                    pass
+                except Signals as e:
+                    self.fail("Raised %s in %s; expected %s" %
+                              (type(e), s, error))
+                else:
+                    self.fail("Did not raise %s in %s" % (error, s))
+            # reset traps
+            for error in ordered_errors:
+                self.context.traps[error] = 0
+
+
         if DEBUG:
             print("--", self.context)
         try:

Modified: python/branches/py3k-jit/Lib/test/test_dictviews.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_dictviews.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_dictviews.py	Thu May  6 23:49:27 2010
@@ -69,6 +69,82 @@
         self.assertEqual(set(values), {10, "ABC"})
         self.assertEqual(len(values), 2)
 
+    def test_dict_repr(self):
+        d = {1: 10, "a": "ABC"}
+        self.assertIsInstance(repr(d), str)
+        r = repr(d.items())
+        self.assertIsInstance(r, str)
+        self.assertTrue(r == "dict_items([('a', 'ABC'), (1, 10)])" or
+                        r == "dict_items([(1, 10), ('a', 'ABC')])")
+        r = repr(d.keys())
+        self.assertIsInstance(r, str)
+        self.assertTrue(r == "dict_keys(['a', 1])" or
+                        r == "dict_keys([1, 'a'])")
+        r = repr(d.values())
+        self.assertIsInstance(r, str)
+        self.assertTrue(r == "dict_values(['ABC', 10])" or
+                        r == "dict_values([10, 'ABC'])")
+
+    def test_keys_set_operations(self):
+        d1 = {'a': 1, 'b': 2}
+        d2 = {'b': 3, 'c': 2}
+        d3 = {'d': 4, 'e': 5}
+        self.assertEqual(d1.keys() & d1.keys(), {'a', 'b'})
+        self.assertEqual(d1.keys() & d2.keys(), {'b'})
+        self.assertEqual(d1.keys() & d3.keys(), set())
+        self.assertEqual(d1.keys() & set(d1.keys()), {'a', 'b'})
+        self.assertEqual(d1.keys() & set(d2.keys()), {'b'})
+        self.assertEqual(d1.keys() & set(d3.keys()), set())
+
+        self.assertEqual(d1.keys() | d1.keys(), {'a', 'b'})
+        self.assertEqual(d1.keys() | d2.keys(), {'a', 'b', 'c'})
+        self.assertEqual(d1.keys() | d3.keys(), {'a', 'b', 'd', 'e'})
+        self.assertEqual(d1.keys() | set(d1.keys()), {'a', 'b'})
+        self.assertEqual(d1.keys() | set(d2.keys()), {'a', 'b', 'c'})
+        self.assertEqual(d1.keys() | set(d3.keys()),
+                         {'a', 'b', 'd', 'e'})
+
+        self.assertEqual(d1.keys() ^ d1.keys(), set())
+        self.assertEqual(d1.keys() ^ d2.keys(), {'a', 'c'})
+        self.assertEqual(d1.keys() ^ d3.keys(), {'a', 'b', 'd', 'e'})
+        self.assertEqual(d1.keys() ^ set(d1.keys()), set())
+        self.assertEqual(d1.keys() ^ set(d2.keys()), {'a', 'c'})
+        self.assertEqual(d1.keys() ^ set(d3.keys()),
+                         {'a', 'b', 'd', 'e'})
+
+    def test_items_set_operations(self):
+        d1 = {'a': 1, 'b': 2}
+        d2 = {'a': 2, 'b': 2}
+        d3 = {'d': 4, 'e': 5}
+        self.assertEqual(
+            d1.items() & d1.items(), {('a', 1), ('b', 2)})
+        self.assertEqual(d1.items() & d2.items(), {('b', 2)})
+        self.assertEqual(d1.items() & d3.items(), set())
+        self.assertEqual(d1.items() & set(d1.items()),
+                         {('a', 1), ('b', 2)})
+        self.assertEqual(d1.items() & set(d2.items()), {('b', 2)})
+        self.assertEqual(d1.items() & set(d3.items()), set())
+
+        self.assertEqual(d1.items() | d1.items(),
+                         {('a', 1), ('b', 2)})
+        self.assertEqual(d1.items() | d2.items(),
+                         {('a', 1), ('a', 2), ('b', 2)})
+        self.assertEqual(d1.items() | d3.items(),
+                         {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+        self.assertEqual(d1.items() | set(d1.items()),
+                         {('a', 1), ('b', 2)})
+        self.assertEqual(d1.items() | set(d2.items()),
+                         {('a', 1), ('a', 2), ('b', 2)})
+        self.assertEqual(d1.items() | set(d3.items()),
+                         {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+
+        self.assertEqual(d1.items() ^ d1.items(), set())
+        self.assertEqual(d1.items() ^ d2.items(),
+                         {('a', 1), ('a', 2)})
+        self.assertEqual(d1.items() ^ d3.items(),
+                         {('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+
+
 def test_main():
     support.run_unittest(DictSetTest)
 

Modified: python/branches/py3k-jit/Lib/test/test_frozen.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_frozen.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_frozen.py	Thu May  6 23:49:27 2010
@@ -39,13 +39,12 @@
         else:
             self.fail("import __phello__.foo should have failed")
 
-            if sys.platform != "mac":  # On the Mac this import does succeed.
-                try:
-                    import __phello__.foo
-                except ImportError:
-                    pass
-                else:
-                    self.fail("import __phello__.foo should have failed")
+            try:
+                import __phello__.foo
+            except ImportError:
+                pass
+            else:
+                self.fail("import __phello__.foo should have failed")
 
         del sys.modules['__hello__']
         del sys.modules['__phello__']

Modified: python/branches/py3k-jit/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_ftplib.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_ftplib.py	Thu May  6 23:49:27 2010
@@ -50,6 +50,9 @@
     def push(self, what):
         super(DummyDTPHandler, self).push(what.encode('ascii'))
 
+    def handle_error(self):
+        raise
+
 
 class DummyFTPHandler(asynchat.async_chat):
 

Modified: python/branches/py3k-jit/Lib/test/test_gdb.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_gdb.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_gdb.py	Thu May  6 23:49:27 2010
@@ -121,6 +121,11 @@
 
         # Ignore some noise on stderr due to the pending breakpoint:
         err = err.replace('Function "%s" not defined.\n' % breakpoint, '')
+        # Ignore some other noise on stderr (http://bugs.python.org/issue8600)
+        err = err.replace("warning: Unable to find libthread_db matching"
+                          " inferior's thread library, thread debugging will"
+                          " not be available.\n",
+                          '')
 
         # Ensure no unexpected error messages:
         self.assertEquals(err, '')

Modified: python/branches/py3k-jit/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_ossaudiodev.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_ossaudiodev.py	Thu May  6 23:49:27 2010
@@ -76,7 +76,7 @@
 
         # set parameters based on .au file headers
         dsp.setparameters(AFMT_S16_NE, nchannels, rate)
-        self.assertTrue(abs(expected_time - 2.94) < 1e-2, expected_time)
+        self.assertTrue(abs(expected_time - 3.51) < 1e-2, expected_time)
         t1 = time.time()
         dsp.write(data)
         dsp.close()

Modified: python/branches/py3k-jit/Lib/test/test_reprlib.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_reprlib.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_reprlib.py	Thu May  6 23:49:27 2010
@@ -304,8 +304,7 @@
 
 def test_main():
     run_unittest(ReprTests)
-    if os.name != 'mac':
-        run_unittest(LongReprTest)
+    run_unittest(LongReprTest)
 
 
 if __name__ == "__main__":

Modified: python/branches/py3k-jit/Lib/test/test_select.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_select.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_select.py	Thu May  6 23:49:27 2010
@@ -4,7 +4,7 @@
 import os
 import sys
 
- at unittest.skipIf(sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'),
+ at unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'),
                  "can't easily test on this system")
 class SelectTestCase(unittest.TestCase):
 

Modified: python/branches/py3k-jit/Lib/test/test_shutil.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_shutil.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_shutil.py	Thu May  6 23:49:27 2010
@@ -798,8 +798,112 @@
             shutil.rmtree(TESTFN, ignore_errors=True)
 
 
+class TestCopyFile(unittest.TestCase):
+
+    _delete = False
+
+    class Faux(object):
+        _entered = False
+        _exited_with = None
+        _raised = False
+        def __init__(self, raise_in_exit=False, suppress_at_exit=True):
+            self._raise_in_exit = raise_in_exit
+            self._suppress_at_exit = suppress_at_exit
+        def read(self, *args):
+            return ''
+        def __enter__(self):
+            self._entered = True
+        def __exit__(self, exc_type, exc_val, exc_tb):
+            self._exited_with = exc_type, exc_val, exc_tb
+            if self._raise_in_exit:
+                self._raised = True
+                raise IOError("Cannot close")
+            return self._suppress_at_exit
+
+    def tearDown(self):
+        if self._delete:
+            del shutil.open
+
+    def _set_shutil_open(self, func):
+        shutil.open = func
+        self._delete = True
+
+    def test_w_source_open_fails(self):
+        def _open(filename, mode='r'):
+            if filename == 'srcfile':
+                raise IOError('Cannot open "srcfile"')
+            assert 0  # shouldn't reach here.
+
+        self._set_shutil_open(_open)
+
+        self.assertRaises(IOError, shutil.copyfile, 'srcfile', 'destfile')
+
+    def test_w_dest_open_fails(self):
+
+        srcfile = self.Faux()
+
+        def _open(filename, mode='r'):
+            if filename == 'srcfile':
+                return srcfile
+            if filename == 'destfile':
+                raise IOError('Cannot open "destfile"')
+            assert 0  # shouldn't reach here.
+
+        self._set_shutil_open(_open)
+
+        shutil.copyfile('srcfile', 'destfile')
+        self.assertTrue(srcfile._entered)
+        self.assertTrue(srcfile._exited_with[0] is IOError)
+        self.assertEqual(srcfile._exited_with[1].args,
+                         ('Cannot open "destfile"',))
+
+    def test_w_dest_close_fails(self):
+
+        srcfile = self.Faux()
+        destfile = self.Faux(True)
+
+        def _open(filename, mode='r'):
+            if filename == 'srcfile':
+                return srcfile
+            if filename == 'destfile':
+                return destfile
+            assert 0  # shouldn't reach here.
+
+        self._set_shutil_open(_open)
+
+        shutil.copyfile('srcfile', 'destfile')
+        self.assertTrue(srcfile._entered)
+        self.assertTrue(destfile._entered)
+        self.assertTrue(destfile._raised)
+        self.assertTrue(srcfile._exited_with[0] is IOError)
+        self.assertEqual(srcfile._exited_with[1].args,
+                         ('Cannot close',))
+
+    def test_w_source_close_fails(self):
+
+        srcfile = self.Faux(True)
+        destfile = self.Faux()
+
+        def _open(filename, mode='r'):
+            if filename == 'srcfile':
+                return srcfile
+            if filename == 'destfile':
+                return destfile
+            assert 0  # shouldn't reach here.
+
+        self._set_shutil_open(_open)
+
+        self.assertRaises(IOError,
+                          shutil.copyfile, 'srcfile', 'destfile')
+        self.assertTrue(srcfile._entered)
+        self.assertTrue(destfile._entered)
+        self.assertFalse(destfile._raised)
+        self.assertTrue(srcfile._exited_with[0] is None)
+        self.assertTrue(srcfile._raised)
+
+
 def test_main():
-    support.run_unittest(TestShutil, TestMove)
+    support.run_unittest(TestShutil, TestMove, TestCopyFile)
 
 if __name__ == '__main__':
     test_main()

Modified: python/branches/py3k-jit/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_smtplib.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_smtplib.py	Thu May  6 23:49:27 2010
@@ -374,6 +374,9 @@
         else:
             self.push('550 No access for you!')
 
+    def handle_error(self):
+        raise
+
 
 class SimSMTPServer(smtpd.SMTPServer):
 
@@ -392,6 +395,9 @@
     def add_feature(self, feature):
         self._extra_features.append(feature)
 
+    def handle_error(self):
+        raise
+
 
 # Test various SMTP & ESMTP commands/behaviors that require a simulated server
 # (i.e., something with more features than DebuggingServer)

Modified: python/branches/py3k-jit/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_socket.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_socket.py	Thu May  6 23:49:27 2010
@@ -1465,9 +1465,7 @@
 
 def test_main():
     tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
-             TestExceptions, BufferIOTest, BasicTCPTest2]
-    if sys.platform != 'mac':
-        tests.extend([ BasicUDPTest, UDPTimeoutTest ])
+             TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ]
 
     tests.extend([
         NonBlockingTCPTests,

Modified: python/branches/py3k-jit/Lib/test/test_ssl.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_ssl.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_ssl.py	Thu May  6 23:49:27 2010
@@ -659,7 +659,7 @@
                 if support.verbose:
                     sys.stdout.write("\nsocket.error is %s\n" % x[1])
             else:
-                self.fail("Use of invalid cert should have failed!")
+                raise AssertionError("Use of invalid cert should have failed!")
         finally:
             server.stop()
             server.join()
@@ -704,7 +704,7 @@
                     if support.verbose:
                         sys.stdout.write(" client:  read %r\n" % outdata)
                 if outdata != indata.lower():
-                    self.fail(
+                    raise AssertionError(
                         "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
                         % (outdata[:20], len(outdata),
                            indata[:20].lower(), len(indata)))
@@ -752,7 +752,7 @@
                 raise
         else:
             if not expect_success:
-                self.fail(
+                raise AssertionError(
                     "Client protocol %s succeeded with server protocol %s!"
                     % (ssl.get_protocol_name(client_protocol),
                        ssl.get_protocol_name(server_protocol)))

Modified: python/branches/py3k-jit/Lib/test/test_strptime.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_strptime.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_strptime.py	Thu May  6 23:49:27 2010
@@ -298,9 +298,6 @@
         self.assertEqual(strp_output.tm_isdst, 0)
         strp_output = _strptime._strptime_time("GMT", "%Z")
         self.assertEqual(strp_output.tm_isdst, 0)
-        if sys.platform == "mac":
-            # Timezones don't really work on MacOS9
-            return
         time_tuple = time.localtime()
         strf_output = time.strftime("%Z")  #UTC does not have a timezone
         strp_output = _strptime._strptime_time(strf_output, "%Z")
@@ -317,8 +314,6 @@
     def test_bad_timezone(self):
         # Explicitly test possibility of bad timezone;
         # when time.tzname[0] == time.tzname[1] and time.daylight
-        if sys.platform == "mac":
-            return #MacOS9 has severely broken timezone support.
         tz_name = time.tzname[0]
         if tz_name.upper() in ("UTC", "GMT"):
             return

Modified: python/branches/py3k-jit/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_tarfile.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_tarfile.py	Thu May  6 23:49:27 2010
@@ -1118,8 +1118,8 @@
         if self.format != tarfile.PAX_FORMAT:
             tar = tarfile.open(tmpname, encoding="ascii")
             t = tar.getmember("foo")
-            self.assertEqual(t.uname, "\ufffd\ufffd\ufffd")
-            self.assertEqual(t.gname, "\ufffd\ufffd\ufffd")
+            self.assertEqual(t.uname, "\udce4\udcf6\udcfc")
+            self.assertEqual(t.gname, "\udce4\udcf6\udcfc")
 
 
 class GNUUnicodeTest(UstarUnicodeTest):

Modified: python/branches/py3k-jit/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_tempfile.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_tempfile.py	Thu May  6 23:49:27 2010
@@ -20,9 +20,7 @@
 
 # TEST_FILES may need to be tweaked for systems depending on the maximum
 # number of files that can be opened at one time (see ulimit -n)
-if sys.platform == 'mac':
-    TEST_FILES = 32
-elif sys.platform in ('openbsd3', 'openbsd4'):
+if sys.platform in ('openbsd3', 'openbsd4'):
     TEST_FILES = 48
 else:
     TEST_FILES = 100
@@ -265,7 +263,7 @@
         file = self.do_create()
         mode = stat.S_IMODE(os.stat(file.name).st_mode)
         expected = 0o600
-        if sys.platform in ('win32', 'os2emx', 'mac'):
+        if sys.platform in ('win32', 'os2emx'):
             # There's no distinction among 'user', 'group' and 'world';
             # replicate the 'user' bits.
             user = expected >> 6
@@ -488,7 +486,7 @@
             mode = stat.S_IMODE(os.stat(dir).st_mode)
             mode &= 0o777 # Mask off sticky bits inherited from /tmp
             expected = 0o700
-            if sys.platform in ('win32', 'os2emx', 'mac'):
+            if sys.platform in ('win32', 'os2emx'):
                 # There's no distinction among 'user', 'group' and 'world';
                 # replicate the 'user' bits.
                 user = expected >> 6

Modified: python/branches/py3k-jit/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_urllib2.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_urllib2.py	Thu May  6 23:49:27 2010
@@ -22,11 +22,6 @@
         # XXX Name hacking to get this to work on Windows.
         fname = os.path.abspath(urllib.request.__file__).replace('\\', '/')
 
-        # And more hacking to get it to work on MacOS. This assumes
-        # urllib.pathname2url works, unfortunately...
-        if os.name == 'mac':
-            fname = '/' + fname.replace(':', '/')
-
         if os.name == 'nt':
             file_url = "file:///%s" % fname
         else:

Modified: python/branches/py3k-jit/Lib/test/test_uuid.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_uuid.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_uuid.py	Thu May  6 23:49:27 2010
@@ -457,6 +457,34 @@
             equal(u, uuid.UUID(v))
             equal(str(u), v)
 
+    def testIssue8621(self):
+        import os
+        import sys
+        if os.name != 'posix':
+            return
+
+        # On at least some versions of OSX uuid.uuid4 generates
+        # the same sequence of UUIDs in the parent and any
+        # children started using fork.
+        fds = os.pipe()
+        pid = os.fork()
+        if pid == 0:
+            os.close(fds[0])
+            value = uuid.uuid4()
+            os.write(fds[1], value.hex.encode('latin1'))
+            os._exit(0)
+
+        else:
+            os.close(fds[1])
+            parent_value = uuid.uuid4().hex
+            os.waitpid(pid, 0)
+            child_value = os.read(fds[0], 100).decode('latin1')
+
+            self.assertNotEqual(parent_value, child_value)
+
+
+
+
 
 def test_main():
     support.run_unittest(TestUUID)

Modified: python/branches/py3k-jit/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k-jit/Lib/urllib/request.py	(original)
+++ python/branches/py3k-jit/Lib/urllib/request.py	Thu May  6 23:49:27 2010
@@ -1338,9 +1338,7 @@
 MAXFTPCACHE = 10        # Trim the ftp cache beyond this size
 
 # Helper for non-unix systems
-if os.name == 'mac':
-    from macurl2path import url2pathname, pathname2url
-elif os.name == 'nt':
+if os.name == 'nt':
     from nturl2path import url2pathname, pathname2url
 else:
     def url2pathname(pathname):

Modified: python/branches/py3k-jit/Lib/uuid.py
==============================================================================
--- python/branches/py3k-jit/Lib/uuid.py	(original)
+++ python/branches/py3k-jit/Lib/uuid.py	Thu May  6 23:49:27 2010
@@ -427,6 +427,19 @@
         if hasattr(lib, 'uuid_generate_time'):
             _uuid_generate_time = lib.uuid_generate_time
 
+    # The uuid_generate_* functions are broken on MacOS X 10.6, as noted
+    # in issue #8621 the function generates the same sequence of values
+    # in the parent process and all children created using fork (unless
+    # those children use exec as well).
+    #
+    # Assume that the uuid_generate functions are broken from 10.6 onward,
+    # the test can be adjusted when a later version is fixed.
+    import sys
+    if sys.platform == 'darwin':
+        import os
+        if int(os.uname()[2].split('.')[0]) >= 10:
+            _uuid_generate_random = _uuid_generate_time = None
+
     # On Windows prior to 2000, UuidCreate gives a UUID containing the
     # hardware address.  On Windows 2000 and later, UuidCreate makes a
     # random UUID and UuidCreateSequential gives a UUID containing the

Modified: python/branches/py3k-jit/Mac/Makefile.in
==============================================================================
--- python/branches/py3k-jit/Mac/Makefile.in	(original)
+++ python/branches/py3k-jit/Mac/Makefile.in	Thu May  6 23:49:27 2010
@@ -58,8 +58,8 @@
 ifneq ($(LIPO_32BIT_FLAGS),)
 	lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/python$(VERSION)-32 pythonw
 	lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32 pythonw
-	ln -sf pythonw$(VERSION)-32	"$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
-	ln -sf python$(VERSION)-32	"$(DESTDIR)$(prefix)/bin/python$(VERSION)"
+	ln -sf pythonw$(VERSION)-32	"$(DESTDIR)$(prefix)/bin/pythonw3-32"
+	ln -sf python$(VERSION)-32	"$(DESTDIR)$(prefix)/bin/python3-32"
 endif
 
 #

Modified: python/branches/py3k-jit/Misc/NEWS
==============================================================================
--- python/branches/py3k-jit/Misc/NEWS	(original)
+++ python/branches/py3k-jit/Misc/NEWS	Thu May  6 23:49:27 2010
@@ -54,8 +54,8 @@
 
 - Raise a TypeError when trying to delete a T_STRING_INPLACE struct member.
 
-- Issue #8211: Save/restore CFLAGS around AC_PROG_CC in configure.in, compiler
-  optimizations are disabled when --with-pydebug is used.
+- Issue #8211: Save/restore CFLAGS around AC_PROG_CC in configure.in, in
+  case it is set.
 
 - Issue #8226: sys.setfilesystemencoding() raises a LookupError if the encoding
   is unknown
@@ -348,6 +348,30 @@
 Library
 -------
 
+- Issue #8573: asyncore _strerror() function might throw ValueError.
+
+- Issue #8483: asyncore.dispatcher's __getattr__ method produced confusing 
+  error messages when accessing undefined class attributes because of the cheap 
+  inheritance with the underlying socket object. 
+  The cheap inheritance has been deprecated.
+
+- Issue #4265: shutil.copyfile() was leaking file descriptors when disk fills.
+  Patch by Tres Seaver.
+
+- Issue #8390: tarfile uses surrogateespace as the default error handler
+  (instead of replace in read mode or strict in write mode)
+
+- Issue #7755: Use an unencumbered audio file for tests.
+
+- Issue #8621: uuid.uuid4() returned the same sequence of values in the
+  parent and any children created using ``os.fork`` on MacOS X 10.6.
+
+- Issue #8567: Fix precedence of signals in Decimal module: when a
+  Decimal operation raises multiple signals and more than one of those
+  signals is trapped, the specification determines the order in which
+  the signals should be handled.  In many cases this order wasn't
+  being followed, leading to the wrong Python exception being raised.
+
 - Issue #7865: The close() method of :mod:`io` objects should not swallow
   exceptions raised by the implicit flush().  Also ensure that calling
   close() several times is supported.  Patch by Pascal Chambon.
@@ -1128,6 +1152,12 @@
 Build
 -----
 
+- Issue #8625: Turn off optimization in --with-pydebug builds with
+  gcc.  (Optimization was unintentionally turned on in gcc
+  --with-pydebug builds as a result of the issue #1628484 fix,
+  combined with autoconf's strange choice of default CFLAGS produced
+  by AC_PROG_CC for gcc.)
+
 - Issue #3646: It is now easily possible to install a Python framework into
   your home directory on MacOSX, see Mac/README for more information.
 

Modified: python/branches/py3k-jit/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/callproc.c	(original)
+++ python/branches/py3k-jit/Modules/_ctypes/callproc.c	Thu May  6 23:49:27 2010
@@ -761,7 +761,6 @@
 	ffi_cif cif;
 	int cc;
 #ifdef MS_WIN32
-	int delta;
 #ifndef DONT_USE_SEH
 	DWORD dwExceptionCode = 0;
 	EXCEPTION_RECORD record;
@@ -812,9 +811,8 @@
 #ifndef DONT_USE_SEH
 	__try {
 #endif
-		delta =
 #endif
-			ffi_call(&cif, (void *)pProc, resmem, avalues);
+		ffi_call(&cif, (void *)pProc, resmem, avalues);
 #ifdef MS_WIN32
 #ifndef DONT_USE_SEH
 	}
@@ -846,35 +844,6 @@
 		return -1;
 	}
 #endif
-#ifdef MS_WIN64
-	if (delta != 0) {
-		PyErr_Format(PyExc_RuntimeError,
-			     "ffi_call failed with code %d",
-			     delta);
-		return -1;
-	}
-#else
-	if (delta < 0) {
-		if (flags & FUNCFLAG_CDECL)
-			PyErr_Format(PyExc_ValueError,
-				     "Procedure called with not enough "
-				     "arguments (%d bytes missing) "
-				     "or wrong calling convention",
-				     -delta);
-		else
-			PyErr_Format(PyExc_ValueError,
-				     "Procedure probably called with not enough "
-				     "arguments (%d bytes missing)",
-				     -delta);
-		return -1;
-	} else if (delta > 0) {
-		PyErr_Format(PyExc_ValueError,
-			     "Procedure probably called with too many "
-			     "arguments (%d bytes in excess)",
-			     delta);
-		return -1;
-	}
-#endif
 #endif
 	if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred())
 		return -1;
@@ -1147,11 +1116,7 @@
 	}
 	for (i = 0; i < argcount; ++i) {
 		atypes[i] = args[i].ffi_type;
-		if (atypes[i]->type == FFI_TYPE_STRUCT 
-#ifdef _WIN64
-		    && atypes[i]->size <= sizeof(void *)
-#endif
-		    )
+		if (atypes[i]->type == FFI_TYPE_STRUCT)
 			avalues[i] = (void *)args[i].value.p;
 		else
 			avalues[i] = (void *)&args[i].value;

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/LICENSE
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/LICENSE	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,20 +0,0 @@
-libffi - Copyright (c) 1996-2003  Red Hat, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-``Software''), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,500 +0,0 @@
-This directory contains the libffi package, which is not part of GCC but
-shipped with GCC as convenience.
-
-Status
-======
-
-libffi-2.00 has not been released yet! This is a development snapshot!
-
-libffi-1.20 was released on October 5, 1998. Check the libffi web
-page for updates: <URL:http://sources.redhat.com/libffi/>.
-
-
-What is libffi?
-===============
-
-Compilers for high level languages generate code that follow certain
-conventions. These conventions are necessary, in part, for separate
-compilation to work. One such convention is the "calling
-convention". The "calling convention" is essentially a set of
-assumptions made by the compiler about where function arguments will
-be found on entry to a function. A "calling convention" also specifies
-where the return value for a function is found.
-
-Some programs may not know at the time of compilation what arguments
-are to be passed to a function. For instance, an interpreter may be
-told at run-time about the number and types of arguments used to call
-a given function. Libffi can be used in such programs to provide a
-bridge from the interpreter program to compiled code.
-
-The libffi library provides a portable, high level programming
-interface to various calling conventions. This allows a programmer to
-call any function specified by a call interface description at run
-time.  
-
-Ffi stands for Foreign Function Interface. A foreign function
-interface is the popular name for the interface that allows code
-written in one language to call code written in another language. The
-libffi library really only provides the lowest, machine dependent
-layer of a fully featured foreign function interface. A layer must
-exist above libffi that handles type conversions for values passed
-between the two languages.
-
-
-Supported Platforms and Prerequisites
-=====================================
-
-Libffi has been ported to:
-
-	SunOS 4.1.3 & Solaris 2.x (SPARC-V8, SPARC-V9)
-
-	Irix 5.3 & 6.2 (System V/o32 & n32)
-
-	Intel x86 - Linux (System V ABI)
-
-	Alpha - Linux and OSF/1
-
-	m68k - Linux (System V ABI)
-
-	PowerPC - Linux (System V ABI, Darwin, AIX)
-
-	ARM - Linux (System V ABI)
-
-Libffi has been tested with the egcs 1.0.2 gcc compiler. Chances are
-that other versions will work.  Libffi has also been built and tested
-with the SGI compiler tools.
-
-On PowerPC, the tests failed (see the note below).
-
-You must use GNU make to build libffi. SGI's make will not work.
-Sun's probably won't either.
-	
-If you port libffi to another platform, please let me know! I assume
-that some will be easy (x86 NetBSD), and others will be more difficult
-(HP).
-
-
-Installing libffi
-=================
-
-[Note: before actually performing any of these installation steps,
- you may wish to read the "Platform Specific Notes" below.]
-
-First you must configure the distribution for your particular
-system. Go to the directory you wish to build libffi in and run the
-"configure" program found in the root directory of the libffi source
-distribution.
-
-You may want to tell configure where to install the libffi library and
-header files. To do that, use the --prefix configure switch.  Libffi
-will install under /usr/local by default. 
-
-If you want to enable extra run-time debugging checks use the the
---enable-debug configure switch. This is useful when your program dies
-mysteriously while using libffi. 
-
-Another useful configure switch is --enable-purify-safety. Using this
-will add some extra code which will suppress certain warnings when you
-are using Purify with libffi. Only use this switch when using 
-Purify, as it will slow down the library.
-
-Configure has many other options. Use "configure --help" to see them all.
-
-Once configure has finished, type "make". Note that you must be using
-GNU make. SGI's make will not work.  Sun's probably won't either.
-You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
-
-To ensure that libffi is working as advertised, type "make test".
-
-To install the library and header files, type "make install".
-
-
-Using libffi
-============
-
-	The Basics
-	----------
-
-Libffi assumes that you have a pointer to the function you wish to
-call and that you know the number and types of arguments to pass it,
-as well as the return type of the function.
-
-The first thing you must do is create an ffi_cif object that matches
-the signature of the function you wish to call. The cif in ffi_cif
-stands for Call InterFace. To prepare a call interface object, use the
-following function:
-
-ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi,
-			unsigned int nargs, 
-			ffi_type *rtype, ffi_type **atypes);
-
-	CIF is a pointer to the call interface object you wish
-		to initialize.
-
-	ABI is an enum that specifies the calling convention 
-		to use for the call. FFI_DEFAULT_ABI defaults
-		to the system's native calling convention. Other
-		ABI's may be used with care. They are system
-		specific.
-
-	NARGS is the number of arguments this function accepts.	
-		libffi does not yet support vararg functions.
-
-	RTYPE is a pointer to an ffi_type structure that represents
-		the return type of the function. Ffi_type objects
-		describe the types of values. libffi provides
-		ffi_type objects for many of the native C types:
-		signed int, unsigned int, signed char, unsigned char,
-		etc. There is also a pointer ffi_type object and
-		a void ffi_type. Use &ffi_type_void for functions that 
-		don't return values.
-
-	ATYPES is a vector of ffi_type pointers. ARGS must be NARGS long.
-		If NARGS is 0, this is ignored.
-
-
-ffi_prep_cif will return a status code that you are responsible 
-for checking. It will be one of the following:
-
-	FFI_OK - All is good.
-
-	FFI_BAD_TYPEDEF - One of the ffi_type objects that ffi_prep_cif
-		came across is bad.
-
-
-Before making the call, the VALUES vector should be initialized 
-with pointers to the appropriate argument values.
-
-To call the the function using the initialized ffi_cif, use the
-ffi_call function:
-
-void ffi_call(ffi_cif *cif, void *fn, void *rvalue, void **avalues);
-
-	CIF is a pointer to the ffi_cif initialized specifically
-		for this function.
-
-	FN is a pointer to the function you want to call.
-
-	RVALUE is a pointer to a chunk of memory that is to hold the
-		result of the function call. Currently, it must be
-		at least one word in size (except for the n32 version
-		under Irix 6.x, which must be a pointer to an 8 byte 
-		aligned value (a long long). It must also be at least 
-		word aligned (depending on the return type, and the
-		system's alignment requirements). If RTYPE is 
-		&ffi_type_void, this is ignored. If RVALUE is NULL, 
-		the return value is discarded.
-
-	AVALUES is a vector of void* that point to the memory locations
-		holding the argument values for a call.
-		If NARGS is 0, this is ignored.
-
-
-If you are expecting a return value from FN it will have been stored
-at RVALUE.
-
-
-
-	An Example
-	----------
-
-Here is a trivial example that calls puts() a few times.
-
-    #include <stdio.h>
-    #include <ffi.h>
-    
-    int main()
-    {
-      ffi_cif cif;
-      ffi_type *args[1];
-      void *values[1];
-      char *s;
-      int rc;
-      
-      /* Initialize the argument info vectors */    
-      args[0] = &ffi_type_uint;
-      values[0] = &s;
-      
-      /* Initialize the cif */
-      if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
-    		       &ffi_type_uint, args) == FFI_OK)
-        {
-          s = "Hello World!";
-          ffi_call(&cif, puts, &rc, values);
-          /* rc now holds the result of the call to puts */
-          
-          /* values holds a pointer to the function's arg, so to 
-	     call puts() again all we need to do is change the 
-             value of s */
-          s = "This is cool!";
-          ffi_call(&cif, puts, &rc, values);
-        }
-      
-      return 0;
-    }
-
-
-
-	Aggregate Types
-	---------------
-
-Although libffi has no special support for unions or bit-fields, it is
-perfectly happy passing structures back and forth. You must first
-describe the structure to libffi by creating a new ffi_type object
-for it. Here is the definition of ffi_type:
-
-    typedef struct _ffi_type
-    {
-      unsigned size;
-      short alignment;
-      short type;
-      struct _ffi_type **elements;
-    } ffi_type;
-    
-All structures must have type set to FFI_TYPE_STRUCT.  You may set
-size and alignment to 0. These will be calculated and reset to the
-appropriate values by ffi_prep_cif().
-
-elements is a NULL terminated array of pointers to ffi_type objects
-that describe the type of the structure elements. These may, in turn,
-be structure elements.
-
-The following example initializes a ffi_type object representing the
-tm struct from Linux's time.h:
-
-				    struct tm {
-					int tm_sec;
-					int tm_min;
-					int tm_hour;
-					int tm_mday;
-					int tm_mon;
-					int tm_year;
-					int tm_wday;
-					int tm_yday;
-					int tm_isdst;
-					/* Those are for future use. */
-					long int __tm_gmtoff__;
-					__const char *__tm_zone__;
-				    };
-
-    {
-      ffi_type tm_type;
-      ffi_type *tm_type_elements[12];
-      int i;
-
-      tm_type.size = tm_type.alignment = 0;
-      tm_type.elements = &tm_type_elements;
-    
-      for (i = 0; i < 9; i++)
-          tm_type_elements[i] = &ffi_type_sint;
-
-      tm_type_elements[9] = &ffi_type_slong;
-      tm_type_elements[10] = &ffi_type_pointer;
-      tm_type_elements[11] = NULL;
-
-      /* tm_type can now be used to represent tm argument types and
-	 return types for ffi_prep_cif() */
-    }
-
-
-
-Platform Specific Notes
-=======================
-
-	Intel x86
-	---------
-
-There are no known problems with the x86 port.
-
-	Sun SPARC - SunOS 4.1.3 & Solaris 2.x
-	-------------------------------------
-
-You must use GNU Make to build libffi on Sun platforms.
-
-	MIPS - Irix 5.3 & 6.x
-	---------------------
-
-Irix 6.2 and better supports three different calling conventions: o32,
-n32 and n64. Currently, libffi only supports both o32 and n32 under
-Irix 6.x, but only o32 under Irix 5.3. Libffi will automatically be
-configured for whichever calling convention it was built for.
-
-By default, the configure script will try to build libffi with the GNU
-development tools. To build libffi with the SGI development tools, set
-the environment variable CC to either "cc -32" or "cc -n32" before
-running configure under Irix 6.x (depending on whether you want an o32
-or n32 library), or just "cc" for Irix 5.3.
-
-With the n32 calling convention, when returning structures smaller
-than 16 bytes, be sure to provide an RVALUE that is 8 byte aligned.
-Here's one way of forcing this:
-
-	double struct_storage[2];
-	my_small_struct *s = (my_small_struct *) struct_storage;  
-	/* Use s for RVALUE */
-
-If you don't do this you are liable to get spurious bus errors. 
-
-"long long" values are not supported yet.
-
-You must use GNU Make to build libffi on SGI platforms.
-
-	ARM - System V ABI
-	------------------
-
-The ARM port was performed on a NetWinder running ARM Linux ELF
-(2.0.31) and gcc 2.8.1.
-
-
-
-	PowerPC System V ABI
-	--------------------
-
-There are two `System V ABI's which libffi implements for PowerPC.
-They differ only in how small structures are returned from functions.
-
-In the FFI_SYSV version, structures that are 8 bytes or smaller are
-returned in registers.  This is what GCC does when it is configured
-for solaris, and is what the System V ABI I have (dated September
-1995) says.
-
-In the FFI_GCC_SYSV version, all structures are returned the same way:
-by passing a pointer as the first argument to the function.  This is
-what GCC does when it is configured for linux or a generic sysv
-target.
-
-EGCS 1.0.1 (and probably other versions of EGCS/GCC) also has a
-inconsistency with the SysV ABI: When a procedure is called with many
-floating-point arguments, some of them get put on the stack.  They are
-all supposed to be stored in double-precision format, even if they are
-only single-precision, but EGCS stores single-precision arguments as
-single-precision anyway.  This causes one test to fail (the `many
-arguments' test).
-
-
-What's With The Crazy Comments?
-===============================
-
-You might notice a number of cryptic comments in the code, delimited
-by /*@ and @*/. These are annotations read by the program LCLint, a
-tool for statically checking C programs. You can read all about it at
-<http://larch-www.lcs.mit.edu:8001/larch/lclint/index.html>.
-
-
-History
-=======
-
-1.20 Oct-5-98
-	Raffaele Sena produces ARM port.
-
-1.19 Oct-5-98
-	Fixed x86 long double and long long return support.
-	m68k bug fixes from Andreas Schwab.
-	Patch for DU assembler compatibility for the Alpha from Richard
-	Henderson.
-
-1.18 Apr-17-98
-	Bug fixes and MIPS configuration changes.
-
-1.17 Feb-24-98
-	Bug fixes and m68k port from Andreas Schwab. PowerPC port from
-	Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
-
-1.16 Feb-11-98
-	Richard Henderson produces Alpha port.
-
-1.15 Dec-4-97
-	Fixed an n32 ABI bug. New libtool, auto* support.
-
-1.14 May-13-97
-	libtool is now used to generate shared and static libraries.
-	Fixed a minor portability problem reported by Russ McManus
-	<mcmanr at eq.gs.com>.
-
-1.13 Dec-2-96
-	Added --enable-purify-safety to keep Purify from complaining
-	about certain low level code.
-	Sparc fix for calling functions with < 6 args.
-	Linux x86 a.out fix.
-
-1.12 Nov-22-96
-	Added missing ffi_type_void, needed for supporting void return 
-	types. Fixed test case for non MIPS machines. Cygnus Support 
-	is now Cygnus Solutions. 
-
-1.11 Oct-30-96
-	Added notes about GNU make.
-
-1.10 Oct-29-96
-	Added configuration fix for non GNU compilers.
-
-1.09 Oct-29-96
-	Added --enable-debug configure switch. Clean-ups based on LCLint 
-	feedback. ffi_mips.h is always installed. Many configuration 
-	fixes. Fixed ffitest.c for sparc builds.
-
-1.08 Oct-15-96
-	Fixed n32 problem. Many clean-ups.
-
-1.07 Oct-14-96
-	Gordon Irlam rewrites v8.S again. Bug fixes.
-
-1.06 Oct-14-96
-	Gordon Irlam improved the sparc port. 
-
-1.05 Oct-14-96
-	Interface changes based on feedback.
-
-1.04 Oct-11-96
-	Sparc port complete (modulo struct passing bug).
-
-1.03 Oct-10-96
-	Passing struct args, and returning struct values works for
-	all architectures/calling conventions. Expanded tests.
-
-1.02 Oct-9-96
-	Added SGI n32 support. Fixed bugs in both o32 and Linux support.
-	Added "make test".
-
-1.01 Oct-8-96
-	Fixed float passing bug in mips version. Restructured some
-	of the code. Builds cleanly with SGI tools.
-
-1.00 Oct-7-96
-	First release. No public announcement.
-
-
-Authors & Credits
-=================
-
-libffi was written by Anthony Green <green at cygnus.com>.
-
-Portions of libffi were derived from Gianni Mariani's free gencall
-library for Silicon Graphics machines.
-
-The closure mechanism was designed and implemented by Kresten Krab
-Thorup.
-
-The Sparc port was derived from code contributed by the fine folks at
-Visible Decisions Inc <http://www.vdi.com>. Further enhancements were
-made by Gordon Irlam at Cygnus Solutions <http://www.cygnus.com>.
-
-The Alpha port was written by Richard Henderson at Cygnus Solutions.
-
-Andreas Schwab ported libffi to m68k Linux and provided a number of
-bug fixes.
-
-Geoffrey Keating ported libffi to the PowerPC.
-
-Raffaele Sena ported libffi to the ARM.
-
-Jesper Skov and Andrew Haley both did more than their fair share of
-stepping through the code and tracking down bugs.
-
-Thanks also to Tom Tromey for bug fixes and configuration help.
-
-Thanks to Jim Blandy, who provided some useful feedback on the libffi
-interface.
-
-If you have a problem, or have found a bug, please send a note to
-green at cygnus.com.

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README.ctypes
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/README.ctypes	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,7 +0,0 @@
-The purpose is to hack the libffi sources so that they can be compiled
-with MSVC, and to extend them so that they have the features I need
-for ctypes.
-
-I retrieved the libffi sources from the gcc cvs repository on
-2004-01-27.  Then I did 'configure' in a 'build' subdirectory on a x86
-linux system, and copied the files I found useful.

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.c	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,457 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996, 1998, 1999, 2001  Red Hat, Inc.
-           Copyright (c) 2002  Ranjit Mathew
-           Copyright (c) 2002  Bo Thorsen
-           Copyright (c) 2002  Roger Sayle
-   
-   x86 Foreign Function Interface 
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-
-/* ffi_prep_args is called by the assembly routine once stack space
-   has been allocated for the function's arguments */
-
-extern void Py_FatalError(const char *msg);
-
-/*@-exportheader@*/
-void ffi_prep_args(char *stack, extended_cif *ecif)
-/*@=exportheader@*/
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-  if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
-    {
-      *(void **) argp = ecif->rvalue;
-      argp += sizeof(void *);
-    }
-
-  p_argv = ecif->avalue;
-
-  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
-       i != 0;
-       i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(void *) - 1) & (size_t) argp)
-	argp = (char *) ALIGN(argp, sizeof(void *));
-
-      z = (*p_arg)->size;
-      if (z < sizeof(int))
-	{
-	  z = sizeof(int);
-	  switch ((*p_arg)->type)
-	    {
-	    case FFI_TYPE_SINT8:
-	      *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT8:
-	      *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_SINT16:
-	      *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT16:
-	      *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_SINT32:
-	      *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT32:
-	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_STRUCT:
-	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
-	      break;
-
-	    default:
-	      FFI_ASSERT(0);
-	    }
-	}
-      else
-	{
-	  memcpy(argp, *p_argv, z);
-	}
-      p_argv++;
-      argp += z;
-    }
-
-  if (argp - stack > ecif->cif->bytes) 
-    {
-      Py_FatalError("FFI BUG: not enough stack space for arguments");
-    }
-  return;
-}
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
-{
-  /* Set the return type flag */
-  switch (cif->rtype->type)
-    {
-    case FFI_TYPE_VOID:
-    case FFI_TYPE_STRUCT:
-    case FFI_TYPE_SINT64:
-    case FFI_TYPE_FLOAT:
-    case FFI_TYPE_DOUBLE:
-    case FFI_TYPE_LONGDOUBLE:
-      cif->flags = (unsigned) cif->rtype->type;
-      break;
-
-    case FFI_TYPE_UINT64:
-#ifdef _WIN64
-    case FFI_TYPE_POINTER:
-#endif
-      cif->flags = FFI_TYPE_SINT64;
-      break;
-
-    default:
-      cif->flags = FFI_TYPE_INT;
-      break;
-    }
-
-  return FFI_OK;
-}
-
-#ifdef _WIN32
-extern int
-ffi_call_x86(void (*)(char *, extended_cif *), 
-	     /*@out@*/ extended_cif *, 
-	     unsigned, unsigned, 
-	     /*@out@*/ unsigned *, 
-	     void (*fn)());
-#endif
-
-#ifdef _WIN64
-extern int
-ffi_call_AMD64(void (*)(char *, extended_cif *),
-		 /*@out@*/ extended_cif *,
-		 unsigned, unsigned,
-		 /*@out@*/ unsigned *,
-		 void (*fn)());
-#endif
-
-int
-ffi_call(/*@dependent@*/ ffi_cif *cif, 
-	 void (*fn)(), 
-	 /*@out@*/ void *rvalue, 
-	 /*@dependent@*/ void **avalue)
-{
-  extended_cif ecif;
-
-  ecif.cif = cif;
-  ecif.avalue = avalue;
-  
-  /* If the return value is a struct and we don't have a return	*/
-  /* value address then we need to make one		        */
-
-  if ((rvalue == NULL) && 
-      (cif->rtype->type == FFI_TYPE_STRUCT))
-    {
-      /*@-sysunrecog@*/
-      ecif.rvalue = alloca(cif->rtype->size);
-      /*@=sysunrecog@*/
-    }
-  else
-    ecif.rvalue = rvalue;
-    
-  
-  switch (cif->abi) 
-    {
-#if !defined(_WIN64)
-    case FFI_SYSV:
-    case FFI_STDCALL:
-      return ffi_call_x86(ffi_prep_args, &ecif, cif->bytes, 
-			  cif->flags, ecif.rvalue, fn);
-      break;
-#else
-    case FFI_SYSV:
-      /*@-usedef@*/
-      /* Function call needs at least 40 bytes stack size, on win64 AMD64 */
-      return ffi_call_AMD64(ffi_prep_args, &ecif, cif->bytes ? cif->bytes : 40,
-			   cif->flags, ecif.rvalue, fn);
-      /*@=usedef@*/
-      break;
-#endif
-
-    default:
-      FFI_ASSERT(0);
-      break;
-    }
-  return -1; /* theller: Hrm. */
-}
-
-
-/** private members **/
-
-static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
-					  void** args, ffi_cif* cif);
-/* This function is jumped to by the trampoline */
-
-#ifdef _WIN64
-void *
-#else
-static void __fastcall
-#endif
-ffi_closure_SYSV (ffi_closure *closure, int *argp)
-{
-  // this is our return value storage
-  long double    res;
-
-  // our various things...
-  ffi_cif       *cif;
-  void         **arg_area;
-  unsigned short rtype;
-  void          *resp = (void*)&res;
-  void *args = &argp[1];
-
-  cif         = closure->cif;
-  arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
-
-  /* this call will initialize ARG_AREA, such that each
-   * element in that array points to the corresponding 
-   * value on the stack; and if the function returns
-   * a structure, it will re-set RESP to point to the
-   * structure return address.  */
-
-  ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif);
-  
-  (closure->fun) (cif, resp, arg_area, closure->user_data);
-
-  rtype = cif->flags;
-
-#if defined(_WIN32) && !defined(_WIN64)
-#ifdef _MSC_VER
-  /* now, do a generic return based on the value of rtype */
-  if (rtype == FFI_TYPE_INT)
-    {
-	    _asm mov eax, resp ;
-	    _asm mov eax, [eax] ;
-    }
-  else if (rtype == FFI_TYPE_FLOAT)
-    {
-	    _asm mov eax, resp ;
-	    _asm fld DWORD PTR [eax] ;
-//      asm ("flds (%0)" : : "r" (resp) : "st" );
-    }
-  else if (rtype == FFI_TYPE_DOUBLE)
-    {
-	    _asm mov eax, resp ;
-	    _asm fld QWORD PTR [eax] ;
-//      asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_LONGDOUBLE)
-    {
-//      asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_SINT64)
-    {
-	    _asm mov edx, resp ;
-	    _asm mov eax, [edx] ;
-	    _asm mov edx, [edx + 4] ;
-//      asm ("movl 0(%0),%%eax;"
-//	   "movl 4(%0),%%edx" 
-//	   : : "r"(resp)
-//	   : "eax", "edx");
-    }
-#else
-  /* now, do a generic return based on the value of rtype */
-  if (rtype == FFI_TYPE_INT)
-    {
-      asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
-    }
-  else if (rtype == FFI_TYPE_FLOAT)
-    {
-      asm ("flds (%0)" : : "r" (resp) : "st" );
-    }
-  else if (rtype == FFI_TYPE_DOUBLE)
-    {
-      asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_LONGDOUBLE)
-    {
-      asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_SINT64)
-    {
-      asm ("movl 0(%0),%%eax;"
-	   "movl 4(%0),%%edx" 
-	   : : "r"(resp)
-	   : "eax", "edx");
-    }
-#endif
-#endif
-
-#ifdef _WIN64
-  /* The result is returned in rax.  This does the right thing for
-     result types except for floats; we have to 'mov xmm0, rax' in the
-     caller to correct this.
-  */
-  return *(void **)resp;
-#endif
-}
-
-/*@-exportheader@*/
-static void 
-ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
-			    void **avalue, ffi_cif *cif)
-/*@=exportheader@*/
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-
-  if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
-    *rvalue = *(void **) argp;
-    argp += 4;
-  }
-
-  p_argv = avalue;
-
-  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(char *) - 1) & (size_t) argp) {
-	argp = (char *) ALIGN(argp, sizeof(char*));
-      }
-
-      z = (*p_arg)->size;
-
-      /* because we're little endian, this is what it turns into.   */
-
-      *p_argv = (void*) argp;
-
-      p_argv++;
-      argp += z;
-    }
-  
-  return;
-}
-
-/* the cif must already be prep'ed */
-extern void ffi_closure_OUTER();
-
-ffi_status
-ffi_prep_closure (ffi_closure* closure,
-		  ffi_cif* cif,
-		  void (*fun)(ffi_cif*,void*,void**,void*),
-		  void *user_data)
-{
-  short bytes;
-  char *tramp;
-#ifdef _WIN64
-  int mask;
-#endif
-  FFI_ASSERT (cif->abi == FFI_SYSV);
-  
-  if (cif->abi == FFI_SYSV)
-    bytes = 0;
-#if !defined(_WIN64)
-  else if (cif->abi == FFI_STDCALL)
-    bytes = cif->bytes;
-#endif
-  else
-    return FFI_BAD_ABI;
-
-  tramp = &closure->tramp[0];
-
-#define BYTES(text) memcpy(tramp, text, sizeof(text)), tramp += sizeof(text)-1
-#define POINTER(x) *(void**)tramp = (void*)(x), tramp += sizeof(void*)
-#define SHORT(x) *(short*)tramp = x, tramp += sizeof(short)
-#define INT(x) *(int*)tramp = x, tramp += sizeof(int)
-
-#ifdef _WIN64
-  if (cif->nargs >= 1 &&
-      (cif->arg_types[0]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[0]->type == FFI_TYPE_DOUBLE))
-    mask |= 1;
-  if (cif->nargs >= 2 &&
-      (cif->arg_types[1]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[1]->type == FFI_TYPE_DOUBLE))
-    mask |= 2;
-  if (cif->nargs >= 3 &&
-      (cif->arg_types[2]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[2]->type == FFI_TYPE_DOUBLE))
-    mask |= 4;
-  if (cif->nargs >= 4 &&
-      (cif->arg_types[3]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[3]->type == FFI_TYPE_DOUBLE))
-    mask |= 8;
-
-  /* 41 BB ----         mov         r11d,mask */
-  BYTES("\x41\xBB"); INT(mask);
-
-  /* 48 B8 --------     mov         rax, closure			*/
-  BYTES("\x48\xB8"); POINTER(closure);
-
-  /* 49 BA --------     mov         r10, ffi_closure_OUTER */
-  BYTES("\x49\xBA"); POINTER(ffi_closure_OUTER);
-
-  /* 41 FF E2           jmp         r10 */
-  BYTES("\x41\xFF\xE2");
-
-#else
-
-  /* mov ecx, closure */
-  BYTES("\xb9"); POINTER(closure);
-
-  /* mov edx, esp */
-  BYTES("\x8b\xd4");
-
-  /* call ffi_closure_SYSV */
-  BYTES("\xe8"); POINTER((char*)&ffi_closure_SYSV - (tramp + 4));
-
-  /* ret bytes */
-  BYTES("\xc2");
-  SHORT(bytes);
-  
-#endif
-
-  if (tramp - &closure->tramp[0] > FFI_TRAMPOLINE_SIZE)
-    Py_FatalError("FFI_TRAMPOLINE_SIZE too small in " __FILE__);
-
-  closure->cif  = cif;
-  closure->user_data = user_data;
-  closure->fun  = fun;
-
-  return FFI_OK;
-}

Modified: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.h
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.h	(original)
+++ python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi.h	Thu May  6 23:49:27 2010
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------*-C-*-
-   libffi 2.00-beta - Copyright (c) 1996-2003  Red Hat, Inc.
+   libffi @VERSION@ - Copyright (c) 1996-2003, 2007, 2008  Red Hat, Inc.
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -12,13 +12,14 @@
    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.
 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
 
    ----------------------------------------------------------------------- */
 
@@ -56,7 +57,7 @@
 #endif
 
 /* Specify which architecture libffi is configured for. */
-//XXX #define X86
+/* #define @TARGET@ */
 
 /* ---- System configuration information --------------------------------- */
 
@@ -64,6 +65,10 @@
 
 #ifndef LIBFFI_ASM
 
+#ifdef _MSC_VER
+#define __attribute__(X)
+#endif
+
 #include <stddef.h>
 #include <limits.h>
 
@@ -79,12 +84,21 @@
 #  ifdef __GNUC__
 #   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
 #  endif
-#  ifdef _MSC_VER
-#   define FFI_LONG_LONG_MAX _I64_MAX
-#  endif
 # endif
 #endif
 
+/* The closure code assumes that this works on pointers, i.e. a size_t	*/
+/* can hold a pointer.							*/
+
+typedef struct _ffi_type
+{
+  size_t size;
+  unsigned short alignment;
+  unsigned short type;
+  struct _ffi_type **elements;
+} ffi_type;
+
+#ifndef LIBFFI_HIDE_BASIC_TYPES
 #if SCHAR_MAX == 127
 # define ffi_type_uchar                ffi_type_uint8
 # define ffi_type_schar                ffi_type_sint8
@@ -115,26 +129,23 @@
  #error "int size not supported"
 #endif
 
-#define ffi_type_ulong         ffi_type_uint64
-#define ffi_type_slong         ffi_type_sint64
 #if LONG_MAX == 2147483647
 # if FFI_LONG_LONG_MAX != 9223372036854775807
-  #error "no 64-bit data type supported"
+ #error "no 64-bit data type supported"
 # endif
 #elif LONG_MAX != 9223372036854775807
  #error "long size not supported"
 #endif
 
-/* The closure code assumes that this works on pointers, i.e. a size_t	*/
-/* can hold a pointer.							*/
-
-typedef struct _ffi_type
-{
-  size_t size;
-  unsigned short alignment;
-  unsigned short type;
-  /*@null@*/ struct _ffi_type **elements;
-} ffi_type;
+#if LONG_MAX == 2147483647
+# define ffi_type_ulong        ffi_type_uint32
+# define ffi_type_slong        ffi_type_sint32
+#elif LONG_MAX == 9223372036854775807
+# define ffi_type_ulong        ffi_type_uint64
+# define ffi_type_slong        ffi_type_sint64
+#else
+ #error "long size not supported"
+#endif
 
 /* These are defined in types.c */
 extern ffi_type ffi_type_void;
@@ -148,14 +159,19 @@
 extern ffi_type ffi_type_sint64;
 extern ffi_type ffi_type_float;
 extern ffi_type ffi_type_double;
-extern ffi_type ffi_type_longdouble;
 extern ffi_type ffi_type_pointer;
 
+#if HAVE_LONG_DOUBLE
+extern ffi_type ffi_type_longdouble;
+#else
+#define ffi_type_longdouble ffi_type_double
+#endif
+#endif /* LIBFFI_HIDE_BASIC_TYPES */
 
 typedef enum {
   FFI_OK = 0,
   FFI_BAD_TYPEDEF,
-  FFI_BAD_ABI 
+  FFI_BAD_ABI
 } ffi_status;
 
 typedef unsigned FFI_TYPE;
@@ -163,8 +179,8 @@
 typedef struct {
   ffi_abi abi;
   unsigned nargs;
-  /*@dependent@*/ ffi_type **arg_types;
-  /*@dependent@*/ ffi_type *rtype;
+  ffi_type **arg_types;
+  ffi_type *rtype;
   unsigned bytes;
   unsigned flags;
 #ifdef FFI_EXTRA_CIF_FIELDS
@@ -174,10 +190,16 @@
 
 /* ---- Definitions for the raw API -------------------------------------- */
 
-#ifdef _WIN64
-#define FFI_SIZEOF_ARG 8
-#else
-#define FFI_SIZEOF_ARG 4
+#ifndef FFI_SIZEOF_ARG
+# if LONG_MAX == 2147483647
+#  define FFI_SIZEOF_ARG        4
+# elif LONG_MAX == 9223372036854775807
+#  define FFI_SIZEOF_ARG        8
+# endif
+#endif
+
+#ifndef FFI_SIZEOF_JAVA_RAW
+#  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
 #endif
 
 typedef union {
@@ -188,10 +210,25 @@
   void*     ptr;
 } ffi_raw;
 
-void ffi_raw_call (/*@dependent@*/ ffi_cif *cif, 
-		   void (*fn)(), 
-		   /*@out@*/ void *rvalue, 
-		   /*@dependent@*/ ffi_raw *avalue);
+#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8
+/* This is a special case for mips64/n32 ABI (and perhaps others) where
+   sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8.  */
+typedef union {
+  signed int	sint;
+  unsigned int	uint;
+  float		flt;
+  char		data[FFI_SIZEOF_JAVA_RAW];
+  void*		ptr;
+} ffi_java_raw;
+#else
+typedef ffi_raw ffi_java_raw;
+#endif
+
+
+void ffi_raw_call (ffi_cif *cif,
+		   void (*fn)(void),
+		   void *rvalue,
+		   ffi_raw *avalue);
 
 void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
 void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
@@ -201,25 +238,35 @@
 /* packing, even on 64-bit machines.  I.e. on 64-bit machines		*/
 /* longs and doubles are followed by an empty 64-bit word.		*/
 
-void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif, 
-		        void (*fn)(), 
-		        /*@out@*/ void *rvalue, 
-		        /*@dependent@*/ ffi_raw *avalue);
+void ffi_java_raw_call (ffi_cif *cif,
+			void (*fn)(void),
+			void *rvalue,
+			ffi_java_raw *avalue);
 
-void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
-void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);
+void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);
 size_t ffi_java_raw_size (ffi_cif *cif);
 
 /* ---- Definitions for closures ----------------------------------------- */
 
 #if FFI_CLOSURES
 
+#ifdef _MSC_VER
+__declspec(align(8))
+#endif
 typedef struct {
   char tramp[FFI_TRAMPOLINE_SIZE];
   ffi_cif   *cif;
   void     (*fun)(ffi_cif*,void*,void**,void*);
   void      *user_data;
+#ifdef __GNUC__
+} ffi_closure __attribute__((aligned (8)));
+#else
 } ffi_closure;
+#endif
+
+void *ffi_closure_alloc (size_t size, void **code);
+void ffi_closure_free (void *);
 
 ffi_status
 ffi_prep_closure (ffi_closure*,
@@ -227,6 +274,13 @@
 		  void (*fun)(ffi_cif*,void*,void**,void*),
 		  void *user_data);
 
+ffi_status
+ffi_prep_closure_loc (ffi_closure*,
+		      ffi_cif *,
+		      void (*fun)(ffi_cif*,void*,void**,void*),
+		      void *user_data,
+		      void*codeloc);
+
 typedef struct {
   char tramp[FFI_TRAMPOLINE_SIZE];
 
@@ -248,6 +302,27 @@
 
 } ffi_raw_closure;
 
+typedef struct {
+  char tramp[FFI_TRAMPOLINE_SIZE];
+
+  ffi_cif   *cif;
+
+#if !FFI_NATIVE_RAW_API
+
+  /* if this is enabled, then a raw closure has the same layout 
+     as a regular closure.  We use this to install an intermediate 
+     handler to do the transaltion, void** -> ffi_raw*. */
+
+  void     (*translate_args)(ffi_cif*,void*,void**,void*);
+  void      *this_closure;
+
+#endif
+
+  void     (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);
+  void      *user_data;
+
+} ffi_java_raw_closure;
+
 ffi_status
 ffi_prep_raw_closure (ffi_raw_closure*,
 		      ffi_cif *cif,
@@ -255,29 +330,42 @@
 		      void *user_data);
 
 ffi_status
-ffi_prep_java_raw_closure (ffi_raw_closure*,
+ffi_prep_raw_closure_loc (ffi_raw_closure*,
+			  ffi_cif *cif,
+			  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+			  void *user_data,
+			  void *codeloc);
+
+ffi_status
+ffi_prep_java_raw_closure (ffi_java_raw_closure*,
 		           ffi_cif *cif,
-		           void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+		           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
 		           void *user_data);
 
+ffi_status
+ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
+			       ffi_cif *cif,
+			       void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
+			       void *user_data,
+			       void *codeloc);
+
 #endif /* FFI_CLOSURES */
 
 /* ---- Public interface definition -------------------------------------- */
 
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, 
+ffi_status ffi_prep_cif(ffi_cif *cif,
 			ffi_abi abi,
-			unsigned int nargs, 
-			/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, 
-			/*@dependent@*/ ffi_type **atypes);
-
-int
-ffi_call(/*@dependent@*/ ffi_cif *cif, 
-	 void (*fn)(), 
-	 /*@out@*/ void *rvalue, 
-	 /*@dependent@*/ void **avalue);
+			unsigned int nargs,
+			ffi_type *rtype,
+			ffi_type **atypes);
+
+void ffi_call(ffi_cif *cif,
+	      void (*fn)(void),
+	      void *rvalue,
+	      void **avalue);
 
 /* Useful for eliminating compiler warnings */
-#define FFI_FN(f) ((void (*)())f)
+#define FFI_FN(f) ((void (*)(void))f)
 
 /* ---- Definitions shared with assembly code ---------------------------- */
 
@@ -288,7 +376,7 @@
 #define FFI_TYPE_INT        1
 #define FFI_TYPE_FLOAT      2    
 #define FFI_TYPE_DOUBLE     3
-#if 1
+#if HAVE_LONG_DOUBLE
 #define FFI_TYPE_LONGDOUBLE 4
 #else
 #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
@@ -312,4 +400,3 @@
 #endif
 
 #endif
-

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi_common.h
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffi_common.h	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,77 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi_common.h - Copyright (c) 1996  Red Hat, Inc.
-
-   Common internal definitions and macros. Only necessary for building
-   libffi.
-   ----------------------------------------------------------------------- */
-
-#ifndef FFI_COMMON_H
-#define FFI_COMMON_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <fficonfig.h>
-#include <malloc.h>
-
-/* Check for the existence of memcpy. */
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#if defined(FFI_DEBUG) 
-#include <stdio.h>
-#endif
-
-#ifdef FFI_DEBUG
-/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
-void ffi_stop_here(void);
-void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
-
-#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
-#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
-#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
-#else
-#define FFI_ASSERT(x) 
-#define FFI_ASSERT_AT(x, f, l)
-#define FFI_ASSERT_VALID_TYPE(x)
-#endif
-
-#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
-
-/* Extended cif, used in callback from assembly routine */
-typedef struct
-{
-  /*@dependent@*/ ffi_cif *cif;
-  /*@dependent@*/ void *rvalue;
-  /*@dependent@*/ void **avalue;
-} extended_cif;
-
-/* Terse sized type definitions.  */
-typedef unsigned int UINT8  __attribute__((__mode__(__QI__)));
-typedef signed int   SINT8  __attribute__((__mode__(__QI__)));
-typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
-typedef signed int   SINT16 __attribute__((__mode__(__HI__)));
-typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
-typedef signed int   SINT32 __attribute__((__mode__(__SI__)));
-typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
-typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
-
-typedef float FLOAT32;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-

Modified: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/fficonfig.h
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/fficonfig.h	(original)
+++ python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/fficonfig.h	Thu May  6 23:49:27 2010
@@ -1,96 +1,186 @@
 /* fficonfig.h.  Originally created by configure, now hand_maintained for MSVC. */
 
-/* fficonfig.h.  Generated automatically by configure.  */
-/* fficonfig.h.in.  Generated automatically from configure.in by autoheader.  */
+/* fficonfig.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Define this for MSVC, but not for mingw32! */
-#ifdef _MSC_VER
-#define __attribute__(x) /* */
-#endif
-#define alloca _alloca
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
 
-/*----------------------------------------------------------------*/
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+/* #undef CRAY_STACKSEG_END */
 
-/* Define if using alloca.c.  */
+/* Define to 1 if using `alloca.c'. */
 /* #undef C_ALLOCA */
 
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
-   This function is required for alloca.c support on those systems.  */
-/* #undef CRAY_STACKSEG_END */
+/* Define to the flags needed for the .section .eh_frame directive. */
+/* #undef EH_FRAME_FLAGS */
 
-/* Define if you have alloca, as a function or macro.  */
-#define HAVE_ALLOCA 1
+/* Define this if you want extra debugging. */
+/* #undef FFI_DEBUG */
 
-/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
-/* #define HAVE_ALLOCA_H 1 */
+/* Cannot use malloc on this target, so, we revert to alternative means */
+/* #undef FFI_MMAP_EXEC_WRIT */
 
-/* If using the C implementation of alloca, define if you know the
-   direction of stack growth for your system; otherwise it will be
-   automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-/* #undef STACK_DIRECTION */
+/* Define this is you do not want support for the raw API. */
+#define FFI_NO_RAW_API 1
 
-/* Define if you have the ANSI C header files.  */
-#define STDC_HEADERS 1
+/* Define this is you do not want support for aggregate types. */
+/* #undef FFI_NO_STRUCTS */
 
-/* Define if you have the memcpy function.  */
-#define HAVE_MEMCPY 1
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
 
-/* Define if read-only mmap of a plain file works. */
-//#define HAVE_MMAP_FILE 1
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+/* #undef HAVE_ALLOCA_H */
 
-/* Define if mmap of /dev/zero works. */
-//#define HAVE_MMAP_DEV_ZERO 1
+/* Define if your assembler supports .cfi_* directives. */
+/* #undef HAVE_AS_CFI_PSEUDO_OP */
 
-/* Define if mmap with MAP_ANON(YMOUS) works. */
-//#define HAVE_MMAP_ANON 1
+/* Define if your assembler supports .register. */
+/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
 
-/* The number of bytes in type double */
-#define SIZEOF_DOUBLE 8
+/* Define if your assembler and linker support unaligned PC relative relocs.
+   */
+/* #undef HAVE_AS_SPARC_UA_PCREL */
 
-/* The number of bytes in type long double */
-#define SIZEOF_LONG_DOUBLE 12
+/* Define if your assembler supports PC relative relocs. */
+/* #undef HAVE_AS_X86_PCREL */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define if __attribute__((visibility("hidden"))) is supported. */
+/* #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+/* #undef HAVE_INTTYPES_H */
 
 /* Define if you have the long double type and it is bigger than a double */
-#define HAVE_LONG_DOUBLE 1
+/* #undef HAVE_LONG_DOUBLE */
 
-/* whether byteorder is bigendian */
-/* #undef WORDS_BIGENDIAN */
+/* Define to 1 if you have the `memcpy' function. */
+#define HAVE_MEMCPY 1
 
-/* Define if the host machine stores words of multi-word integers in
-   big-endian order. */
-/* #undef HOST_WORDS_BIG_ENDIAN */
+/* Define to 1 if you have the <memory.h> header file. */
+/* #undef HAVE_MEMORY_H */
 
-/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
-#define BYTEORDER 1234
+/* Define to 1 if you have the `mmap' function. */
+/* #undef HAVE_MMAP */
 
-/* Define if your assembler and linker support unaligned PC relative relocs. */
-/* #undef HAVE_AS_SPARC_UA_PCREL */
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+/* #undef HAVE_MMAP_ANON */
 
-/* Define if your assembler supports .register. */
-/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
+/* Define if mmap of /dev/zero works. */
+/* #undef HAVE_MMAP_DEV_ZERO */
+
+/* Define if read-only mmap of a plain file works. */
+/* #undef HAVE_MMAP_FILE */
 
 /* Define if .eh_frame sections should be read-only. */
 /* #undef HAVE_RO_EH_FRAME */
 
-/* Define to the flags needed for the .section .eh_frame directive. */
-/* #define EH_FRAME_FLAGS "aw" */
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
 
-/* Define to the flags needed for the .section .eh_frame directive. */
-/* #define EH_FRAME_FLAGS "aw" */
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
 
-/* Define this if you want extra debugging. */
-/* #undef FFI_DEBUG */
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
 
-/* Define this is you do not want support for aggregate types. */
-/* #undef FFI_NO_STRUCTS */
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
 
-/* Define this is you do not want support for the raw API. */
-/* #undef FFI_NO_RAW_API */
+/* Define to 1 if you have the <sys/mman.h> header file. */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+/* #undef HAVE_SYS_STAT_H */
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+/* #undef HAVE_SYS_TYPES_H */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+/* #undef HAVE_UNISTD_H */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+/* #undef LT_OBJDIR */
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+/* #undef PACKAGE */
+
+/* Define to the address where bug reports for this package should be sent. */
+/* #undef PACKAGE_BUGREPORT */
+
+/* Define to the full name of this package. */
+/* #undef PACKAGE_NAME */
+
+/* Define to the full name and version of this package. */
+/* #undef PACKAGE_STRING */
+
+/* Define to the one symbol short name of this package. */
+/* #undef PACKAGE_TARNAME */
+
+/* Define to the home page for this package. */
+/* #undef PACKAGE_URL */
+
+/* Define to the version of this package. */
+/* #undef PACKAGE_VERSION */
 
-/* Define this if you are using Purify and want to suppress spurious messages. */
+/* The size of `double', as computed by sizeof. */
+#define SIZEOF_DOUBLE 8
+
+/* The size of `long double', as computed by sizeof. */
+#undef SIZEOF_LONG_DOUBLE
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define this if you are using Purify and want to suppress spurious messages.
+   */
 /* #undef USING_PURIFY */
 
+/* Version number of package */
+/* #undef VERSION */
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
+
+
+#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name) .hidden name
+#else
+#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
+#endif
+#else
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name)
+#else
+#define FFI_HIDDEN
+#endif
+#endif
+

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffitarget.h
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/ffitarget.h	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,85 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
-   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
-   Target configuration macros for x86 and x86-64.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-
-   ----------------------------------------------------------------------- */
-
-#ifndef LIBFFI_TARGET_H
-#define LIBFFI_TARGET_H
-
-/* ---- System specific configurations ----------------------------------- */
-
-#if defined (X86_64) && defined (__i386__)
-#undef X86_64
-#define X86
-#endif
-
-/* ---- Generic type definitions ----------------------------------------- */
-
-#ifndef LIBFFI_ASM
-#ifndef _WIN64
-typedef unsigned long          ffi_arg;
-#else
-typedef unsigned __int64       ffi_arg;
-#endif
-typedef signed long            ffi_sarg;
-
-typedef enum ffi_abi {
-  FFI_FIRST_ABI = 0,
-
-  /* ---- Intel x86 Win32 ---------- */
-  FFI_SYSV,
-#ifndef _WIN64
-  FFI_STDCALL,
-#endif
-  /* TODO: Add fastcall support for the sake of completeness */
-  FFI_DEFAULT_ABI = FFI_SYSV,
-
-  /* ---- Intel x86 and AMD x86-64 - */
-/* #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) */
-/*   FFI_SYSV, */
-/*   FFI_UNIX64,*/   /* Unix variants all use the same ABI for x86-64  */
-/* #ifdef __i386__ */
-/*   FFI_DEFAULT_ABI = FFI_SYSV, */
-/* #else */
-/*   FFI_DEFAULT_ABI = FFI_UNIX64, */
-/* #endif */
-/* #endif */
-
-  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
-} ffi_abi;
-#endif
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#define FFI_CLOSURES 1
-
-#ifdef _WIN64
-#define FFI_TRAMPOLINE_SIZE 29
-#define FFI_NATIVE_RAW_API 0
-#else
-#define FFI_TRAMPOLINE_SIZE 15
-#define FFI_NATIVE_RAW_API 1	/* x86 has native raw api support */
-#endif
-
-#endif
-

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/prep_cif.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/prep_cif.c	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,175 +0,0 @@
-/* -----------------------------------------------------------------------
-   prep_cif.c - Copyright (c) 1996, 1998  Red Hat, Inc.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-#include <stdlib.h>
-
-
-/* Round up to FFI_SIZEOF_ARG. */
-
-#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
-
-/* Perform machine independent initialization of aggregate type
-   specifications. */
-
-static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
-{
-  ffi_type **ptr; 
-
-  FFI_ASSERT(arg != NULL);
-
-  /*@-usedef@*/
-
-  FFI_ASSERT(arg->elements != NULL);
-  FFI_ASSERT(arg->size == 0);
-  FFI_ASSERT(arg->alignment == 0);
-
-  ptr = &(arg->elements[0]);
-
-  while ((*ptr) != NULL)
-    {
-      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
-	return FFI_BAD_TYPEDEF;
-      
-      /* Perform a sanity check on the argument type */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-      arg->size = ALIGN(arg->size, (*ptr)->alignment);
-      arg->size += (*ptr)->size;
-
-      arg->alignment = (arg->alignment > (*ptr)->alignment) ? 
-	arg->alignment : (*ptr)->alignment;
-
-      ptr++;
-    }
-
-  /* Structure size includes tail padding.  This is important for
-     structures that fit in one register on ABIs like the PowerPC64
-     Linux ABI that right justify small structs in a register.
-     It's also needed for nested structure layout, for example
-     struct A { long a; char b; }; struct B { struct A x; char y; };
-     should find y at an offset of 2*sizeof(long) and result in a
-     total size of 3*sizeof(long).  */
-  arg->size = ALIGN (arg->size, arg->alignment);
-
-  if (arg->size == 0)
-    return FFI_BAD_TYPEDEF;
-  else
-    return FFI_OK;
-
-  /*@=usedef@*/
-}
-
-/* Perform machine independent ffi_cif preparation, then call
-   machine dependent routine. */
-
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, 
-			ffi_abi abi, unsigned int nargs, 
-			/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, 
-			/*@dependent@*/ ffi_type **atypes)
-{
-  unsigned bytes = 0;
-  unsigned int i;
-  ffi_type **ptr;
-
-  FFI_ASSERT(cif != NULL);
-  FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
-
-  cif->abi = abi;
-  cif->arg_types = atypes;
-  cif->nargs = nargs;
-  cif->rtype = rtype;
-
-  cif->flags = 0;
-
-  /* Initialize the return type if necessary */
-  /*@-usedef@*/
-  if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
-    return FFI_BAD_TYPEDEF;
-  /*@=usedef@*/
-
-  /* Perform a sanity check on the return type */
-  FFI_ASSERT_VALID_TYPE(cif->rtype);
-
-  /* x86-64 and s390 stack space allocation is handled in prep_machdep.  */
-#if !defined M68K && !defined __x86_64__ && !defined S390
-  /* Make space for the return structure pointer */
-  if (cif->rtype->type == FFI_TYPE_STRUCT
-      /* MSVC returns small structures in registers.  But we have a different
-      workaround: pretend int32 or int64 return type, and converting to
-      structure afterwards. */
-#ifdef SPARC
-      && (cif->abi != FFI_V9 || cif->rtype->size > 32)
-#endif
-      )
-    bytes = STACK_ARG_SIZE(sizeof(void*));
-#endif
-
-  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
-    {
-
-      /* Initialize any uninitialized aggregate type definitions */
-      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
-	return FFI_BAD_TYPEDEF;
-
-      /* Perform a sanity check on the argument type, do this 
-	 check after the initialization.  */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-#if !defined __x86_64__ && !defined S390
-#ifdef SPARC
-      if (((*ptr)->type == FFI_TYPE_STRUCT
-	   && ((*ptr)->size > 16 || cif->abi != FFI_V9))
-	  || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
-	      && cif->abi != FFI_V9))
-	bytes += sizeof(void*);
-      else
-#endif
-	{
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-		/* Don't know if this is a libffi bug or not.  At least on
-		   Windows with MSVC, function call parameters are *not*
-		   aligned in the same way as structure fields are, they are
-		   only aligned in integer boundaries.
-
-		   This doesn't do any harm for cdecl functions and closures,
-		   since the caller cleans up the stack, but it is wrong for
-		   stdcall functions where the callee cleans.
-		*/
-
-	  /* Add any padding if necessary */
-	  if (((*ptr)->alignment - 1) & bytes)
-	    bytes = ALIGN(bytes, (*ptr)->alignment);
-	  
-#endif
-	  bytes += (unsigned)STACK_ARG_SIZE((*ptr)->size);
-	}
-#endif
-    }
-
-  cif->bytes = bytes;
-
-  /* Perform machine dependent cif processing */
-  return ffi_prep_cif_machdep(cif);
-}

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/types.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/types.c	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,104 +0,0 @@
-/* -----------------------------------------------------------------------
-   types.c - Copyright (c) 1996, 1998  Red Hat, Inc.
-   
-   Predefined ffi_types needed by libffi.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-/* Type definitions */
-
-#define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
-#define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
-
-/* Size and alignment are fake here. They must not be 0. */
-FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
-
-FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
-FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
-FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
-FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
-FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
-FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
-FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
-
-#if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
-    || defined IA64
-
-FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
-
-#endif
-
-#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
-
-#elif defined SH
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
-
-#endif
-
-
-#if defined X86 || defined X86_WIN32 || defined M68K
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
-
-#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
-
-#elif defined SPARC
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-#ifdef SPARC64
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
-#else
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
-#endif
-
-#elif defined X86_64
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
-
-#endif
-

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win32.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win32.c	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,162 +0,0 @@
-/* -----------------------------------------------------------------------
-   win32.S - Copyright (c) 1996, 1998, 2001, 2002  Red Hat, Inc.
-	     Copyright (c) 2001  John Beniton
-	     Copyright (c) 2002  Ranjit Mathew
-			
- 
-   X86 Foreign Function Interface
- 
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
- 
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
- 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-/* theller: almost verbatim translation from gas syntax to MSVC inline
-   assembler code. */
-
-/* theller: ffi_call_x86 now returns an integer - the difference of the stack
-   pointer before and after the function call.  If everything is ok, zero is
-   returned.  If stdcall functions are passed the wrong number of arguments,
-   the difference will be nonzero. */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-__declspec(naked) int
-ffi_call_x86(void (* prepfunc)(char *, extended_cif *), /* 8 */
-	     extended_cif *ecif, /* 12 */
-	     unsigned bytes, /* 16 */
-	     unsigned flags, /* 20 */
-	     unsigned *rvalue, /* 24 */
-	     void (*fn)()) /* 28 */
-{
-	_asm {
-		push ebp
-		mov ebp, esp
-
-		push esi // NEW: this register must be preserved across function calls
-// XXX SAVE ESP NOW!
-		mov esi, esp		// save stack pointer before the call
-
-// Make room for all of the new args.
-		mov ecx, [ebp+16]
-		sub esp, ecx		// sub esp, bytes
-		
-		mov eax, esp
-
-// Place all of the ffi_prep_args in position
-		push [ebp + 12] // ecif
-		push eax
-		call [ebp + 8] // prepfunc
-
-// Return stack to previous state and call the function
-		add esp, 8
-// FIXME: Align the stack to a 128-bit boundary to avoid
-// potential performance hits.
-		call [ebp + 28]
-
-// Load ecif->cif->abi
-		mov ecx, [ebp + 12]
-		mov ecx, [ecx]ecif.cif
-		mov ecx, [ecx]ecif.cif.abi
-		
-		cmp ecx, FFI_STDCALL
-		je noclean
-// STDCALL: Remove the space we pushed for the args
-		mov ecx, [ebp + 16]
-		add esp, ecx
-// CDECL: Caller has already cleaned the stack
-noclean:
-// Check that esp has the same value as before!
-		sub esi, esp
-
-// Load %ecx with the return type code
-		mov ecx, [ebp + 20]
-
-// If the return value pointer is NULL, assume no return value.
-/*
-  Intel asm is weird. We have to explicitely specify 'DWORD PTR' in the nexr instruction,
-  otherwise only one BYTE will be compared (instead of a DWORD)!
- */
-		cmp DWORD PTR [ebp + 24], 0
-		jne sc_retint
-
-// Even if there is no space for the return value, we are
-// obliged to handle floating-point values.
-		cmp ecx, FFI_TYPE_FLOAT
-		jne sc_noretval
-//        fstp  %st(0)
-		fstp st(0)
-
-		jmp sc_epilogue
-
-sc_retint:
-		cmp ecx, FFI_TYPE_INT
-		jne sc_retfloat
-//        # Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp + 24]
-		mov [ecx + 0], eax
-		jmp sc_epilogue
-
-sc_retfloat:
-		cmp ecx, FFI_TYPE_FLOAT
-		jne sc_retdouble
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-//        fstps (%ecx)
-		fstp DWORD PTR [ecx]
-		jmp sc_epilogue
-
-sc_retdouble:
-		cmp ecx, FFI_TYPE_DOUBLE
-		jne sc_retlongdouble
-//        movl  24(%ebp),%ecx
-		mov ecx, [ebp+24]
-		fstp QWORD PTR [ecx]
-		jmp sc_epilogue
-
-		jmp sc_retlongdouble // avoid warning about unused label
-sc_retlongdouble:
-		cmp ecx, FFI_TYPE_LONGDOUBLE
-		jne sc_retint64
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-//        fstpt (%ecx)
-		fstp QWORD PTR [ecx] /* XXX ??? */
-		jmp sc_epilogue
-
-sc_retint64:
-		cmp ecx, FFI_TYPE_SINT64
-		jne sc_retstruct
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-		mov [ecx+0], eax
-		mov [ecx+4], edx
-
-sc_retstruct:
-// Nothing to do!
-
-sc_noretval:
-sc_epilogue:
-		mov eax, esi
-		pop esi // NEW restore: must be preserved across function calls
-		mov esp, ebp
-		pop ebp
-		ret
-	}
-}

Deleted: python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win64.asm
==============================================================================
--- python/branches/py3k-jit/Modules/_ctypes/libffi_msvc/win64.asm	Thu May  6 23:49:27 2010
+++ (empty file)
@@ -1,156 +0,0 @@
-PUBLIC	ffi_call_AMD64
-
-EXTRN	__chkstk:NEAR
-EXTRN	ffi_closure_SYSV:NEAR
-
-_TEXT	SEGMENT
-
-;;; ffi_closure_OUTER will be called with these registers set:
-;;;    rax points to 'closure'
-;;;    r11 contains a bit mask that specifies which of the
-;;;    first four parameters are float or double
-;;;
-;;; It must move the parameters passed in registers to their stack location,
-;;; call ffi_closure_SYSV for the actual work, then return the result.
-;;; 
-ffi_closure_OUTER PROC FRAME
-	;; save actual arguments to their stack space.
-	test	r11, 1
-	jne	first_is_float	
-	mov	QWORD PTR [rsp+8], rcx
-	jmp	second
-first_is_float:
-	movlpd	QWORD PTR [rsp+8], xmm0
-
-second:
-	test	r11, 2
-	jne	second_is_float	
-	mov	QWORD PTR [rsp+16], rdx
-	jmp	third
-second_is_float:
-	movlpd	QWORD PTR [rsp+16], xmm1
-
-third:
-	test	r11, 4
-	jne	third_is_float	
-	mov	QWORD PTR [rsp+24], r8
-	jmp	forth
-third_is_float:
-	movlpd	QWORD PTR [rsp+24], xmm2
-
-forth:
-	test	r11, 8
-	jne	forth_is_float	
-	mov	QWORD PTR [rsp+32], r9
-	jmp	done
-forth_is_float:
-	movlpd	QWORD PTR [rsp+32], xmm3
-
-done:
-.ALLOCSTACK 40
-	sub	rsp, 40
-.ENDPROLOG
-	mov	rcx, rax	; context is first parameter
-	mov	rdx, rsp	; stack is second parameter
-	add	rdx, 40		; correct our own area
-	mov	rax, ffi_closure_SYSV
-	call	rax		; call the real closure function
-	;; Here, code is missing that handles float return values
-	add	rsp, 40
-	movd	xmm0, rax	; In case the closure returned a float.
-	ret	0
-ffi_closure_OUTER ENDP
-
-
-;;; ffi_call_AMD64
-
-stack$ = 0
-prepfunc$ = 32
-ecif$ = 40
-bytes$ = 48
-flags$ = 56
-rvalue$ = 64
-fn$ = 72
-
-ffi_call_AMD64 PROC FRAME
-
-	mov	QWORD PTR [rsp+32], r9
-	mov	QWORD PTR [rsp+24], r8
-	mov	QWORD PTR [rsp+16], rdx
-	mov	QWORD PTR [rsp+8], rcx
-.PUSHREG rbp
-	push	rbp
-.ALLOCSTACK 48
-	sub	rsp, 48					; 00000030H
-.SETFRAME rbp, 32
-	lea	rbp, QWORD PTR [rsp+32]
-.ENDPROLOG
-
-	mov	eax, DWORD PTR bytes$[rbp]
-	add	rax, 15
-	and	rax, -16
-	call	__chkstk
-	sub	rsp, rax
-	lea	rax, QWORD PTR [rsp+32]
-	mov	QWORD PTR stack$[rbp], rax
-
-	mov	rdx, QWORD PTR ecif$[rbp]
-	mov	rcx, QWORD PTR stack$[rbp]
-	call	QWORD PTR prepfunc$[rbp]
-
-	mov	rsp, QWORD PTR stack$[rbp]
-
-	movlpd	xmm3, QWORD PTR [rsp+24]
-	movd	r9, xmm3
-
-	movlpd	xmm2, QWORD PTR [rsp+16]
-	movd	r8, xmm2
-
-	movlpd	xmm1, QWORD PTR [rsp+8]
-	movd	rdx, xmm1
-
-	movlpd	xmm0, QWORD PTR [rsp]
-	movd	rcx, xmm0
-
-	call	QWORD PTR fn$[rbp]
-ret_int$:
- 	cmp	DWORD PTR flags$[rbp], 1 ; FFI_TYPE_INT
- 	jne	ret_float$
-
-	mov	rcx, QWORD PTR rvalue$[rbp]
-	mov	DWORD PTR [rcx], eax
-	jmp	SHORT ret_nothing$
-
-ret_float$:
- 	cmp	DWORD PTR flags$[rbp], 2 ; FFI_TYPE_FLOAT
- 	jne	SHORT ret_double$
-
- 	mov	rax, QWORD PTR rvalue$[rbp]
- 	movlpd	QWORD PTR [rax], xmm0
- 	jmp	SHORT ret_nothing$
-
-ret_double$:
- 	cmp	DWORD PTR flags$[rbp], 3 ; FFI_TYPE_DOUBLE
- 	jne	SHORT ret_int64$
-
- 	mov	rax, QWORD PTR rvalue$[rbp]
- 	movlpd	QWORD PTR [rax], xmm0
- 	jmp	SHORT ret_nothing$
-
-ret_int64$:
-  	cmp	DWORD PTR flags$[rbp], 12 ; FFI_TYPE_SINT64
-  	jne	ret_nothing$
-
- 	mov	rcx, QWORD PTR rvalue$[rbp]
- 	mov	QWORD PTR [rcx], rax
- 	jmp	SHORT ret_nothing$
-	
-ret_nothing$:
-	xor	eax, eax
-
-	lea	rsp, QWORD PTR [rbp+16]
-	pop	rbp
-	ret	0
-ffi_call_AMD64 ENDP
-_TEXT	ENDS
-END

Modified: python/branches/py3k-jit/Modules/_io/fileio.c
==============================================================================
--- python/branches/py3k-jit/Modules/_io/fileio.c	(original)
+++ python/branches/py3k-jit/Modules/_io/fileio.c	Thu May  6 23:49:27 2010
@@ -49,14 +49,14 @@
 #endif
 
 typedef struct {
-	PyObject_HEAD
-	int fd;
-	unsigned int readable : 1;
-	unsigned int writable : 1;
-	signed int seekable : 2; /* -1 means unknown */
-	unsigned int closefd : 1;
-	PyObject *weakreflist;
-	PyObject *dict;
+    PyObject_HEAD
+    int fd;
+    unsigned int readable : 1;
+    unsigned int writable : 1;
+    signed int seekable : 2; /* -1 means unknown */
+    unsigned int closefd : 1;
+    PyObject *weakreflist;
+    PyObject *dict;
 } fileio;
 
 PyTypeObject PyFileIO_Type;
@@ -66,7 +66,7 @@
 int
 _PyFileIO_closed(PyObject *self)
 {
-	return ((fileio *)self)->fd < 0;
+    return ((fileio *)self)->fd < 0;
 }
 
 static PyObject *
@@ -78,64 +78,64 @@
 static int
 internal_close(fileio *self)
 {
-	int err = 0;
-	int save_errno = 0;
-	if (self->fd >= 0) {
-		int fd = self->fd;
-		self->fd = -1;
-		/* fd is accessible and someone else may have closed it */
-		if (_PyVerify_fd(fd)) {
-			Py_BEGIN_ALLOW_THREADS
-			err = close(fd);
-			if (err < 0)
-				save_errno = errno;
-			Py_END_ALLOW_THREADS
-		} else {
-			save_errno = errno;
-			err = -1;
-		}
-	}
-	if (err < 0) {
-		errno = save_errno;
-		PyErr_SetFromErrno(PyExc_IOError);
-		return -1;
-	}
-	return 0;
+    int err = 0;
+    int save_errno = 0;
+    if (self->fd >= 0) {
+        int fd = self->fd;
+        self->fd = -1;
+        /* fd is accessible and someone else may have closed it */
+        if (_PyVerify_fd(fd)) {
+            Py_BEGIN_ALLOW_THREADS
+            err = close(fd);
+            if (err < 0)
+                save_errno = errno;
+            Py_END_ALLOW_THREADS
+        } else {
+            save_errno = errno;
+            err = -1;
+        }
+    }
+    if (err < 0) {
+        errno = save_errno;
+        PyErr_SetFromErrno(PyExc_IOError);
+        return -1;
+    }
+    return 0;
 }
 
 static PyObject *
 fileio_close(fileio *self)
 {
-	if (!self->closefd) {
-		self->fd = -1;
-		Py_RETURN_NONE;
-	}
-	errno = internal_close(self);
-	if (errno < 0)
-		return NULL;
+    if (!self->closefd) {
+        self->fd = -1;
+        Py_RETURN_NONE;
+    }
+    errno = internal_close(self);
+    if (errno < 0)
+        return NULL;
 
-	return PyObject_CallMethod((PyObject*)&PyRawIOBase_Type,
-				   "close", "O", self);
+    return PyObject_CallMethod((PyObject*)&PyRawIOBase_Type,
+                               "close", "O", self);
 }
 
 static PyObject *
 fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	fileio *self;
+    fileio *self;
 
-	assert(type != NULL && type->tp_alloc != NULL);
+    assert(type != NULL && type->tp_alloc != NULL);
 
-	self = (fileio *) type->tp_alloc(type, 0);
-	if (self != NULL) {
-		self->fd = -1;
-		self->readable = 0;
-		self->writable = 0;
-		self->seekable = -1;
-		self->closefd = 1;
-		self->weakreflist = NULL;
-	}
+    self = (fileio *) type->tp_alloc(type, 0);
+    if (self != NULL) {
+        self->fd = -1;
+        self->readable = 0;
+        self->writable = 0;
+        self->seekable = -1;
+        self->closefd = 1;
+        self->weakreflist = NULL;
+    }
 
-	return (PyObject *) self;
+    return (PyObject *) self;
 }
 
 /* On Unix, open will succeed for directories.
@@ -146,535 +146,535 @@
 dircheck(fileio* self, const char *name)
 {
 #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
-	struct stat buf;
-	if (self->fd < 0)
-		return 0;
-	if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) {
-		char *msg = strerror(EISDIR);
-		PyObject *exc;
-		if (internal_close(self))
-			return -1;
-
-		exc = PyObject_CallFunction(PyExc_IOError, "(iss)",
-					    EISDIR, msg, name);
-		PyErr_SetObject(PyExc_IOError, exc);
-		Py_XDECREF(exc);
-		return -1;
-	}
+    struct stat buf;
+    if (self->fd < 0)
+        return 0;
+    if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) {
+        char *msg = strerror(EISDIR);
+        PyObject *exc;
+        if (internal_close(self))
+            return -1;
+
+        exc = PyObject_CallFunction(PyExc_IOError, "(iss)",
+                                    EISDIR, msg, name);
+        PyErr_SetObject(PyExc_IOError, exc);
+        Py_XDECREF(exc);
+        return -1;
+    }
 #endif
-	return 0;
+    return 0;
 }
 
 static int
 check_fd(int fd)
 {
 #if defined(HAVE_FSTAT)
-	struct stat buf;
-	if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) {
-		PyObject *exc;
-		char *msg = strerror(EBADF);
-		exc = PyObject_CallFunction(PyExc_OSError, "(is)",
-					    EBADF, msg);
-		PyErr_SetObject(PyExc_OSError, exc);
-		Py_XDECREF(exc);
-		return -1;
-	}
+    struct stat buf;
+    if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) {
+        PyObject *exc;
+        char *msg = strerror(EBADF);
+        exc = PyObject_CallFunction(PyExc_OSError, "(is)",
+                                    EBADF, msg);
+        PyErr_SetObject(PyExc_OSError, exc);
+        Py_XDECREF(exc);
+        return -1;
+    }
 #endif
-	return 0;
+    return 0;
 }
 
 
 static int
 fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 {
-	fileio *self = (fileio *) oself;
-	static char *kwlist[] = {"file", "mode", "closefd", NULL};
-	const char *name = NULL;
-	PyObject *nameobj, *stringobj = NULL;
-	char *mode = "r";
-	char *s;
+    fileio *self = (fileio *) oself;
+    static char *kwlist[] = {"file", "mode", "closefd", NULL};
+    const char *name = NULL;
+    PyObject *nameobj, *stringobj = NULL;
+    char *mode = "r";
+    char *s;
 #ifdef MS_WINDOWS
-	Py_UNICODE *widename = NULL;
+    Py_UNICODE *widename = NULL;
 #endif
-	int ret = 0;
-	int rwa = 0, plus = 0, append = 0;
-	int flags = 0;
-	int fd = -1;
-	int closefd = 1;
-
-	assert(PyFileIO_Check(oself));
-	if (self->fd >= 0) {
-		/* Have to close the existing file first. */
-		if (internal_close(self) < 0)
-			return -1;
-	}
-
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:fileio",
-					 kwlist, &nameobj, &mode, &closefd))
-		return -1;
-
-	if (PyFloat_Check(nameobj)) {
-		PyErr_SetString(PyExc_TypeError,
-				"integer argument expected, got float");
-		return -1;
-	}
-
-	fd = PyLong_AsLong(nameobj);
-	if (fd < 0) {
-		if (!PyErr_Occurred()) {
-			PyErr_SetString(PyExc_ValueError,
-					"Negative filedescriptor");
-			return -1;
-		}
-		PyErr_Clear();
-	}
+    int ret = 0;
+    int rwa = 0, plus = 0, append = 0;
+    int flags = 0;
+    int fd = -1;
+    int closefd = 1;
+
+    assert(PyFileIO_Check(oself));
+    if (self->fd >= 0) {
+        /* Have to close the existing file first. */
+        if (internal_close(self) < 0)
+            return -1;
+    }
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:fileio",
+                                     kwlist, &nameobj, &mode, &closefd))
+        return -1;
+
+    if (PyFloat_Check(nameobj)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "integer argument expected, got float");
+        return -1;
+    }
+
+    fd = PyLong_AsLong(nameobj);
+    if (fd < 0) {
+        if (!PyErr_Occurred()) {
+            PyErr_SetString(PyExc_ValueError,
+                            "Negative filedescriptor");
+            return -1;
+        }
+        PyErr_Clear();
+    }
 
 #ifdef MS_WINDOWS
-	if (PyUnicode_Check(nameobj))
-		widename = PyUnicode_AS_UNICODE(nameobj);
-	if (widename == NULL)
+    if (PyUnicode_Check(nameobj))
+        widename = PyUnicode_AS_UNICODE(nameobj);
+    if (widename == NULL)
 #endif
-	if (fd < 0)
-	{
-		if (PyBytes_Check(nameobj) || PyByteArray_Check(nameobj)) {
-			Py_ssize_t namelen;
-			if (PyObject_AsCharBuffer(nameobj, &name, &namelen) < 0)
-				return -1;
-		}
-		else {
-			PyObject *u = PyUnicode_FromObject(nameobj);
-
-			if (u == NULL)
-				return -1;
-
-			stringobj = PyUnicode_AsEncodedString(
-				u, Py_FileSystemDefaultEncoding, "surrogateescape");
-			Py_DECREF(u);
-			if (stringobj == NULL)
-				return -1;
-			if (!PyBytes_Check(stringobj)) {
-				PyErr_SetString(PyExc_TypeError,
-						"encoder failed to return bytes");
-				goto error;
-			}
-			name = PyBytes_AS_STRING(stringobj);
-		}
-	}
-
-	s = mode;
-	while (*s) {
-		switch (*s++) {
-		case 'r':
-			if (rwa) {
-			bad_mode:
-				PyErr_SetString(PyExc_ValueError,
-						"Must have exactly one of read/write/append mode");
-				goto error;
-			}
-			rwa = 1;
-			self->readable = 1;
-			break;
-		case 'w':
-			if (rwa)
-				goto bad_mode;
-			rwa = 1;
-			self->writable = 1;
-			flags |= O_CREAT | O_TRUNC;
-			break;
-		case 'a':
-			if (rwa)
-				goto bad_mode;
-			rwa = 1;
-			self->writable = 1;
-			flags |= O_CREAT;
-			append = 1;
-			break;
-		case 'b':
-			break;
-		case '+':
-			if (plus)
-				goto bad_mode;
-			self->readable = self->writable = 1;
-			plus = 1;
-			break;
-		default:
-			PyErr_Format(PyExc_ValueError,
-				     "invalid mode: %.200s", mode);
-			goto error;
-		}
-	}
-
-	if (!rwa)
-		goto bad_mode;
-
-	if (self->readable && self->writable)
-		flags |= O_RDWR;
-	else if (self->readable)
-		flags |= O_RDONLY;
-	else
-		flags |= O_WRONLY;
+    if (fd < 0)
+    {
+        if (PyBytes_Check(nameobj) || PyByteArray_Check(nameobj)) {
+            Py_ssize_t namelen;
+            if (PyObject_AsCharBuffer(nameobj, &name, &namelen) < 0)
+                return -1;
+        }
+        else {
+            PyObject *u = PyUnicode_FromObject(nameobj);
+
+            if (u == NULL)
+                return -1;
+
+            stringobj = PyUnicode_AsEncodedString(
+                u, Py_FileSystemDefaultEncoding, "surrogateescape");
+            Py_DECREF(u);
+            if (stringobj == NULL)
+                return -1;
+            if (!PyBytes_Check(stringobj)) {
+                PyErr_SetString(PyExc_TypeError,
+                                "encoder failed to return bytes");
+                goto error;
+            }
+            name = PyBytes_AS_STRING(stringobj);
+        }
+    }
+
+    s = mode;
+    while (*s) {
+        switch (*s++) {
+        case 'r':
+            if (rwa) {
+            bad_mode:
+                PyErr_SetString(PyExc_ValueError,
+                                "Must have exactly one of read/write/append mode");
+                goto error;
+            }
+            rwa = 1;
+            self->readable = 1;
+            break;
+        case 'w':
+            if (rwa)
+                goto bad_mode;
+            rwa = 1;
+            self->writable = 1;
+            flags |= O_CREAT | O_TRUNC;
+            break;
+        case 'a':
+            if (rwa)
+                goto bad_mode;
+            rwa = 1;
+            self->writable = 1;
+            flags |= O_CREAT;
+            append = 1;
+            break;
+        case 'b':
+            break;
+        case '+':
+            if (plus)
+                goto bad_mode;
+            self->readable = self->writable = 1;
+            plus = 1;
+            break;
+        default:
+            PyErr_Format(PyExc_ValueError,
+                         "invalid mode: %.200s", mode);
+            goto error;
+        }
+    }
+
+    if (!rwa)
+        goto bad_mode;
+
+    if (self->readable && self->writable)
+        flags |= O_RDWR;
+    else if (self->readable)
+        flags |= O_RDONLY;
+    else
+        flags |= O_WRONLY;
 
 #ifdef O_BINARY
-	flags |= O_BINARY;
+    flags |= O_BINARY;
 #endif
 
 #ifdef O_APPEND
-	if (append)
-		flags |= O_APPEND;
+    if (append)
+        flags |= O_APPEND;
 #endif
 
-	if (fd >= 0) {
-		if (check_fd(fd))
-			goto error;
-		self->fd = fd;
-		self->closefd = closefd;
-	}
-	else {
-		self->closefd = 1;
-		if (!closefd) {
-			PyErr_SetString(PyExc_ValueError,
-                            "Cannot use closefd=False with file name");
-			goto error;
-		}
+    if (fd >= 0) {
+        if (check_fd(fd))
+            goto error;
+        self->fd = fd;
+        self->closefd = closefd;
+    }
+    else {
+        self->closefd = 1;
+        if (!closefd) {
+            PyErr_SetString(PyExc_ValueError,
+                "Cannot use closefd=False with file name");
+            goto error;
+        }
 
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
 #ifdef MS_WINDOWS
-		if (widename != NULL)
-			self->fd = _wopen(widename, flags, 0666);
-		else
+        if (widename != NULL)
+            self->fd = _wopen(widename, flags, 0666);
+        else
 #endif
-			self->fd = open(name, flags, 0666);
-		Py_END_ALLOW_THREADS
-		if (self->fd < 0) {
+            self->fd = open(name, flags, 0666);
+        Py_END_ALLOW_THREADS
+        if (self->fd < 0) {
 #ifdef MS_WINDOWS
-			if (widename != NULL)
-				PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
-			else
+            if (widename != NULL)
+                PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
+            else
 #endif
-				PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
-			goto error;
-		}
-		if(dircheck(self, name) < 0)
-			goto error;
-	}
-
-	if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0)
-		goto error;
-
-	if (append) {
-		/* For consistent behaviour, we explicitly seek to the
-		   end of file (otherwise, it might be done only on the
-		   first write()). */
-		PyObject *pos = portable_lseek(self->fd, NULL, 2);
-		if (pos == NULL)
-			goto error;
-		Py_DECREF(pos);
-	}
+                PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+            goto error;
+        }
+        if(dircheck(self, name) < 0)
+            goto error;
+    }
+
+    if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0)
+        goto error;
+
+    if (append) {
+        /* For consistent behaviour, we explicitly seek to the
+           end of file (otherwise, it might be done only on the
+           first write()). */
+        PyObject *pos = portable_lseek(self->fd, NULL, 2);
+        if (pos == NULL)
+            goto error;
+        Py_DECREF(pos);
+    }
 
-	goto done;
+    goto done;
 
  error:
-	ret = -1;
+    ret = -1;
 
  done:
-	Py_CLEAR(stringobj);
-	return ret;
+    Py_CLEAR(stringobj);
+    return ret;
 }
 
 static int
 fileio_traverse(fileio *self, visitproc visit, void *arg)
 {
-	Py_VISIT(self->dict);
-	return 0;
+    Py_VISIT(self->dict);
+    return 0;
 }
 
 static int
 fileio_clear(fileio *self)
 {
-	Py_CLEAR(self->dict);
-	return 0;
+    Py_CLEAR(self->dict);
+    return 0;
 }
 
 static void
 fileio_dealloc(fileio *self)
 {
-	if (_PyIOBase_finalize((PyObject *) self) < 0)
-		return;
-	_PyObject_GC_UNTRACK(self);
-	if (self->weakreflist != NULL)
-		PyObject_ClearWeakRefs((PyObject *) self);
-	Py_CLEAR(self->dict);
-	Py_TYPE(self)->tp_free((PyObject *)self);
+    if (_PyIOBase_finalize((PyObject *) self) < 0)
+        return;
+    _PyObject_GC_UNTRACK(self);
+    if (self->weakreflist != NULL)
+        PyObject_ClearWeakRefs((PyObject *) self);
+    Py_CLEAR(self->dict);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static PyObject *
 err_closed(void)
 {
-	PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
-	return NULL;
+    PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
+    return NULL;
 }
 
 static PyObject *
 err_mode(char *action)
 {
-	PyErr_Format(PyExc_ValueError, "File not open for %s", action);
-	return NULL;
+    PyErr_Format(PyExc_ValueError, "File not open for %s", action);
+    return NULL;
 }
 
 static PyObject *
 fileio_fileno(fileio *self)
 {
-	if (self->fd < 0)
-		return err_closed();
-	return PyLong_FromLong((long) self->fd);
+    if (self->fd < 0)
+        return err_closed();
+    return PyLong_FromLong((long) self->fd);
 }
 
 static PyObject *
 fileio_readable(fileio *self)
 {
-	if (self->fd < 0)
-		return err_closed();
-	return PyBool_FromLong((long) self->readable);
+    if (self->fd < 0)
+        return err_closed();
+    return PyBool_FromLong((long) self->readable);
 }
 
 static PyObject *
 fileio_writable(fileio *self)
 {
-	if (self->fd < 0)
-		return err_closed();
-	return PyBool_FromLong((long) self->writable);
+    if (self->fd < 0)
+        return err_closed();
+    return PyBool_FromLong((long) self->writable);
 }
 
 static PyObject *
 fileio_seekable(fileio *self)
 {
-	if (self->fd < 0)
-		return err_closed();
-	if (self->seekable < 0) {
-		PyObject *pos = portable_lseek(self->fd, NULL, SEEK_CUR);
-		if (pos == NULL) {
-			PyErr_Clear();
-			self->seekable = 0;
-		} else {
-			Py_DECREF(pos);
-			self->seekable = 1;
-		}
-	}
-	return PyBool_FromLong((long) self->seekable);
+    if (self->fd < 0)
+        return err_closed();
+    if (self->seekable < 0) {
+        PyObject *pos = portable_lseek(self->fd, NULL, SEEK_CUR);
+        if (pos == NULL) {
+            PyErr_Clear();
+            self->seekable = 0;
+        } else {
+            Py_DECREF(pos);
+            self->seekable = 1;
+        }
+    }
+    return PyBool_FromLong((long) self->seekable);
 }
 
 static PyObject *
 fileio_readinto(fileio *self, PyObject *args)
 {
-	Py_buffer pbuf;
-	Py_ssize_t n;
+    Py_buffer pbuf;
+    Py_ssize_t n;
 
-	if (self->fd < 0)
-		return err_closed();
-	if (!self->readable)
-		return err_mode("reading");
-
-	if (!PyArg_ParseTuple(args, "w*", &pbuf))
-		return NULL;
-
-	if (_PyVerify_fd(self->fd)) {
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
-		n = read(self->fd, pbuf.buf, pbuf.len);
-		Py_END_ALLOW_THREADS
-	} else
-		n = -1;
-	PyBuffer_Release(&pbuf);
-	if (n < 0) {
-		if (errno == EAGAIN)
-			Py_RETURN_NONE;
-		PyErr_SetFromErrno(PyExc_IOError);
-		return NULL;
-	}
+    if (self->fd < 0)
+        return err_closed();
+    if (!self->readable)
+        return err_mode("reading");
+
+    if (!PyArg_ParseTuple(args, "w*", &pbuf))
+        return NULL;
+
+    if (_PyVerify_fd(self->fd)) {
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
+        n = read(self->fd, pbuf.buf, pbuf.len);
+        Py_END_ALLOW_THREADS
+    } else
+        n = -1;
+    PyBuffer_Release(&pbuf);
+    if (n < 0) {
+        if (errno == EAGAIN)
+            Py_RETURN_NONE;
+        PyErr_SetFromErrno(PyExc_IOError);
+        return NULL;
+    }
 
-	return PyLong_FromSsize_t(n);
+    return PyLong_FromSsize_t(n);
 }
 
 static size_t
 new_buffersize(fileio *self, size_t currentsize)
 {
 #ifdef HAVE_FSTAT
-	off_t pos, end;
-	struct stat st;
-	if (fstat(self->fd, &st) == 0) {
-		end = st.st_size;
-		pos = lseek(self->fd, 0L, SEEK_CUR);
-		/* Files claiming a size smaller than SMALLCHUNK may
-		   actually be streaming pseudo-files. In this case, we
-		   apply the more aggressive algorithm below.
-		*/
-		if (end >= SMALLCHUNK && end >= pos && pos >= 0) {
-			/* Add 1 so if the file were to grow we'd notice. */
-			return currentsize + end - pos + 1;
-		}
-	}
+    off_t pos, end;
+    struct stat st;
+    if (fstat(self->fd, &st) == 0) {
+        end = st.st_size;
+        pos = lseek(self->fd, 0L, SEEK_CUR);
+        /* Files claiming a size smaller than SMALLCHUNK may
+           actually be streaming pseudo-files. In this case, we
+           apply the more aggressive algorithm below.
+        */
+        if (end >= SMALLCHUNK && end >= pos && pos >= 0) {
+            /* Add 1 so if the file were to grow we'd notice. */
+            return currentsize + end - pos + 1;
+        }
+    }
 #endif
-	if (currentsize > SMALLCHUNK) {
-		/* Keep doubling until we reach BIGCHUNK;
-		   then keep adding BIGCHUNK. */
-		if (currentsize <= BIGCHUNK)
-			return currentsize + currentsize;
-		else
-			return currentsize + BIGCHUNK;
-	}
-	return currentsize + SMALLCHUNK;
+    if (currentsize > SMALLCHUNK) {
+        /* Keep doubling until we reach BIGCHUNK;
+           then keep adding BIGCHUNK. */
+        if (currentsize <= BIGCHUNK)
+            return currentsize + currentsize;
+        else
+            return currentsize + BIGCHUNK;
+    }
+    return currentsize + SMALLCHUNK;
 }
 
 static PyObject *
 fileio_readall(fileio *self)
 {
-	PyObject *result;
-	Py_ssize_t total = 0;
-	int n;
-
-	if (!_PyVerify_fd(self->fd))
-		return PyErr_SetFromErrno(PyExc_IOError);
-
-	result = PyBytes_FromStringAndSize(NULL, SMALLCHUNK);
-	if (result == NULL)
-		return NULL;
-
-	while (1) {
-		size_t newsize = new_buffersize(self, total);
-		if (newsize > PY_SSIZE_T_MAX || newsize <= 0) {
-			PyErr_SetString(PyExc_OverflowError,
-				"unbounded read returned more bytes "
-				"than a Python string can hold ");
-			Py_DECREF(result);
-			return NULL;
-		}
-
-		if (PyBytes_GET_SIZE(result) < (Py_ssize_t)newsize) {
-			if (_PyBytes_Resize(&result, newsize) < 0) {
-				if (total == 0) {
-					Py_DECREF(result);
-					return NULL;
-				}
-				PyErr_Clear();
-				break;
-			}
-		}
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
-		n = read(self->fd,
-			 PyBytes_AS_STRING(result) + total,
-			 newsize - total);
-		Py_END_ALLOW_THREADS
-		if (n == 0)
-			break;
-		if (n < 0) {
-			if (total > 0)
-				break;
-			if (errno == EAGAIN) {
-				Py_DECREF(result);
-				Py_RETURN_NONE;
-			}
-			Py_DECREF(result);
-			PyErr_SetFromErrno(PyExc_IOError);
-			return NULL;
-		}
-		total += n;
-	}
-
-	if (PyBytes_GET_SIZE(result) > total) {
-		if (_PyBytes_Resize(&result, total) < 0) {
-			/* This should never happen, but just in case */
-			Py_DECREF(result);
-			return NULL;
-		}
-	}
-	return result;
+    PyObject *result;
+    Py_ssize_t total = 0;
+    int n;
+
+    if (!_PyVerify_fd(self->fd))
+        return PyErr_SetFromErrno(PyExc_IOError);
+
+    result = PyBytes_FromStringAndSize(NULL, SMALLCHUNK);
+    if (result == NULL)
+        return NULL;
+
+    while (1) {
+        size_t newsize = new_buffersize(self, total);
+        if (newsize > PY_SSIZE_T_MAX || newsize <= 0) {
+            PyErr_SetString(PyExc_OverflowError,
+                "unbounded read returned more bytes "
+                "than a Python string can hold ");
+            Py_DECREF(result);
+            return NULL;
+        }
+
+        if (PyBytes_GET_SIZE(result) < (Py_ssize_t)newsize) {
+            if (_PyBytes_Resize(&result, newsize) < 0) {
+                if (total == 0) {
+                    Py_DECREF(result);
+                    return NULL;
+                }
+                PyErr_Clear();
+                break;
+            }
+        }
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
+        n = read(self->fd,
+                 PyBytes_AS_STRING(result) + total,
+                 newsize - total);
+        Py_END_ALLOW_THREADS
+        if (n == 0)
+            break;
+        if (n < 0) {
+            if (total > 0)
+                break;
+            if (errno == EAGAIN) {
+                Py_DECREF(result);
+                Py_RETURN_NONE;
+            }
+            Py_DECREF(result);
+            PyErr_SetFromErrno(PyExc_IOError);
+            return NULL;
+        }
+        total += n;
+    }
+
+    if (PyBytes_GET_SIZE(result) > total) {
+        if (_PyBytes_Resize(&result, total) < 0) {
+            /* This should never happen, but just in case */
+            Py_DECREF(result);
+            return NULL;
+        }
+    }
+    return result;
 }
 
 static PyObject *
 fileio_read(fileio *self, PyObject *args)
 {
-	char *ptr;
-	Py_ssize_t n;
-	Py_ssize_t size = -1;
-	PyObject *bytes;
-
-	if (self->fd < 0)
-		return err_closed();
-	if (!self->readable)
-		return err_mode("reading");
-
-	if (!PyArg_ParseTuple(args, "|O&", &_PyIO_ConvertSsize_t, &size))
-		return NULL;
-
-        if (size < 0) {
-		return fileio_readall(self);
-	}
-
-	bytes = PyBytes_FromStringAndSize(NULL, size);
-	if (bytes == NULL)
-		return NULL;
-	ptr = PyBytes_AS_STRING(bytes);
-
-	if (_PyVerify_fd(self->fd)) {
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
-		n = read(self->fd, ptr, size);
-		Py_END_ALLOW_THREADS
-	} else
-		n = -1;
-
-	if (n < 0) {
-		Py_DECREF(bytes);
-		if (errno == EAGAIN)
-			Py_RETURN_NONE;
-		PyErr_SetFromErrno(PyExc_IOError);
-		return NULL;
-	}
-
-	if (n != size) {
-		if (_PyBytes_Resize(&bytes, n) < 0) {
-			Py_DECREF(bytes);
-			return NULL;
-		}
-	}
+    char *ptr;
+    Py_ssize_t n;
+    Py_ssize_t size = -1;
+    PyObject *bytes;
+
+    if (self->fd < 0)
+        return err_closed();
+    if (!self->readable)
+        return err_mode("reading");
+
+    if (!PyArg_ParseTuple(args, "|O&", &_PyIO_ConvertSsize_t, &size))
+        return NULL;
+
+    if (size < 0) {
+        return fileio_readall(self);
+    }
+
+    bytes = PyBytes_FromStringAndSize(NULL, size);
+    if (bytes == NULL)
+        return NULL;
+    ptr = PyBytes_AS_STRING(bytes);
+
+    if (_PyVerify_fd(self->fd)) {
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
+        n = read(self->fd, ptr, size);
+        Py_END_ALLOW_THREADS
+    } else
+        n = -1;
+
+    if (n < 0) {
+        Py_DECREF(bytes);
+        if (errno == EAGAIN)
+            Py_RETURN_NONE;
+        PyErr_SetFromErrno(PyExc_IOError);
+        return NULL;
+    }
+
+    if (n != size) {
+        if (_PyBytes_Resize(&bytes, n) < 0) {
+            Py_DECREF(bytes);
+            return NULL;
+        }
+    }
 
-	return (PyObject *) bytes;
+    return (PyObject *) bytes;
 }
 
 static PyObject *
 fileio_write(fileio *self, PyObject *args)
 {
-	Py_buffer pbuf;
-	Py_ssize_t n;
+    Py_buffer pbuf;
+    Py_ssize_t n;
 
-	if (self->fd < 0)
-		return err_closed();
-	if (!self->writable)
-		return err_mode("writing");
-
-	if (!PyArg_ParseTuple(args, "y*", &pbuf))
-		return NULL;
-
-	if (_PyVerify_fd(self->fd)) {
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
-		n = write(self->fd, pbuf.buf, pbuf.len);
-		Py_END_ALLOW_THREADS
-	} else
-		n = -1;
-
-	PyBuffer_Release(&pbuf);
-
-	if (n < 0) {
-		if (errno == EAGAIN)
-			Py_RETURN_NONE;
-		PyErr_SetFromErrno(PyExc_IOError);
-		return NULL;
-	}
+    if (self->fd < 0)
+        return err_closed();
+    if (!self->writable)
+        return err_mode("writing");
+
+    if (!PyArg_ParseTuple(args, "y*", &pbuf))
+        return NULL;
+
+    if (_PyVerify_fd(self->fd)) {
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
+        n = write(self->fd, pbuf.buf, pbuf.len);
+        Py_END_ALLOW_THREADS
+    } else
+        n = -1;
+
+    PyBuffer_Release(&pbuf);
+
+    if (n < 0) {
+        if (errno == EAGAIN)
+            Py_RETURN_NONE;
+        PyErr_SetFromErrno(PyExc_IOError);
+        return NULL;
+    }
 
-	return PyLong_FromSsize_t(n);
+    return PyLong_FromSsize_t(n);
 }
 
 /* XXX Windows support below is likely incomplete */
@@ -683,235 +683,235 @@
 static PyObject *
 portable_lseek(int fd, PyObject *posobj, int whence)
 {
-	Py_off_t pos, res;
+    Py_off_t pos, res;
 
 #ifdef SEEK_SET
-	/* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
-	switch (whence) {
+    /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
+    switch (whence) {
 #if SEEK_SET != 0
-	case 0: whence = SEEK_SET; break;
+    case 0: whence = SEEK_SET; break;
 #endif
 #if SEEK_CUR != 1
-	case 1: whence = SEEK_CUR; break;
+    case 1: whence = SEEK_CUR; break;
 #endif
 #if SEEK_END != 2
-	case 2: whence = SEEK_END; break;
+    case 2: whence = SEEK_END; break;
 #endif
-	}
+    }
 #endif /* SEEK_SET */
 
-	if (posobj == NULL)
-		pos = 0;
-	else {
-		if(PyFloat_Check(posobj)) {
-			PyErr_SetString(PyExc_TypeError, "an integer is required");
-			return NULL;
-		}
+    if (posobj == NULL)
+        pos = 0;
+    else {
+        if(PyFloat_Check(posobj)) {
+            PyErr_SetString(PyExc_TypeError, "an integer is required");
+            return NULL;
+        }
 #if defined(HAVE_LARGEFILE_SUPPORT)
-		pos = PyLong_AsLongLong(posobj);
+        pos = PyLong_AsLongLong(posobj);
 #else
-		pos = PyLong_AsLong(posobj);
+        pos = PyLong_AsLong(posobj);
 #endif
-		if (PyErr_Occurred())
-			return NULL;
-	}
+        if (PyErr_Occurred())
+            return NULL;
+    }
 
-	if (_PyVerify_fd(fd)) {
-		Py_BEGIN_ALLOW_THREADS
+    if (_PyVerify_fd(fd)) {
+        Py_BEGIN_ALLOW_THREADS
 #if defined(MS_WIN64) || defined(MS_WINDOWS)
-		res = _lseeki64(fd, pos, whence);
+        res = _lseeki64(fd, pos, whence);
 #else
-		res = lseek(fd, pos, whence);
+        res = lseek(fd, pos, whence);
 #endif
-		Py_END_ALLOW_THREADS
-	} else
-		res = -1;
-	if (res < 0)
-		return PyErr_SetFromErrno(PyExc_IOError);
+        Py_END_ALLOW_THREADS
+    } else
+        res = -1;
+    if (res < 0)
+        return PyErr_SetFromErrno(PyExc_IOError);
 
 #if defined(HAVE_LARGEFILE_SUPPORT)
-	return PyLong_FromLongLong(res);
+    return PyLong_FromLongLong(res);
 #else
-	return PyLong_FromLong(res);
+    return PyLong_FromLong(res);
 #endif
 }
 
 static PyObject *
 fileio_seek(fileio *self, PyObject *args)
 {
-	PyObject *posobj;
-	int whence = 0;
+    PyObject *posobj;
+    int whence = 0;
 
-	if (self->fd < 0)
-		return err_closed();
+    if (self->fd < 0)
+        return err_closed();
 
-	if (!PyArg_ParseTuple(args, "O|i", &posobj, &whence))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "O|i", &posobj, &whence))
+        return NULL;
 
-	return portable_lseek(self->fd, posobj, whence);
+    return portable_lseek(self->fd, posobj, whence);
 }
 
 static PyObject *
 fileio_tell(fileio *self, PyObject *args)
 {
-	if (self->fd < 0)
-		return err_closed();
+    if (self->fd < 0)
+        return err_closed();
 
-	return portable_lseek(self->fd, NULL, 1);
+    return portable_lseek(self->fd, NULL, 1);
 }
 
 #ifdef HAVE_FTRUNCATE
 static PyObject *
 fileio_truncate(fileio *self, PyObject *args)
 {
-	PyObject *posobj = NULL; /* the new size wanted by the user */
+    PyObject *posobj = NULL; /* the new size wanted by the user */
 #ifndef MS_WINDOWS
-	Py_off_t pos;
+    Py_off_t pos;
 #endif
-	int ret;
-	int fd;
+    int ret;
+    int fd;
 
-	fd = self->fd;
-	if (fd < 0)
-		return err_closed();
-	if (!self->writable)
-		return err_mode("writing");
-
-	if (!PyArg_ParseTuple(args, "|O", &posobj))
-		return NULL;
-
-	if (posobj == Py_None || posobj == NULL) {
-		/* Get the current position. */
-		posobj = portable_lseek(fd, NULL, 1);
-		if (posobj == NULL)
-			return NULL;
-	}
-	else {
-		Py_INCREF(posobj);
-	}
+    fd = self->fd;
+    if (fd < 0)
+        return err_closed();
+    if (!self->writable)
+        return err_mode("writing");
+
+    if (!PyArg_ParseTuple(args, "|O", &posobj))
+        return NULL;
+
+    if (posobj == Py_None || posobj == NULL) {
+        /* Get the current position. */
+        posobj = portable_lseek(fd, NULL, 1);
+        if (posobj == NULL)
+            return NULL;
+    }
+    else {
+        Py_INCREF(posobj);
+    }
 
 #ifdef MS_WINDOWS
-	/* MS _chsize doesn't work if newsize doesn't fit in 32 bits,
-	   so don't even try using it. */
-	{
-		PyObject *oldposobj, *tempposobj;
-		HANDLE hFile;
-	
-		/* we save the file pointer position */
-		oldposobj = portable_lseek(fd, NULL, 1); 
-		if (oldposobj == NULL) {
-			Py_DECREF(posobj);
-			return NULL;
-		}
-
-		/* we then move to the truncation position */
-		tempposobj = portable_lseek(fd, posobj, 0);
-		if (tempposobj == NULL) {
-			Py_DECREF(oldposobj);
-			Py_DECREF(posobj);
-			return NULL;
-		}
-		Py_DECREF(tempposobj);
-
-		/* Truncate.  Note that this may grow the file! */
-		Py_BEGIN_ALLOW_THREADS
-		errno = 0;
-		hFile = (HANDLE)_get_osfhandle(fd);
-		ret = hFile == (HANDLE)-1; /* testing for INVALID_HANDLE value */
-		if (ret == 0) {
-			ret = SetEndOfFile(hFile) == 0;
-			if (ret)
-				errno = EACCES;
-		}
-		Py_END_ALLOW_THREADS
-
-		/* we restore the file pointer position in any case */
-		tempposobj = portable_lseek(fd, oldposobj, 0);
-		Py_DECREF(oldposobj);
-		if (tempposobj == NULL) {
-			Py_DECREF(posobj);
-			return NULL;
-		}
-		Py_DECREF(tempposobj);
-	}
+    /* MS _chsize doesn't work if newsize doesn't fit in 32 bits,
+       so don't even try using it. */
+    {
+        PyObject *oldposobj, *tempposobj;
+        HANDLE hFile;
+
+        /* we save the file pointer position */
+        oldposobj = portable_lseek(fd, NULL, 1);
+        if (oldposobj == NULL) {
+            Py_DECREF(posobj);
+            return NULL;
+        }
+
+        /* we then move to the truncation position */
+        tempposobj = portable_lseek(fd, posobj, 0);
+        if (tempposobj == NULL) {
+            Py_DECREF(oldposobj);
+            Py_DECREF(posobj);
+            return NULL;
+        }
+        Py_DECREF(tempposobj);
+
+        /* Truncate.  Note that this may grow the file! */
+        Py_BEGIN_ALLOW_THREADS
+        errno = 0;
+        hFile = (HANDLE)_get_osfhandle(fd);
+        ret = hFile == (HANDLE)-1; /* testing for INVALID_HANDLE value */
+        if (ret == 0) {
+            ret = SetEndOfFile(hFile) == 0;
+            if (ret)
+                errno = EACCES;
+        }
+        Py_END_ALLOW_THREADS
+
+        /* we restore the file pointer position in any case */
+        tempposobj = portable_lseek(fd, oldposobj, 0);
+        Py_DECREF(oldposobj);
+        if (tempposobj == NULL) {
+            Py_DECREF(posobj);
+            return NULL;
+        }
+        Py_DECREF(tempposobj);
+    }
 #else
 
 #if defined(HAVE_LARGEFILE_SUPPORT)
-	pos = PyLong_AsLongLong(posobj);
+    pos = PyLong_AsLongLong(posobj);
 #else
-	pos = PyLong_AsLong(posobj);
+    pos = PyLong_AsLong(posobj);
 #endif
-	if (PyErr_Occurred()){
-		Py_DECREF(posobj);
-		return NULL;
-	}
-
-	Py_BEGIN_ALLOW_THREADS
-	errno = 0;
-	ret = ftruncate(fd, pos);
-	Py_END_ALLOW_THREADS
+    if (PyErr_Occurred()){
+        Py_DECREF(posobj);
+        return NULL;
+    }
+
+    Py_BEGIN_ALLOW_THREADS
+    errno = 0;
+    ret = ftruncate(fd, pos);
+    Py_END_ALLOW_THREADS
 
 #endif /* !MS_WINDOWS */
 
-	if (ret != 0) {
-		Py_DECREF(posobj);
-		PyErr_SetFromErrno(PyExc_IOError);
-		return NULL;
-	}
+    if (ret != 0) {
+        Py_DECREF(posobj);
+        PyErr_SetFromErrno(PyExc_IOError);
+        return NULL;
+    }
 
-	return posobj;
+    return posobj;
 }
 #endif /* HAVE_FTRUNCATE */
 
 static char *
 mode_string(fileio *self)
 {
-	if (self->readable) {
-		if (self->writable)
-			return "rb+";
-		else
-			return "rb";
-	}
-	else
-		return "wb";
+    if (self->readable) {
+        if (self->writable)
+            return "rb+";
+        else
+            return "rb";
+    }
+    else
+        return "wb";
 }
 
 static PyObject *
 fileio_repr(fileio *self)
 {
-	PyObject *nameobj, *res;
+    PyObject *nameobj, *res;
 
-        if (self->fd < 0)
-		return PyUnicode_FromFormat("<_io.FileIO [closed]>");
+    if (self->fd < 0)
+        return PyUnicode_FromFormat("<_io.FileIO [closed]>");
 
-	nameobj = PyObject_GetAttrString((PyObject *) self, "name");
-	if (nameobj == NULL) {
-		if (PyErr_ExceptionMatches(PyExc_AttributeError))
-			PyErr_Clear();
-		else
-			return NULL;
-		res = PyUnicode_FromFormat("<_io.FileIO fd=%d mode='%s'>",
-					   self->fd, mode_string(self));
-	}
-	else {
-		res = PyUnicode_FromFormat("<_io.FileIO name=%R mode='%s'>",
-					   nameobj, mode_string(self));
-		Py_DECREF(nameobj);
-	}
-	return res;
+    nameobj = PyObject_GetAttrString((PyObject *) self, "name");
+    if (nameobj == NULL) {
+        if (PyErr_ExceptionMatches(PyExc_AttributeError))
+            PyErr_Clear();
+        else
+            return NULL;
+        res = PyUnicode_FromFormat("<_io.FileIO fd=%d mode='%s'>",
+                                   self->fd, mode_string(self));
+    }
+    else {
+        res = PyUnicode_FromFormat("<_io.FileIO name=%R mode='%s'>",
+                                   nameobj, mode_string(self));
+        Py_DECREF(nameobj);
+    }
+    return res;
 }
 
 static PyObject *
 fileio_isatty(fileio *self)
 {
-	long res;
+    long res;
 
-	if (self->fd < 0)
-		return err_closed();
-	Py_BEGIN_ALLOW_THREADS
-	res = isatty(self->fd);
-	Py_END_ALLOW_THREADS
-	return PyBool_FromLong(res);
+    if (self->fd < 0)
+        return err_closed();
+    Py_BEGIN_ALLOW_THREADS
+    res = isatty(self->fd);
+    Py_END_ALLOW_THREADS
+    return PyBool_FromLong(res);
 }
 
 
@@ -919,7 +919,7 @@
 "file(name: str[, mode: str]) -> file IO object\n"
 "\n"
 "Open a file.  The mode can be 'r', 'w' or 'a' for reading (default),\n"
-"writing or appending.	The file will be created if it doesn't exist\n"
+"writing or appending.  The file will be created if it doesn't exist\n"
 "when opened for writing or appending; it will be truncated when\n"
 "opened for writing.  Add a '+' to the mode to allow simultaneous\n"
 "reading and writing.");
@@ -961,14 +961,14 @@
 
 #ifdef HAVE_FTRUNCATE
 PyDoc_STRVAR(truncate_doc,
-"truncate([size: int]) -> None.	 Truncate the file to at most size bytes.\n"
+"truncate([size: int]) -> None.  Truncate the file to at most size bytes.\n"
 "\n"
 "Size defaults to the current file position, as returned by tell()."
 "The current file position is changed to the value of size.");
 #endif
 
 PyDoc_STRVAR(tell_doc,
-"tell() -> int.	 Current file position");
+"tell() -> int.  Current file position");
 
 PyDoc_STRVAR(readinto_doc,
 "readinto() -> Same as RawIOBase.readinto().");
@@ -992,22 +992,22 @@
 "writable() -> bool.  True if file was opened in a write mode.");
 
 static PyMethodDef fileio_methods[] = {
-	{"read",     (PyCFunction)fileio_read,	   METH_VARARGS, read_doc},
-	{"readall",  (PyCFunction)fileio_readall,  METH_NOARGS,  readall_doc},
-	{"readinto", (PyCFunction)fileio_readinto, METH_VARARGS, readinto_doc},
-	{"write",    (PyCFunction)fileio_write,	   METH_VARARGS, write_doc},
-	{"seek",     (PyCFunction)fileio_seek,	   METH_VARARGS, seek_doc},
-	{"tell",     (PyCFunction)fileio_tell,	   METH_VARARGS, tell_doc},
+    {"read",     (PyCFunction)fileio_read,         METH_VARARGS, read_doc},
+    {"readall",  (PyCFunction)fileio_readall,  METH_NOARGS,  readall_doc},
+    {"readinto", (PyCFunction)fileio_readinto, METH_VARARGS, readinto_doc},
+    {"write",    (PyCFunction)fileio_write,        METH_VARARGS, write_doc},
+    {"seek",     (PyCFunction)fileio_seek,         METH_VARARGS, seek_doc},
+    {"tell",     (PyCFunction)fileio_tell,         METH_VARARGS, tell_doc},
 #ifdef HAVE_FTRUNCATE
-	{"truncate", (PyCFunction)fileio_truncate, METH_VARARGS, truncate_doc},
+    {"truncate", (PyCFunction)fileio_truncate, METH_VARARGS, truncate_doc},
 #endif
-	{"close",    (PyCFunction)fileio_close,	   METH_NOARGS,	 close_doc},
-	{"seekable", (PyCFunction)fileio_seekable, METH_NOARGS,	 seekable_doc},
-	{"readable", (PyCFunction)fileio_readable, METH_NOARGS,	 readable_doc},
-	{"writable", (PyCFunction)fileio_writable, METH_NOARGS,	 writable_doc},
-	{"fileno",   (PyCFunction)fileio_fileno,   METH_NOARGS,	 fileno_doc},
-	{"isatty",   (PyCFunction)fileio_isatty,   METH_NOARGS,	 isatty_doc},
-	{NULL,	     NULL}	       /* sentinel */
+    {"close",    (PyCFunction)fileio_close,        METH_NOARGS,  close_doc},
+    {"seekable", (PyCFunction)fileio_seekable, METH_NOARGS,      seekable_doc},
+    {"readable", (PyCFunction)fileio_readable, METH_NOARGS,      readable_doc},
+    {"writable", (PyCFunction)fileio_writable, METH_NOARGS,      writable_doc},
+    {"fileno",   (PyCFunction)fileio_fileno,   METH_NOARGS,      fileno_doc},
+    {"isatty",   (PyCFunction)fileio_isatty,   METH_NOARGS,      isatty_doc},
+    {NULL,           NULL}             /* sentinel */
 };
 
 /* 'closed' and 'mode' are attributes for backwards compatibility reasons. */
@@ -1015,68 +1015,68 @@
 static PyObject *
 get_closed(fileio *self, void *closure)
 {
-	return PyBool_FromLong((long)(self->fd < 0));
+    return PyBool_FromLong((long)(self->fd < 0));
 }
 
 static PyObject *
 get_closefd(fileio *self, void *closure)
 {
-	return PyBool_FromLong((long)(self->closefd));
+    return PyBool_FromLong((long)(self->closefd));
 }
 
 static PyObject *
 get_mode(fileio *self, void *closure)
 {
-	return PyUnicode_FromString(mode_string(self));
+    return PyUnicode_FromString(mode_string(self));
 }
 
 static PyGetSetDef fileio_getsetlist[] = {
-	{"closed", (getter)get_closed, NULL, "True if the file is closed"},
-	{"closefd", (getter)get_closefd, NULL, 
-		"True if the file descriptor will be closed"},
-	{"mode", (getter)get_mode, NULL, "String giving the file mode"},
-	{NULL},
+    {"closed", (getter)get_closed, NULL, "True if the file is closed"},
+    {"closefd", (getter)get_closefd, NULL,
+        "True if the file descriptor will be closed"},
+    {"mode", (getter)get_mode, NULL, "String giving the file mode"},
+    {NULL},
 };
 
 PyTypeObject PyFileIO_Type = {
-	PyVarObject_HEAD_INIT(NULL, 0)
-	"_io.FileIO",
-	sizeof(fileio),
-	0,
-	(destructor)fileio_dealloc,		/* tp_dealloc */
-	0,					/* tp_print */
-	0,					/* tp_getattr */
-	0,					/* tp_setattr */
-	0,					/* tp_reserved */
-	(reprfunc)fileio_repr,			/* tp_repr */
-	0,					/* tp_as_number */
-	0,					/* tp_as_sequence */
-	0,					/* tp_as_mapping */
-	0,					/* tp_hash */
-	0,					/* tp_call */
-	0,					/* tp_str */
-	PyObject_GenericGetAttr,		/* tp_getattro */
-	0,					/* tp_setattro */
-	0,					/* tp_as_buffer */
-	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
-			| Py_TPFLAGS_HAVE_GC,	/* tp_flags */
-	fileio_doc,				/* tp_doc */
-	(traverseproc)fileio_traverse,		/* tp_traverse */
-	(inquiry)fileio_clear,			/* tp_clear */
-	0,					/* tp_richcompare */
-	offsetof(fileio, weakreflist),	/* tp_weaklistoffset */
-	0,					/* tp_iter */
-	0,					/* tp_iternext */
-	fileio_methods,				/* tp_methods */
-	0,					/* tp_members */
-	fileio_getsetlist,			/* tp_getset */
-	0,					/* tp_base */
-	0,					/* tp_dict */
-	0,					/* tp_descr_get */
-	0,					/* tp_descr_set */
-	offsetof(fileio, dict),         /* tp_dictoffset */
-	fileio_init,				/* tp_init */
-	PyType_GenericAlloc,			/* tp_alloc */
-	fileio_new,				/* tp_new */
-	PyObject_GC_Del,			/* tp_free */
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "_io.FileIO",
+    sizeof(fileio),
+    0,
+    (destructor)fileio_dealloc,                 /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_reserved */
+    (reprfunc)fileio_repr,                      /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    0,                                          /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    PyObject_GenericGetAttr,                    /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
+                    | Py_TPFLAGS_HAVE_GC,       /* tp_flags */
+    fileio_doc,                                 /* tp_doc */
+    (traverseproc)fileio_traverse,              /* tp_traverse */
+    (inquiry)fileio_clear,                      /* tp_clear */
+    0,                                          /* tp_richcompare */
+    offsetof(fileio, weakreflist),      /* tp_weaklistoffset */
+    0,                                          /* tp_iter */
+    0,                                          /* tp_iternext */
+    fileio_methods,                             /* tp_methods */
+    0,                                          /* tp_members */
+    fileio_getsetlist,                          /* tp_getset */
+    0,                                          /* tp_base */
+    0,                                          /* tp_dict */
+    0,                                          /* tp_descr_get */
+    0,                                          /* tp_descr_set */
+    offsetof(fileio, dict),         /* tp_dictoffset */
+    fileio_init,                                /* tp_init */
+    PyType_GenericAlloc,                        /* tp_alloc */
+    fileio_new,                                 /* tp_new */
+    PyObject_GC_Del,                            /* tp_free */
 };

Modified: python/branches/py3k-jit/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ssl.c	(original)
+++ python/branches/py3k-jit/Modules/_ssl.c	Thu May  6 23:49:27 2010
@@ -19,14 +19,14 @@
 #ifdef WITH_THREAD
 #include "pythread.h"
 #define PySSL_BEGIN_ALLOW_THREADS { \
-			PyThreadState *_save = NULL;  \
-			if (_ssl_locks_count>0) {_save = PyEval_SaveThread();}
-#define PySSL_BLOCK_THREADS	if (_ssl_locks_count>0){PyEval_RestoreThread(_save)};
-#define PySSL_UNBLOCK_THREADS	if (_ssl_locks_count>0){_save = PyEval_SaveThread()};
-#define PySSL_END_ALLOW_THREADS	if (_ssl_locks_count>0){PyEval_RestoreThread(_save);} \
-		 }
+            PyThreadState *_save = NULL;  \
+            if (_ssl_locks_count>0) {_save = PyEval_SaveThread();}
+#define PySSL_BLOCK_THREADS     if (_ssl_locks_count>0){PyEval_RestoreThread(_save)};
+#define PySSL_UNBLOCK_THREADS   if (_ssl_locks_count>0){_save = PyEval_SaveThread()};
+#define PySSL_END_ALLOW_THREADS if (_ssl_locks_count>0){PyEval_RestoreThread(_save);} \
+         }
 
-#else	/* no WITH_THREAD */
+#else   /* no WITH_THREAD */
 
 #define PySSL_BEGIN_ALLOW_THREADS
 #define PySSL_BLOCK_THREADS
@@ -36,37 +36,37 @@
 #endif
 
 enum py_ssl_error {
-	/* these mirror ssl.h */
-	PY_SSL_ERROR_NONE,
-	PY_SSL_ERROR_SSL,
-	PY_SSL_ERROR_WANT_READ,
-	PY_SSL_ERROR_WANT_WRITE,
-	PY_SSL_ERROR_WANT_X509_LOOKUP,
-	PY_SSL_ERROR_SYSCALL,     /* look at error stack/return value/errno */
-	PY_SSL_ERROR_ZERO_RETURN,
-	PY_SSL_ERROR_WANT_CONNECT,
-	/* start of non ssl.h errorcodes */
-	PY_SSL_ERROR_EOF,         /* special case of SSL_ERROR_SYSCALL */
-        PY_SSL_ERROR_NO_SOCKET,   /* socket has been GC'd */
-	PY_SSL_ERROR_INVALID_ERROR_CODE
+    /* these mirror ssl.h */
+    PY_SSL_ERROR_NONE,
+    PY_SSL_ERROR_SSL,
+    PY_SSL_ERROR_WANT_READ,
+    PY_SSL_ERROR_WANT_WRITE,
+    PY_SSL_ERROR_WANT_X509_LOOKUP,
+    PY_SSL_ERROR_SYSCALL,     /* look at error stack/return value/errno */
+    PY_SSL_ERROR_ZERO_RETURN,
+    PY_SSL_ERROR_WANT_CONNECT,
+    /* start of non ssl.h errorcodes */
+    PY_SSL_ERROR_EOF,         /* special case of SSL_ERROR_SYSCALL */
+    PY_SSL_ERROR_NO_SOCKET,   /* socket has been GC'd */
+    PY_SSL_ERROR_INVALID_ERROR_CODE
 };
 
 enum py_ssl_server_or_client {
-	PY_SSL_CLIENT,
-	PY_SSL_SERVER
+    PY_SSL_CLIENT,
+    PY_SSL_SERVER
 };
 
 enum py_ssl_cert_requirements {
-	PY_SSL_CERT_NONE,
-	PY_SSL_CERT_OPTIONAL,
-	PY_SSL_CERT_REQUIRED
+    PY_SSL_CERT_NONE,
+    PY_SSL_CERT_OPTIONAL,
+    PY_SSL_CERT_REQUIRED
 };
 
 enum py_ssl_version {
-	PY_SSL_VERSION_SSL2,
-	PY_SSL_VERSION_SSL3,
-	PY_SSL_VERSION_SSL23,
-	PY_SSL_VERSION_TLS1
+    PY_SSL_VERSION_SSL2,
+    PY_SSL_VERSION_SSL3,
+    PY_SSL_VERSION_SSL23,
+    PY_SSL_VERSION_TLS1
 };
 
 /* Include symbols from _socket module */
@@ -114,12 +114,12 @@
 #endif
 
 typedef struct {
-	PyObject_HEAD
-	PyObject        *Socket;	/* weakref to socket on which we're layered */
-	SSL_CTX*	ctx;
-	SSL*		ssl;
-	X509*		peer_cert;
-	int		shutdown_seen_zero;
+    PyObject_HEAD
+    PyObject        *Socket;            /* weakref to socket on which we're layered */
+    SSL_CTX*            ctx;
+    SSL*                ssl;
+    X509*               peer_cert;
+    int                 shutdown_seen_zero;
 
 } PySSLObject;
 
@@ -127,19 +127,19 @@
 static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args);
 static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args);
 static int check_socket_and_wait_for_timeout(PySocketSockObject *s,
-					     int writing);
+                                             int writing);
 static PyObject *PySSL_peercert(PySSLObject *self, PyObject *args);
 static PyObject *PySSL_cipher(PySSLObject *self);
 
-#define PySSLObject_Check(v)	(Py_TYPE(v) == &PySSL_Type)
+#define PySSLObject_Check(v)    (Py_TYPE(v) == &PySSL_Type)
 
 typedef enum {
-	SOCKET_IS_NONBLOCKING,
-	SOCKET_IS_BLOCKING,
-	SOCKET_HAS_TIMED_OUT,
-	SOCKET_HAS_BEEN_CLOSED,
-	SOCKET_TOO_LARGE_FOR_SELECT,
-	SOCKET_OPERATION_OK
+    SOCKET_IS_NONBLOCKING,
+    SOCKET_IS_BLOCKING,
+    SOCKET_HAS_TIMED_OUT,
+    SOCKET_HAS_BEEN_CLOSED,
+    SOCKET_TOO_LARGE_FOR_SELECT,
+    SOCKET_OPERATION_OK
 } timeout_state;
 
 /* Wrap error strings with filename and line # */
@@ -156,293 +156,293 @@
 static PyObject *
 PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
 {
-	PyObject *v;
-	char buf[2048];
-	char *errstr;
-	int err;
-	enum py_ssl_error p = PY_SSL_ERROR_NONE;
-
-	assert(ret <= 0);
-
-	if (obj->ssl != NULL) {
-		err = SSL_get_error(obj->ssl, ret);
-
-		switch (err) {
-		case SSL_ERROR_ZERO_RETURN:
-			errstr = "TLS/SSL connection has been closed";
-			p = PY_SSL_ERROR_ZERO_RETURN;
-			break;
-		case SSL_ERROR_WANT_READ:
-			errstr = "The operation did not complete (read)";
-			p = PY_SSL_ERROR_WANT_READ;
-			break;
-		case SSL_ERROR_WANT_WRITE:
-			p = PY_SSL_ERROR_WANT_WRITE;
-			errstr = "The operation did not complete (write)";
-			break;
-		case SSL_ERROR_WANT_X509_LOOKUP:
-			p = PY_SSL_ERROR_WANT_X509_LOOKUP;
-			errstr =
-                            "The operation did not complete (X509 lookup)";
-			break;
-		case SSL_ERROR_WANT_CONNECT:
-			p = PY_SSL_ERROR_WANT_CONNECT;
-			errstr = "The operation did not complete (connect)";
-			break;
-		case SSL_ERROR_SYSCALL:
-		{
-			unsigned long e = ERR_get_error();
-			if (e == 0) {
-                                PySocketSockObject *s
-                                  = (PySocketSockObject *) PyWeakref_GetObject(obj->Socket);
-				if (ret == 0 || (((PyObject *)s) == Py_None)) {
-				  p = PY_SSL_ERROR_EOF;
-				  errstr =
-                                      "EOF occurred in violation of protocol";
-				} else if (ret == -1) {
-				  /* underlying BIO reported an I/O error */
-                                  return s->errorhandler();
-				} else { /* possible? */
-                                  p = PY_SSL_ERROR_SYSCALL;
-                                  errstr = "Some I/O error occurred";
-				}
-			} else {
-				p = PY_SSL_ERROR_SYSCALL;
-				/* XXX Protected by global interpreter lock */
-				errstr = ERR_error_string(e, NULL);
-			}
-			break;
-		}
-		case SSL_ERROR_SSL:
-		{
-			unsigned long e = ERR_get_error();
-			p = PY_SSL_ERROR_SSL;
-			if (e != 0)
-				/* XXX Protected by global interpreter lock */
-				errstr = ERR_error_string(e, NULL);
-			else {	/* possible? */
-				errstr =
-                                    "A failure in the SSL library occurred";
-			}
-			break;
-		}
-		default:
-			p = PY_SSL_ERROR_INVALID_ERROR_CODE;
-			errstr = "Invalid error code";
-		}
-	} else {
-		errstr = ERR_error_string(ERR_peek_last_error(), NULL);
-	}
-	PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
-	v = Py_BuildValue("(is)", p, buf);
-	if (v != NULL) {
-		PyErr_SetObject(PySSLErrorObject, v);
-		Py_DECREF(v);
-	}
-	return NULL;
+    PyObject *v;
+    char buf[2048];
+    char *errstr;
+    int err;
+    enum py_ssl_error p = PY_SSL_ERROR_NONE;
+
+    assert(ret <= 0);
+
+    if (obj->ssl != NULL) {
+        err = SSL_get_error(obj->ssl, ret);
+
+        switch (err) {
+        case SSL_ERROR_ZERO_RETURN:
+            errstr = "TLS/SSL connection has been closed";
+            p = PY_SSL_ERROR_ZERO_RETURN;
+            break;
+        case SSL_ERROR_WANT_READ:
+            errstr = "The operation did not complete (read)";
+            p = PY_SSL_ERROR_WANT_READ;
+            break;
+        case SSL_ERROR_WANT_WRITE:
+            p = PY_SSL_ERROR_WANT_WRITE;
+            errstr = "The operation did not complete (write)";
+            break;
+        case SSL_ERROR_WANT_X509_LOOKUP:
+            p = PY_SSL_ERROR_WANT_X509_LOOKUP;
+            errstr =
+                "The operation did not complete (X509 lookup)";
+            break;
+        case SSL_ERROR_WANT_CONNECT:
+            p = PY_SSL_ERROR_WANT_CONNECT;
+            errstr = "The operation did not complete (connect)";
+            break;
+        case SSL_ERROR_SYSCALL:
+        {
+            unsigned long e = ERR_get_error();
+            if (e == 0) {
+                PySocketSockObject *s
+                  = (PySocketSockObject *) PyWeakref_GetObject(obj->Socket);
+                if (ret == 0 || (((PyObject *)s) == Py_None)) {
+                  p = PY_SSL_ERROR_EOF;
+                  errstr =
+                      "EOF occurred in violation of protocol";
+                } else if (ret == -1) {
+                  /* underlying BIO reported an I/O error */
+                  return s->errorhandler();
+                } else { /* possible? */
+                  p = PY_SSL_ERROR_SYSCALL;
+                  errstr = "Some I/O error occurred";
+                }
+            } else {
+                p = PY_SSL_ERROR_SYSCALL;
+                /* XXX Protected by global interpreter lock */
+                errstr = ERR_error_string(e, NULL);
+            }
+            break;
+        }
+        case SSL_ERROR_SSL:
+        {
+            unsigned long e = ERR_get_error();
+            p = PY_SSL_ERROR_SSL;
+            if (e != 0)
+                /* XXX Protected by global interpreter lock */
+                errstr = ERR_error_string(e, NULL);
+            else {              /* possible? */
+                errstr =
+                    "A failure in the SSL library occurred";
+            }
+            break;
+        }
+        default:
+            p = PY_SSL_ERROR_INVALID_ERROR_CODE;
+            errstr = "Invalid error code";
+        }
+    } else {
+        errstr = ERR_error_string(ERR_peek_last_error(), NULL);
+    }
+    PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
+    v = Py_BuildValue("(is)", p, buf);
+    if (v != NULL) {
+        PyErr_SetObject(PySSLErrorObject, v);
+        Py_DECREF(v);
+    }
+    return NULL;
 }
 
 static PyObject *
 _setSSLError (char *errstr, int errcode, char *filename, int lineno) {
 
-	char buf[2048];
-	PyObject *v;
+    char buf[2048];
+    PyObject *v;
 
-	if (errstr == NULL) {
-		errcode = ERR_peek_last_error();
-		errstr = ERR_error_string(errcode, NULL);
-	}
-	PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
-	v = Py_BuildValue("(is)", errcode, buf);
-	if (v != NULL) {
-		PyErr_SetObject(PySSLErrorObject, v);
-		Py_DECREF(v);
-	}
-	return NULL;
+    if (errstr == NULL) {
+        errcode = ERR_peek_last_error();
+        errstr = ERR_error_string(errcode, NULL);
+    }
+    PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
+    v = Py_BuildValue("(is)", errcode, buf);
+    if (v != NULL) {
+        PyErr_SetObject(PySSLErrorObject, v);
+        Py_DECREF(v);
+    }
+    return NULL;
 }
 
 static PySSLObject *
 newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
-	       enum py_ssl_server_or_client socket_type,
-	       enum py_ssl_cert_requirements certreq,
-	       enum py_ssl_version proto_version,
-	       char *cacerts_file, char *ciphers)
+               enum py_ssl_server_or_client socket_type,
+               enum py_ssl_cert_requirements certreq,
+               enum py_ssl_version proto_version,
+               char *cacerts_file, char *ciphers)
 {
-	PySSLObject *self;
-	char *errstr = NULL;
-	int ret;
-	int verification_mode;
-
-	self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */
-	if (self == NULL)
-		return NULL;
-	self->peer_cert = NULL;
-	self->ssl = NULL;
-	self->ctx = NULL;
-	self->Socket = NULL;
-
-	/* Make sure the SSL error state is initialized */
-	(void) ERR_get_state();
-	ERR_clear_error();
-
-	if ((key_file && !cert_file) || (!key_file && cert_file)) {
-		errstr = ERRSTR("Both the key & certificate files "
-                                "must be specified");
-		goto fail;
-	}
-
-	if ((socket_type == PY_SSL_SERVER) &&
-	    ((key_file == NULL) || (cert_file == NULL))) {
-		errstr = ERRSTR("Both the key & certificate files "
-                                "must be specified for server-side operation");
-		goto fail;
-	}
-
-	PySSL_BEGIN_ALLOW_THREADS
-	if (proto_version == PY_SSL_VERSION_TLS1)
-		self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
-	else if (proto_version == PY_SSL_VERSION_SSL3)
-		self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
-	else if (proto_version == PY_SSL_VERSION_SSL2)
-		self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
-	else if (proto_version == PY_SSL_VERSION_SSL23)
-		self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
-	PySSL_END_ALLOW_THREADS
-
-	if (self->ctx == NULL) {
-		errstr = ERRSTR("Invalid SSL protocol variant specified.");
-		goto fail;
-	}
-
-	if (ciphers != NULL) {
-		ret = SSL_CTX_set_cipher_list(self->ctx, ciphers);
-		if (ret == 0) {
-			errstr = ERRSTR("No cipher can be selected.");
-			goto fail;
-		}
-	}
-
-	if (certreq != PY_SSL_CERT_NONE) {
-		if (cacerts_file == NULL) {
-			errstr = ERRSTR("No root certificates specified for "
-                                  "verification of other-side certificates.");
-			goto fail;
-		} else {
-			PySSL_BEGIN_ALLOW_THREADS
-			ret = SSL_CTX_load_verify_locations(self->ctx,
-							    cacerts_file,
-                                                            NULL);
-			PySSL_END_ALLOW_THREADS
-			if (ret != 1) {
-				_setSSLError(NULL, 0, __FILE__, __LINE__);
-				goto fail;
-			}
-		}
-	}
-	if (key_file) {
-		PySSL_BEGIN_ALLOW_THREADS
-		ret = SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
-						  SSL_FILETYPE_PEM);
-		PySSL_END_ALLOW_THREADS
-		if (ret != 1) {
-			_setSSLError(NULL, ret, __FILE__, __LINE__);
-			goto fail;
-		}
-
-		PySSL_BEGIN_ALLOW_THREADS
-		ret = SSL_CTX_use_certificate_chain_file(self->ctx,
-							 cert_file);
-		PySSL_END_ALLOW_THREADS
-		if (ret != 1) {
-			/*
-			fprintf(stderr, "ret is %d, errcode is %lu, %lu, with file \"%s\"\n",
-				ret, ERR_peek_error(), ERR_peek_last_error(), cert_file);
-				*/
-			if (ERR_peek_last_error() != 0) {
-				_setSSLError(NULL, ret, __FILE__, __LINE__);
-				goto fail;
-			}
-		}
-	}
-
-        /* ssl compatibility */
-        SSL_CTX_set_options(self->ctx, SSL_OP_ALL);
-
-	verification_mode = SSL_VERIFY_NONE;
-	if (certreq == PY_SSL_CERT_OPTIONAL)
-		verification_mode = SSL_VERIFY_PEER;
-	else if (certreq == PY_SSL_CERT_REQUIRED)
-		verification_mode = (SSL_VERIFY_PEER |
-				     SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
-	SSL_CTX_set_verify(self->ctx, verification_mode,
-			   NULL); /* set verify lvl */
-
-	PySSL_BEGIN_ALLOW_THREADS
-	self->ssl = SSL_new(self->ctx); /* New ssl struct */
-	PySSL_END_ALLOW_THREADS
-	SSL_set_fd(self->ssl, Sock->sock_fd);	/* Set the socket for SSL */
+    PySSLObject *self;
+    char *errstr = NULL;
+    int ret;
+    int verification_mode;
+
+    self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */
+    if (self == NULL)
+        return NULL;
+    self->peer_cert = NULL;
+    self->ssl = NULL;
+    self->ctx = NULL;
+    self->Socket = NULL;
+
+    /* Make sure the SSL error state is initialized */
+    (void) ERR_get_state();
+    ERR_clear_error();
+
+    if ((key_file && !cert_file) || (!key_file && cert_file)) {
+        errstr = ERRSTR("Both the key & certificate files "
+                        "must be specified");
+        goto fail;
+    }
+
+    if ((socket_type == PY_SSL_SERVER) &&
+        ((key_file == NULL) || (cert_file == NULL))) {
+        errstr = ERRSTR("Both the key & certificate files "
+                        "must be specified for server-side operation");
+        goto fail;
+    }
+
+    PySSL_BEGIN_ALLOW_THREADS
+    if (proto_version == PY_SSL_VERSION_TLS1)
+        self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
+    else if (proto_version == PY_SSL_VERSION_SSL3)
+        self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
+    else if (proto_version == PY_SSL_VERSION_SSL2)
+        self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
+    else if (proto_version == PY_SSL_VERSION_SSL23)
+        self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
+    PySSL_END_ALLOW_THREADS
+
+    if (self->ctx == NULL) {
+        errstr = ERRSTR("Invalid SSL protocol variant specified.");
+        goto fail;
+    }
+
+    if (ciphers != NULL) {
+        ret = SSL_CTX_set_cipher_list(self->ctx, ciphers);
+        if (ret == 0) {
+            errstr = ERRSTR("No cipher can be selected.");
+            goto fail;
+        }
+    }
+
+    if (certreq != PY_SSL_CERT_NONE) {
+        if (cacerts_file == NULL) {
+            errstr = ERRSTR("No root certificates specified for "
+                      "verification of other-side certificates.");
+            goto fail;
+        } else {
+            PySSL_BEGIN_ALLOW_THREADS
+            ret = SSL_CTX_load_verify_locations(self->ctx,
+                                                cacerts_file,
+                                                NULL);
+            PySSL_END_ALLOW_THREADS
+            if (ret != 1) {
+                _setSSLError(NULL, 0, __FILE__, __LINE__);
+                goto fail;
+            }
+        }
+    }
+    if (key_file) {
+        PySSL_BEGIN_ALLOW_THREADS
+        ret = SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
+                                          SSL_FILETYPE_PEM);
+        PySSL_END_ALLOW_THREADS
+        if (ret != 1) {
+            _setSSLError(NULL, ret, __FILE__, __LINE__);
+            goto fail;
+        }
+
+        PySSL_BEGIN_ALLOW_THREADS
+        ret = SSL_CTX_use_certificate_chain_file(self->ctx,
+                                                 cert_file);
+        PySSL_END_ALLOW_THREADS
+        if (ret != 1) {
+            /*
+            fprintf(stderr, "ret is %d, errcode is %lu, %lu, with file \"%s\"\n",
+                ret, ERR_peek_error(), ERR_peek_last_error(), cert_file);
+                */
+            if (ERR_peek_last_error() != 0) {
+                _setSSLError(NULL, ret, __FILE__, __LINE__);
+                goto fail;
+            }
+        }
+    }
+
+    /* ssl compatibility */
+    SSL_CTX_set_options(self->ctx, SSL_OP_ALL);
+
+    verification_mode = SSL_VERIFY_NONE;
+    if (certreq == PY_SSL_CERT_OPTIONAL)
+        verification_mode = SSL_VERIFY_PEER;
+    else if (certreq == PY_SSL_CERT_REQUIRED)
+        verification_mode = (SSL_VERIFY_PEER |
+                             SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
+    SSL_CTX_set_verify(self->ctx, verification_mode,
+                       NULL); /* set verify lvl */
+
+    PySSL_BEGIN_ALLOW_THREADS
+    self->ssl = SSL_new(self->ctx); /* New ssl struct */
+    PySSL_END_ALLOW_THREADS
+    SSL_set_fd(self->ssl, Sock->sock_fd);       /* Set the socket for SSL */
 #ifdef SSL_MODE_AUTO_RETRY
-	SSL_set_mode(self->ssl, SSL_MODE_AUTO_RETRY);
+    SSL_set_mode(self->ssl, SSL_MODE_AUTO_RETRY);
 #endif
 
-	/* If the socket is in non-blocking mode or timeout mode, set the BIO
-	 * to non-blocking mode (blocking is the default)
-	 */
-	if (Sock->sock_timeout >= 0.0) {
-		/* Set both the read and write BIO's to non-blocking mode */
-		BIO_set_nbio(SSL_get_rbio(self->ssl), 1);
-		BIO_set_nbio(SSL_get_wbio(self->ssl), 1);
-	}
-
-	PySSL_BEGIN_ALLOW_THREADS
-	if (socket_type == PY_SSL_CLIENT)
-		SSL_set_connect_state(self->ssl);
-	else
-		SSL_set_accept_state(self->ssl);
-	PySSL_END_ALLOW_THREADS
+    /* If the socket is in non-blocking mode or timeout mode, set the BIO
+     * to non-blocking mode (blocking is the default)
+     */
+    if (Sock->sock_timeout >= 0.0) {
+        /* Set both the read and write BIO's to non-blocking mode */
+        BIO_set_nbio(SSL_get_rbio(self->ssl), 1);
+        BIO_set_nbio(SSL_get_wbio(self->ssl), 1);
+    }
+
+    PySSL_BEGIN_ALLOW_THREADS
+    if (socket_type == PY_SSL_CLIENT)
+        SSL_set_connect_state(self->ssl);
+    else
+        SSL_set_accept_state(self->ssl);
+    PySSL_END_ALLOW_THREADS
 
-	self->Socket = PyWeakref_NewRef((PyObject *) Sock, Py_None);
-	return self;
+    self->Socket = PyWeakref_NewRef((PyObject *) Sock, Py_None);
+    return self;
  fail:
-	if (errstr)
-		PyErr_SetString(PySSLErrorObject, errstr);
-	Py_DECREF(self);
-	return NULL;
+    if (errstr)
+        PyErr_SetString(PySSLErrorObject, errstr);
+    Py_DECREF(self);
+    return NULL;
 }
 
 static PyObject *
 PySSL_sslwrap(PyObject *self, PyObject *args)
 {
-	PySocketSockObject *Sock;
-	int server_side = 0;
-	int verification_mode = PY_SSL_CERT_NONE;
-	int protocol = PY_SSL_VERSION_SSL23;
-	char *key_file = NULL;
-	char *cert_file = NULL;
-	char *cacerts_file = NULL;
-	char *ciphers = NULL;
-
-	if (!PyArg_ParseTuple(args, "O!i|zziizz:sslwrap",
-			      PySocketModule.Sock_Type,
-			      &Sock,
-			      &server_side,
-			      &key_file, &cert_file,
-			      &verification_mode, &protocol,
-			      &cacerts_file, &ciphers))
-		return NULL;
-
-	/*
-	fprintf(stderr,
-		"server_side is %d, keyfile %p, certfile %p, verify_mode %d, "
-		"protocol %d, certs %p\n",
-		server_side, key_file, cert_file, verification_mode,
-		protocol, cacerts_file);
-	 */
-
-	return (PyObject *) newPySSLObject(Sock, key_file, cert_file,
-					   server_side, verification_mode,
-					   protocol, cacerts_file,
-					   ciphers);
+    PySocketSockObject *Sock;
+    int server_side = 0;
+    int verification_mode = PY_SSL_CERT_NONE;
+    int protocol = PY_SSL_VERSION_SSL23;
+    char *key_file = NULL;
+    char *cert_file = NULL;
+    char *cacerts_file = NULL;
+    char *ciphers = NULL;
+
+    if (!PyArg_ParseTuple(args, "O!i|zziizz:sslwrap",
+                          PySocketModule.Sock_Type,
+                          &Sock,
+                          &server_side,
+                          &key_file, &cert_file,
+                          &verification_mode, &protocol,
+                          &cacerts_file, &ciphers))
+        return NULL;
+
+    /*
+    fprintf(stderr,
+        "server_side is %d, keyfile %p, certfile %p, verify_mode %d, "
+        "protocol %d, certs %p\n",
+        server_side, key_file, cert_file, verification_mode,
+        protocol, cacerts_file);
+     */
+
+    return (PyObject *) newPySSLObject(Sock, key_file, cert_file,
+                                       server_side, verification_mode,
+                                       protocol, cacerts_file,
+                                       ciphers);
 }
 
 PyDoc_STRVAR(ssl_doc,
@@ -453,580 +453,580 @@
 
 static PyObject *PySSL_SSLdo_handshake(PySSLObject *self)
 {
-	int ret;
-	int err;
-	int sockstate, nonblocking;
-        PySocketSockObject *sock
-          = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
-
-	if (((PyObject*)sock) == Py_None) {
-                _setSSLError("Underlying socket connection gone",
-                             PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
-                return NULL;
-        }
-
-	/* just in case the blocking state of the socket has been changed */
-	nonblocking = (sock->sock_timeout >= 0.0);
-	BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
-	BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
-
-	/* Actually negotiate SSL connection */
-	/* XXX If SSL_do_handshake() returns 0, it's also a failure. */
-	sockstate = 0;
-	do {
-		PySSL_BEGIN_ALLOW_THREADS
-		ret = SSL_do_handshake(self->ssl);
-		err = SSL_get_error(self->ssl, ret);
-		PySSL_END_ALLOW_THREADS
-		if(PyErr_CheckSignals()) {
-			return NULL;
-		}
-		if (err == SSL_ERROR_WANT_READ) {
-			sockstate = check_socket_and_wait_for_timeout(sock, 0);
-		} else if (err == SSL_ERROR_WANT_WRITE) {
-			sockstate = check_socket_and_wait_for_timeout(sock, 1);
-		} else {
-			sockstate = SOCKET_OPERATION_OK;
-		}
-		if (sockstate == SOCKET_HAS_TIMED_OUT) {
-			PyErr_SetString(PySSLErrorObject,
-				ERRSTR("The handshake operation timed out"));
-			return NULL;
-		} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
-			PyErr_SetString(PySSLErrorObject,
-				ERRSTR("Underlying socket has been closed."));
-			return NULL;
-		} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
-			PyErr_SetString(PySSLErrorObject,
-			  ERRSTR("Underlying socket too large for select()."));
-			return NULL;
-		} else if (sockstate == SOCKET_IS_NONBLOCKING) {
-			break;
-		}
-	} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
-	if (ret < 1)
-		return PySSL_SetError(self, ret, __FILE__, __LINE__);
-	self->ssl->debug = 1;
+    int ret;
+    int err;
+    int sockstate, nonblocking;
+    PySocketSockObject *sock
+      = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
+
+    if (((PyObject*)sock) == Py_None) {
+        _setSSLError("Underlying socket connection gone",
+                     PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
+        return NULL;
+    }
 
-	if (self->peer_cert)
-		X509_free (self->peer_cert);
+    /* just in case the blocking state of the socket has been changed */
+    nonblocking = (sock->sock_timeout >= 0.0);
+    BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
+    BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
+
+    /* Actually negotiate SSL connection */
+    /* XXX If SSL_do_handshake() returns 0, it's also a failure. */
+    sockstate = 0;
+    do {
         PySSL_BEGIN_ALLOW_THREADS
-	self->peer_cert = SSL_get_peer_certificate(self->ssl);
-	PySSL_END_ALLOW_THREADS
+        ret = SSL_do_handshake(self->ssl);
+        err = SSL_get_error(self->ssl, ret);
+        PySSL_END_ALLOW_THREADS
+        if(PyErr_CheckSignals()) {
+            return NULL;
+        }
+        if (err == SSL_ERROR_WANT_READ) {
+            sockstate = check_socket_and_wait_for_timeout(sock, 0);
+        } else if (err == SSL_ERROR_WANT_WRITE) {
+            sockstate = check_socket_and_wait_for_timeout(sock, 1);
+        } else {
+            sockstate = SOCKET_OPERATION_OK;
+        }
+        if (sockstate == SOCKET_HAS_TIMED_OUT) {
+            PyErr_SetString(PySSLErrorObject,
+                ERRSTR("The handshake operation timed out"));
+            return NULL;
+        } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
+            PyErr_SetString(PySSLErrorObject,
+                ERRSTR("Underlying socket has been closed."));
+            return NULL;
+        } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
+            PyErr_SetString(PySSLErrorObject,
+              ERRSTR("Underlying socket too large for select()."));
+            return NULL;
+        } else if (sockstate == SOCKET_IS_NONBLOCKING) {
+            break;
+        }
+    } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
+    if (ret < 1)
+        return PySSL_SetError(self, ret, __FILE__, __LINE__);
+    self->ssl->debug = 1;
+
+    if (self->peer_cert)
+        X509_free (self->peer_cert);
+    PySSL_BEGIN_ALLOW_THREADS
+    self->peer_cert = SSL_get_peer_certificate(self->ssl);
+    PySSL_END_ALLOW_THREADS
 
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 _create_tuple_for_attribute (ASN1_OBJECT *name, ASN1_STRING *value) {
 
-	char namebuf[X509_NAME_MAXLEN];
-	int buflen;
-	PyObject *name_obj;
-	PyObject *value_obj;
-	PyObject *attr;
-	unsigned char *valuebuf = NULL;
-
-	buflen = OBJ_obj2txt(namebuf, sizeof(namebuf), name, 0);
-	if (buflen < 0) {
-		_setSSLError(NULL, 0, __FILE__, __LINE__);
-		goto fail;
-	}
-	name_obj = PyUnicode_FromStringAndSize(namebuf, buflen);
-	if (name_obj == NULL)
-		goto fail;
-
-	buflen = ASN1_STRING_to_UTF8(&valuebuf, value);
-	if (buflen < 0) {
-		_setSSLError(NULL, 0, __FILE__, __LINE__);
-		Py_DECREF(name_obj);
-		goto fail;
-	}
-	value_obj = PyUnicode_DecodeUTF8((char *) valuebuf,
-						 buflen, "strict");
-	OPENSSL_free(valuebuf);
-	if (value_obj == NULL) {
-		Py_DECREF(name_obj);
-		goto fail;
-	}
-	attr = PyTuple_New(2);
-	if (attr == NULL) {
-		Py_DECREF(name_obj);
-		Py_DECREF(value_obj);
-		goto fail;
-	}
-	PyTuple_SET_ITEM(attr, 0, name_obj);
-	PyTuple_SET_ITEM(attr, 1, value_obj);
-	return attr;
+    char namebuf[X509_NAME_MAXLEN];
+    int buflen;
+    PyObject *name_obj;
+    PyObject *value_obj;
+    PyObject *attr;
+    unsigned char *valuebuf = NULL;
+
+    buflen = OBJ_obj2txt(namebuf, sizeof(namebuf), name, 0);
+    if (buflen < 0) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        goto fail;
+    }
+    name_obj = PyUnicode_FromStringAndSize(namebuf, buflen);
+    if (name_obj == NULL)
+        goto fail;
+
+    buflen = ASN1_STRING_to_UTF8(&valuebuf, value);
+    if (buflen < 0) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        Py_DECREF(name_obj);
+        goto fail;
+    }
+    value_obj = PyUnicode_DecodeUTF8((char *) valuebuf,
+                                             buflen, "strict");
+    OPENSSL_free(valuebuf);
+    if (value_obj == NULL) {
+        Py_DECREF(name_obj);
+        goto fail;
+    }
+    attr = PyTuple_New(2);
+    if (attr == NULL) {
+        Py_DECREF(name_obj);
+        Py_DECREF(value_obj);
+        goto fail;
+    }
+    PyTuple_SET_ITEM(attr, 0, name_obj);
+    PyTuple_SET_ITEM(attr, 1, value_obj);
+    return attr;
 
   fail:
-	return NULL;
+    return NULL;
 }
 
 static PyObject *
 _create_tuple_for_X509_NAME (X509_NAME *xname)
 {
-	PyObject *dn = NULL;    /* tuple which represents the "distinguished name" */
-        PyObject *rdn = NULL;   /* tuple to hold a "relative distinguished name" */
-	PyObject *rdnt;
-        PyObject *attr = NULL;   /* tuple to hold an attribute */
-        int entry_count = X509_NAME_entry_count(xname);
-	X509_NAME_ENTRY *entry;
-	ASN1_OBJECT *name;
-	ASN1_STRING *value;
-	int index_counter;
-	int rdn_level = -1;
-	int retcode;
-
-        dn = PyList_New(0);
-	if (dn == NULL)
-		return NULL;
-        /* now create another tuple to hold the top-level RDN */
-        rdn = PyList_New(0);
-	if (rdn == NULL)
-		goto fail0;
-
-	for (index_counter = 0;
-	     index_counter < entry_count;
-	     index_counter++)
-	{
-		entry = X509_NAME_get_entry(xname, index_counter);
-
-		/* check to see if we've gotten to a new RDN */
-		if (rdn_level >= 0) {
-			if (rdn_level != entry->set) {
-				/* yes, new RDN */
-				/* add old RDN to DN */
-				rdnt = PyList_AsTuple(rdn);
-				Py_DECREF(rdn);
-				if (rdnt == NULL)
-					goto fail0;
-				retcode = PyList_Append(dn, rdnt);
-				Py_DECREF(rdnt);
-				if (retcode < 0)
-					goto fail0;
-				/* create new RDN */
-				rdn = PyList_New(0);
-				if (rdn == NULL)
-					goto fail0;
-			}
-		}
-		rdn_level = entry->set;
-
-		/* now add this attribute to the current RDN */
-		name = X509_NAME_ENTRY_get_object(entry);
-		value = X509_NAME_ENTRY_get_data(entry);
-		attr = _create_tuple_for_attribute(name, value);
-                /*
-                fprintf(stderr, "RDN level %d, attribute %s: %s\n",
-                        entry->set,
-                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
-                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 1)));
-                */
-		if (attr == NULL)
-			goto fail1;
-                retcode = PyList_Append(rdn, attr);
-		Py_DECREF(attr);
-		if (retcode < 0)
-			goto fail1;
-	}
-	/* now, there's typically a dangling RDN */
-	if ((rdn != NULL) && (PyList_Size(rdn) > 0)) {
-		rdnt = PyList_AsTuple(rdn);
-		Py_DECREF(rdn);
-		if (rdnt == NULL)
-			goto fail0;
-		retcode = PyList_Append(dn, rdnt);
-		Py_DECREF(rdnt);
-		if (retcode < 0)
-			goto fail0;
-	}
-
-	/* convert list to tuple */
-	rdnt = PyList_AsTuple(dn);
-	Py_DECREF(dn);
-	if (rdnt == NULL)
-		return NULL;
-	return rdnt;
+    PyObject *dn = NULL;    /* tuple which represents the "distinguished name" */
+    PyObject *rdn = NULL;   /* tuple to hold a "relative distinguished name" */
+    PyObject *rdnt;
+    PyObject *attr = NULL;   /* tuple to hold an attribute */
+    int entry_count = X509_NAME_entry_count(xname);
+    X509_NAME_ENTRY *entry;
+    ASN1_OBJECT *name;
+    ASN1_STRING *value;
+    int index_counter;
+    int rdn_level = -1;
+    int retcode;
+
+    dn = PyList_New(0);
+    if (dn == NULL)
+        return NULL;
+    /* now create another tuple to hold the top-level RDN */
+    rdn = PyList_New(0);
+    if (rdn == NULL)
+        goto fail0;
+
+    for (index_counter = 0;
+         index_counter < entry_count;
+         index_counter++)
+    {
+        entry = X509_NAME_get_entry(xname, index_counter);
+
+        /* check to see if we've gotten to a new RDN */
+        if (rdn_level >= 0) {
+            if (rdn_level != entry->set) {
+                /* yes, new RDN */
+                /* add old RDN to DN */
+                rdnt = PyList_AsTuple(rdn);
+                Py_DECREF(rdn);
+                if (rdnt == NULL)
+                    goto fail0;
+                retcode = PyList_Append(dn, rdnt);
+                Py_DECREF(rdnt);
+                if (retcode < 0)
+                    goto fail0;
+                /* create new RDN */
+                rdn = PyList_New(0);
+                if (rdn == NULL)
+                    goto fail0;
+            }
+        }
+        rdn_level = entry->set;
+
+        /* now add this attribute to the current RDN */
+        name = X509_NAME_ENTRY_get_object(entry);
+        value = X509_NAME_ENTRY_get_data(entry);
+        attr = _create_tuple_for_attribute(name, value);
+        /*
+        fprintf(stderr, "RDN level %d, attribute %s: %s\n",
+            entry->set,
+            PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
+            PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 1)));
+        */
+        if (attr == NULL)
+            goto fail1;
+        retcode = PyList_Append(rdn, attr);
+        Py_DECREF(attr);
+        if (retcode < 0)
+            goto fail1;
+    }
+    /* now, there's typically a dangling RDN */
+    if ((rdn != NULL) && (PyList_Size(rdn) > 0)) {
+        rdnt = PyList_AsTuple(rdn);
+        Py_DECREF(rdn);
+        if (rdnt == NULL)
+            goto fail0;
+        retcode = PyList_Append(dn, rdnt);
+        Py_DECREF(rdnt);
+        if (retcode < 0)
+            goto fail0;
+    }
+
+    /* convert list to tuple */
+    rdnt = PyList_AsTuple(dn);
+    Py_DECREF(dn);
+    if (rdnt == NULL)
+        return NULL;
+    return rdnt;
 
   fail1:
-	Py_XDECREF(rdn);
+    Py_XDECREF(rdn);
 
   fail0:
-	Py_XDECREF(dn);
-	return NULL;
+    Py_XDECREF(dn);
+    return NULL;
 }
 
 static PyObject *
 _get_peer_alt_names (X509 *certificate) {
 
-	/* this code follows the procedure outlined in
-	   OpenSSL's crypto/x509v3/v3_prn.c:X509v3_EXT_print()
-	   function to extract the STACK_OF(GENERAL_NAME),
-	   then iterates through the stack to add the
-	   names. */
-
-	int i, j;
-	PyObject *peer_alt_names = Py_None;
-	PyObject *v, *t;
-	X509_EXTENSION *ext = NULL;
-	GENERAL_NAMES *names = NULL;
-	GENERAL_NAME *name;
-	X509V3_EXT_METHOD *method;
-	BIO *biobuf = NULL;
-	char buf[2048];
-	char *vptr;
-	int len;
-	/* Issue #2973: ASN1_item_d2i() API changed in OpenSSL 0.9.6m */
+    /* this code follows the procedure outlined in
+       OpenSSL's crypto/x509v3/v3_prn.c:X509v3_EXT_print()
+       function to extract the STACK_OF(GENERAL_NAME),
+       then iterates through the stack to add the
+       names. */
+
+    int i, j;
+    PyObject *peer_alt_names = Py_None;
+    PyObject *v, *t;
+    X509_EXTENSION *ext = NULL;
+    GENERAL_NAMES *names = NULL;
+    GENERAL_NAME *name;
+    X509V3_EXT_METHOD *method;
+    BIO *biobuf = NULL;
+    char buf[2048];
+    char *vptr;
+    int len;
+    /* Issue #2973: ASN1_item_d2i() API changed in OpenSSL 0.9.6m */
 #if OPENSSL_VERSION_NUMBER >= 0x009060dfL
-	const unsigned char *p;
+    const unsigned char *p;
 #else
-	unsigned char *p;
+    unsigned char *p;
 #endif
 
-	if (certificate == NULL)
-		return peer_alt_names;
+    if (certificate == NULL)
+        return peer_alt_names;
+
+    /* get a memory buffer */
+    biobuf = BIO_new(BIO_s_mem());
 
-	/* get a memory buffer */
-	biobuf = BIO_new(BIO_s_mem());
+    i = 0;
+    while ((i = X509_get_ext_by_NID(
+                    certificate, NID_subject_alt_name, i)) >= 0) {
+
+        if (peer_alt_names == Py_None) {
+            peer_alt_names = PyList_New(0);
+            if (peer_alt_names == NULL)
+                goto fail;
+        }
+
+        /* now decode the altName */
+        ext = X509_get_ext(certificate, i);
+        if(!(method = X509V3_EXT_get(ext))) {
+            PyErr_SetString
+              (PySSLErrorObject,
+               ERRSTR("No method for internalizing subjectAltName!"));
+            goto fail;
+        }
 
-	i = 0;
-	while ((i = X509_get_ext_by_NID(
-			certificate, NID_subject_alt_name, i)) >= 0) {
-
-		if (peer_alt_names == Py_None) {
-                        peer_alt_names = PyList_New(0);
-                        if (peer_alt_names == NULL)
-				goto fail;
-		}
-
-		/* now decode the altName */
-		ext = X509_get_ext(certificate, i);
-		if(!(method = X509V3_EXT_get(ext))) {
-			PyErr_SetString
-                          (PySSLErrorObject,
-                           ERRSTR("No method for internalizing subjectAltName!"));
-			goto fail;
-		}
-
-		p = ext->value->data;
-		if (method->it)
-			names = (GENERAL_NAMES*)
-                          (ASN1_item_d2i(NULL,
-                                         &p,
-                                         ext->value->length,
-                                         ASN1_ITEM_ptr(method->it)));
-		else
-			names = (GENERAL_NAMES*)
-                          (method->d2i(NULL,
-                                       &p,
-                                       ext->value->length));
-
-		for(j = 0; j < sk_GENERAL_NAME_num(names); j++) {
-
-			/* get a rendering of each name in the set of names */
-
-			name = sk_GENERAL_NAME_value(names, j);
-			if (name->type == GEN_DIRNAME) {
-
-				/* we special-case DirName as a tuple of
-                                   tuples of attributes */
-
-				t = PyTuple_New(2);
-				if (t == NULL) {
-					goto fail;
-				}
-
-				v = PyUnicode_FromString("DirName");
-				if (v == NULL) {
-					Py_DECREF(t);
-					goto fail;
-				}
-				PyTuple_SET_ITEM(t, 0, v);
-
-				v = _create_tuple_for_X509_NAME (name->d.dirn);
-				if (v == NULL) {
-					Py_DECREF(t);
-					goto fail;
-				}
-				PyTuple_SET_ITEM(t, 1, v);
-
-			} else {
-
-				/* for everything else, we use the OpenSSL print form */
-
-				(void) BIO_reset(biobuf);
-				GENERAL_NAME_print(biobuf, name);
-				len = BIO_gets(biobuf, buf, sizeof(buf)-1);
-				if (len < 0) {
-					_setSSLError(NULL, 0, __FILE__, __LINE__);
-					goto fail;
-				}
-				vptr = strchr(buf, ':');
-				if (vptr == NULL)
-					goto fail;
-				t = PyTuple_New(2);
-				if (t == NULL)
-					goto fail;
-				v = PyUnicode_FromStringAndSize(buf, (vptr - buf));
-				if (v == NULL) {
-					Py_DECREF(t);
-					goto fail;
-				}
-				PyTuple_SET_ITEM(t, 0, v);
-				v = PyUnicode_FromStringAndSize((vptr + 1),
-                                                                (len - (vptr - buf + 1)));
-				if (v == NULL) {
-					Py_DECREF(t);
-					goto fail;
-				}
-				PyTuple_SET_ITEM(t, 1, v);
-			}
-
-			/* and add that rendering to the list */
-
-			if (PyList_Append(peer_alt_names, t) < 0) {
-				Py_DECREF(t);
-				goto fail;
-			}
-			Py_DECREF(t);
-		}
-	}
-	BIO_free(biobuf);
-	if (peer_alt_names != Py_None) {
-		v = PyList_AsTuple(peer_alt_names);
-		Py_DECREF(peer_alt_names);
-		return v;
-	} else {
-		return peer_alt_names;
-	}
+        p = ext->value->data;
+        if (method->it)
+            names = (GENERAL_NAMES*)
+              (ASN1_item_d2i(NULL,
+                             &p,
+                             ext->value->length,
+                             ASN1_ITEM_ptr(method->it)));
+        else
+            names = (GENERAL_NAMES*)
+              (method->d2i(NULL,
+                           &p,
+                           ext->value->length));
+
+        for(j = 0; j < sk_GENERAL_NAME_num(names); j++) {
+
+            /* get a rendering of each name in the set of names */
+
+            name = sk_GENERAL_NAME_value(names, j);
+            if (name->type == GEN_DIRNAME) {
+
+                /* we special-case DirName as a tuple of
+                   tuples of attributes */
+
+                t = PyTuple_New(2);
+                if (t == NULL) {
+                    goto fail;
+                }
+
+                v = PyUnicode_FromString("DirName");
+                if (v == NULL) {
+                    Py_DECREF(t);
+                    goto fail;
+                }
+                PyTuple_SET_ITEM(t, 0, v);
+
+                v = _create_tuple_for_X509_NAME (name->d.dirn);
+                if (v == NULL) {
+                    Py_DECREF(t);
+                    goto fail;
+                }
+                PyTuple_SET_ITEM(t, 1, v);
+
+            } else {
+
+                /* for everything else, we use the OpenSSL print form */
+
+                (void) BIO_reset(biobuf);
+                GENERAL_NAME_print(biobuf, name);
+                len = BIO_gets(biobuf, buf, sizeof(buf)-1);
+                if (len < 0) {
+                    _setSSLError(NULL, 0, __FILE__, __LINE__);
+                    goto fail;
+                }
+                vptr = strchr(buf, ':');
+                if (vptr == NULL)
+                    goto fail;
+                t = PyTuple_New(2);
+                if (t == NULL)
+                    goto fail;
+                v = PyUnicode_FromStringAndSize(buf, (vptr - buf));
+                if (v == NULL) {
+                    Py_DECREF(t);
+                    goto fail;
+                }
+                PyTuple_SET_ITEM(t, 0, v);
+                v = PyUnicode_FromStringAndSize((vptr + 1),
+                                                (len - (vptr - buf + 1)));
+                if (v == NULL) {
+                    Py_DECREF(t);
+                    goto fail;
+                }
+                PyTuple_SET_ITEM(t, 1, v);
+            }
+
+            /* and add that rendering to the list */
+
+            if (PyList_Append(peer_alt_names, t) < 0) {
+                Py_DECREF(t);
+                goto fail;
+            }
+            Py_DECREF(t);
+        }
+    }
+    BIO_free(biobuf);
+    if (peer_alt_names != Py_None) {
+        v = PyList_AsTuple(peer_alt_names);
+        Py_DECREF(peer_alt_names);
+        return v;
+    } else {
+        return peer_alt_names;
+    }
 
 
   fail:
-	if (biobuf != NULL)
-		BIO_free(biobuf);
+    if (biobuf != NULL)
+        BIO_free(biobuf);
 
-	if (peer_alt_names != Py_None) {
-		Py_XDECREF(peer_alt_names);
-	}
+    if (peer_alt_names != Py_None) {
+        Py_XDECREF(peer_alt_names);
+    }
 
-	return NULL;
+    return NULL;
 }
 
 static PyObject *
 _decode_certificate (X509 *certificate, int verbose) {
 
-	PyObject *retval = NULL;
-	BIO *biobuf = NULL;
-	PyObject *peer;
-	PyObject *peer_alt_names = NULL;
-	PyObject *issuer;
-	PyObject *version;
-	PyObject *sn_obj;
-	ASN1_INTEGER *serialNumber;
-	char buf[2048];
-	int len;
-	ASN1_TIME *notBefore, *notAfter;
-	PyObject *pnotBefore, *pnotAfter;
-
-	retval = PyDict_New();
-	if (retval == NULL)
-		return NULL;
-
-	peer = _create_tuple_for_X509_NAME(
-		X509_get_subject_name(certificate));
-	if (peer == NULL)
-		goto fail0;
-	if (PyDict_SetItemString(retval, (const char *) "subject", peer) < 0) {
-		Py_DECREF(peer);
-		goto fail0;
-	}
-	Py_DECREF(peer);
-
-	if (verbose) {
-		issuer = _create_tuple_for_X509_NAME(
-			X509_get_issuer_name(certificate));
-		if (issuer == NULL)
-			goto fail0;
-		if (PyDict_SetItemString(retval, (const char *)"issuer", issuer) < 0) {
-			Py_DECREF(issuer);
-			goto fail0;
-		}
-		Py_DECREF(issuer);
-
-		version = PyLong_FromLong(X509_get_version(certificate) + 1);
-		if (PyDict_SetItemString(retval, "version", version) < 0) {
-			Py_DECREF(version);
-			goto fail0;
-		}
-		Py_DECREF(version);
-	}
-
-	/* get a memory buffer */
-	biobuf = BIO_new(BIO_s_mem());
-
-	if (verbose) {
-
-		(void) BIO_reset(biobuf);
-		serialNumber = X509_get_serialNumber(certificate);
-		/* should not exceed 20 octets, 160 bits, so buf is big enough */
-		i2a_ASN1_INTEGER(biobuf, serialNumber);
-		len = BIO_gets(biobuf, buf, sizeof(buf)-1);
-		if (len < 0) {
-			_setSSLError(NULL, 0, __FILE__, __LINE__);
-			goto fail1;
-		}
-		sn_obj = PyUnicode_FromStringAndSize(buf, len);
-		if (sn_obj == NULL)
-			goto fail1;
-		if (PyDict_SetItemString(retval, "serialNumber", sn_obj) < 0) {
-			Py_DECREF(sn_obj);
-			goto fail1;
-		}
-		Py_DECREF(sn_obj);
-
-		(void) BIO_reset(biobuf);
-		notBefore = X509_get_notBefore(certificate);
-		ASN1_TIME_print(biobuf, notBefore);
-		len = BIO_gets(biobuf, buf, sizeof(buf)-1);
-		if (len < 0) {
-			_setSSLError(NULL, 0, __FILE__, __LINE__);
-			goto fail1;
-		}
-		pnotBefore = PyUnicode_FromStringAndSize(buf, len);
-		if (pnotBefore == NULL)
-			goto fail1;
-		if (PyDict_SetItemString(retval, "notBefore", pnotBefore) < 0) {
-			Py_DECREF(pnotBefore);
-			goto fail1;
-		}
-		Py_DECREF(pnotBefore);
-	}
-
-	(void) BIO_reset(biobuf);
-	notAfter = X509_get_notAfter(certificate);
-	ASN1_TIME_print(biobuf, notAfter);
-	len = BIO_gets(biobuf, buf, sizeof(buf)-1);
-	if (len < 0) {
-		_setSSLError(NULL, 0, __FILE__, __LINE__);
-		goto fail1;
-	}
-	pnotAfter = PyUnicode_FromStringAndSize(buf, len);
-	if (pnotAfter == NULL)
-		goto fail1;
-	if (PyDict_SetItemString(retval, "notAfter", pnotAfter) < 0) {
-		Py_DECREF(pnotAfter);
-		goto fail1;
-	}
-	Py_DECREF(pnotAfter);
-
-	/* Now look for subjectAltName */
-
-	peer_alt_names = _get_peer_alt_names(certificate);
-	if (peer_alt_names == NULL)
-		goto fail1;
-	else if (peer_alt_names != Py_None) {
-		if (PyDict_SetItemString(retval, "subjectAltName",
-					 peer_alt_names) < 0) {
-			Py_DECREF(peer_alt_names);
-			goto fail1;
-		}
-		Py_DECREF(peer_alt_names);
-	}
+    PyObject *retval = NULL;
+    BIO *biobuf = NULL;
+    PyObject *peer;
+    PyObject *peer_alt_names = NULL;
+    PyObject *issuer;
+    PyObject *version;
+    PyObject *sn_obj;
+    ASN1_INTEGER *serialNumber;
+    char buf[2048];
+    int len;
+    ASN1_TIME *notBefore, *notAfter;
+    PyObject *pnotBefore, *pnotAfter;
+
+    retval = PyDict_New();
+    if (retval == NULL)
+        return NULL;
+
+    peer = _create_tuple_for_X509_NAME(
+        X509_get_subject_name(certificate));
+    if (peer == NULL)
+        goto fail0;
+    if (PyDict_SetItemString(retval, (const char *) "subject", peer) < 0) {
+        Py_DECREF(peer);
+        goto fail0;
+    }
+    Py_DECREF(peer);
+
+    if (verbose) {
+        issuer = _create_tuple_for_X509_NAME(
+            X509_get_issuer_name(certificate));
+        if (issuer == NULL)
+            goto fail0;
+        if (PyDict_SetItemString(retval, (const char *)"issuer", issuer) < 0) {
+            Py_DECREF(issuer);
+            goto fail0;
+        }
+        Py_DECREF(issuer);
+
+        version = PyLong_FromLong(X509_get_version(certificate) + 1);
+        if (PyDict_SetItemString(retval, "version", version) < 0) {
+            Py_DECREF(version);
+            goto fail0;
+        }
+        Py_DECREF(version);
+    }
+
+    /* get a memory buffer */
+    biobuf = BIO_new(BIO_s_mem());
+
+    if (verbose) {
+
+        (void) BIO_reset(biobuf);
+        serialNumber = X509_get_serialNumber(certificate);
+        /* should not exceed 20 octets, 160 bits, so buf is big enough */
+        i2a_ASN1_INTEGER(biobuf, serialNumber);
+        len = BIO_gets(biobuf, buf, sizeof(buf)-1);
+        if (len < 0) {
+            _setSSLError(NULL, 0, __FILE__, __LINE__);
+            goto fail1;
+        }
+        sn_obj = PyUnicode_FromStringAndSize(buf, len);
+        if (sn_obj == NULL)
+            goto fail1;
+        if (PyDict_SetItemString(retval, "serialNumber", sn_obj) < 0) {
+            Py_DECREF(sn_obj);
+            goto fail1;
+        }
+        Py_DECREF(sn_obj);
+
+        (void) BIO_reset(biobuf);
+        notBefore = X509_get_notBefore(certificate);
+        ASN1_TIME_print(biobuf, notBefore);
+        len = BIO_gets(biobuf, buf, sizeof(buf)-1);
+        if (len < 0) {
+            _setSSLError(NULL, 0, __FILE__, __LINE__);
+            goto fail1;
+        }
+        pnotBefore = PyUnicode_FromStringAndSize(buf, len);
+        if (pnotBefore == NULL)
+            goto fail1;
+        if (PyDict_SetItemString(retval, "notBefore", pnotBefore) < 0) {
+            Py_DECREF(pnotBefore);
+            goto fail1;
+        }
+        Py_DECREF(pnotBefore);
+    }
 
-	BIO_free(biobuf);
-	return retval;
+    (void) BIO_reset(biobuf);
+    notAfter = X509_get_notAfter(certificate);
+    ASN1_TIME_print(biobuf, notAfter);
+    len = BIO_gets(biobuf, buf, sizeof(buf)-1);
+    if (len < 0) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        goto fail1;
+    }
+    pnotAfter = PyUnicode_FromStringAndSize(buf, len);
+    if (pnotAfter == NULL)
+        goto fail1;
+    if (PyDict_SetItemString(retval, "notAfter", pnotAfter) < 0) {
+        Py_DECREF(pnotAfter);
+        goto fail1;
+    }
+    Py_DECREF(pnotAfter);
+
+    /* Now look for subjectAltName */
+
+    peer_alt_names = _get_peer_alt_names(certificate);
+    if (peer_alt_names == NULL)
+        goto fail1;
+    else if (peer_alt_names != Py_None) {
+        if (PyDict_SetItemString(retval, "subjectAltName",
+                                 peer_alt_names) < 0) {
+            Py_DECREF(peer_alt_names);
+            goto fail1;
+        }
+        Py_DECREF(peer_alt_names);
+    }
+
+    BIO_free(biobuf);
+    return retval;
 
   fail1:
-	if (biobuf != NULL)
-		BIO_free(biobuf);
+    if (biobuf != NULL)
+        BIO_free(biobuf);
   fail0:
-	Py_XDECREF(retval);
-	return NULL;
+    Py_XDECREF(retval);
+    return NULL;
 }
 
 
 static PyObject *
 PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
 
-	PyObject *retval = NULL;
-	char *filename = NULL;
-	X509 *x=NULL;
-	BIO *cert;
-	int verbose = 1;
-
-	if (!PyArg_ParseTuple(args, "s|i:test_decode_certificate",
-                              &filename, &verbose))
-		return NULL;
-
-	if ((cert=BIO_new(BIO_s_file())) == NULL) {
-		PyErr_SetString(PySSLErrorObject,
-                                "Can't malloc memory to read file");
-		goto fail0;
-	}
-
-	if (BIO_read_filename(cert,filename) <= 0) {
-		PyErr_SetString(PySSLErrorObject,
-                                "Can't open file");
-		goto fail0;
-	}
-
-	x = PEM_read_bio_X509_AUX(cert,NULL, NULL, NULL);
-	if (x == NULL) {
-		PyErr_SetString(PySSLErrorObject,
-                                "Error decoding PEM-encoded file");
-		goto fail0;
-	}
+    PyObject *retval = NULL;
+    char *filename = NULL;
+    X509 *x=NULL;
+    BIO *cert;
+    int verbose = 1;
+
+    if (!PyArg_ParseTuple(args, "s|i:test_decode_certificate",
+                          &filename, &verbose))
+        return NULL;
+
+    if ((cert=BIO_new(BIO_s_file())) == NULL) {
+        PyErr_SetString(PySSLErrorObject,
+                        "Can't malloc memory to read file");
+        goto fail0;
+    }
+
+    if (BIO_read_filename(cert,filename) <= 0) {
+        PyErr_SetString(PySSLErrorObject,
+                        "Can't open file");
+        goto fail0;
+    }
+
+    x = PEM_read_bio_X509_AUX(cert,NULL, NULL, NULL);
+    if (x == NULL) {
+        PyErr_SetString(PySSLErrorObject,
+                        "Error decoding PEM-encoded file");
+        goto fail0;
+    }
 
-	retval = _decode_certificate(x, verbose);
+    retval = _decode_certificate(x, verbose);
 
   fail0:
 
-	if (cert != NULL) BIO_free(cert);
-	return retval;
+    if (cert != NULL) BIO_free(cert);
+    return retval;
 }
 
 
 static PyObject *
 PySSL_peercert(PySSLObject *self, PyObject *args)
 {
-	PyObject *retval = NULL;
-	int len;
-	int verification;
-	PyObject *binary_mode = Py_None;
-
-	if (!PyArg_ParseTuple(args, "|O:peer_certificate", &binary_mode))
-		return NULL;
-
-	if (!self->peer_cert)
-		Py_RETURN_NONE;
-
-	if (PyObject_IsTrue(binary_mode)) {
-		/* return cert in DER-encoded format */
-
-		unsigned char *bytes_buf = NULL;
-
-		bytes_buf = NULL;
-		len = i2d_X509(self->peer_cert, &bytes_buf);
-		if (len < 0) {
-			PySSL_SetError(self, len, __FILE__, __LINE__);
-			return NULL;
-		}
-                /* this is actually an immutable bytes sequence */
-		retval = PyBytes_FromStringAndSize
-                  ((const char *) bytes_buf, len);
-		OPENSSL_free(bytes_buf);
-		return retval;
-
-	} else {
-
-		verification = SSL_CTX_get_verify_mode(self->ctx);
-		if ((verification & SSL_VERIFY_PEER) == 0)
-			return PyDict_New();
-		else
-			return _decode_certificate (self->peer_cert, 0);
-	}
+    PyObject *retval = NULL;
+    int len;
+    int verification;
+    PyObject *binary_mode = Py_None;
+
+    if (!PyArg_ParseTuple(args, "|O:peer_certificate", &binary_mode))
+        return NULL;
+
+    if (!self->peer_cert)
+        Py_RETURN_NONE;
+
+    if (PyObject_IsTrue(binary_mode)) {
+        /* return cert in DER-encoded format */
+
+        unsigned char *bytes_buf = NULL;
+
+        bytes_buf = NULL;
+        len = i2d_X509(self->peer_cert, &bytes_buf);
+        if (len < 0) {
+            PySSL_SetError(self, len, __FILE__, __LINE__);
+            return NULL;
+        }
+        /* this is actually an immutable bytes sequence */
+        retval = PyBytes_FromStringAndSize
+          ((const char *) bytes_buf, len);
+        OPENSSL_free(bytes_buf);
+        return retval;
+
+    } else {
+
+        verification = SSL_CTX_get_verify_mode(self->ctx);
+        if ((verification & SSL_VERIFY_PEER) == 0)
+            return PyDict_New();
+        else
+            return _decode_certificate (self->peer_cert, 0);
+    }
 }
 
 PyDoc_STRVAR(PySSL_peercert_doc,
@@ -1043,60 +1043,60 @@
 
 static PyObject *PySSL_cipher (PySSLObject *self) {
 
-	PyObject *retval, *v;
-	SSL_CIPHER *current;
-	char *cipher_name;
-	char *cipher_protocol;
-
-	if (self->ssl == NULL)
-		return Py_None;
-	current = SSL_get_current_cipher(self->ssl);
-	if (current == NULL)
-		return Py_None;
-
-	retval = PyTuple_New(3);
-	if (retval == NULL)
-		return NULL;
-
-	cipher_name = (char *) SSL_CIPHER_get_name(current);
-	if (cipher_name == NULL) {
-		PyTuple_SET_ITEM(retval, 0, Py_None);
-	} else {
-		v = PyUnicode_FromString(cipher_name);
-		if (v == NULL)
-			goto fail0;
-		PyTuple_SET_ITEM(retval, 0, v);
-	}
-	cipher_protocol = SSL_CIPHER_get_version(current);
-	if (cipher_protocol == NULL) {
-		PyTuple_SET_ITEM(retval, 1, Py_None);
-	} else {
-		v = PyUnicode_FromString(cipher_protocol);
-		if (v == NULL)
-			goto fail0;
-		PyTuple_SET_ITEM(retval, 1, v);
-	}
-	v = PyLong_FromLong(SSL_CIPHER_get_bits(current, NULL));
-	if (v == NULL)
-		goto fail0;
-	PyTuple_SET_ITEM(retval, 2, v);
-	return retval;
+    PyObject *retval, *v;
+    SSL_CIPHER *current;
+    char *cipher_name;
+    char *cipher_protocol;
+
+    if (self->ssl == NULL)
+        return Py_None;
+    current = SSL_get_current_cipher(self->ssl);
+    if (current == NULL)
+        return Py_None;
+
+    retval = PyTuple_New(3);
+    if (retval == NULL)
+        return NULL;
+
+    cipher_name = (char *) SSL_CIPHER_get_name(current);
+    if (cipher_name == NULL) {
+        PyTuple_SET_ITEM(retval, 0, Py_None);
+    } else {
+        v = PyUnicode_FromString(cipher_name);
+        if (v == NULL)
+            goto fail0;
+        PyTuple_SET_ITEM(retval, 0, v);
+    }
+    cipher_protocol = SSL_CIPHER_get_version(current);
+    if (cipher_protocol == NULL) {
+        PyTuple_SET_ITEM(retval, 1, Py_None);
+    } else {
+        v = PyUnicode_FromString(cipher_protocol);
+        if (v == NULL)
+            goto fail0;
+        PyTuple_SET_ITEM(retval, 1, v);
+    }
+    v = PyLong_FromLong(SSL_CIPHER_get_bits(current, NULL));
+    if (v == NULL)
+        goto fail0;
+    PyTuple_SET_ITEM(retval, 2, v);
+    return retval;
 
   fail0:
-	Py_DECREF(retval);
-	return NULL;
+    Py_DECREF(retval);
+    return NULL;
 }
 
 static void PySSL_dealloc(PySSLObject *self)
 {
-	if (self->peer_cert)	/* Possible not to have one? */
-		X509_free (self->peer_cert);
-	if (self->ssl)
-		SSL_free(self->ssl);
-	if (self->ctx)
-		SSL_CTX_free(self->ctx);
-	Py_XDECREF(self->Socket);
-	PyObject_Del(self);
+    if (self->peer_cert)        /* Possible not to have one? */
+        X509_free (self->peer_cert);
+    if (self->ssl)
+        SSL_free(self->ssl);
+    if (self->ctx)
+        SSL_CTX_free(self->ctx);
+    Py_XDECREF(self->Socket);
+    PyObject_Del(self);
 }
 
 /* If the socket has a timeout, do a select()/poll() on the socket.
@@ -1107,146 +1107,146 @@
 static int
 check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing)
 {
-	fd_set fds;
-	struct timeval tv;
-	int rc;
-
-	/* Nothing to do unless we're in timeout mode (not non-blocking) */
-	if (s->sock_timeout < 0.0)
-		return SOCKET_IS_BLOCKING;
-	else if (s->sock_timeout == 0.0)
-		return SOCKET_IS_NONBLOCKING;
-
-	/* Guard against closed socket */
-	if (s->sock_fd < 0)
-		return SOCKET_HAS_BEEN_CLOSED;
+    fd_set fds;
+    struct timeval tv;
+    int rc;
+
+    /* Nothing to do unless we're in timeout mode (not non-blocking) */
+    if (s->sock_timeout < 0.0)
+        return SOCKET_IS_BLOCKING;
+    else if (s->sock_timeout == 0.0)
+        return SOCKET_IS_NONBLOCKING;
+
+    /* Guard against closed socket */
+    if (s->sock_fd < 0)
+        return SOCKET_HAS_BEEN_CLOSED;
 
-	/* Prefer poll, if available, since you can poll() any fd
-	 * which can't be done with select(). */
+    /* Prefer poll, if available, since you can poll() any fd
+     * which can't be done with select(). */
 #ifdef HAVE_POLL
-	{
-		struct pollfd pollfd;
-		int timeout;
-
-		pollfd.fd = s->sock_fd;
-		pollfd.events = writing ? POLLOUT : POLLIN;
-
-		/* s->sock_timeout is in seconds, timeout in ms */
-		timeout = (int)(s->sock_timeout * 1000 + 0.5);
-		PySSL_BEGIN_ALLOW_THREADS
-		rc = poll(&pollfd, 1, timeout);
-		PySSL_END_ALLOW_THREADS
+    {
+        struct pollfd pollfd;
+        int timeout;
+
+        pollfd.fd = s->sock_fd;
+        pollfd.events = writing ? POLLOUT : POLLIN;
 
-		goto normal_return;
-	}
+        /* s->sock_timeout is in seconds, timeout in ms */
+        timeout = (int)(s->sock_timeout * 1000 + 0.5);
+        PySSL_BEGIN_ALLOW_THREADS
+        rc = poll(&pollfd, 1, timeout);
+        PySSL_END_ALLOW_THREADS
+
+        goto normal_return;
+    }
 #endif
 
-	/* Guard against socket too large for select*/
+    /* Guard against socket too large for select*/
 #ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
-	if (s->sock_fd >= FD_SETSIZE)
-		return SOCKET_TOO_LARGE_FOR_SELECT;
+    if (s->sock_fd >= FD_SETSIZE)
+        return SOCKET_TOO_LARGE_FOR_SELECT;
 #endif
 
-	/* Construct the arguments to select */
-	tv.tv_sec = (int)s->sock_timeout;
-	tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
-	FD_ZERO(&fds);
-	FD_SET(s->sock_fd, &fds);
-
-	/* See if the socket is ready */
-	PySSL_BEGIN_ALLOW_THREADS
-	if (writing)
-		rc = select(s->sock_fd+1, NULL, &fds, NULL, &tv);
-	else
-		rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
-	PySSL_END_ALLOW_THREADS
+    /* Construct the arguments to select */
+    tv.tv_sec = (int)s->sock_timeout;
+    tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
+    FD_ZERO(&fds);
+    FD_SET(s->sock_fd, &fds);
+
+    /* See if the socket is ready */
+    PySSL_BEGIN_ALLOW_THREADS
+    if (writing)
+        rc = select(s->sock_fd+1, NULL, &fds, NULL, &tv);
+    else
+        rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
+    PySSL_END_ALLOW_THREADS
 
 #ifdef HAVE_POLL
 normal_return:
 #endif
-	/* Return SOCKET_TIMED_OUT on timeout, SOCKET_OPERATION_OK otherwise
-	   (when we are able to write or when there's something to read) */
-	return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK;
+    /* Return SOCKET_TIMED_OUT on timeout, SOCKET_OPERATION_OK otherwise
+       (when we are able to write or when there's something to read) */
+    return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK;
 }
 
 static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args)
 {
-	Py_buffer buf;
-	int len;
-	int sockstate;
-	int err;
-        int nonblocking;
-        PySocketSockObject *sock
-          = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
-
-        if (((PyObject*)sock) == Py_None) {
-                _setSSLError("Underlying socket connection gone",
-                             PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
-                return NULL;
-        }
-
-	if (!PyArg_ParseTuple(args, "y*:write", &buf))
-		return NULL;
-
-        /* just in case the blocking state of the socket has been changed */
-	nonblocking = (sock->sock_timeout >= 0.0);
-        BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
-        BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
-
-	sockstate = check_socket_and_wait_for_timeout(sock, 1);
-	if (sockstate == SOCKET_HAS_TIMED_OUT) {
-		PyErr_SetString(PySSLErrorObject,
-                                "The write operation timed out");
-		goto error;
-	} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
-		PyErr_SetString(PySSLErrorObject,
-                                "Underlying socket has been closed.");
-		goto error;
-	} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
-		PyErr_SetString(PySSLErrorObject,
-                                "Underlying socket too large for select().");
-		goto error;
-	}
-	do {
-		err = 0;
-		PySSL_BEGIN_ALLOW_THREADS
-		len = SSL_write(self->ssl, buf.buf, buf.len);
-		err = SSL_get_error(self->ssl, len);
-		PySSL_END_ALLOW_THREADS
-		if (PyErr_CheckSignals()) {
-			goto error;
-		}
-		if (err == SSL_ERROR_WANT_READ) {
-			sockstate =
-                            check_socket_and_wait_for_timeout(sock, 0);
-		} else if (err == SSL_ERROR_WANT_WRITE) {
-			sockstate =
-                            check_socket_and_wait_for_timeout(sock, 1);
-		} else {
-			sockstate = SOCKET_OPERATION_OK;
-		}
-		if (sockstate == SOCKET_HAS_TIMED_OUT) {
-			PyErr_SetString(PySSLErrorObject,
-                                        "The write operation timed out");
-			goto error;
-		} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
-			PyErr_SetString(PySSLErrorObject,
-                                        "Underlying socket has been closed.");
-			goto error;
-		} else if (sockstate == SOCKET_IS_NONBLOCKING) {
-			break;
-		}
-	} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
-
-	PyBuffer_Release(&buf);
-	if (len > 0)
-		return PyLong_FromLong(len);
-	else
-		return PySSL_SetError(self, len, __FILE__, __LINE__);
+    Py_buffer buf;
+    int len;
+    int sockstate;
+    int err;
+    int nonblocking;
+    PySocketSockObject *sock
+      = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
+
+    if (((PyObject*)sock) == Py_None) {
+        _setSSLError("Underlying socket connection gone",
+                     PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
+        return NULL;
+    }
+
+    if (!PyArg_ParseTuple(args, "y*:write", &buf))
+        return NULL;
+
+    /* just in case the blocking state of the socket has been changed */
+    nonblocking = (sock->sock_timeout >= 0.0);
+    BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
+    BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
+
+    sockstate = check_socket_and_wait_for_timeout(sock, 1);
+    if (sockstate == SOCKET_HAS_TIMED_OUT) {
+        PyErr_SetString(PySSLErrorObject,
+                        "The write operation timed out");
+        goto error;
+    } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
+        PyErr_SetString(PySSLErrorObject,
+                        "Underlying socket has been closed.");
+        goto error;
+    } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
+        PyErr_SetString(PySSLErrorObject,
+                        "Underlying socket too large for select().");
+        goto error;
+    }
+    do {
+        err = 0;
+        PySSL_BEGIN_ALLOW_THREADS
+        len = SSL_write(self->ssl, buf.buf, buf.len);
+        err = SSL_get_error(self->ssl, len);
+        PySSL_END_ALLOW_THREADS
+        if (PyErr_CheckSignals()) {
+            goto error;
+        }
+        if (err == SSL_ERROR_WANT_READ) {
+            sockstate =
+                check_socket_and_wait_for_timeout(sock, 0);
+        } else if (err == SSL_ERROR_WANT_WRITE) {
+            sockstate =
+                check_socket_and_wait_for_timeout(sock, 1);
+        } else {
+            sockstate = SOCKET_OPERATION_OK;
+        }
+        if (sockstate == SOCKET_HAS_TIMED_OUT) {
+            PyErr_SetString(PySSLErrorObject,
+                            "The write operation timed out");
+            goto error;
+        } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
+            PyErr_SetString(PySSLErrorObject,
+                            "Underlying socket has been closed.");
+            goto error;
+        } else if (sockstate == SOCKET_IS_NONBLOCKING) {
+            break;
+        }
+    } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
+
+    PyBuffer_Release(&buf);
+    if (len > 0)
+        return PyLong_FromLong(len);
+    else
+        return PySSL_SetError(self, len, __FILE__, __LINE__);
 
 error:
-	PyBuffer_Release(&buf);
-	return NULL;
+    PyBuffer_Release(&buf);
+    return NULL;
 }
 
 PyDoc_STRVAR(PySSL_SSLwrite_doc,
@@ -1257,15 +1257,15 @@
 
 static PyObject *PySSL_SSLpending(PySSLObject *self)
 {
-	int count = 0;
+    int count = 0;
 
-	PySSL_BEGIN_ALLOW_THREADS
-	count = SSL_pending(self->ssl);
-	PySSL_END_ALLOW_THREADS
-	if (count < 0)
-		return PySSL_SetError(self, count, __FILE__, __LINE__);
-	else
-		return PyLong_FromLong(count);
+    PySSL_BEGIN_ALLOW_THREADS
+    count = SSL_pending(self->ssl);
+    PySSL_END_ALLOW_THREADS
+    if (count < 0)
+        return PySSL_SetError(self, count, __FILE__, __LINE__);
+    else
+        return PyLong_FromLong(count);
 }
 
 PyDoc_STRVAR(PySSL_SSLpending_doc,
@@ -1276,122 +1276,122 @@
 
 static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
 {
-	PyObject *dest = NULL;
-	Py_buffer buf;
-	int buf_passed = 0;
-	int count = -1;
-	char *mem;
-	/* XXX this should use Py_ssize_t */
-	int len = 1024;
-	int sockstate;
-	int err;
-        int nonblocking;
-        PySocketSockObject *sock
-          = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
-
-        if (((PyObject*)sock) == Py_None) {
-                _setSSLError("Underlying socket connection gone",
-                             PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
-                return NULL;
-        }
-
-	if (!PyArg_ParseTuple(args, "|Oi:read", &dest, &count))
-		return NULL;
-        if ((dest == NULL) || (dest == Py_None)) {
-		if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
-			return NULL;
-		mem = PyByteArray_AS_STRING(dest);
-        } else if (PyLong_Check(dest)) {
-		len = PyLong_AS_LONG(dest);
-		if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
-			return NULL;
-		mem = PyByteArray_AS_STRING(dest);
-	} else {
-		if (PyObject_GetBuffer(dest, &buf, PyBUF_CONTIG) < 0)
-			return NULL;
-		mem = buf.buf;
-		len = buf.len;
-		if ((count > 0) && (count <= len))
-			len = count;
-		buf_passed = 1;
-	}
-
-        /* just in case the blocking state of the socket has been changed */
-	nonblocking = (sock->sock_timeout >= 0.0);
-        BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
-        BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
-
-	/* first check if there are bytes ready to be read */
-	PySSL_BEGIN_ALLOW_THREADS
-	count = SSL_pending(self->ssl);
-	PySSL_END_ALLOW_THREADS
-
-	if (!count) {
-		sockstate = check_socket_and_wait_for_timeout(sock, 0);
-		if (sockstate == SOCKET_HAS_TIMED_OUT) {
-			PyErr_SetString(PySSLErrorObject,
-					"The read operation timed out");
-			goto error;
-		} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
-			PyErr_SetString(PySSLErrorObject,
-				"Underlying socket too large for select().");
-			goto error;
-		} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
-			count = 0;
-			goto done;
-		}
-	}
-	do {
-		err = 0;
-		PySSL_BEGIN_ALLOW_THREADS
-		count = SSL_read(self->ssl, mem, len);
-		err = SSL_get_error(self->ssl, count);
-		PySSL_END_ALLOW_THREADS
-		if (PyErr_CheckSignals())
-			goto error;
-		if (err == SSL_ERROR_WANT_READ) {
-			sockstate =
-			  check_socket_and_wait_for_timeout(sock, 0);
-		} else if (err == SSL_ERROR_WANT_WRITE) {
-			sockstate =
-			  check_socket_and_wait_for_timeout(sock, 1);
-		} else if ((err == SSL_ERROR_ZERO_RETURN) &&
-			   (SSL_get_shutdown(self->ssl) ==
-			    SSL_RECEIVED_SHUTDOWN))
-		{
-			count = 0;
-			goto done;
-		} else {
-			sockstate = SOCKET_OPERATION_OK;
-		}
-		if (sockstate == SOCKET_HAS_TIMED_OUT) {
-			PyErr_SetString(PySSLErrorObject,
-					"The read operation timed out");
-			goto error;
-		} else if (sockstate == SOCKET_IS_NONBLOCKING) {
-			break;
-		}
-	} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
-	if (count <= 0) {
-		PySSL_SetError(self, count, __FILE__, __LINE__);
-		goto error;
-	}
+    PyObject *dest = NULL;
+    Py_buffer buf;
+    int buf_passed = 0;
+    int count = -1;
+    char *mem;
+    /* XXX this should use Py_ssize_t */
+    int len = 1024;
+    int sockstate;
+    int err;
+    int nonblocking;
+    PySocketSockObject *sock
+      = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
+
+    if (((PyObject*)sock) == Py_None) {
+        _setSSLError("Underlying socket connection gone",
+                     PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
+        return NULL;
+    }
+
+    if (!PyArg_ParseTuple(args, "|Oi:read", &dest, &count))
+        return NULL;
+    if ((dest == NULL) || (dest == Py_None)) {
+        if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
+            return NULL;
+        mem = PyByteArray_AS_STRING(dest);
+    } else if (PyLong_Check(dest)) {
+        len = PyLong_AS_LONG(dest);
+        if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
+            return NULL;
+        mem = PyByteArray_AS_STRING(dest);
+    } else {
+        if (PyObject_GetBuffer(dest, &buf, PyBUF_CONTIG) < 0)
+            return NULL;
+        mem = buf.buf;
+        len = buf.len;
+        if ((count > 0) && (count <= len))
+            len = count;
+        buf_passed = 1;
+    }
+
+    /* just in case the blocking state of the socket has been changed */
+    nonblocking = (sock->sock_timeout >= 0.0);
+    BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
+    BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
+
+    /* first check if there are bytes ready to be read */
+    PySSL_BEGIN_ALLOW_THREADS
+    count = SSL_pending(self->ssl);
+    PySSL_END_ALLOW_THREADS
+
+    if (!count) {
+        sockstate = check_socket_and_wait_for_timeout(sock, 0);
+        if (sockstate == SOCKET_HAS_TIMED_OUT) {
+            PyErr_SetString(PySSLErrorObject,
+                            "The read operation timed out");
+            goto error;
+        } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
+            PyErr_SetString(PySSLErrorObject,
+                "Underlying socket too large for select().");
+            goto error;
+        } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
+            count = 0;
+            goto done;
+        }
+    }
+    do {
+        err = 0;
+        PySSL_BEGIN_ALLOW_THREADS
+        count = SSL_read(self->ssl, mem, len);
+        err = SSL_get_error(self->ssl, count);
+        PySSL_END_ALLOW_THREADS
+        if (PyErr_CheckSignals())
+            goto error;
+        if (err == SSL_ERROR_WANT_READ) {
+            sockstate =
+              check_socket_and_wait_for_timeout(sock, 0);
+        } else if (err == SSL_ERROR_WANT_WRITE) {
+            sockstate =
+              check_socket_and_wait_for_timeout(sock, 1);
+        } else if ((err == SSL_ERROR_ZERO_RETURN) &&
+                   (SSL_get_shutdown(self->ssl) ==
+                    SSL_RECEIVED_SHUTDOWN))
+        {
+            count = 0;
+            goto done;
+        } else {
+            sockstate = SOCKET_OPERATION_OK;
+        }
+        if (sockstate == SOCKET_HAS_TIMED_OUT) {
+            PyErr_SetString(PySSLErrorObject,
+                            "The read operation timed out");
+            goto error;
+        } else if (sockstate == SOCKET_IS_NONBLOCKING) {
+            break;
+        }
+    } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
+    if (count <= 0) {
+        PySSL_SetError(self, count, __FILE__, __LINE__);
+        goto error;
+    }
   done:
-	if (!buf_passed) {
-		PyObject *res = PyBytes_FromStringAndSize(mem, count);
-		Py_DECREF(dest);
-		return res;
-	} else {
-		PyBuffer_Release(&buf);
-		return PyLong_FromLong(count);
-	}
+    if (!buf_passed) {
+        PyObject *res = PyBytes_FromStringAndSize(mem, count);
+        Py_DECREF(dest);
+        return res;
+    } else {
+        PyBuffer_Release(&buf);
+        return PyLong_FromLong(count);
+    }
   error:
-	if (!buf_passed) {
-		Py_DECREF(dest);
-	} else {
-		PyBuffer_Release(&buf);
-	}
-	return NULL;
+    if (!buf_passed) {
+        Py_DECREF(dest);
+    } else {
+        PyBuffer_Release(&buf);
+    }
+    return NULL;
 }
 
 PyDoc_STRVAR(PySSL_SSLread_doc,
@@ -1401,84 +1401,84 @@
 
 static PyObject *PySSL_SSLshutdown(PySSLObject *self)
 {
-	int err, ssl_err, sockstate, nonblocking;
-	int zeros = 0;
-        PySocketSockObject *sock
-          = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
-
-	/* Guard against closed socket */
-        if ((((PyObject*)sock) == Py_None) || (sock->sock_fd < 0)) {
-                _setSSLError("Underlying socket connection gone",
-                             PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
-                return NULL;
-        }
-
-        /* Just in case the blocking state of the socket has been changed */
-	nonblocking = (sock->sock_timeout >= 0.0);
-	BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
-	BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
-
-	while (1) {
-		PySSL_BEGIN_ALLOW_THREADS
-		/* Disable read-ahead so that unwrap can work correctly.
-		 * Otherwise OpenSSL might read in too much data,
-		 * eating clear text data that happens to be
-		 * transmitted after the SSL shutdown.
-		 * Should be safe to call repeatedly everytime this
-		 * function is used and the shutdown_seen_zero != 0
-		 * condition is met.
-		 */
-		if (self->shutdown_seen_zero)
-			SSL_set_read_ahead(self->ssl, 0);
-		err = SSL_shutdown(self->ssl);
-		PySSL_END_ALLOW_THREADS
-		/* If err == 1, a secure shutdown with SSL_shutdown() is complete */
-		if (err > 0)
-			break;
-		if (err == 0) {
-			/* Don't loop endlessly; instead preserve legacy
-			   behaviour of trying SSL_shutdown() only twice.
-			   This looks necessary for OpenSSL < 0.9.8m */
-			if (++zeros > 1)
-				break;
-			/* Shutdown was sent, now try receiving */
-			self->shutdown_seen_zero = 1;
-			continue;
-		}
-
-		/* Possibly retry shutdown until timeout or failure */
-		ssl_err = SSL_get_error(self->ssl, err);
-		if (ssl_err == SSL_ERROR_WANT_READ)
-			sockstate = check_socket_and_wait_for_timeout(sock, 0);
-		else if (ssl_err == SSL_ERROR_WANT_WRITE)
-			sockstate = check_socket_and_wait_for_timeout(sock, 1);
-		else
-			break;
-		if (sockstate == SOCKET_HAS_TIMED_OUT) {
-			if (ssl_err == SSL_ERROR_WANT_READ)
-				PyErr_SetString(PySSLErrorObject,
-		                                "The read operation timed out");
-			else
-				PyErr_SetString(PySSLErrorObject,
-		                                "The write operation timed out");
-			return NULL;
-		}
-		else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
-			PyErr_SetString(PySSLErrorObject,
-	                                "Underlying socket too large for select().");
-			return NULL;
-		}
-		else if (sockstate != SOCKET_OPERATION_OK)
-			/* Retain the SSL error code */
-			break;
-	}
-
-	if (err < 0)
-		return PySSL_SetError(self, err, __FILE__, __LINE__);
-	else {
-                Py_INCREF(sock);
-                return (PyObject *) sock;
-	}
+    int err, ssl_err, sockstate, nonblocking;
+    int zeros = 0;
+    PySocketSockObject *sock
+      = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
+
+    /* Guard against closed socket */
+    if ((((PyObject*)sock) == Py_None) || (sock->sock_fd < 0)) {
+        _setSSLError("Underlying socket connection gone",
+                     PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__);
+        return NULL;
+    }
+
+    /* Just in case the blocking state of the socket has been changed */
+    nonblocking = (sock->sock_timeout >= 0.0);
+    BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking);
+    BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking);
+
+    while (1) {
+        PySSL_BEGIN_ALLOW_THREADS
+        /* Disable read-ahead so that unwrap can work correctly.
+         * Otherwise OpenSSL might read in too much data,
+         * eating clear text data that happens to be
+         * transmitted after the SSL shutdown.
+         * Should be safe to call repeatedly everytime this
+         * function is used and the shutdown_seen_zero != 0
+         * condition is met.
+         */
+        if (self->shutdown_seen_zero)
+            SSL_set_read_ahead(self->ssl, 0);
+        err = SSL_shutdown(self->ssl);
+        PySSL_END_ALLOW_THREADS
+        /* If err == 1, a secure shutdown with SSL_shutdown() is complete */
+        if (err > 0)
+            break;
+        if (err == 0) {
+            /* Don't loop endlessly; instead preserve legacy
+               behaviour of trying SSL_shutdown() only twice.
+               This looks necessary for OpenSSL < 0.9.8m */
+            if (++zeros > 1)
+                break;
+            /* Shutdown was sent, now try receiving */
+            self->shutdown_seen_zero = 1;
+            continue;
+        }
+
+        /* Possibly retry shutdown until timeout or failure */
+        ssl_err = SSL_get_error(self->ssl, err);
+        if (ssl_err == SSL_ERROR_WANT_READ)
+            sockstate = check_socket_and_wait_for_timeout(sock, 0);
+        else if (ssl_err == SSL_ERROR_WANT_WRITE)
+            sockstate = check_socket_and_wait_for_timeout(sock, 1);
+        else
+            break;
+        if (sockstate == SOCKET_HAS_TIMED_OUT) {
+            if (ssl_err == SSL_ERROR_WANT_READ)
+                PyErr_SetString(PySSLErrorObject,
+                                "The read operation timed out");
+            else
+                PyErr_SetString(PySSLErrorObject,
+                                "The write operation timed out");
+            return NULL;
+        }
+        else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
+            PyErr_SetString(PySSLErrorObject,
+                            "Underlying socket too large for select().");
+            return NULL;
+        }
+        else if (sockstate != SOCKET_OPERATION_OK)
+            /* Retain the SSL error code */
+            break;
+    }
+
+    if (err < 0)
+        return PySSL_SetError(self, err, __FILE__, __LINE__);
+    else {
+        Py_INCREF(sock);
+        return (PyObject *) sock;
+    }
 }
 
 PyDoc_STRVAR(PySSL_SSLshutdown_doc,
@@ -1489,51 +1489,51 @@
 
 
 static PyMethodDef PySSLMethods[] = {
-	{"do_handshake", (PyCFunction)PySSL_SSLdo_handshake, METH_NOARGS},
-	{"write", (PyCFunction)PySSL_SSLwrite, METH_VARARGS,
-	 PySSL_SSLwrite_doc},
-	{"read", (PyCFunction)PySSL_SSLread, METH_VARARGS,
-	 PySSL_SSLread_doc},
-	{"pending", (PyCFunction)PySSL_SSLpending, METH_NOARGS,
-	 PySSL_SSLpending_doc},
-	{"peer_certificate", (PyCFunction)PySSL_peercert, METH_VARARGS,
-	 PySSL_peercert_doc},
-	{"cipher", (PyCFunction)PySSL_cipher, METH_NOARGS},
-	{"shutdown", (PyCFunction)PySSL_SSLshutdown, METH_NOARGS,
-	 PySSL_SSLshutdown_doc},
-	{NULL, NULL}
+    {"do_handshake", (PyCFunction)PySSL_SSLdo_handshake, METH_NOARGS},
+    {"write", (PyCFunction)PySSL_SSLwrite, METH_VARARGS,
+     PySSL_SSLwrite_doc},
+    {"read", (PyCFunction)PySSL_SSLread, METH_VARARGS,
+     PySSL_SSLread_doc},
+    {"pending", (PyCFunction)PySSL_SSLpending, METH_NOARGS,
+     PySSL_SSLpending_doc},
+    {"peer_certificate", (PyCFunction)PySSL_peercert, METH_VARARGS,
+     PySSL_peercert_doc},
+    {"cipher", (PyCFunction)PySSL_cipher, METH_NOARGS},
+    {"shutdown", (PyCFunction)PySSL_SSLshutdown, METH_NOARGS,
+     PySSL_SSLshutdown_doc},
+    {NULL, NULL}
 };
 
 static PyTypeObject PySSL_Type = {
-	PyVarObject_HEAD_INIT(NULL, 0)
-	"ssl.SSLContext",		/*tp_name*/
-	sizeof(PySSLObject),		/*tp_basicsize*/
-	0,				/*tp_itemsize*/
-	/* methods */
-	(destructor)PySSL_dealloc,	/*tp_dealloc*/
-	0,				/*tp_print*/
-	0,				/*tp_getattr*/
-	0,				/*tp_setattr*/
-	0,				/*tp_reserved*/
-	0,				/*tp_repr*/
-	0,				/*tp_as_number*/
-	0,				/*tp_as_sequence*/
-	0,				/*tp_as_mapping*/
-	0,				/*tp_hash*/
-	0,				/*tp_call*/
-	0,				/*tp_str*/
-	0,				/*tp_getattro*/
-	0,				/*tp_setattro*/
-	0,				/*tp_as_buffer*/
-	Py_TPFLAGS_DEFAULT,		/*tp_flags*/
-	0,				/*tp_doc*/
-	0,				/*tp_traverse*/
-	0,				/*tp_clear*/
-	0,				/*tp_richcompare*/
-	0,				/*tp_weaklistoffset*/
-	0,				/*tp_iter*/
-	0,				/*tp_iternext*/
-	PySSLMethods,			/*tp_methods*/
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "ssl.SSLContext",                   /*tp_name*/
+    sizeof(PySSLObject),                /*tp_basicsize*/
+    0,                                  /*tp_itemsize*/
+    /* methods */
+    (destructor)PySSL_dealloc,          /*tp_dealloc*/
+    0,                                  /*tp_print*/
+    0,                                  /*tp_getattr*/
+    0,                                  /*tp_setattr*/
+    0,                                  /*tp_reserved*/
+    0,                                  /*tp_repr*/
+    0,                                  /*tp_as_number*/
+    0,                                  /*tp_as_sequence*/
+    0,                                  /*tp_as_mapping*/
+    0,                                  /*tp_hash*/
+    0,                                  /*tp_call*/
+    0,                                  /*tp_str*/
+    0,                                  /*tp_getattro*/
+    0,                                  /*tp_setattro*/
+    0,                                  /*tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT,                 /*tp_flags*/
+    0,                                  /*tp_doc*/
+    0,                                  /*tp_traverse*/
+    0,                                  /*tp_clear*/
+    0,                                  /*tp_richcompare*/
+    0,                                  /*tp_weaklistoffset*/
+    0,                                  /*tp_iter*/
+    0,                                  /*tp_iternext*/
+    PySSLMethods,                       /*tp_methods*/
 };
 
 #ifdef HAVE_OPENSSL_RAND
@@ -1547,7 +1547,7 @@
     double entropy;
 
     if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
-	return NULL;
+    return NULL;
     RAND_add(buf, len, entropy);
     Py_INCREF(Py_None);
     return Py_None;
@@ -1578,15 +1578,15 @@
     int bytes;
 
     if (!PyUnicode_Check(arg))
-	return PyErr_Format(PyExc_TypeError,
-			    "RAND_egd() expected string, found %s",
-			    Py_TYPE(arg)->tp_name);
+    return PyErr_Format(PyExc_TypeError,
+                        "RAND_egd() expected string, found %s",
+                        Py_TYPE(arg)->tp_name);
     bytes = RAND_egd(_PyUnicode_AsString(arg));
     if (bytes == -1) {
-	PyErr_SetString(PySSLErrorObject,
-			"EGD connection failed or EGD did not return "
-			"enough data to seed the PRNG");
-	return NULL;
+    PyErr_SetString(PySSLErrorObject,
+                    "EGD connection failed or EGD did not return "
+                    "enough data to seed the PRNG");
+    return NULL;
     }
     return PyLong_FromLong(bytes);
 }
@@ -1605,19 +1605,19 @@
 /* List of functions exported by this module. */
 
 static PyMethodDef PySSL_methods[] = {
-	{"sslwrap",             PySSL_sslwrap,
-         METH_VARARGS, ssl_doc},
-	{"_test_decode_cert",	PySSL_test_decode_certificate,
-	 METH_VARARGS},
+    {"sslwrap",             PySSL_sslwrap,
+     METH_VARARGS, ssl_doc},
+    {"_test_decode_cert",       PySSL_test_decode_certificate,
+     METH_VARARGS},
 #ifdef HAVE_OPENSSL_RAND
-	{"RAND_add",            PySSL_RAND_add, METH_VARARGS,
-	 PySSL_RAND_add_doc},
-	{"RAND_egd",            PySSL_RAND_egd, METH_O,
-	 PySSL_RAND_egd_doc},
-	{"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
-	 PySSL_RAND_status_doc},
+    {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
+     PySSL_RAND_add_doc},
+    {"RAND_egd",            PySSL_RAND_egd, METH_O,
+     PySSL_RAND_egd_doc},
+    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
+     PySSL_RAND_status_doc},
 #endif
-	{NULL,                  NULL}            /* Sentinel */
+    {NULL,                  NULL}            /* Sentinel */
 };
 
 
@@ -1629,66 +1629,66 @@
 static PyThread_type_lock *_ssl_locks = NULL;
 
 static unsigned long _ssl_thread_id_function (void) {
-	return PyThread_get_thread_ident();
+    return PyThread_get_thread_ident();
 }
 
 static void _ssl_thread_locking_function
-        (int mode, int n, const char *file, int line) {
-	/* this function is needed to perform locking on shared data
-	   structures. (Note that OpenSSL uses a number of global data
-	   structures that will be implicitly shared whenever multiple
-	   threads use OpenSSL.) Multi-threaded applications will
-	   crash at random if it is not set.
-
-	   locking_function() must be able to handle up to
-	   CRYPTO_num_locks() different mutex locks. It sets the n-th
-	   lock if mode & CRYPTO_LOCK, and releases it otherwise.
-
-	   file and line are the file number of the function setting the
-	   lock. They can be useful for debugging.
-	*/
-
-	if ((_ssl_locks == NULL) ||
-	    (n < 0) || ((unsigned)n >= _ssl_locks_count))
-		return;
-
-	if (mode & CRYPTO_LOCK) {
-		PyThread_acquire_lock(_ssl_locks[n], 1);
-	} else {
-		PyThread_release_lock(_ssl_locks[n]);
-	}
+    (int mode, int n, const char *file, int line) {
+    /* this function is needed to perform locking on shared data
+       structures. (Note that OpenSSL uses a number of global data
+       structures that will be implicitly shared whenever multiple
+       threads use OpenSSL.) Multi-threaded applications will
+       crash at random if it is not set.
+
+       locking_function() must be able to handle up to
+       CRYPTO_num_locks() different mutex locks. It sets the n-th
+       lock if mode & CRYPTO_LOCK, and releases it otherwise.
+
+       file and line are the file number of the function setting the
+       lock. They can be useful for debugging.
+    */
+
+    if ((_ssl_locks == NULL) ||
+        (n < 0) || ((unsigned)n >= _ssl_locks_count))
+        return;
+
+    if (mode & CRYPTO_LOCK) {
+        PyThread_acquire_lock(_ssl_locks[n], 1);
+    } else {
+        PyThread_release_lock(_ssl_locks[n]);
+    }
 }
 
 static int _setup_ssl_threads(void) {
 
-	unsigned int i;
+    unsigned int i;
 
-	if (_ssl_locks == NULL) {
-		_ssl_locks_count = CRYPTO_num_locks();
-		_ssl_locks = (PyThread_type_lock *)
-			malloc(sizeof(PyThread_type_lock) * _ssl_locks_count);
-		if (_ssl_locks == NULL)
-			return 0;
-		memset(_ssl_locks, 0,
-                       sizeof(PyThread_type_lock) * _ssl_locks_count);
-		for (i = 0;  i < _ssl_locks_count;  i++) {
-			_ssl_locks[i] = PyThread_allocate_lock();
-			if (_ssl_locks[i] == NULL) {
-				unsigned int j;
-				for (j = 0;  j < i;  j++) {
-					PyThread_free_lock(_ssl_locks[j]);
-				}
-				free(_ssl_locks);
-				return 0;
-			}
-		}
-		CRYPTO_set_locking_callback(_ssl_thread_locking_function);
-		CRYPTO_set_id_callback(_ssl_thread_id_function);
-	}
-	return 1;
+    if (_ssl_locks == NULL) {
+        _ssl_locks_count = CRYPTO_num_locks();
+        _ssl_locks = (PyThread_type_lock *)
+            malloc(sizeof(PyThread_type_lock) * _ssl_locks_count);
+        if (_ssl_locks == NULL)
+            return 0;
+        memset(_ssl_locks, 0,
+               sizeof(PyThread_type_lock) * _ssl_locks_count);
+        for (i = 0;  i < _ssl_locks_count;  i++) {
+            _ssl_locks[i] = PyThread_allocate_lock();
+            if (_ssl_locks[i] == NULL) {
+                unsigned int j;
+                for (j = 0;  j < i;  j++) {
+                    PyThread_free_lock(_ssl_locks[j]);
+                }
+                free(_ssl_locks);
+                return 0;
+            }
+        }
+        CRYPTO_set_locking_callback(_ssl_thread_locking_function);
+        CRYPTO_set_id_callback(_ssl_thread_id_function);
+    }
+    return 1;
 }
 
-#endif	/* def HAVE_THREAD */
+#endif  /* def HAVE_THREAD */
 
 PyDoc_STRVAR(module_doc,
 "Implementation module for SSL socket operations.  See the socket module\n\
@@ -1696,123 +1696,123 @@
 
 
 static struct PyModuleDef _sslmodule = {
-	PyModuleDef_HEAD_INIT,
-	"_ssl",
-	module_doc,
-	-1,
-	PySSL_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
+    PyModuleDef_HEAD_INIT,
+    "_ssl",
+    module_doc,
+    -1,
+    PySSL_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
 };
 
 PyMODINIT_FUNC
 PyInit__ssl(void)
 {
-	PyObject *m, *d, *r;
-	unsigned long libver;
-	unsigned int major, minor, fix, patch, status;
-        PySocketModule_APIObject *socket_api;
-
-	if (PyType_Ready(&PySSL_Type) < 0)
-		return NULL;
-
-	m = PyModule_Create(&_sslmodule);
-	if (m == NULL)
-		return NULL;
-	d = PyModule_GetDict(m);
-
-	/* Load _socket module and its C API */
-        socket_api = PySocketModule_ImportModuleAndAPI();
-	if (!socket_api)
-		return NULL;
-        PySocketModule = *socket_api;
-
-	/* Init OpenSSL */
-	SSL_load_error_strings();
-	SSL_library_init();
+    PyObject *m, *d, *r;
+    unsigned long libver;
+    unsigned int major, minor, fix, patch, status;
+    PySocketModule_APIObject *socket_api;
+
+    if (PyType_Ready(&PySSL_Type) < 0)
+        return NULL;
+
+    m = PyModule_Create(&_sslmodule);
+    if (m == NULL)
+        return NULL;
+    d = PyModule_GetDict(m);
+
+    /* Load _socket module and its C API */
+    socket_api = PySocketModule_ImportModuleAndAPI();
+    if (!socket_api)
+        return NULL;
+    PySocketModule = *socket_api;
+
+    /* Init OpenSSL */
+    SSL_load_error_strings();
+    SSL_library_init();
 #ifdef WITH_THREAD
-	/* note that this will start threading if not already started */
-	if (!_setup_ssl_threads()) {
-		return NULL;
-	}
+    /* note that this will start threading if not already started */
+    if (!_setup_ssl_threads()) {
+        return NULL;
+    }
 #endif
-	OpenSSL_add_all_algorithms();
+    OpenSSL_add_all_algorithms();
 
-	/* Add symbols to module dict */
-	PySSLErrorObject = PyErr_NewException("ssl.SSLError",
-					      PySocketModule.error,
-					      NULL);
-	if (PySSLErrorObject == NULL)
-		return NULL;
-	if (PyDict_SetItemString(d, "SSLError", PySSLErrorObject) != 0)
-		return NULL;
-	if (PyDict_SetItemString(d, "SSLType",
-				 (PyObject *)&PySSL_Type) != 0)
-		return NULL;
-	PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN",
-				PY_SSL_ERROR_ZERO_RETURN);
-	PyModule_AddIntConstant(m, "SSL_ERROR_WANT_READ",
-				PY_SSL_ERROR_WANT_READ);
-	PyModule_AddIntConstant(m, "SSL_ERROR_WANT_WRITE",
-				PY_SSL_ERROR_WANT_WRITE);
-	PyModule_AddIntConstant(m, "SSL_ERROR_WANT_X509_LOOKUP",
-				PY_SSL_ERROR_WANT_X509_LOOKUP);
-	PyModule_AddIntConstant(m, "SSL_ERROR_SYSCALL",
-				PY_SSL_ERROR_SYSCALL);
-	PyModule_AddIntConstant(m, "SSL_ERROR_SSL",
-				PY_SSL_ERROR_SSL);
-	PyModule_AddIntConstant(m, "SSL_ERROR_WANT_CONNECT",
-				PY_SSL_ERROR_WANT_CONNECT);
-	/* non ssl.h errorcodes */
-	PyModule_AddIntConstant(m, "SSL_ERROR_EOF",
-				PY_SSL_ERROR_EOF);
-	PyModule_AddIntConstant(m, "SSL_ERROR_INVALID_ERROR_CODE",
-				PY_SSL_ERROR_INVALID_ERROR_CODE);
-	/* cert requirements */
-	PyModule_AddIntConstant(m, "CERT_NONE",
-				PY_SSL_CERT_NONE);
-	PyModule_AddIntConstant(m, "CERT_OPTIONAL",
-				PY_SSL_CERT_OPTIONAL);
-	PyModule_AddIntConstant(m, "CERT_REQUIRED",
-				PY_SSL_CERT_REQUIRED);
-
-	/* protocol versions */
-	PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
-				PY_SSL_VERSION_SSL2);
-	PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
-				PY_SSL_VERSION_SSL3);
-	PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
-				PY_SSL_VERSION_SSL23);
-	PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
-				PY_SSL_VERSION_TLS1);
-
-	/* OpenSSL version */
-	/* SSLeay() gives us the version of the library linked against,
-	   which could be different from the headers version.
-	*/
-	libver = SSLeay();
-	r = PyLong_FromUnsignedLong(libver);
-	if (r == NULL)
-		return NULL;
-	if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
-		return NULL;
-	status = libver & 0xF;
-	libver >>= 4;
-	patch = libver & 0xFF;
-	libver >>= 8;
-	fix = libver & 0xFF;
-	libver >>= 8;
-	minor = libver & 0xFF;
-	libver >>= 8;
-	major = libver & 0xFF;
-	r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
-	if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
-		return NULL;
-	r = PyUnicode_FromString(SSLeay_version(SSLEAY_VERSION));
-	if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
-		return NULL;
+    /* Add symbols to module dict */
+    PySSLErrorObject = PyErr_NewException("ssl.SSLError",
+                                          PySocketModule.error,
+                                          NULL);
+    if (PySSLErrorObject == NULL)
+        return NULL;
+    if (PyDict_SetItemString(d, "SSLError", PySSLErrorObject) != 0)
+        return NULL;
+    if (PyDict_SetItemString(d, "SSLType",
+                             (PyObject *)&PySSL_Type) != 0)
+        return NULL;
+    PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN",
+                            PY_SSL_ERROR_ZERO_RETURN);
+    PyModule_AddIntConstant(m, "SSL_ERROR_WANT_READ",
+                            PY_SSL_ERROR_WANT_READ);
+    PyModule_AddIntConstant(m, "SSL_ERROR_WANT_WRITE",
+                            PY_SSL_ERROR_WANT_WRITE);
+    PyModule_AddIntConstant(m, "SSL_ERROR_WANT_X509_LOOKUP",
+                            PY_SSL_ERROR_WANT_X509_LOOKUP);
+    PyModule_AddIntConstant(m, "SSL_ERROR_SYSCALL",
+                            PY_SSL_ERROR_SYSCALL);
+    PyModule_AddIntConstant(m, "SSL_ERROR_SSL",
+                            PY_SSL_ERROR_SSL);
+    PyModule_AddIntConstant(m, "SSL_ERROR_WANT_CONNECT",
+                            PY_SSL_ERROR_WANT_CONNECT);
+    /* non ssl.h errorcodes */
+    PyModule_AddIntConstant(m, "SSL_ERROR_EOF",
+                            PY_SSL_ERROR_EOF);
+    PyModule_AddIntConstant(m, "SSL_ERROR_INVALID_ERROR_CODE",
+                            PY_SSL_ERROR_INVALID_ERROR_CODE);
+    /* cert requirements */
+    PyModule_AddIntConstant(m, "CERT_NONE",
+                            PY_SSL_CERT_NONE);
+    PyModule_AddIntConstant(m, "CERT_OPTIONAL",
+                            PY_SSL_CERT_OPTIONAL);
+    PyModule_AddIntConstant(m, "CERT_REQUIRED",
+                            PY_SSL_CERT_REQUIRED);
+
+    /* protocol versions */
+    PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
+                            PY_SSL_VERSION_SSL2);
+    PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
+                            PY_SSL_VERSION_SSL3);
+    PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
+                            PY_SSL_VERSION_SSL23);
+    PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
+                            PY_SSL_VERSION_TLS1);
+
+    /* OpenSSL version */
+    /* SSLeay() gives us the version of the library linked against,
+       which could be different from the headers version.
+    */
+    libver = SSLeay();
+    r = PyLong_FromUnsignedLong(libver);
+    if (r == NULL)
+        return NULL;
+    if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
+        return NULL;
+    status = libver & 0xF;
+    libver >>= 4;
+    patch = libver & 0xFF;
+    libver >>= 8;
+    fix = libver & 0xFF;
+    libver >>= 8;
+    minor = libver & 0xFF;
+    libver >>= 8;
+    major = libver & 0xFF;
+    r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
+    if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
+        return NULL;
+    r = PyUnicode_FromString(SSLeay_version(SSLEAY_VERSION));
+    if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
+        return NULL;
 
-	return m;
+    return m;
 }

Modified: python/branches/py3k-jit/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k-jit/Modules/posixmodule.c	(original)
+++ python/branches/py3k-jit/Modules/posixmodule.c	Thu May  6 23:49:27 2010
@@ -15,7 +15,7 @@
 
 #ifdef __APPLE__
    /*
-    * Step 1 of support for weak-linking a number of symbols existing on 
+    * Step 1 of support for weak-linking a number of symbols existing on
     * OSX 10.4 and later, see the comment in the #ifdef __APPLE__ block
     * at the end of this file for more information.
     */
@@ -69,7 +69,7 @@
 #endif /* HAVE_SYS_STAT_H */
 
 #ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>		/* For WNOHANG */
+#include <sys/wait.h>           /* For WNOHANG */
 #endif
 
 #ifdef HAVE_SIGNAL_H
@@ -101,41 +101,41 @@
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
 #include <process.h>
 #else
-#if defined(__WATCOMC__) && !defined(__QNX__)		/* Watcom compiler */
+#if defined(__WATCOMC__) && !defined(__QNX__)           /* Watcom compiler */
 #define HAVE_GETCWD     1
 #define HAVE_OPENDIR    1
-#define HAVE_SYSTEM	1
+#define HAVE_SYSTEM     1
 #if defined(__OS2__)
 #define HAVE_EXECV      1
 #define HAVE_WAIT       1
 #endif
 #include <process.h>
 #else
-#ifdef __BORLANDC__		/* Borland compiler */
+#ifdef __BORLANDC__             /* Borland compiler */
 #define HAVE_EXECV      1
 #define HAVE_GETCWD     1
 #define HAVE_OPENDIR    1
 #define HAVE_PIPE       1
-#define HAVE_SYSTEM	1
+#define HAVE_SYSTEM     1
 #define HAVE_WAIT       1
 #else
-#ifdef _MSC_VER		/* Microsoft compiler */
+#ifdef _MSC_VER         /* Microsoft compiler */
 #define HAVE_GETCWD     1
-#define HAVE_SPAWNV	1
+#define HAVE_SPAWNV     1
 #define HAVE_EXECV      1
 #define HAVE_PIPE       1
-#define HAVE_SYSTEM	1
-#define HAVE_CWAIT	1
-#define HAVE_FSYNC	1
+#define HAVE_SYSTEM     1
+#define HAVE_CWAIT      1
+#define HAVE_FSYNC      1
 #define fsync _commit
 #else
 #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
 /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
-#else			/* all other compilers */
+#else                   /* all other compilers */
 /* Unix functions that the configure script doesn't check for */
 #define HAVE_EXECV      1
 #define HAVE_FORK       1
-#if defined(__USLC__) && defined(__SCO_VERSION__)	/* SCO UDK Compiler */
+#if defined(__USLC__) && defined(__SCO_VERSION__)       /* SCO UDK Compiler */
 #define HAVE_FORK1      1
 #endif
 #define HAVE_GETCWD     1
@@ -147,9 +147,9 @@
 #define HAVE_KILL       1
 #define HAVE_OPENDIR    1
 #define HAVE_PIPE       1
-#define HAVE_SYSTEM	1
+#define HAVE_SYSTEM     1
 #define HAVE_WAIT       1
-#define HAVE_TTYNAME	1
+#define HAVE_TTYNAME    1
 #endif  /* PYOS_OS2 && PYCC_GCC && __VMS */
 #endif  /* _MSC_VER */
 #endif  /* __BORLANDC__ */
@@ -265,7 +265,7 @@
 #include "osdefs.h"
 #include <malloc.h>
 #include <windows.h>
-#include <shellapi.h>	/* for ShellExecute() */
+#include <shellapi.h>   /* for ShellExecute() */
 #endif /* _MSC_VER */
 
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -312,13 +312,13 @@
 /* choose the appropriate stat and fstat functions and return structs */
 #undef STAT
 #if defined(MS_WIN64) || defined(MS_WINDOWS)
-#	define STAT win32_stat
-#	define FSTAT win32_fstat
-#	define STRUCT_STAT struct win32_stat
-#else
-#	define STAT stat
-#	define FSTAT fstat
-#	define STRUCT_STAT struct stat
+#       define STAT win32_stat
+#       define FSTAT win32_fstat
+#       define STRUCT_STAT struct win32_stat
+#else
+#       define STAT stat
+#       define FSTAT fstat
+#       define STRUCT_STAT struct stat
 #endif
 
 #if defined(MAJOR_IN_MKDEV)
@@ -345,7 +345,7 @@
  * as a fd and should merely raise a python exception on error.
  * The Microsoft CRT doesn't provide an official way to check for the
  * validity of a file descriptor, but we can emulate its internal behaviour
- * by using the exported __pinfo data member and knowledge of the 
+ * by using the exported __pinfo data member and knowledge of the
  * internal structures involved.
  * The structures below must be updated for each version of visual studio
  * according to the file internal.h in the CRT source, until MS comes
@@ -357,8 +357,8 @@
  * Only the first items must be present.
  */
 typedef struct {
-        intptr_t osfhnd;
-        char osfile;
+    intptr_t osfhnd;
+    char osfile;
 } my_ioinfo;
 
 extern __declspec(dllimport) char * __pioinfo[];
@@ -373,52 +373,52 @@
 int
 _PyVerify_fd(int fd)
 {
-	const int i1 = fd >> IOINFO_L2E;
-	const int i2 = fd & ((1 << IOINFO_L2E) - 1);
-    
-	static int sizeof_ioinfo = 0;
-
-	/* Determine the actual size of the ioinfo structure, 
-	 * as used by the CRT loaded in memory
-	 */
-	if (sizeof_ioinfo == 0 && __pioinfo[0] != NULL) {
-		sizeof_ioinfo = _msize(__pioinfo[0]) / IOINFO_ARRAY_ELTS;
-	}
-	if (sizeof_ioinfo == 0) {
-		/* This should not happen... */
-		goto fail;
-	}
-
-	/* See that it isn't a special CLEAR fileno */
-	if (fd != _NO_CONSOLE_FILENO) {
-		/* Microsoft CRT would check that 0<=fd<_nhandle but we can't do that.  Instead
-		 * we check pointer validity and other info
-		 */
-		if (0 <= i1 && i1 < IOINFO_ARRAYS && __pioinfo[i1] != NULL) {
-			/* finally, check that the file is open */
-			my_ioinfo* info = (my_ioinfo*)(__pioinfo[i1] + i2 * sizeof_ioinfo);
-			if (info->osfile & FOPEN) {
-				return 1;
-			}
-		}
-	}
+    const int i1 = fd >> IOINFO_L2E;
+    const int i2 = fd & ((1 << IOINFO_L2E) - 1);
+
+    static int sizeof_ioinfo = 0;
+
+    /* Determine the actual size of the ioinfo structure,
+     * as used by the CRT loaded in memory
+     */
+    if (sizeof_ioinfo == 0 && __pioinfo[0] != NULL) {
+        sizeof_ioinfo = _msize(__pioinfo[0]) / IOINFO_ARRAY_ELTS;
+    }
+    if (sizeof_ioinfo == 0) {
+        /* This should not happen... */
+        goto fail;
+    }
+
+    /* See that it isn't a special CLEAR fileno */
+    if (fd != _NO_CONSOLE_FILENO) {
+        /* Microsoft CRT would check that 0<=fd<_nhandle but we can't do that.  Instead
+         * we check pointer validity and other info
+         */
+        if (0 <= i1 && i1 < IOINFO_ARRAYS && __pioinfo[i1] != NULL) {
+            /* finally, check that the file is open */
+            my_ioinfo* info = (my_ioinfo*)(__pioinfo[i1] + i2 * sizeof_ioinfo);
+            if (info->osfile & FOPEN) {
+                return 1;
+            }
+        }
+    }
   fail:
-	errno = EBADF;
-	return 0;
+    errno = EBADF;
+    return 0;
 }
 
 /* the special case of checking dup2.  The target fd must be in a sensible range */
 static int
 _PyVerify_fd_dup2(int fd1, int fd2)
 {
-	if (!_PyVerify_fd(fd1))
-		return 0;
-	if (fd2 == _NO_CONSOLE_FILENO)
-		return 0;
-	if ((unsigned)fd2 < _NHANDLE_)
-		return 1;
-	else
-		return 0;
+    if (!_PyVerify_fd(fd1))
+        return 0;
+    if (fd2 == _NO_CONSOLE_FILENO)
+        return 0;
+    if ((unsigned)fd2 < _NHANDLE_)
+        return 1;
+    else
+        return 0;
 }
 #else
 /* dummy version. _PyVerify_fd() is already defined in fileobject.h */
@@ -439,101 +439,101 @@
 static PyObject *
 convertenviron(void)
 {
-	PyObject *d;
+    PyObject *d;
 #ifdef MS_WINDOWS
-	wchar_t **e;
+    wchar_t **e;
 #else
-	char **e;
+    char **e;
+#endif
+#if defined(PYOS_OS2)
+    APIRET rc;
+    char   buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */
 #endif
-	d = PyDict_New();
-	if (d == NULL)
-		return NULL;
+
+    d = PyDict_New();
+    if (d == NULL)
+        return NULL;
 #ifdef WITH_NEXT_FRAMEWORK
-	if (environ == NULL)
-		environ = *_NSGetEnviron();
+    if (environ == NULL)
+        environ = *_NSGetEnviron();
 #endif
 #ifdef MS_WINDOWS
-	/* _wenviron must be initialized in this way if the program is started
-	   through main() instead of wmain(). */
-	_wgetenv(L"");
-	if (_wenviron == NULL)
-		return d;
-	/* This part ignores errors */
-	for (e = _wenviron; *e != NULL; e++) {
-		PyObject *k;
-		PyObject *v;
-		wchar_t *p = wcschr(*e, L'=');
-		if (p == NULL)
-			continue;
-		k = PyUnicode_FromWideChar(*e, (Py_ssize_t)(p-*e));
-		if (k == NULL) {
-			PyErr_Clear();
-			continue;
-		}
-		v = PyUnicode_FromWideChar(p+1, wcslen(p+1));
-		if (v == NULL) {
-			PyErr_Clear();
-			Py_DECREF(k);
-			continue;
-		}
-		if (PyDict_GetItem(d, k) == NULL) {
-			if (PyDict_SetItem(d, k, v) != 0)
-				PyErr_Clear();
-		}
-		Py_DECREF(k);
-		Py_DECREF(v);
-	}
-#else
-	if (environ == NULL)
-		return d;
-	/* This part ignores errors */
-	for (e = environ; *e != NULL; e++) {
-		PyObject *k;
-		PyObject *v;
-		char *p = strchr(*e, '=');
-		if (p == NULL)
-			continue;
-		k = PyUnicode_Decode(*e, (int)(p-*e),
-				     Py_FileSystemDefaultEncoding, "surrogateescape");
-		if (k == NULL) {
-			PyErr_Clear();
-			continue;
-		}
-		v = PyUnicode_Decode(p+1, strlen(p+1),
-				     Py_FileSystemDefaultEncoding, "surrogateescape");
-		if (v == NULL) {
-			PyErr_Clear();
-			Py_DECREF(k);
-			continue;
-		}
-		if (PyDict_GetItem(d, k) == NULL) {
-			if (PyDict_SetItem(d, k, v) != 0)
-				PyErr_Clear();
-		}
-		Py_DECREF(k);
-		Py_DECREF(v);
-	}
-#endif
-#if defined(PYOS_OS2)
-    {
-        APIRET rc;
-        char   buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */
-
-        rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
-	if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
-            PyObject *v = PyBytes_FromString(buffer);
-	    PyDict_SetItemString(d, "BEGINLIBPATH", v);
-            Py_DECREF(v);
+    /* _wenviron must be initialized in this way if the program is started
+       through main() instead of wmain(). */
+    _wgetenv(L"");
+    if (_wenviron == NULL)
+        return d;
+    /* This part ignores errors */
+    for (e = _wenviron; *e != NULL; e++) {
+        PyObject *k;
+        PyObject *v;
+        wchar_t *p = wcschr(*e, L'=');
+        if (p == NULL)
+            continue;
+        k = PyUnicode_FromWideChar(*e, (Py_ssize_t)(p-*e));
+        if (k == NULL) {
+            PyErr_Clear();
+            continue;
         }
-        rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
-        if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
-            PyObject *v = PyBytes_FromString(buffer);
-	    PyDict_SetItemString(d, "ENDLIBPATH", v);
-            Py_DECREF(v);
+        v = PyUnicode_FromWideChar(p+1, wcslen(p+1));
+        if (v == NULL) {
+            PyErr_Clear();
+            Py_DECREF(k);
+            continue;
+        }
+        if (PyDict_GetItem(d, k) == NULL) {
+            if (PyDict_SetItem(d, k, v) != 0)
+                PyErr_Clear();
         }
+        Py_DECREF(k);
+        Py_DECREF(v);
+    }
+#else
+    if (environ == NULL)
+        return d;
+    /* This part ignores errors */
+    for (e = environ; *e != NULL; e++) {
+        PyObject *k;
+        PyObject *v;
+        char *p = strchr(*e, '=');
+        if (p == NULL)
+            continue;
+        k = PyUnicode_Decode(*e, (int)(p-*e),
+                             Py_FileSystemDefaultEncoding, "surrogateescape");
+        if (k == NULL) {
+            PyErr_Clear();
+            continue;
+        }
+        v = PyUnicode_Decode(p+1, strlen(p+1),
+                             Py_FileSystemDefaultEncoding, "surrogateescape");
+        if (v == NULL) {
+            PyErr_Clear();
+            Py_DECREF(k);
+            continue;
+        }
+        if (PyDict_GetItem(d, k) == NULL) {
+            if (PyDict_SetItem(d, k, v) != 0)
+                PyErr_Clear();
+        }
+        Py_DECREF(k);
+        Py_DECREF(v);
+    }
+#endif
+#if defined(PYOS_OS2)
+    rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
+    if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
+        PyObject *v = PyBytes_FromString(buffer);
+        PyDict_SetItemString(d, "BEGINLIBPATH", v);
+        Py_DECREF(v);
+    }
+    rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
+    if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
+        PyObject *v = PyBytes_FromString(buffer);
+        PyDict_SetItemString(d, "ENDLIBPATH", v);
+        Py_DECREF(v);
     }
 #endif
-	return d;
+    return d;
 }
 
 /* Set a POSIX-specific error from errno, and return NULL */
@@ -541,19 +541,19 @@
 static PyObject *
 posix_error(void)
 {
-	return PyErr_SetFromErrno(PyExc_OSError);
+    return PyErr_SetFromErrno(PyExc_OSError);
 }
 static PyObject *
 posix_error_with_filename(char* name)
 {
-	return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
+    return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
 }
 
 #ifdef MS_WINDOWS
 static PyObject *
 posix_error_with_unicode_filename(Py_UNICODE* name)
 {
-	return PyErr_SetFromErrnoWithUnicodeFilename(PyExc_OSError, name);
+    return PyErr_SetFromErrnoWithUnicodeFilename(PyExc_OSError, name);
 }
 #endif /* MS_WINDOWS */
 
@@ -561,54 +561,54 @@
 static PyObject *
 posix_error_with_allocated_filename(PyObject* name)
 {
-	PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, 
-						      PyBytes_AsString(name));
-	Py_DECREF(name);
-	return rc;
+    PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError,
+                                                  PyBytes_AsString(name));
+    Py_DECREF(name);
+    return rc;
 }
 
 #ifdef MS_WINDOWS
 static PyObject *
 win32_error(char* function, char* filename)
 {
-	/* XXX We should pass the function name along in the future.
-	   (winreg.c also wants to pass the function name.)
-	   This would however require an additional param to the
-	   Windows error object, which is non-trivial.
-	*/
-	errno = GetLastError();
-	if (filename)
-		return PyErr_SetFromWindowsErrWithFilename(errno, filename);
-	else
-		return PyErr_SetFromWindowsErr(errno);
+    /* XXX We should pass the function name along in the future.
+       (winreg.c also wants to pass the function name.)
+       This would however require an additional param to the
+       Windows error object, which is non-trivial.
+    */
+    errno = GetLastError();
+    if (filename)
+        return PyErr_SetFromWindowsErrWithFilename(errno, filename);
+    else
+        return PyErr_SetFromWindowsErr(errno);
 }
 
 static PyObject *
 win32_error_unicode(char* function, Py_UNICODE* filename)
 {
-	/* XXX - see win32_error for comments on 'function' */
-	errno = GetLastError();
-	if (filename)
-		return PyErr_SetFromWindowsErrWithUnicodeFilename(errno, filename);
-	else
-		return PyErr_SetFromWindowsErr(errno);
+    /* XXX - see win32_error for comments on 'function' */
+    errno = GetLastError();
+    if (filename)
+        return PyErr_SetFromWindowsErrWithUnicodeFilename(errno, filename);
+    else
+        return PyErr_SetFromWindowsErr(errno);
 }
 
 static int
 convert_to_unicode(PyObject **param)
 {
-	if (PyUnicode_CheckExact(*param))
-		Py_INCREF(*param);
-	else if (PyUnicode_Check(*param))
-		/* For a Unicode subtype that's not a Unicode object,
-		   return a true Unicode object with the same data. */
-		*param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(*param),
-					       PyUnicode_GET_SIZE(*param));
-	else
-		*param = PyUnicode_FromEncodedObject(*param,
-				                     Py_FileSystemDefaultEncoding,
-					             "strict");
-	return (*param) != NULL;
+    if (PyUnicode_CheckExact(*param))
+        Py_INCREF(*param);
+    else if (PyUnicode_Check(*param))
+        /* For a Unicode subtype that's not a Unicode object,
+           return a true Unicode object with the same data. */
+        *param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(*param),
+                                       PyUnicode_GET_SIZE(*param));
+    else
+        *param = PyUnicode_FromEncodedObject(*param,
+                                             Py_FileSystemDefaultEncoding,
+                                             "strict");
+    return (*param) != NULL;
 }
 
 #endif /* MS_WINDOWS */
@@ -617,7 +617,7 @@
 /**********************************************************************
  *         Helper Function to Trim and Format OS/2 Messages
  **********************************************************************/
-    static void
+static void
 os2_formatmsg(char *msgbuf, int msglen, char *reason)
 {
     msgbuf[msglen] = '\0'; /* OS/2 Doesn't Guarantee a Terminator */
@@ -647,7 +647,7 @@
  *   the file OSO001.MSG in the \OS2 directory hierarchy.
  *
  **********************************************************************/
-    static char *
+static char *
 os2_strerror(char *msgbuf, int msgbuflen, int errorcode, char *reason)
 {
     APIRET rc;
@@ -663,7 +663,7 @@
         os2_formatmsg(msgbuf, msglen, reason);
     else
         PyOS_snprintf(msgbuf, msgbuflen,
-        	      "unknown OS error #%d", errorcode);
+                      "unknown OS error #%d", errorcode);
 
     return msgbuf;
 }
@@ -672,7 +672,8 @@
    errors are not in a global variable e.g. 'errno' nor are
    they congruent with posix error numbers. */
 
-static PyObject * os2_error(int code)
+static PyObject *
+os2_error(int code)
 {
     char text[1024];
     PyObject *v;
@@ -694,99 +695,99 @@
 static PyObject *
 posix_fildes(PyObject *fdobj, int (*func)(int))
 {
-	int fd;
-	int res;
-	fd = PyObject_AsFileDescriptor(fdobj);
-	if (fd < 0)
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	res = (*func)(fd);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int fd;
+    int res;
+    fd = PyObject_AsFileDescriptor(fdobj);
+    if (fd < 0)
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    res = (*func)(fd);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 posix_1str(PyObject *args, char *format, int (*func)(const char*))
 {
-	PyObject *opath1 = NULL;
-	char *path1;
-	int res;
-	if (!PyArg_ParseTuple(args, format,
-	                      PyUnicode_FSConverter, &opath1))
-		return NULL;
-	path1 = PyBytes_AsString(opath1);
-	Py_BEGIN_ALLOW_THREADS
-	res = (*func)(path1);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath1);
-	Py_DECREF(opath1);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath1 = NULL;
+    char *path1;
+    int res;
+    if (!PyArg_ParseTuple(args, format,
+                          PyUnicode_FSConverter, &opath1))
+        return NULL;
+    path1 = PyBytes_AsString(opath1);
+    Py_BEGIN_ALLOW_THREADS
+    res = (*func)(path1);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath1);
+    Py_DECREF(opath1);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 posix_2str(PyObject *args,
-	   char *format,
-	   int (*func)(const char *, const char *))
+           char *format,
+           int (*func)(const char *, const char *))
 {
-	PyObject *opath1 = NULL, *opath2 = NULL;
-	char *path1, *path2;
-	int res;
-	if (!PyArg_ParseTuple(args, format,
-	                      PyUnicode_FSConverter, &opath1,
-	                      PyUnicode_FSConverter, &opath2)) {
-		return NULL;
-	}
-	path1 = PyBytes_AsString(opath1);
-	path2 = PyBytes_AsString(opath2);
-	Py_BEGIN_ALLOW_THREADS
-	res = (*func)(path1, path2);
-	Py_END_ALLOW_THREADS
-	Py_DECREF(opath1);
-	Py_DECREF(opath2);
-	if (res != 0)
-		/* XXX how to report both path1 and path2??? */
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath1 = NULL, *opath2 = NULL;
+    char *path1, *path2;
+    int res;
+    if (!PyArg_ParseTuple(args, format,
+                          PyUnicode_FSConverter, &opath1,
+                          PyUnicode_FSConverter, &opath2)) {
+        return NULL;
+    }
+    path1 = PyBytes_AsString(opath1);
+    path2 = PyBytes_AsString(opath2);
+    Py_BEGIN_ALLOW_THREADS
+    res = (*func)(path1, path2);
+    Py_END_ALLOW_THREADS
+    Py_DECREF(opath1);
+    Py_DECREF(opath2);
+    if (res != 0)
+        /* XXX how to report both path1 and path2??? */
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 #ifdef MS_WINDOWS
 static PyObject*
-win32_1str(PyObject* args, char* func, 
-	   char* format, BOOL (__stdcall *funcA)(LPCSTR), 
-	   char* wformat, BOOL (__stdcall *funcW)(LPWSTR))
-{
-	PyObject *uni;
-	char *ansi;
-	BOOL result;
-
-	if (!PyArg_ParseTuple(args, wformat, &uni))
-		PyErr_Clear();
-	else {
-		Py_BEGIN_ALLOW_THREADS
-		result = funcW(PyUnicode_AsUnicode(uni));
-		Py_END_ALLOW_THREADS
-		if (!result)
-			return win32_error_unicode(func, PyUnicode_AsUnicode(uni));
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
-	if (!PyArg_ParseTuple(args, format, &ansi))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	result = funcA(ansi);
-	Py_END_ALLOW_THREADS
-	if (!result)
-		return win32_error(func, ansi);
-	Py_INCREF(Py_None);
-	return Py_None;
+win32_1str(PyObject* args, char* func,
+           char* format, BOOL (__stdcall *funcA)(LPCSTR),
+           char* wformat, BOOL (__stdcall *funcW)(LPWSTR))
+{
+    PyObject *uni;
+    char *ansi;
+    BOOL result;
+
+    if (!PyArg_ParseTuple(args, wformat, &uni))
+        PyErr_Clear();
+    else {
+        Py_BEGIN_ALLOW_THREADS
+        result = funcW(PyUnicode_AsUnicode(uni));
+        Py_END_ALLOW_THREADS
+        if (!result)
+            return win32_error_unicode(func, PyUnicode_AsUnicode(uni));
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    if (!PyArg_ParseTuple(args, format, &ansi))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    result = funcA(ansi);
+    Py_END_ALLOW_THREADS
+    if (!result)
+        return win32_error(func, ansi);
+    Py_INCREF(Py_None);
+    return Py_None;
 
 }
 
@@ -798,24 +799,24 @@
 static BOOL __stdcall
 win32_chdir(LPCSTR path)
 {
-	char new_path[MAX_PATH+1];
-	int result;
-	char env[4] = "=x:";
-
-	if(!SetCurrentDirectoryA(path))
-		return FALSE;
-	result = GetCurrentDirectoryA(MAX_PATH+1, new_path);
-	if (!result)
-		return FALSE;
-	/* In the ANSI API, there should not be any paths longer
-	   than MAX_PATH. */
-	assert(result <= MAX_PATH+1);
-	if (strncmp(new_path, "\\\\", 2) == 0 ||
-	    strncmp(new_path, "//", 2) == 0)
-	    /* UNC path, nothing to do. */
-	    return TRUE;
-	env[1] = new_path[0];
-	return SetEnvironmentVariableA(env, new_path);
+    char new_path[MAX_PATH+1];
+    int result;
+    char env[4] = "=x:";
+
+    if(!SetCurrentDirectoryA(path))
+        return FALSE;
+    result = GetCurrentDirectoryA(MAX_PATH+1, new_path);
+    if (!result)
+        return FALSE;
+    /* In the ANSI API, there should not be any paths longer
+       than MAX_PATH. */
+    assert(result <= MAX_PATH+1);
+    if (strncmp(new_path, "\\\\", 2) == 0 ||
+        strncmp(new_path, "//", 2) == 0)
+        /* UNC path, nothing to do. */
+        return TRUE;
+    env[1] = new_path[0];
+    return SetEnvironmentVariableA(env, new_path);
 }
 
 /* The Unicode version differs from the ANSI version
@@ -823,36 +824,36 @@
 static BOOL __stdcall
 win32_wchdir(LPCWSTR path)
 {
-	wchar_t _new_path[MAX_PATH+1], *new_path = _new_path;
-	int result;
-	wchar_t env[4] = L"=x:";
-
-	if(!SetCurrentDirectoryW(path))
-		return FALSE;
-	result = GetCurrentDirectoryW(MAX_PATH+1, new_path);
-	if (!result)
-		return FALSE;
-	if (result > MAX_PATH+1) {
-		new_path = malloc(result * sizeof(wchar_t));
-		if (!new_path) {
-			SetLastError(ERROR_OUTOFMEMORY);
-			return FALSE;
-		}
-		result = GetCurrentDirectoryW(result, new_path);
-		if (!result) {
-			free(new_path);
-			return FALSE;
-		}
-	}
-	if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
-	    wcsncmp(new_path, L"//", 2) == 0)
-	    /* UNC path, nothing to do. */
-	    return TRUE;
-	env[1] = new_path[0];
-	result = SetEnvironmentVariableW(env, new_path);
-	if (new_path != _new_path)
-		free(new_path);
-	return result;
+    wchar_t _new_path[MAX_PATH+1], *new_path = _new_path;
+    int result;
+    wchar_t env[4] = L"=x:";
+
+    if(!SetCurrentDirectoryW(path))
+        return FALSE;
+    result = GetCurrentDirectoryW(MAX_PATH+1, new_path);
+    if (!result)
+        return FALSE;
+    if (result > MAX_PATH+1) {
+        new_path = malloc(result * sizeof(wchar_t));
+        if (!new_path) {
+            SetLastError(ERROR_OUTOFMEMORY);
+            return FALSE;
+        }
+        result = GetCurrentDirectoryW(result, new_path);
+        if (!result) {
+            free(new_path);
+            return FALSE;
+        }
+    }
+    if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
+        wcsncmp(new_path, L"//", 2) == 0)
+        /* UNC path, nothing to do. */
+        return TRUE;
+    env[1] = new_path[0];
+    result = SetEnvironmentVariableW(env, new_path);
+    if (new_path != _new_path)
+        free(new_path);
+    return result;
 }
 #endif
 
@@ -863,7 +864,7 @@
      UTC and local time
    Therefore, we implement our own stat, based on the Win32 API directly.
 */
-#define HAVE_STAT_NSEC 1 
+#define HAVE_STAT_NSEC 1
 
 struct win32_stat{
     int st_dev;
@@ -887,24 +888,24 @@
 static void
 FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out)
 {
-	/* XXX endianness. Shouldn't matter, as all Windows implementations are little-endian */
-	/* Cannot simply cast and dereference in_ptr, 
-	   since it might not be aligned properly */
-	__int64 in;
-	memcpy(&in, in_ptr, sizeof(in));
-	*nsec_out = (int)(in % 10000000) * 100; /* FILETIME is in units of 100 nsec. */
-	/* XXX Win32 supports time stamps past 2038; we currently don't */
-	*time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, int);
+    /* XXX endianness. Shouldn't matter, as all Windows implementations are little-endian */
+    /* Cannot simply cast and dereference in_ptr,
+       since it might not be aligned properly */
+    __int64 in;
+    memcpy(&in, in_ptr, sizeof(in));
+    *nsec_out = (int)(in % 10000000) * 100; /* FILETIME is in units of 100 nsec. */
+    /* XXX Win32 supports time stamps past 2038; we currently don't */
+    *time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, int);
 }
 
 static void
 time_t_to_FILE_TIME(int time_in, int nsec_in, FILETIME *out_ptr)
 {
-	/* XXX endianness */
-	__int64 out;
-	out = time_in + secs_between_epochs;
-	out = out * 10000000 + nsec_in / 100;
-	memcpy(out_ptr, &out, sizeof(out));
+    /* XXX endianness */
+    __int64 out;
+    out = time_in + secs_between_epochs;
+    out = out * 10000000 + nsec_in / 100;
+    memcpy(out_ptr, &out, sizeof(out));
 }
 
 /* Below, we *know* that ugo+r is 0444 */
@@ -914,193 +915,193 @@
 static int
 attributes_to_mode(DWORD attr)
 {
-	int m = 0;
-	if (attr & FILE_ATTRIBUTE_DIRECTORY)
-		m |= _S_IFDIR | 0111; /* IFEXEC for user,group,other */
-	else
-		m |= _S_IFREG;
-	if (attr & FILE_ATTRIBUTE_READONLY)
-		m |= 0444;
-	else
-		m |= 0666;
-	return m;
+    int m = 0;
+    if (attr & FILE_ATTRIBUTE_DIRECTORY)
+        m |= _S_IFDIR | 0111; /* IFEXEC for user,group,other */
+    else
+        m |= _S_IFREG;
+    if (attr & FILE_ATTRIBUTE_READONLY)
+        m |= 0444;
+    else
+        m |= 0666;
+    return m;
 }
 
 static int
 attribute_data_to_stat(WIN32_FILE_ATTRIBUTE_DATA *info, struct win32_stat *result)
 {
-	memset(result, 0, sizeof(*result));
-	result->st_mode = attributes_to_mode(info->dwFileAttributes);
-	result->st_size = (((__int64)info->nFileSizeHigh)<<32) + info->nFileSizeLow;
-	FILE_TIME_to_time_t_nsec(&info->ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
-	FILE_TIME_to_time_t_nsec(&info->ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
-	FILE_TIME_to_time_t_nsec(&info->ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
+    memset(result, 0, sizeof(*result));
+    result->st_mode = attributes_to_mode(info->dwFileAttributes);
+    result->st_size = (((__int64)info->nFileSizeHigh)<<32) + info->nFileSizeLow;
+    FILE_TIME_to_time_t_nsec(&info->ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
+    FILE_TIME_to_time_t_nsec(&info->ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
+    FILE_TIME_to_time_t_nsec(&info->ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
 
-	return 0;
+    return 0;
 }
 
 static BOOL
 attributes_from_dir(LPCSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
 {
-	HANDLE hFindFile;
-	WIN32_FIND_DATAA FileData;
-	hFindFile = FindFirstFileA(pszFile, &FileData);
-	if (hFindFile == INVALID_HANDLE_VALUE)
-		return FALSE;
-	FindClose(hFindFile);
-	pfad->dwFileAttributes = FileData.dwFileAttributes;
-	pfad->ftCreationTime   = FileData.ftCreationTime;
-	pfad->ftLastAccessTime = FileData.ftLastAccessTime;
-	pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
-	pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
-	pfad->nFileSizeLow     = FileData.nFileSizeLow;
-	return TRUE;
+    HANDLE hFindFile;
+    WIN32_FIND_DATAA FileData;
+    hFindFile = FindFirstFileA(pszFile, &FileData);
+    if (hFindFile == INVALID_HANDLE_VALUE)
+        return FALSE;
+    FindClose(hFindFile);
+    pfad->dwFileAttributes = FileData.dwFileAttributes;
+    pfad->ftCreationTime   = FileData.ftCreationTime;
+    pfad->ftLastAccessTime = FileData.ftLastAccessTime;
+    pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
+    pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
+    pfad->nFileSizeLow     = FileData.nFileSizeLow;
+    return TRUE;
 }
 
 static BOOL
 attributes_from_dir_w(LPCWSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
 {
-	HANDLE hFindFile;
-	WIN32_FIND_DATAW FileData;
-	hFindFile = FindFirstFileW(pszFile, &FileData);
-	if (hFindFile == INVALID_HANDLE_VALUE)
-		return FALSE;
-	FindClose(hFindFile);
-	pfad->dwFileAttributes = FileData.dwFileAttributes;
-	pfad->ftCreationTime   = FileData.ftCreationTime;
-	pfad->ftLastAccessTime = FileData.ftLastAccessTime;
-	pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
-	pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
-	pfad->nFileSizeLow     = FileData.nFileSizeLow;
-	return TRUE;
+    HANDLE hFindFile;
+    WIN32_FIND_DATAW FileData;
+    hFindFile = FindFirstFileW(pszFile, &FileData);
+    if (hFindFile == INVALID_HANDLE_VALUE)
+        return FALSE;
+    FindClose(hFindFile);
+    pfad->dwFileAttributes = FileData.dwFileAttributes;
+    pfad->ftCreationTime   = FileData.ftCreationTime;
+    pfad->ftLastAccessTime = FileData.ftLastAccessTime;
+    pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
+    pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
+    pfad->nFileSizeLow     = FileData.nFileSizeLow;
+    return TRUE;
 }
 
-static int 
+static int
 win32_stat(const char* path, struct win32_stat *result)
 {
-	WIN32_FILE_ATTRIBUTE_DATA info;
-	int code;
-	char *dot;
-	if (!GetFileAttributesExA(path, GetFileExInfoStandard, &info)) {
-		if (GetLastError() != ERROR_SHARING_VIOLATION) {
-			/* Protocol violation: we explicitly clear errno, instead of
-			   setting it to a POSIX error. Callers should use GetLastError. */
-			errno = 0;
-			return -1;
-		} else {
-			/* Could not get attributes on open file. Fall back to
-			   reading the directory. */
-			if (!attributes_from_dir(path, &info)) {
-				/* Very strange. This should not fail now */
-				errno = 0;
-				return -1;
-			}
-		}
-	}
-	code = attribute_data_to_stat(&info, result);
-	if (code != 0)
-		return code;
-	/* Set S_IFEXEC if it is an .exe, .bat, ... */
-	dot = strrchr(path, '.');
-	if (dot) {
-		if (stricmp(dot, ".bat") == 0 ||
-		stricmp(dot, ".cmd") == 0 ||
-		stricmp(dot, ".exe") == 0 ||
-		stricmp(dot, ".com") == 0)
-		result->st_mode |= 0111;
-	}
-	return code;
+    WIN32_FILE_ATTRIBUTE_DATA info;
+    int code;
+    char *dot;
+    if (!GetFileAttributesExA(path, GetFileExInfoStandard, &info)) {
+        if (GetLastError() != ERROR_SHARING_VIOLATION) {
+            /* Protocol violation: we explicitly clear errno, instead of
+               setting it to a POSIX error. Callers should use GetLastError. */
+            errno = 0;
+            return -1;
+        } else {
+            /* Could not get attributes on open file. Fall back to
+               reading the directory. */
+            if (!attributes_from_dir(path, &info)) {
+                /* Very strange. This should not fail now */
+                errno = 0;
+                return -1;
+            }
+        }
+    }
+    code = attribute_data_to_stat(&info, result);
+    if (code != 0)
+        return code;
+    /* Set S_IFEXEC if it is an .exe, .bat, ... */
+    dot = strrchr(path, '.');
+    if (dot) {
+        if (stricmp(dot, ".bat") == 0 ||
+        stricmp(dot, ".cmd") == 0 ||
+        stricmp(dot, ".exe") == 0 ||
+        stricmp(dot, ".com") == 0)
+            result->st_mode |= 0111;
+    }
+    return code;
 }
 
-static int 
+static int
 win32_wstat(const wchar_t* path, struct win32_stat *result)
 {
-	int code;
-	const wchar_t *dot;
-	WIN32_FILE_ATTRIBUTE_DATA info;
-	if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) {
-		if (GetLastError() != ERROR_SHARING_VIOLATION) {
-			/* Protocol violation: we explicitly clear errno, instead of
-			   setting it to a POSIX error. Callers should use GetLastError. */
-			errno = 0;
-			return -1;
-		} else {
-			/* Could not get attributes on open file. Fall back to
-			   reading the directory. */
-			if (!attributes_from_dir_w(path, &info)) {
-				/* Very strange. This should not fail now */
-				errno = 0;
-				return -1;
-			}
-		}
-	}
-	code = attribute_data_to_stat(&info, result);
-	if (code < 0)
-		return code;
-	/* Set IFEXEC if it is an .exe, .bat, ... */
-	dot = wcsrchr(path, '.');
-	if (dot) {
-		if (_wcsicmp(dot, L".bat") == 0 ||
-		    _wcsicmp(dot, L".cmd") == 0 ||
-		    _wcsicmp(dot, L".exe") == 0 ||
-		    _wcsicmp(dot, L".com") == 0)
-			result->st_mode |= 0111;
-	}
-	return code;
+    int code;
+    const wchar_t *dot;
+    WIN32_FILE_ATTRIBUTE_DATA info;
+    if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) {
+        if (GetLastError() != ERROR_SHARING_VIOLATION) {
+            /* Protocol violation: we explicitly clear errno, instead of
+               setting it to a POSIX error. Callers should use GetLastError. */
+            errno = 0;
+            return -1;
+        } else {
+            /* Could not get attributes on open file. Fall back to
+               reading the directory. */
+            if (!attributes_from_dir_w(path, &info)) {
+                /* Very strange. This should not fail now */
+                errno = 0;
+                return -1;
+            }
+        }
+    }
+    code = attribute_data_to_stat(&info, result);
+    if (code < 0)
+        return code;
+    /* Set IFEXEC if it is an .exe, .bat, ... */
+    dot = wcsrchr(path, '.');
+    if (dot) {
+        if (_wcsicmp(dot, L".bat") == 0 ||
+            _wcsicmp(dot, L".cmd") == 0 ||
+            _wcsicmp(dot, L".exe") == 0 ||
+            _wcsicmp(dot, L".com") == 0)
+            result->st_mode |= 0111;
+    }
+    return code;
 }
 
 static int
 win32_fstat(int file_number, struct win32_stat *result)
 {
-	BY_HANDLE_FILE_INFORMATION info;
-	HANDLE h;
-	int type;
-    
-	h = (HANDLE)_get_osfhandle(file_number);
-    
-	/* Protocol violation: we explicitly clear errno, instead of
-	   setting it to a POSIX error. Callers should use GetLastError. */
-	errno = 0;
-
-	if (h == INVALID_HANDLE_VALUE) {
-    		/* This is really a C library error (invalid file handle).
-		   We set the Win32 error to the closes one matching. */
-		SetLastError(ERROR_INVALID_HANDLE);
-		return -1;
-	}
-	memset(result, 0, sizeof(*result));
-
-	type = GetFileType(h);
-	if (type == FILE_TYPE_UNKNOWN) {
-	    DWORD error = GetLastError();
-	    if (error != 0) {
-		return -1;
-	    }
-	    /* else: valid but unknown file */
-	}
-
-	if (type != FILE_TYPE_DISK) {
-		if (type == FILE_TYPE_CHAR)
-			result->st_mode = _S_IFCHR;
-		else if (type == FILE_TYPE_PIPE)
-			result->st_mode = _S_IFIFO;
-		return 0;
-	}
-
-	if (!GetFileInformationByHandle(h, &info)) {
-		return -1;
-	}
-
-	/* similar to stat() */
-	result->st_mode = attributes_to_mode(info.dwFileAttributes);
-	result->st_size = (((__int64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
-	FILE_TIME_to_time_t_nsec(&info.ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
-	FILE_TIME_to_time_t_nsec(&info.ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
-	FILE_TIME_to_time_t_nsec(&info.ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
-	/* specific to fstat() */
-	result->st_nlink = info.nNumberOfLinks;
-	result->st_ino = (((__int64)info.nFileIndexHigh)<<32) + info.nFileIndexLow;
-	return 0;
+    BY_HANDLE_FILE_INFORMATION info;
+    HANDLE h;
+    int type;
+
+    h = (HANDLE)_get_osfhandle(file_number);
+
+    /* Protocol violation: we explicitly clear errno, instead of
+       setting it to a POSIX error. Callers should use GetLastError. */
+    errno = 0;
+
+    if (h == INVALID_HANDLE_VALUE) {
+        /* This is really a C library error (invalid file handle).
+           We set the Win32 error to the closes one matching. */
+        SetLastError(ERROR_INVALID_HANDLE);
+        return -1;
+    }
+    memset(result, 0, sizeof(*result));
+
+    type = GetFileType(h);
+    if (type == FILE_TYPE_UNKNOWN) {
+        DWORD error = GetLastError();
+        if (error != 0) {
+        return -1;
+        }
+        /* else: valid but unknown file */
+    }
+
+    if (type != FILE_TYPE_DISK) {
+        if (type == FILE_TYPE_CHAR)
+            result->st_mode = _S_IFCHR;
+        else if (type == FILE_TYPE_PIPE)
+            result->st_mode = _S_IFIFO;
+        return 0;
+    }
+
+    if (!GetFileInformationByHandle(h, &info)) {
+        return -1;
+    }
+
+    /* similar to stat() */
+    result->st_mode = attributes_to_mode(info.dwFileAttributes);
+    result->st_size = (((__int64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
+    FILE_TIME_to_time_t_nsec(&info.ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
+    FILE_TIME_to_time_t_nsec(&info.ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
+    FILE_TIME_to_time_t_nsec(&info.ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
+    /* specific to fstat() */
+    result->st_nlink = info.nNumberOfLinks;
+    result->st_ino = (((__int64)info.nFileIndexHigh)<<32) + info.nFileIndexLow;
+    return 0;
 }
 
 #endif /* MS_WINDOWS */
@@ -1117,39 +1118,39 @@
 See os.stat for more information.");
 
 static PyStructSequence_Field stat_result_fields[] = {
-	{"st_mode",    "protection bits"},
-	{"st_ino",     "inode"},
-	{"st_dev",     "device"},
-	{"st_nlink",   "number of hard links"},
-	{"st_uid",     "user ID of owner"},
-	{"st_gid",     "group ID of owner"},
-	{"st_size",    "total size, in bytes"},
-	/* The NULL is replaced with PyStructSequence_UnnamedField later. */
-	{NULL,   "integer time of last access"},
-	{NULL,   "integer time of last modification"},
-	{NULL,   "integer time of last change"},
-	{"st_atime",   "time of last access"},
-	{"st_mtime",   "time of last modification"},
-	{"st_ctime",   "time of last change"},
+    {"st_mode",    "protection bits"},
+    {"st_ino",     "inode"},
+    {"st_dev",     "device"},
+    {"st_nlink",   "number of hard links"},
+    {"st_uid",     "user ID of owner"},
+    {"st_gid",     "group ID of owner"},
+    {"st_size",    "total size, in bytes"},
+    /* The NULL is replaced with PyStructSequence_UnnamedField later. */
+    {NULL,   "integer time of last access"},
+    {NULL,   "integer time of last modification"},
+    {NULL,   "integer time of last change"},
+    {"st_atime",   "time of last access"},
+    {"st_mtime",   "time of last modification"},
+    {"st_ctime",   "time of last change"},
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
-	{"st_blksize", "blocksize for filesystem I/O"},
+    {"st_blksize", "blocksize for filesystem I/O"},
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
-	{"st_blocks",  "number of blocks allocated"},
+    {"st_blocks",  "number of blocks allocated"},
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
-	{"st_rdev",    "device type (if inode device)"},
+    {"st_rdev",    "device type (if inode device)"},
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_FLAGS
-	{"st_flags",   "user defined flags for file"},
+    {"st_flags",   "user defined flags for file"},
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_GEN
-	{"st_gen",    "generation number"},
+    {"st_gen",    "generation number"},
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
-	{"st_birthtime",   "time of creation"},
+    {"st_birthtime",   "time of creation"},
 #endif
-	{0}
+    {0}
 };
 
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
@@ -1189,10 +1190,10 @@
 #endif
 
 static PyStructSequence_Desc stat_result_desc = {
-	"stat_result", /* name */
-	stat_result__doc__, /* doc */
-	stat_result_fields,
-	10
+    "stat_result", /* name */
+    stat_result__doc__, /* doc */
+    stat_result_fields,
+    10
 };
 
 PyDoc_STRVAR(statvfs_result__doc__,
@@ -1204,24 +1205,24 @@
 See os.statvfs for more information.");
 
 static PyStructSequence_Field statvfs_result_fields[] = {
-        {"f_bsize",  },
-        {"f_frsize", },
-        {"f_blocks", },
-        {"f_bfree",  },
-        {"f_bavail", },
-        {"f_files",  },
-        {"f_ffree",  },
-        {"f_favail", },
-        {"f_flag",   },
-        {"f_namemax",},
-        {0}
+    {"f_bsize",  },
+    {"f_frsize", },
+    {"f_blocks", },
+    {"f_bfree",  },
+    {"f_bavail", },
+    {"f_files",  },
+    {"f_ffree",  },
+    {"f_favail", },
+    {"f_flag",   },
+    {"f_namemax",},
+    {0}
 };
 
 static PyStructSequence_Desc statvfs_result_desc = {
-	"statvfs_result", /* name */
-	statvfs_result__doc__, /* doc */
-	statvfs_result_fields,
-	10
+    "statvfs_result", /* name */
+    statvfs_result__doc__, /* doc */
+    statvfs_result_fields,
+    10
 };
 
 static int initialized;
@@ -1232,23 +1233,23 @@
 static PyObject *
 statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	PyStructSequence *result;
-	int i;
+    PyStructSequence *result;
+    int i;
 
-	result = (PyStructSequence*)structseq_new(type, args, kwds);
-	if (!result)
-		return NULL;
-	/* If we have been initialized from a tuple,
-	   st_?time might be set to None. Initialize it
-	   from the int slots.  */
-	for (i = 7; i <= 9; i++) {
-		if (result->ob_item[i+3] == Py_None) {
-			Py_DECREF(Py_None);
-			Py_INCREF(result->ob_item[i]);
-			result->ob_item[i+3] = result->ob_item[i];
-		}
-	}
-	return (PyObject*)result;
+    result = (PyStructSequence*)structseq_new(type, args, kwds);
+    if (!result)
+        return NULL;
+    /* If we have been initialized from a tuple,
+       st_?time might be set to None. Initialize it
+       from the int slots.  */
+    for (i = 7; i <= 9; i++) {
+        if (result->ob_item[i+3] == Py_None) {
+            Py_DECREF(Py_None);
+            Py_INCREF(result->ob_item[i]);
+            result->ob_item[i+3] = result->ob_item[i];
+        }
+    }
+    return (PyObject*)result;
 }
 
 
@@ -1266,36 +1267,36 @@
 static PyObject*
 stat_float_times(PyObject* self, PyObject *args)
 {
-	int newval = -1;
-	if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval))
-		return NULL;
-	if (newval == -1)
-		/* Return old value */
-		return PyBool_FromLong(_stat_float_times);
-	_stat_float_times = newval;
-	Py_INCREF(Py_None);
-	return Py_None;
+    int newval = -1;
+    if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval))
+        return NULL;
+    if (newval == -1)
+        /* Return old value */
+        return PyBool_FromLong(_stat_float_times);
+    _stat_float_times = newval;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static void
 fill_time(PyObject *v, int index, time_t sec, unsigned long nsec)
 {
-	PyObject *fval,*ival;
+    PyObject *fval,*ival;
 #if SIZEOF_TIME_T > SIZEOF_LONG
-	ival = PyLong_FromLongLong((PY_LONG_LONG)sec);
+    ival = PyLong_FromLongLong((PY_LONG_LONG)sec);
 #else
-	ival = PyLong_FromLong((long)sec);
+    ival = PyLong_FromLong((long)sec);
 #endif
-	if (!ival)
-		return;
-	if (_stat_float_times) {
-		fval = PyFloat_FromDouble(sec + 1e-9*nsec);
-	} else {
-		fval = ival;
-		Py_INCREF(fval);
-	}
-	PyStructSequence_SET_ITEM(v, index, ival);
-	PyStructSequence_SET_ITEM(v, index+3, fval);
+    if (!ival)
+        return;
+    if (_stat_float_times) {
+        fval = PyFloat_FromDouble(sec + 1e-9*nsec);
+    } else {
+        fval = ival;
+        Py_INCREF(fval);
+    }
+    PyStructSequence_SET_ITEM(v, index, ival);
+    PyStructSequence_SET_ITEM(v, index+3, fval);
 }
 
 /* pack a system stat C structure into the Python stat tuple
@@ -1303,99 +1304,99 @@
 static PyObject*
 _pystat_fromstructstat(STRUCT_STAT *st)
 {
-	unsigned long ansec, mnsec, cnsec;
-	PyObject *v = PyStructSequence_New(&StatResultType);
-	if (v == NULL)
-		return NULL;
+    unsigned long ansec, mnsec, cnsec;
+    PyObject *v = PyStructSequence_New(&StatResultType);
+    if (v == NULL)
+        return NULL;
 
-        PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
+    PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
 #ifdef HAVE_LARGEFILE_SUPPORT
-        PyStructSequence_SET_ITEM(v, 1,
-				  PyLong_FromLongLong((PY_LONG_LONG)st->st_ino));
+    PyStructSequence_SET_ITEM(v, 1,
+                              PyLong_FromLongLong((PY_LONG_LONG)st->st_ino));
 #else
-        PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino));
+    PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino));
 #endif
 #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
-        PyStructSequence_SET_ITEM(v, 2,
-				  PyLong_FromLongLong((PY_LONG_LONG)st->st_dev));
+    PyStructSequence_SET_ITEM(v, 2,
+                              PyLong_FromLongLong((PY_LONG_LONG)st->st_dev));
 #else
-        PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long)st->st_dev));
+    PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long)st->st_dev));
 #endif
-        PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long)st->st_nlink));
-        PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long)st->st_uid));
-        PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long)st->st_gid));
+    PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long)st->st_nlink));
+    PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long)st->st_uid));
+    PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long)st->st_gid));
 #ifdef HAVE_LARGEFILE_SUPPORT
-        PyStructSequence_SET_ITEM(v, 6,
-				  PyLong_FromLongLong((PY_LONG_LONG)st->st_size));
+    PyStructSequence_SET_ITEM(v, 6,
+                              PyLong_FromLongLong((PY_LONG_LONG)st->st_size));
 #else
-        PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size));
+    PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size));
 #endif
 
 #if defined(HAVE_STAT_TV_NSEC)
-	ansec = st->st_atim.tv_nsec;
-	mnsec = st->st_mtim.tv_nsec;
-	cnsec = st->st_ctim.tv_nsec;
+    ansec = st->st_atim.tv_nsec;
+    mnsec = st->st_mtim.tv_nsec;
+    cnsec = st->st_ctim.tv_nsec;
 #elif defined(HAVE_STAT_TV_NSEC2)
-	ansec = st->st_atimespec.tv_nsec;
-	mnsec = st->st_mtimespec.tv_nsec;
-	cnsec = st->st_ctimespec.tv_nsec;
+    ansec = st->st_atimespec.tv_nsec;
+    mnsec = st->st_mtimespec.tv_nsec;
+    cnsec = st->st_ctimespec.tv_nsec;
 #elif defined(HAVE_STAT_NSEC)
-	ansec = st->st_atime_nsec;
-	mnsec = st->st_mtime_nsec;
-	cnsec = st->st_ctime_nsec;
-#else
-	ansec = mnsec = cnsec = 0;
-#endif
-	fill_time(v, 7, st->st_atime, ansec);
-	fill_time(v, 8, st->st_mtime, mnsec);
-	fill_time(v, 9, st->st_ctime, cnsec);
+    ansec = st->st_atime_nsec;
+    mnsec = st->st_mtime_nsec;
+    cnsec = st->st_ctime_nsec;
+#else
+    ansec = mnsec = cnsec = 0;
+#endif
+    fill_time(v, 7, st->st_atime, ansec);
+    fill_time(v, 8, st->st_mtime, mnsec);
+    fill_time(v, 9, st->st_ctime, cnsec);
 
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
-	PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX,
-			 PyLong_FromLong((long)st->st_blksize));
+    PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX,
+                              PyLong_FromLong((long)st->st_blksize));
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
-	PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX,
-			 PyLong_FromLong((long)st->st_blocks));
+    PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX,
+                              PyLong_FromLong((long)st->st_blocks));
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_RDEV
-	PyStructSequence_SET_ITEM(v, ST_RDEV_IDX,
-			 PyLong_FromLong((long)st->st_rdev));
+    PyStructSequence_SET_ITEM(v, ST_RDEV_IDX,
+                              PyLong_FromLong((long)st->st_rdev));
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_GEN
-	PyStructSequence_SET_ITEM(v, ST_GEN_IDX,
-			 PyLong_FromLong((long)st->st_gen));
+    PyStructSequence_SET_ITEM(v, ST_GEN_IDX,
+                              PyLong_FromLong((long)st->st_gen));
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
-	{
-	  PyObject *val;
-	  unsigned long bsec,bnsec;
-	  bsec = (long)st->st_birthtime;
+    {
+      PyObject *val;
+      unsigned long bsec,bnsec;
+      bsec = (long)st->st_birthtime;
 #ifdef HAVE_STAT_TV_NSEC2
-	  bnsec = st->st_birthtimespec.tv_nsec;
+      bnsec = st->st_birthtimespec.tv_nsec;
 #else
-	  bnsec = 0;
+      bnsec = 0;
 #endif
-	  if (_stat_float_times) {
-	    val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
-	  } else {
-	    val = PyLong_FromLong((long)bsec);
-	  }
-	  PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX,
-				    val);
-	}
+      if (_stat_float_times) {
+        val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
+      } else {
+        val = PyLong_FromLong((long)bsec);
+      }
+      PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX,
+                                val);
+    }
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_FLAGS
-	PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX,
-			 PyLong_FromLong((long)st->st_flags));
+    PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX,
+                              PyLong_FromLong((long)st->st_flags));
 #endif
 
-	if (PyErr_Occurred()) {
-		Py_DECREF(v);
-		return NULL;
-	}
+    if (PyErr_Occurred()) {
+        Py_DECREF(v);
+        return NULL;
+    }
 
-	return v;
+    return v;
 }
 
 #ifdef MS_WINDOWS
@@ -1414,107 +1415,107 @@
 static BOOL
 IsUNCRootA(char *path, int pathlen)
 {
-	#define ISSLASH ISSLASHA
+    #define ISSLASH ISSLASHA
 
-	int i, share;
+    int i, share;
 
-	if (pathlen < 5 || !ISSLASH(path[0]) || !ISSLASH(path[1]))
-		/* minimum UNCRoot is \\x\y */
-		return FALSE;
-	for (i = 2; i < pathlen ; i++)
-		if (ISSLASH(path[i])) break;
-	if (i == 2 || i == pathlen)
-		/* do not allow \\\SHARE or \\SERVER */
-		return FALSE;
-	share = i+1;
-	for (i = share; i < pathlen; i++)
-		if (ISSLASH(path[i])) break;
-	return (i != share && (i == pathlen || i == pathlen-1));
+    if (pathlen < 5 || !ISSLASH(path[0]) || !ISSLASH(path[1]))
+        /* minimum UNCRoot is \\x\y */
+        return FALSE;
+    for (i = 2; i < pathlen ; i++)
+        if (ISSLASH(path[i])) break;
+    if (i == 2 || i == pathlen)
+        /* do not allow \\\SHARE or \\SERVER */
+        return FALSE;
+    share = i+1;
+    for (i = share; i < pathlen; i++)
+        if (ISSLASH(path[i])) break;
+    return (i != share && (i == pathlen || i == pathlen-1));
 
-	#undef ISSLASH
+    #undef ISSLASH
 }
 
 static BOOL
 IsUNCRootW(Py_UNICODE *path, int pathlen)
 {
-	#define ISSLASH ISSLASHW
+    #define ISSLASH ISSLASHW
 
-	int i, share;
+    int i, share;
 
-	if (pathlen < 5 || !ISSLASH(path[0]) || !ISSLASH(path[1]))
-		/* minimum UNCRoot is \\x\y */
-		return FALSE;
-	for (i = 2; i < pathlen ; i++)
-		if (ISSLASH(path[i])) break;
-	if (i == 2 || i == pathlen)
-		/* do not allow \\\SHARE or \\SERVER */
-		return FALSE;
-	share = i+1;
-	for (i = share; i < pathlen; i++)
-		if (ISSLASH(path[i])) break;
-	return (i != share && (i == pathlen || i == pathlen-1));
+    if (pathlen < 5 || !ISSLASH(path[0]) || !ISSLASH(path[1]))
+        /* minimum UNCRoot is \\x\y */
+        return FALSE;
+    for (i = 2; i < pathlen ; i++)
+        if (ISSLASH(path[i])) break;
+    if (i == 2 || i == pathlen)
+        /* do not allow \\\SHARE or \\SERVER */
+        return FALSE;
+    share = i+1;
+    for (i = share; i < pathlen; i++)
+        if (ISSLASH(path[i])) break;
+    return (i != share && (i == pathlen || i == pathlen-1));
 
-	#undef ISSLASH
+    #undef ISSLASH
 }
 #endif /* MS_WINDOWS */
 
 static PyObject *
 posix_do_stat(PyObject *self, PyObject *args,
-	      char *format,
+              char *format,
 #ifdef __VMS
-	      int (*statfunc)(const char *, STRUCT_STAT *, ...),
+              int (*statfunc)(const char *, STRUCT_STAT *, ...),
 #else
-	      int (*statfunc)(const char *, STRUCT_STAT *),
+              int (*statfunc)(const char *, STRUCT_STAT *),
 #endif
-	      char *wformat,
-	      int (*wstatfunc)(const Py_UNICODE *, STRUCT_STAT *))
+              char *wformat,
+              int (*wstatfunc)(const Py_UNICODE *, STRUCT_STAT *))
 {
-	STRUCT_STAT st;
-	PyObject *opath;
-	char *path;
-	int res;
-	PyObject *result;
+    STRUCT_STAT st;
+    PyObject *opath;
+    char *path;
+    int res;
+    PyObject *result;
 
 #ifdef MS_WINDOWS
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, wformat, &po)) {
-		Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
-
-		Py_BEGIN_ALLOW_THREADS
-			/* PyUnicode_AS_UNICODE result OK without
-			   thread lock as it is a simple dereference. */
-		res = wstatfunc(wpath, &st);
-		Py_END_ALLOW_THREADS
-
-		if (res != 0)
-			return win32_error_unicode("stat", wpath);
-		return _pystat_fromstructstat(&st);
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-#endif
-
-	if (!PyArg_ParseTuple(args, format,
-	                      PyUnicode_FSConverter, &opath))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = (*statfunc)(path, &st);
-	Py_END_ALLOW_THREADS
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, wformat, &po)) {
+        Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
+
+        Py_BEGIN_ALLOW_THREADS
+            /* PyUnicode_AS_UNICODE result OK without
+               thread lock as it is a simple dereference. */
+        res = wstatfunc(wpath, &st);
+        Py_END_ALLOW_THREADS
+
+        if (res != 0)
+            return win32_error_unicode("stat", wpath);
+        return _pystat_fromstructstat(&st);
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+#endif
+
+    if (!PyArg_ParseTuple(args, format,
+                          PyUnicode_FSConverter, &opath))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = (*statfunc)(path, &st);
+    Py_END_ALLOW_THREADS
 
-	if (res != 0) {
+    if (res != 0) {
 #ifdef MS_WINDOWS
-		result = win32_error("stat", path);
+        result = win32_error("stat", path);
 #else
-		result = posix_error_with_filename(path);
+        result = posix_error_with_filename(path);
 #endif
-	} 
-	else
-		result = _pystat_fromstructstat(&st);
+    }
+    else
+        result = _pystat_fromstructstat(&st);
 
-	Py_DECREF(opath);
-	return result;
+    Py_DECREF(opath);
+    return result;
 }
 
 /* POSIX methods */
@@ -1530,53 +1531,53 @@
 static PyObject *
 posix_access(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	int mode;
-	
+    PyObject *opath;
+    char *path;
+    int mode;
+
 #ifdef MS_WINDOWS
-	DWORD attr;
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) {
-		Py_BEGIN_ALLOW_THREADS
-		/* PyUnicode_AS_UNICODE OK without thread lock as
-		   it is a simple dereference. */
-		attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po));
-		Py_END_ALLOW_THREADS
-		goto finish;
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-	if (!PyArg_ParseTuple(args, "O&i:access",
-			      PyUnicode_FSConverter, &opath, &mode))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	attr = GetFileAttributesA(path);
-	Py_END_ALLOW_THREADS
-	Py_DECREF(opath);
+    DWORD attr;
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) {
+        Py_BEGIN_ALLOW_THREADS
+        /* PyUnicode_AS_UNICODE OK without thread lock as
+           it is a simple dereference. */
+        attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po));
+        Py_END_ALLOW_THREADS
+        goto finish;
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+    if (!PyArg_ParseTuple(args, "O&i:access",
+                          PyUnicode_FSConverter, &opath, &mode))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    attr = GetFileAttributesA(path);
+    Py_END_ALLOW_THREADS
+    Py_DECREF(opath);
 finish:
-	if (attr == 0xFFFFFFFF)
-		/* File does not exist, or cannot read attributes */
-		return PyBool_FromLong(0);
-	/* Access is possible if either write access wasn't requested, or
-	   the file isn't read-only, or if it's a directory, as there are
-	   no read-only directories on Windows. */
-	return PyBool_FromLong(!(mode & 2) 
-	                       || !(attr & FILE_ATTRIBUTE_READONLY)
-			       || (attr & FILE_ATTRIBUTE_DIRECTORY));
-#else
-	int res;
-	if (!PyArg_ParseTuple(args, "O&i:access", 
-			      PyUnicode_FSConverter, &opath, &mode))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = access(path, mode);
-	Py_END_ALLOW_THREADS
-	Py_DECREF(opath);
-	return PyBool_FromLong(res == 0);
+    if (attr == 0xFFFFFFFF)
+        /* File does not exist, or cannot read attributes */
+        return PyBool_FromLong(0);
+    /* Access is possible if either write access wasn't requested, or
+       the file isn't read-only, or if it's a directory, as there are
+       no read-only directories on Windows. */
+    return PyBool_FromLong(!(mode & 2)
+                           || !(attr & FILE_ATTRIBUTE_READONLY)
+                           || (attr & FILE_ATTRIBUTE_DIRECTORY));
+#else
+    int res;
+    if (!PyArg_ParseTuple(args, "O&i:access",
+                          PyUnicode_FSConverter, &opath, &mode))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = access(path, mode);
+    Py_END_ALLOW_THREADS
+    Py_DECREF(opath);
+    return PyBool_FromLong(res == 0);
 #endif
 }
 
@@ -1601,26 +1602,26 @@
 static PyObject *
 posix_ttyname(PyObject *self, PyObject *args)
 {
-	int id;
-	char *ret;
+    int id;
+    char *ret;
 
-	if (!PyArg_ParseTuple(args, "i:ttyname", &id))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:ttyname", &id))
+        return NULL;
 
 #if defined(__VMS)
-        /* file descriptor 0 only, the default input device (stdin) */
-	if (id == 0) {
-		ret = ttyname();
-	}
-	else {
-		ret = NULL;
-	}
-#else
-	ret = ttyname(id);
-#endif
-	if (ret == NULL)
-		return posix_error();
-	return PyUnicode_FromString(ret);
+    /* file descriptor 0 only, the default input device (stdin) */
+    if (id == 0) {
+        ret = ttyname();
+    }
+    else {
+        ret = NULL;
+    }
+#else
+    ret = ttyname(id);
+#endif
+    if (ret == NULL)
+        return posix_error();
+    return PyUnicode_FromString(ret);
 }
 #endif
 
@@ -1632,17 +1633,17 @@
 static PyObject *
 posix_ctermid(PyObject *self, PyObject *noargs)
 {
-        char *ret;
-        char buffer[L_ctermid];
+    char *ret;
+    char buffer[L_ctermid];
 
 #ifdef USE_CTERMID_R
-	ret = ctermid_r(buffer);
+    ret = ctermid_r(buffer);
 #else
-        ret = ctermid(buffer);
+    ret = ctermid(buffer);
 #endif
-	if (ret == NULL)
-		return posix_error();
-	return PyUnicode_FromString(buffer);
+    if (ret == NULL)
+        return posix_error();
+    return PyUnicode_FromString(buffer);
 }
 #endif
 
@@ -1654,13 +1655,13 @@
 posix_chdir(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	return win32_1str(args, "chdir", "y:chdir", win32_chdir, "U:chdir", win32_wchdir);
+    return win32_1str(args, "chdir", "y:chdir", win32_chdir, "U:chdir", win32_wchdir);
 #elif defined(PYOS_OS2) && defined(PYCC_GCC)
-	return posix_1str(args, "O&:chdir", _chdir2);
+    return posix_1str(args, "O&:chdir", _chdir2);
 #elif defined(__VMS)
-	return posix_1str(args, "O&:chdir", (int (*)(const char *))chdir);
+    return posix_1str(args, "O&:chdir", (int (*)(const char *))chdir);
 #else
-	return posix_1str(args, "O&:chdir", chdir);
+    return posix_1str(args, "O&:chdir", chdir);
 #endif
 }
 
@@ -1673,7 +1674,7 @@
 static PyObject *
 posix_fchdir(PyObject *self, PyObject *fdobj)
 {
-	return posix_fildes(fdobj, fchdir);
+    return posix_fildes(fdobj, fchdir);
 }
 #endif /* HAVE_FCHDIR */
 
@@ -1685,73 +1686,73 @@
 static PyObject *
 posix_chmod(PyObject *self, PyObject *args)
 {
-	PyObject *opath = NULL;
-	char *path = NULL;
-	int i;
-	int res;
+    PyObject *opath = NULL;
+    char *path = NULL;
+    int i;
+    int res;
 #ifdef MS_WINDOWS
-	DWORD attr;
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) {
-		Py_BEGIN_ALLOW_THREADS
-		attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po));
-		if (attr != 0xFFFFFFFF) {
-			if (i & _S_IWRITE)
-				attr &= ~FILE_ATTRIBUTE_READONLY;
-			else
-				attr |= FILE_ATTRIBUTE_READONLY;
-			res = SetFileAttributesW(PyUnicode_AS_UNICODE(po), attr);
-		}
-		else
-			res = 0;
-		Py_END_ALLOW_THREADS
-		if (!res)
-			return win32_error_unicode("chmod",
-					PyUnicode_AS_UNICODE(po));
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-
-	if (!PyArg_ParseTuple(args, "O&i:chmod", PyUnicode_FSConverter,
-	                      &opath, &i))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	attr = GetFileAttributesA(path);
-	if (attr != 0xFFFFFFFF) {
-		if (i & _S_IWRITE)
-			attr &= ~FILE_ATTRIBUTE_READONLY;
-		else
-			attr |= FILE_ATTRIBUTE_READONLY;
-		res = SetFileAttributesA(path, attr);
-	}
-	else
-		res = 0;
-	Py_END_ALLOW_THREADS
-	if (!res) {
-		win32_error("chmod", path);
-		Py_DECREF(opath);
-		return NULL;
-	}
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    DWORD attr;
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) {
+        Py_BEGIN_ALLOW_THREADS
+        attr = GetFileAttributesW(PyUnicode_AS_UNICODE(po));
+        if (attr != 0xFFFFFFFF) {
+            if (i & _S_IWRITE)
+                attr &= ~FILE_ATTRIBUTE_READONLY;
+            else
+                attr |= FILE_ATTRIBUTE_READONLY;
+            res = SetFileAttributesW(PyUnicode_AS_UNICODE(po), attr);
+        }
+        else
+            res = 0;
+        Py_END_ALLOW_THREADS
+        if (!res)
+            return win32_error_unicode("chmod",
+                                       PyUnicode_AS_UNICODE(po));
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+
+    if (!PyArg_ParseTuple(args, "O&i:chmod", PyUnicode_FSConverter,
+                          &opath, &i))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    attr = GetFileAttributesA(path);
+    if (attr != 0xFFFFFFFF) {
+        if (i & _S_IWRITE)
+            attr &= ~FILE_ATTRIBUTE_READONLY;
+        else
+            attr |= FILE_ATTRIBUTE_READONLY;
+        res = SetFileAttributesA(path, attr);
+    }
+    else
+        res = 0;
+    Py_END_ALLOW_THREADS
+    if (!res) {
+        win32_error("chmod", path);
+        Py_DECREF(opath);
+        return NULL;
+    }
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 #else /* MS_WINDOWS */
-	if (!PyArg_ParseTuple(args, "O&i:chmod", PyUnicode_FSConverter,
-	                      &opath, &i))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = chmod(path, i);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    if (!PyArg_ParseTuple(args, "O&i:chmod", PyUnicode_FSConverter,
+                          &opath, &i))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = chmod(path, i);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 #endif
 }
 
@@ -1764,15 +1765,15 @@
 static PyObject *
 posix_fchmod(PyObject *self, PyObject *args)
 {
-	int fd, mode, res;
-	if (!PyArg_ParseTuple(args, "ii:fchmod", &fd, &mode))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = fchmod(fd, mode);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_RETURN_NONE;
+    int fd, mode, res;
+    if (!PyArg_ParseTuple(args, "ii:fchmod", &fd, &mode))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = fchmod(fd, mode);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_RETURN_NONE;
 }
 #endif /* HAVE_FCHMOD */
 
@@ -1785,21 +1786,21 @@
 static PyObject *
 posix_lchmod(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	int i;
-	int res;
-	if (!PyArg_ParseTuple(args, "O&i:lchmod", PyUnicode_FSConverter,
-	                      &opath, &i))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = lchmod(path, i);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_RETURN_NONE;
+    PyObject *opath;
+    char *path;
+    int i;
+    int res;
+    if (!PyArg_ParseTuple(args, "O&i:lchmod", PyUnicode_FSConverter,
+                          &opath, &i))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = lchmod(path, i);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_RETURN_NONE;
 }
 #endif /* HAVE_LCHMOD */
 
@@ -1812,22 +1813,22 @@
 static PyObject *
 posix_chflags(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	unsigned long flags;
-	int res;
-	if (!PyArg_ParseTuple(args, "O&k:chflags",
-			      PyUnicode_FSConverter, &opath, &flags))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = chflags(path, flags);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath;
+    char *path;
+    unsigned long flags;
+    int res;
+    if (!PyArg_ParseTuple(args, "O&k:chflags",
+                          PyUnicode_FSConverter, &opath, &flags))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = chflags(path, flags);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_CHFLAGS */
 
@@ -1840,22 +1841,22 @@
 static PyObject *
 posix_lchflags(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	unsigned long flags;
-	int res;
-	if (!PyArg_ParseTuple(args, "O&k:lchflags",
-			      PyUnicode_FSConverter, &opath, &flags))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = lchflags(path, flags);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath;
+    char *path;
+    unsigned long flags;
+    int res;
+    if (!PyArg_ParseTuple(args, "O&k:lchflags",
+                          PyUnicode_FSConverter, &opath, &flags))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = lchflags(path, flags);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_LCHFLAGS */
 
@@ -1867,7 +1868,7 @@
 static PyObject *
 posix_chroot(PyObject *self, PyObject *args)
 {
-	return posix_1str(args, "O&:chroot", chroot);
+    return posix_1str(args, "O&:chroot", chroot);
 }
 #endif
 
@@ -1910,23 +1911,23 @@
 static PyObject *
 posix_chown(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	long uid, gid;
-	int res;
-	if (!PyArg_ParseTuple(args, "O&ll:chown",
-	                      PyUnicode_FSConverter, &opath,
-	                      &uid, &gid))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = chown(path, (uid_t) uid, (gid_t) gid);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath;
+    char *path;
+    long uid, gid;
+    int res;
+    if (!PyArg_ParseTuple(args, "O&ll:chown",
+                          PyUnicode_FSConverter, &opath,
+                          &uid, &gid))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = chown(path, (uid_t) uid, (gid_t) gid);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_CHOWN */
 
@@ -1939,17 +1940,17 @@
 static PyObject *
 posix_fchown(PyObject *self, PyObject *args)
 {
-	int fd;
-	long uid, gid;
-	int res;
-	if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = fchown(fd, (uid_t) uid, (gid_t) gid);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_RETURN_NONE;
+    int fd;
+    long uid, gid;
+    int res;
+    if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = fchown(fd, (uid_t) uid, (gid_t) gid);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_RETURN_NONE;
 }
 #endif /* HAVE_FCHOWN */
 
@@ -1962,23 +1963,23 @@
 static PyObject *
 posix_lchown(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	long uid, gid;
-	int res;
-	if (!PyArg_ParseTuple(args, "O&ll:lchown",
-	                      PyUnicode_FSConverter, &opath,
-	                      &uid, &gid))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	res = lchown(path, (uid_t) uid, (gid_t) gid);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *opath;
+    char *path;
+    long uid, gid;
+    int res;
+    if (!PyArg_ParseTuple(args, "O&ll:lchown",
+                          PyUnicode_FSConverter, &opath,
+                          &uid, &gid))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    res = lchown(path, (uid_t) uid, (gid_t) gid);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_LCHOWN */
 
@@ -1987,52 +1988,52 @@
 static PyObject *
 posix_getcwd(int use_bytes)
 {
-	char buf[1026];
-	char *res;
+    char buf[1026];
+    char *res;
 
 #ifdef MS_WINDOWS
-	if (!use_bytes) {
-		wchar_t wbuf[1026];
-		wchar_t *wbuf2 = wbuf;
-		PyObject *resobj;
-		DWORD len;
-		Py_BEGIN_ALLOW_THREADS
-		len = GetCurrentDirectoryW(sizeof wbuf/ sizeof wbuf[0], wbuf);
-		/* If the buffer is large enough, len does not include the
-		   terminating \0. If the buffer is too small, len includes
-		   the space needed for the terminator. */
-		if (len >= sizeof wbuf/ sizeof wbuf[0]) {
-			wbuf2 = malloc(len * sizeof(wchar_t));
-			if (wbuf2)
-				len = GetCurrentDirectoryW(len, wbuf2);
-		}
-		Py_END_ALLOW_THREADS
-		if (!wbuf2) {
-			PyErr_NoMemory();
-			return NULL;
-		}
-		if (!len) {
-			if (wbuf2 != wbuf) free(wbuf2);
-			return win32_error("getcwdu", NULL);
-		}
-		resobj = PyUnicode_FromWideChar(wbuf2, len);
-		if (wbuf2 != wbuf) free(wbuf2);
-		return resobj;
-	}
+    if (!use_bytes) {
+        wchar_t wbuf[1026];
+        wchar_t *wbuf2 = wbuf;
+        PyObject *resobj;
+        DWORD len;
+        Py_BEGIN_ALLOW_THREADS
+        len = GetCurrentDirectoryW(sizeof wbuf/ sizeof wbuf[0], wbuf);
+        /* If the buffer is large enough, len does not include the
+           terminating \0. If the buffer is too small, len includes
+           the space needed for the terminator. */
+        if (len >= sizeof wbuf/ sizeof wbuf[0]) {
+            wbuf2 = malloc(len * sizeof(wchar_t));
+            if (wbuf2)
+                len = GetCurrentDirectoryW(len, wbuf2);
+        }
+        Py_END_ALLOW_THREADS
+        if (!wbuf2) {
+            PyErr_NoMemory();
+            return NULL;
+        }
+        if (!len) {
+            if (wbuf2 != wbuf) free(wbuf2);
+            return win32_error("getcwdu", NULL);
+        }
+        resobj = PyUnicode_FromWideChar(wbuf2, len);
+        if (wbuf2 != wbuf) free(wbuf2);
+        return resobj;
+    }
 #endif
 
-	Py_BEGIN_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
 #if defined(PYOS_OS2) && defined(PYCC_GCC)
-	res = _getcwd2(buf, sizeof buf);
+    res = _getcwd2(buf, sizeof buf);
 #else
-	res = getcwd(buf, sizeof buf);
+    res = getcwd(buf, sizeof buf);
 #endif
-	Py_END_ALLOW_THREADS
-	if (res == NULL)
-		return posix_error();
-	if (use_bytes)
-		return PyBytes_FromStringAndSize(buf, strlen(buf));
-	return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"surrogateescape");
+    Py_END_ALLOW_THREADS
+    if (res == NULL)
+        return posix_error();
+    if (use_bytes)
+        return PyBytes_FromStringAndSize(buf, strlen(buf));
+    return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"surrogateescape");
 }
 
 PyDoc_STRVAR(posix_getcwd__doc__,
@@ -2065,7 +2066,7 @@
 static PyObject *
 posix_link(PyObject *self, PyObject *args)
 {
-	return posix_2str(args, "O&O&:link", link);
+    return posix_2str(args, "O&O&:link", link);
 }
 #endif /* HAVE_LINK */
 
@@ -2074,7 +2075,7 @@
 "listdir(path) -> list_of_strings\n\n\
 Return a list containing the names of the entries in the directory.\n\
 \n\
-	path: path of directory to list\n\
+    path: path of directory to list\n\
 \n\
 The list is in arbitrary order.  It does not include the special\n\
 entries '.' and '..' even if they are present in the directory.");
@@ -2082,163 +2083,163 @@
 static PyObject *
 posix_listdir(PyObject *self, PyObject *args)
 {
-	/* XXX Should redo this putting the (now four) versions of opendir
-	   in separate files instead of having them all here... */
+    /* XXX Should redo this putting the (now four) versions of opendir
+       in separate files instead of having them all here... */
 #if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR)
 
-	PyObject *d, *v;
-	HANDLE hFindFile;
-	BOOL result;
-	WIN32_FIND_DATA FileData;
-	PyObject *opath;
-	char namebuf[MAX_PATH+5]; /* Overallocate for \\*.*\0 */
-	char *bufptr = namebuf;
-	Py_ssize_t len = sizeof(namebuf)-5; /* only claim to have space for MAX_PATH */
-
-	PyObject *po;
-	if (PyArg_ParseTuple(args, "U:listdir", &po)) {
-		WIN32_FIND_DATAW wFileData;
-		Py_UNICODE *wnamebuf;
-		/* Overallocate for \\*.*\0 */
-		len = PyUnicode_GET_SIZE(po);
-		wnamebuf = malloc((len + 5) * sizeof(wchar_t));
-		if (!wnamebuf) {
-			PyErr_NoMemory();
-			return NULL;
-		}
-		wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po));
-		if (len > 0) {
-			Py_UNICODE wch = wnamebuf[len-1];
-			if (wch != L'/' && wch != L'\\' && wch != L':')
-				wnamebuf[len++] = L'\\';
-			wcscpy(wnamebuf + len, L"*.*");
-		}
-		if ((d = PyList_New(0)) == NULL) {
-			free(wnamebuf);
-			return NULL;
-		}
-		hFindFile = FindFirstFileW(wnamebuf, &wFileData);
-		if (hFindFile == INVALID_HANDLE_VALUE) {
-			int error = GetLastError();
-			if (error == ERROR_FILE_NOT_FOUND) {
-				free(wnamebuf);
-				return d;
-			}
-			Py_DECREF(d);
-			win32_error_unicode("FindFirstFileW", wnamebuf);
-			free(wnamebuf);
-			return NULL;
-		}
-		do {
-			/* Skip over . and .. */
-			if (wcscmp(wFileData.cFileName, L".") != 0 &&
-			    wcscmp(wFileData.cFileName, L"..") != 0) {
-				v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName));
-				if (v == NULL) {
-					Py_DECREF(d);
-					d = NULL;
-					break;
-				}
-				if (PyList_Append(d, v) != 0) {
-					Py_DECREF(v);
-					Py_DECREF(d);
-					d = NULL;
-					break;
-				}
-				Py_DECREF(v);
-			}
-			Py_BEGIN_ALLOW_THREADS
-			result = FindNextFileW(hFindFile, &wFileData);
-			Py_END_ALLOW_THREADS
-			/* FindNextFile sets error to ERROR_NO_MORE_FILES if
-			   it got to the end of the directory. */
-			if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
-			    Py_DECREF(d);
-			    win32_error_unicode("FindNextFileW", wnamebuf);
-			    FindClose(hFindFile);
-			    free(wnamebuf);
-			    return NULL;
-			}
-		} while (result == TRUE);
-
-		if (FindClose(hFindFile) == FALSE) {
-			Py_DECREF(d);
-			win32_error_unicode("FindClose", wnamebuf);
-			free(wnamebuf);
-			return NULL;
-		}
-		free(wnamebuf);
-		return d;
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-
-	if (!PyArg_ParseTuple(args, "O&:listdir",
-	                      PyUnicode_FSConverter, &opath))
-		return NULL;
-	if (PyBytes_GET_SIZE(opath)+1 > MAX_PATH) {
-		PyErr_SetString(PyExc_ValueError, "path too long");
-		Py_DECREF(opath);
-		return NULL;
-	}
-	strcpy(namebuf, PyBytes_AsString(opath));
-	len = PyObject_Size(opath);
-	if (len > 0) {
-		char ch = namebuf[len-1];
-		if (ch != SEP && ch != ALTSEP && ch != ':')
-			namebuf[len++] = '/';
-		strcpy(namebuf + len, "*.*");
-	}
-
-	if ((d = PyList_New(0)) == NULL)
-		return NULL;
-
-	hFindFile = FindFirstFile(namebuf, &FileData);
-	if (hFindFile == INVALID_HANDLE_VALUE) {
-		int error = GetLastError();
-		if (error == ERROR_FILE_NOT_FOUND)
-			return d;
-		Py_DECREF(d);
-		return win32_error("FindFirstFile", namebuf);
-	}
-	do {
-		/* Skip over . and .. */
-		if (strcmp(FileData.cFileName, ".") != 0 &&
-		    strcmp(FileData.cFileName, "..") != 0) {
-			v = PyBytes_FromString(FileData.cFileName);
-			if (v == NULL) {
-				Py_DECREF(d);
-				d = NULL;
-				break;
-			}
-			if (PyList_Append(d, v) != 0) {
-				Py_DECREF(v);
-				Py_DECREF(d);
-				d = NULL;
-				break;
-			}
-			Py_DECREF(v);
-		}
-		Py_BEGIN_ALLOW_THREADS
-		result = FindNextFile(hFindFile, &FileData);
-		Py_END_ALLOW_THREADS
-		/* FindNextFile sets error to ERROR_NO_MORE_FILES if
-		   it got to the end of the directory. */
-		if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
-		    Py_DECREF(d);
-		    win32_error("FindNextFile", namebuf);
-		    FindClose(hFindFile);
-		    return NULL;
-		}
-	} while (result == TRUE);
-
-	if (FindClose(hFindFile) == FALSE) {
-		Py_DECREF(d);
-		return win32_error("FindClose", namebuf);
-	}
+    PyObject *d, *v;
+    HANDLE hFindFile;
+    BOOL result;
+    WIN32_FIND_DATA FileData;
+    PyObject *opath;
+    char namebuf[MAX_PATH+5]; /* Overallocate for \\*.*\0 */
+    char *bufptr = namebuf;
+    Py_ssize_t len = sizeof(namebuf)-5; /* only claim to have space for MAX_PATH */
+
+    PyObject *po;
+    if (PyArg_ParseTuple(args, "U:listdir", &po)) {
+        WIN32_FIND_DATAW wFileData;
+        Py_UNICODE *wnamebuf;
+        /* Overallocate for \\*.*\0 */
+        len = PyUnicode_GET_SIZE(po);
+        wnamebuf = malloc((len + 5) * sizeof(wchar_t));
+        if (!wnamebuf) {
+            PyErr_NoMemory();
+            return NULL;
+        }
+        wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po));
+        if (len > 0) {
+            Py_UNICODE wch = wnamebuf[len-1];
+            if (wch != L'/' && wch != L'\\' && wch != L':')
+                wnamebuf[len++] = L'\\';
+            wcscpy(wnamebuf + len, L"*.*");
+        }
+        if ((d = PyList_New(0)) == NULL) {
+            free(wnamebuf);
+            return NULL;
+        }
+        hFindFile = FindFirstFileW(wnamebuf, &wFileData);
+        if (hFindFile == INVALID_HANDLE_VALUE) {
+            int error = GetLastError();
+            if (error == ERROR_FILE_NOT_FOUND) {
+                free(wnamebuf);
+                return d;
+            }
+            Py_DECREF(d);
+            win32_error_unicode("FindFirstFileW", wnamebuf);
+            free(wnamebuf);
+            return NULL;
+        }
+        do {
+            /* Skip over . and .. */
+            if (wcscmp(wFileData.cFileName, L".") != 0 &&
+                wcscmp(wFileData.cFileName, L"..") != 0) {
+                v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName));
+                if (v == NULL) {
+                    Py_DECREF(d);
+                    d = NULL;
+                    break;
+                }
+                if (PyList_Append(d, v) != 0) {
+                    Py_DECREF(v);
+                    Py_DECREF(d);
+                    d = NULL;
+                    break;
+                }
+                Py_DECREF(v);
+            }
+            Py_BEGIN_ALLOW_THREADS
+            result = FindNextFileW(hFindFile, &wFileData);
+            Py_END_ALLOW_THREADS
+            /* FindNextFile sets error to ERROR_NO_MORE_FILES if
+               it got to the end of the directory. */
+            if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+                Py_DECREF(d);
+                win32_error_unicode("FindNextFileW", wnamebuf);
+                FindClose(hFindFile);
+                free(wnamebuf);
+                return NULL;
+            }
+        } while (result == TRUE);
+
+        if (FindClose(hFindFile) == FALSE) {
+            Py_DECREF(d);
+            win32_error_unicode("FindClose", wnamebuf);
+            free(wnamebuf);
+            return NULL;
+        }
+        free(wnamebuf);
+        return d;
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+
+    if (!PyArg_ParseTuple(args, "O&:listdir",
+                          PyUnicode_FSConverter, &opath))
+        return NULL;
+    if (PyBytes_GET_SIZE(opath)+1 > MAX_PATH) {
+        PyErr_SetString(PyExc_ValueError, "path too long");
+        Py_DECREF(opath);
+        return NULL;
+    }
+    strcpy(namebuf, PyBytes_AsString(opath));
+    len = PyObject_Size(opath);
+    if (len > 0) {
+        char ch = namebuf[len-1];
+        if (ch != SEP && ch != ALTSEP && ch != ':')
+            namebuf[len++] = '/';
+        strcpy(namebuf + len, "*.*");
+    }
+
+    if ((d = PyList_New(0)) == NULL)
+        return NULL;
+
+    hFindFile = FindFirstFile(namebuf, &FileData);
+    if (hFindFile == INVALID_HANDLE_VALUE) {
+        int error = GetLastError();
+        if (error == ERROR_FILE_NOT_FOUND)
+            return d;
+        Py_DECREF(d);
+        return win32_error("FindFirstFile", namebuf);
+    }
+    do {
+        /* Skip over . and .. */
+        if (strcmp(FileData.cFileName, ".") != 0 &&
+            strcmp(FileData.cFileName, "..") != 0) {
+            v = PyBytes_FromString(FileData.cFileName);
+            if (v == NULL) {
+                Py_DECREF(d);
+                d = NULL;
+                break;
+            }
+            if (PyList_Append(d, v) != 0) {
+                Py_DECREF(v);
+                Py_DECREF(d);
+                d = NULL;
+                break;
+            }
+            Py_DECREF(v);
+        }
+        Py_BEGIN_ALLOW_THREADS
+        result = FindNextFile(hFindFile, &FileData);
+        Py_END_ALLOW_THREADS
+        /* FindNextFile sets error to ERROR_NO_MORE_FILES if
+           it got to the end of the directory. */
+        if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+            Py_DECREF(d);
+            win32_error("FindNextFile", namebuf);
+            FindClose(hFindFile);
+            return NULL;
+        }
+    } while (result == TRUE);
+
+    if (FindClose(hFindFile) == FALSE) {
+        Py_DECREF(d);
+        return win32_error("FindClose", namebuf);
+    }
 
-	return d;
+    return d;
 
 #elif defined(PYOS_OS2)
 
@@ -2255,7 +2256,7 @@
     FILEFINDBUF3   ep;
     APIRET rc;
 
-    if (!PyArg_ParseTuple(args, "O&:listdir", 
+    if (!PyArg_ParseTuple(args, "O&:listdir",
                           PyUnicode_FSConverter, &oname))
         return NULL;
     name = PyBytes_AsString(oname);
@@ -2320,82 +2321,82 @@
     Py_DECREF(oname);
     return d;
 #else
-	PyObject *oname;
-	char *name;
-	PyObject *d, *v;
-	DIR *dirp;
-	struct dirent *ep;
-	int arg_is_unicode = 1;
-
-	errno = 0;
-	if (!PyArg_ParseTuple(args, "U:listdir", &v)) {
-		arg_is_unicode = 0;
-		PyErr_Clear();
-	}
-	if (!PyArg_ParseTuple(args, "O&:listdir", PyUnicode_FSConverter, &oname))
-		return NULL;
-	name = PyBytes_AsString(oname);
-	if ((dirp = opendir(name)) == NULL) {
-		return posix_error_with_allocated_filename(oname);
-	}
-	if ((d = PyList_New(0)) == NULL) {
-		closedir(dirp);
-		Py_DECREF(oname);
-		return NULL;
-	}
-	for (;;) {
-		errno = 0;
-		Py_BEGIN_ALLOW_THREADS
-		ep = readdir(dirp);
-		Py_END_ALLOW_THREADS
-		if (ep == NULL) {
-			if (errno == 0) {
-				break;
-			} else {
-				closedir(dirp);
-				Py_DECREF(d);
-				return posix_error_with_allocated_filename(oname);
-			}
-		}
-		if (ep->d_name[0] == '.' &&
-		    (NAMLEN(ep) == 1 ||
-		     (ep->d_name[1] == '.' && NAMLEN(ep) == 2)))
-			continue;
-		v = PyBytes_FromStringAndSize(ep->d_name, NAMLEN(ep));
-		if (v == NULL) {
-			Py_DECREF(d);
-			d = NULL;
-			break;
-		}
-		if (arg_is_unicode) {
-			PyObject *w;
-
-			w = PyUnicode_FromEncodedObject(v,
-					Py_FileSystemDefaultEncoding,
-					"surrogateescape");
-			Py_DECREF(v);
-			if (w != NULL)
-				v = w;
-			else {
-				/* Encoding failed to decode ASCII bytes.
-				   Raise exception. */
-				Py_DECREF(d);
-				d = NULL;
-				break;
-			}
-		}
-		if (PyList_Append(d, v) != 0) {
-			Py_DECREF(v);
-			Py_DECREF(d);
-			d = NULL;
-			break;
-		}
-		Py_DECREF(v);
-	}
-	closedir(dirp);
-	Py_DECREF(oname);
+    PyObject *oname;
+    char *name;
+    PyObject *d, *v;
+    DIR *dirp;
+    struct dirent *ep;
+    int arg_is_unicode = 1;
+
+    errno = 0;
+    if (!PyArg_ParseTuple(args, "U:listdir", &v)) {
+        arg_is_unicode = 0;
+        PyErr_Clear();
+    }
+    if (!PyArg_ParseTuple(args, "O&:listdir", PyUnicode_FSConverter, &oname))
+        return NULL;
+    name = PyBytes_AsString(oname);
+    if ((dirp = opendir(name)) == NULL) {
+        return posix_error_with_allocated_filename(oname);
+    }
+    if ((d = PyList_New(0)) == NULL) {
+        closedir(dirp);
+        Py_DECREF(oname);
+        return NULL;
+    }
+    for (;;) {
+        errno = 0;
+        Py_BEGIN_ALLOW_THREADS
+        ep = readdir(dirp);
+        Py_END_ALLOW_THREADS
+        if (ep == NULL) {
+            if (errno == 0) {
+                break;
+            } else {
+                closedir(dirp);
+                Py_DECREF(d);
+                return posix_error_with_allocated_filename(oname);
+            }
+        }
+        if (ep->d_name[0] == '.' &&
+            (NAMLEN(ep) == 1 ||
+             (ep->d_name[1] == '.' && NAMLEN(ep) == 2)))
+            continue;
+        v = PyBytes_FromStringAndSize(ep->d_name, NAMLEN(ep));
+        if (v == NULL) {
+            Py_DECREF(d);
+            d = NULL;
+            break;
+        }
+        if (arg_is_unicode) {
+            PyObject *w;
+
+            w = PyUnicode_FromEncodedObject(v,
+                                            Py_FileSystemDefaultEncoding,
+                                            "surrogateescape");
+            Py_DECREF(v);
+            if (w != NULL)
+                v = w;
+            else {
+                /* Encoding failed to decode ASCII bytes.
+                   Raise exception. */
+                Py_DECREF(d);
+                d = NULL;
+                break;
+            }
+        }
+        if (PyList_Append(d, v) != 0) {
+            Py_DECREF(v);
+            Py_DECREF(d);
+            d = NULL;
+            break;
+        }
+        Py_DECREF(v);
+    }
+    closedir(dirp);
+    Py_DECREF(oname);
 
-	return d;
+    return d;
 
 #endif /* which OS */
 }  /* end of posix_listdir */
@@ -2405,56 +2406,56 @@
 static PyObject *
 posix__getfullpathname(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	char outbuf[MAX_PATH*2];
-	char *temp;
+    PyObject *opath;
+    char *path;
+    char outbuf[MAX_PATH*2];
+    char *temp;
 #ifdef MS_WINDOWS
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
-		Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
-		Py_UNICODE woutbuf[MAX_PATH*2], *woutbufp = woutbuf;
-		Py_UNICODE *wtemp;
-		DWORD result;
-		PyObject *v;
-		result = GetFullPathNameW(wpath,
-					   sizeof(woutbuf)/sizeof(woutbuf[0]),
-					    woutbuf, &wtemp);
-		if (result > sizeof(woutbuf)/sizeof(woutbuf[0])) {
-			woutbufp = malloc(result * sizeof(Py_UNICODE));
-			if (!woutbufp)
-				return PyErr_NoMemory();
-			result = GetFullPathNameW(wpath, result, woutbufp, &wtemp);
-		}
-		if (result)
-			v = PyUnicode_FromUnicode(woutbufp, wcslen(woutbufp));
-		else
-			v = win32_error_unicode("GetFullPathNameW", wpath);
-		if (woutbufp != woutbuf)
-			free(woutbufp);
-		return v;
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-
-#endif
-	if (!PyArg_ParseTuple (args, "O&:_getfullpathname",
-	                       PyUnicode_FSConverter, &opath))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (!GetFullPathName(path, sizeof(outbuf)/sizeof(outbuf[0]),
-	                     outbuf, &temp)) {
-		win32_error("GetFullPathName", path);
-		Py_DECREF(opath);
-		return NULL;
-	}
-	Py_DECREF(opath);
-	if (PyUnicode_Check(PyTuple_GetItem(args, 0))) {
-		return PyUnicode_Decode(outbuf, strlen(outbuf),
-			Py_FileSystemDefaultEncoding, NULL);
-	}
-	return PyBytes_FromString(outbuf);
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
+        Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
+        Py_UNICODE woutbuf[MAX_PATH*2], *woutbufp = woutbuf;
+        Py_UNICODE *wtemp;
+        DWORD result;
+        PyObject *v;
+        result = GetFullPathNameW(wpath,
+                                  sizeof(woutbuf)/sizeof(woutbuf[0]),
+                                  woutbuf, &wtemp);
+        if (result > sizeof(woutbuf)/sizeof(woutbuf[0])) {
+            woutbufp = malloc(result * sizeof(Py_UNICODE));
+            if (!woutbufp)
+                return PyErr_NoMemory();
+            result = GetFullPathNameW(wpath, result, woutbufp, &wtemp);
+        }
+        if (result)
+            v = PyUnicode_FromUnicode(woutbufp, wcslen(woutbufp));
+        else
+            v = win32_error_unicode("GetFullPathNameW", wpath);
+        if (woutbufp != woutbuf)
+            free(woutbufp);
+        return v;
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+
+#endif
+    if (!PyArg_ParseTuple (args, "O&:_getfullpathname",
+                           PyUnicode_FSConverter, &opath))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (!GetFullPathName(path, sizeof(outbuf)/sizeof(outbuf[0]),
+                         outbuf, &temp)) {
+        win32_error("GetFullPathName", path);
+        Py_DECREF(opath);
+        return NULL;
+    }
+    Py_DECREF(opath);
+    if (PyUnicode_Check(PyTuple_GetItem(args, 0))) {
+        return PyUnicode_Decode(outbuf, strlen(outbuf),
+                                Py_FileSystemDefaultEncoding, NULL);
+    }
+    return PyBytes_FromString(outbuf);
 } /* end of posix__getfullpathname */
 #endif /* MS_WINDOWS */
 
@@ -2465,62 +2466,62 @@
 static PyObject *
 posix_mkdir(PyObject *self, PyObject *args)
 {
-	int res;
-	PyObject *opath;
-	char *path;
-	int mode = 0777;
+    int res;
+    PyObject *opath;
+    char *path;
+    int mode = 0777;
 
 #ifdef MS_WINDOWS
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) {
-		Py_BEGIN_ALLOW_THREADS
-		/* PyUnicode_AS_UNICODE OK without thread lock as
-		   it is a simple dereference. */
-		res = CreateDirectoryW(PyUnicode_AS_UNICODE(po), NULL);
-		Py_END_ALLOW_THREADS
-		if (!res)
-			return win32_error_unicode("mkdir", PyUnicode_AS_UNICODE(po));
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-	if (!PyArg_ParseTuple(args, "O&|i:mkdir",
-	                      PyUnicode_FSConverter, &opath, &mode))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
-	/* PyUnicode_AS_UNICODE OK without thread lock as
-	   it is a simple dereference. */
-	res = CreateDirectoryA(path, NULL);
-	Py_END_ALLOW_THREADS
-	if (!res) {
-		win32_error("mkdir", path);
-		Py_DECREF(opath);
-		return NULL;
-	}
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
-#else
-
-	if (!PyArg_ParseTuple(args, "O&|i:mkdir",
-	                      PyUnicode_FSConverter, &opath, &mode))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	Py_BEGIN_ALLOW_THREADS
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) {
+        Py_BEGIN_ALLOW_THREADS
+        /* PyUnicode_AS_UNICODE OK without thread lock as
+           it is a simple dereference. */
+        res = CreateDirectoryW(PyUnicode_AS_UNICODE(po), NULL);
+        Py_END_ALLOW_THREADS
+        if (!res)
+            return win32_error_unicode("mkdir", PyUnicode_AS_UNICODE(po));
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+    if (!PyArg_ParseTuple(args, "O&|i:mkdir",
+                          PyUnicode_FSConverter, &opath, &mode))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
+    /* PyUnicode_AS_UNICODE OK without thread lock as
+       it is a simple dereference. */
+    res = CreateDirectoryA(path, NULL);
+    Py_END_ALLOW_THREADS
+    if (!res) {
+        win32_error("mkdir", path);
+        Py_DECREF(opath);
+        return NULL;
+    }
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
+#else
+
+    if (!PyArg_ParseTuple(args, "O&|i:mkdir",
+                          PyUnicode_FSConverter, &opath, &mode))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    Py_BEGIN_ALLOW_THREADS
 #if ( defined(__WATCOMC__) || defined(PYCC_VACPP) ) && !defined(__QNX__)
-	res = mkdir(path);
+    res = mkdir(path);
 #else
-	res = mkdir(path, mode);
+    res = mkdir(path, mode);
 #endif
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error_with_allocated_filename(opath);
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error_with_allocated_filename(opath);
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 #endif
 }
 
@@ -2539,31 +2540,31 @@
 static PyObject *
 posix_nice(PyObject *self, PyObject *args)
 {
-	int increment, value;
+    int increment, value;
 
-	if (!PyArg_ParseTuple(args, "i:nice", &increment))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:nice", &increment))
+        return NULL;
 
-	/* There are two flavours of 'nice': one that returns the new
-	   priority (as required by almost all standards out there) and the
-	   Linux/FreeBSD/BSDI one, which returns '0' on success and advices
-	   the use of getpriority() to get the new priority.
-
-	   If we are of the nice family that returns the new priority, we
-	   need to clear errno before the call, and check if errno is filled
-	   before calling posix_error() on a returnvalue of -1, because the
-	   -1 may be the actual new priority! */
+    /* There are two flavours of 'nice': one that returns the new
+       priority (as required by almost all standards out there) and the
+       Linux/FreeBSD/BSDI one, which returns '0' on success and advices
+       the use of getpriority() to get the new priority.
+
+       If we are of the nice family that returns the new priority, we
+       need to clear errno before the call, and check if errno is filled
+       before calling posix_error() on a returnvalue of -1, because the
+       -1 may be the actual new priority! */
 
-	errno = 0;
-	value = nice(increment);
+    errno = 0;
+    value = nice(increment);
 #if defined(HAVE_BROKEN_NICE) && defined(HAVE_GETPRIORITY)
-	if (value == 0)
-		value = getpriority(PRIO_PROCESS, 0);
+    if (value == 0)
+        value = getpriority(PRIO_PROCESS, 0);
 #endif
-	if (value == -1 && errno != 0)
-		/* either nice() or getpriority() returned an error */
-		return posix_error();
-	return PyLong_FromLong((long) value);
+    if (value == -1 && errno != 0)
+        /* either nice() or getpriority() returned an error */
+        return posix_error();
+    return PyLong_FromLong((long) value);
 }
 #endif /* HAVE_NICE */
 
@@ -2575,40 +2576,40 @@
 posix_rename(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	PyObject *o1, *o2;
-	char *p1, *p2;
-	BOOL result;
-	if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2))
-		goto error;
-	if (!convert_to_unicode(&o1))
-		goto error;
-	if (!convert_to_unicode(&o2)) {
-		Py_DECREF(o1);
-		goto error;
-	}
-	Py_BEGIN_ALLOW_THREADS
-	result = MoveFileW(PyUnicode_AsUnicode(o1),
-			   PyUnicode_AsUnicode(o2));
-	Py_END_ALLOW_THREADS
-	Py_DECREF(o1);
-	Py_DECREF(o2);
-	if (!result)
-		return win32_error("rename", NULL);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *o1, *o2;
+    char *p1, *p2;
+    BOOL result;
+    if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2))
+        goto error;
+    if (!convert_to_unicode(&o1))
+        goto error;
+    if (!convert_to_unicode(&o2)) {
+        Py_DECREF(o1);
+        goto error;
+    }
+    Py_BEGIN_ALLOW_THREADS
+    result = MoveFileW(PyUnicode_AsUnicode(o1),
+                       PyUnicode_AsUnicode(o2));
+    Py_END_ALLOW_THREADS
+    Py_DECREF(o1);
+    Py_DECREF(o2);
+    if (!result)
+        return win32_error("rename", NULL);
+    Py_INCREF(Py_None);
+    return Py_None;
 error:
-	PyErr_Clear();
-	if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	result = MoveFileA(p1, p2);
-	Py_END_ALLOW_THREADS
-	if (!result)
-		return win32_error("rename", NULL);
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyErr_Clear();
+    if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    result = MoveFileA(p1, p2);
+    Py_END_ALLOW_THREADS
+    if (!result)
+        return win32_error("rename", NULL);
+    Py_INCREF(Py_None);
+    return Py_None;
 #else
-	return posix_2str(args, "O&O&:rename", rename);
+    return posix_2str(args, "O&O&:rename", rename);
 #endif
 }
 
@@ -2621,9 +2622,9 @@
 posix_rmdir(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	return win32_1str(args, "rmdir", "y:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW);
+    return win32_1str(args, "rmdir", "y:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW);
 #else
-	return posix_1str(args, "O&:rmdir", rmdir);
+    return posix_1str(args, "O&:rmdir", rmdir);
 #endif
 }
 
@@ -2636,9 +2637,9 @@
 posix_stat(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	return posix_do_stat(self, args, "O&:stat", STAT, "U:stat", win32_wstat);
+    return posix_do_stat(self, args, "O&:stat", STAT, "U:stat", win32_wstat);
 #else
-	return posix_do_stat(self, args, "O&:stat", STAT, NULL, NULL);
+    return posix_do_stat(self, args, "O&:stat", STAT, NULL, NULL);
 #endif
 }
 
@@ -2651,29 +2652,29 @@
 static PyObject *
 posix_system(PyObject *self, PyObject *args)
 {
-	long sts;
+    long sts;
 #ifdef MS_WINDOWS
-	wchar_t *command;
-	if (!PyArg_ParseTuple(args, "u:system", &command))
-		return NULL;
-
-	Py_BEGIN_ALLOW_THREADS
-	sts = _wsystem(command);
-	Py_END_ALLOW_THREADS
-#else
-	PyObject *command_obj;
-	char *command;
-	if (!PyArg_ParseTuple(args, "O&:system",
-	                      PyUnicode_FSConverter, &command_obj))
-		return NULL;
-
-	command = PyBytes_AsString(command_obj);
-	Py_BEGIN_ALLOW_THREADS
-	sts = system(command);
-	Py_END_ALLOW_THREADS
-	Py_DECREF(command_obj);
+    wchar_t *command;
+    if (!PyArg_ParseTuple(args, "u:system", &command))
+        return NULL;
+
+    Py_BEGIN_ALLOW_THREADS
+    sts = _wsystem(command);
+    Py_END_ALLOW_THREADS
+#else
+    PyObject *command_obj;
+    char *command;
+    if (!PyArg_ParseTuple(args, "O&:system",
+                          PyUnicode_FSConverter, &command_obj))
+        return NULL;
+
+    command = PyBytes_AsString(command_obj);
+    Py_BEGIN_ALLOW_THREADS
+    sts = system(command);
+    Py_END_ALLOW_THREADS
+    Py_DECREF(command_obj);
 #endif
-	return PyLong_FromLong(sts);
+    return PyLong_FromLong(sts);
 }
 #endif
 
@@ -2685,13 +2686,13 @@
 static PyObject *
 posix_umask(PyObject *self, PyObject *args)
 {
-	int i;
-	if (!PyArg_ParseTuple(args, "i:umask", &i))
-		return NULL;
-	i = (int)umask(i);
-	if (i < 0)
-		return posix_error();
-	return PyLong_FromLong((long)i);
+    int i;
+    if (!PyArg_ParseTuple(args, "i:umask", &i))
+        return NULL;
+    i = (int)umask(i);
+    if (i < 0)
+        return posix_error();
+    return PyLong_FromLong((long)i);
 }
 
 
@@ -2707,9 +2708,9 @@
 posix_unlink(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	return win32_1str(args, "remove", "y:remove", DeleteFileA, "U:remove", DeleteFileW);
+    return win32_1str(args, "remove", "y:remove", DeleteFileA, "U:remove", DeleteFileW);
 #else
-	return posix_1str(args, "O&:remove", unlink);
+    return posix_1str(args, "O&:remove", unlink);
 #endif
 }
 
@@ -2722,50 +2723,50 @@
 static PyObject *
 posix_uname(PyObject *self, PyObject *noargs)
 {
-	struct utsname u;
-	int res;
+    struct utsname u;
+    int res;
 
-	Py_BEGIN_ALLOW_THREADS
-	res = uname(&u);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	return Py_BuildValue("(sssss)",
-			     u.sysname,
-			     u.nodename,
-			     u.release,
-			     u.version,
-			     u.machine);
+    Py_BEGIN_ALLOW_THREADS
+    res = uname(&u);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    return Py_BuildValue("(sssss)",
+                         u.sysname,
+                         u.nodename,
+                         u.release,
+                         u.version,
+                         u.machine);
 }
 #endif /* HAVE_UNAME */
 
 static int
 extract_time(PyObject *t, long* sec, long* usec)
 {
-	long intval;
-	if (PyFloat_Check(t)) {
-		double tval = PyFloat_AsDouble(t);
-		PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t);
-		if (!intobj)
-			return -1;
-		intval = PyLong_AsLong(intobj);
-		Py_DECREF(intobj);
-		if (intval == -1 && PyErr_Occurred())
-			return -1;
-		*sec = intval;
-		*usec = (long)((tval - intval) * 1e6); /* can't exceed 1000000 */
-		if (*usec < 0)
-			/* If rounding gave us a negative number,
-			   truncate.  */
-			*usec = 0;
-		return 0;
-	}
-	intval = PyLong_AsLong(t);
-	if (intval == -1 && PyErr_Occurred())
-		return -1;
-	*sec = intval;
-	*usec = 0;
+    long intval;
+    if (PyFloat_Check(t)) {
+        double tval = PyFloat_AsDouble(t);
+        PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t);
+        if (!intobj)
+            return -1;
+        intval = PyLong_AsLong(intobj);
+        Py_DECREF(intobj);
+        if (intval == -1 && PyErr_Occurred())
+            return -1;
+        *sec = intval;
+        *usec = (long)((tval - intval) * 1e6); /* can't exceed 1000000 */
+        if (*usec < 0)
+            /* If rounding gave us a negative number,
+               truncate.  */
+            *usec = 0;
         return 0;
+    }
+    intval = PyLong_AsLong(t);
+    if (intval == -1 && PyErr_Occurred())
+        return -1;
+    *sec = intval;
+    *usec = 0;
+    return 0;
 }
 
 PyDoc_STRVAR(posix_utime__doc__,
@@ -2778,157 +2779,157 @@
 posix_utime(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-	PyObject *arg;
-	PyUnicodeObject *obwpath;
-	wchar_t *wpath = NULL;
-	PyObject *oapath;
-	char *apath;
-	HANDLE hFile;
-	long atimesec, mtimesec, ausec, musec;
-	FILETIME atime, mtime;
-	PyObject *result = NULL;
-
-	if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) {
-		wpath = PyUnicode_AS_UNICODE(obwpath);
-		Py_BEGIN_ALLOW_THREADS
-		hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0,
-				    NULL, OPEN_EXISTING,
-				    FILE_FLAG_BACKUP_SEMANTICS, NULL);
-		Py_END_ALLOW_THREADS
-		if (hFile == INVALID_HANDLE_VALUE)
-			return win32_error_unicode("utime", wpath);
-	} else
-		/* Drop the argument parsing error as narrow strings
-		   are also valid. */
-		PyErr_Clear();
-
-	if (!wpath) {
-		if (!PyArg_ParseTuple(args, "O&O:utime",
-				PyUnicode_FSConverter, &oapath, &arg))
-			return NULL;
-		apath = PyBytes_AsString(oapath);
-		Py_BEGIN_ALLOW_THREADS
-		hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0,
-				    NULL, OPEN_EXISTING,
-				    FILE_FLAG_BACKUP_SEMANTICS, NULL);
-		Py_END_ALLOW_THREADS
-		if (hFile == INVALID_HANDLE_VALUE) {
-			win32_error("utime", apath);
-			Py_DECREF(oapath);
-			return NULL;
-		}
-		Py_DECREF(oapath);
-	}
-	
-	if (arg == Py_None) {
-		SYSTEMTIME now;
-		GetSystemTime(&now);
-		if (!SystemTimeToFileTime(&now, &mtime) ||
-		    !SystemTimeToFileTime(&now, &atime)) {
-			win32_error("utime", NULL);
-			goto done;
-		    }
-	}
-	else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
-		PyErr_SetString(PyExc_TypeError,
-				"utime() arg 2 must be a tuple (atime, mtime)");
-		goto done;
-	}
-	else {
-		if (extract_time(PyTuple_GET_ITEM(arg, 0),
-				 &atimesec, &ausec) == -1)
-			goto done;
-		time_t_to_FILE_TIME(atimesec, 1000*ausec, &atime);
-		if (extract_time(PyTuple_GET_ITEM(arg, 1),
-				 &mtimesec, &musec) == -1)
-			goto done;
-		time_t_to_FILE_TIME(mtimesec, 1000*musec, &mtime);
-	}
-	if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
-		/* Avoid putting the file name into the error here,
-		   as that may confuse the user into believing that
-		   something is wrong with the file, when it also
-		   could be the time stamp that gives a problem. */
-		win32_error("utime", NULL);
-	}
-	Py_INCREF(Py_None);
-	result = Py_None;
+    PyObject *arg;
+    PyUnicodeObject *obwpath;
+    wchar_t *wpath = NULL;
+    PyObject *oapath;
+    char *apath;
+    HANDLE hFile;
+    long atimesec, mtimesec, ausec, musec;
+    FILETIME atime, mtime;
+    PyObject *result = NULL;
+
+    if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) {
+        wpath = PyUnicode_AS_UNICODE(obwpath);
+        Py_BEGIN_ALLOW_THREADS
+        hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0,
+                            NULL, OPEN_EXISTING,
+                            FILE_FLAG_BACKUP_SEMANTICS, NULL);
+        Py_END_ALLOW_THREADS
+        if (hFile == INVALID_HANDLE_VALUE)
+            return win32_error_unicode("utime", wpath);
+    } else
+        /* Drop the argument parsing error as narrow strings
+           are also valid. */
+        PyErr_Clear();
+
+    if (!wpath) {
+        if (!PyArg_ParseTuple(args, "O&O:utime",
+                        PyUnicode_FSConverter, &oapath, &arg))
+            return NULL;
+        apath = PyBytes_AsString(oapath);
+        Py_BEGIN_ALLOW_THREADS
+        hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0,
+                            NULL, OPEN_EXISTING,
+                            FILE_FLAG_BACKUP_SEMANTICS, NULL);
+        Py_END_ALLOW_THREADS
+        if (hFile == INVALID_HANDLE_VALUE) {
+            win32_error("utime", apath);
+            Py_DECREF(oapath);
+            return NULL;
+        }
+        Py_DECREF(oapath);
+    }
+
+    if (arg == Py_None) {
+        SYSTEMTIME now;
+        GetSystemTime(&now);
+        if (!SystemTimeToFileTime(&now, &mtime) ||
+            !SystemTimeToFileTime(&now, &atime)) {
+            win32_error("utime", NULL);
+            goto done;
+            }
+    }
+    else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
+        PyErr_SetString(PyExc_TypeError,
+                        "utime() arg 2 must be a tuple (atime, mtime)");
+        goto done;
+    }
+    else {
+        if (extract_time(PyTuple_GET_ITEM(arg, 0),
+                         &atimesec, &ausec) == -1)
+            goto done;
+        time_t_to_FILE_TIME(atimesec, 1000*ausec, &atime);
+        if (extract_time(PyTuple_GET_ITEM(arg, 1),
+                         &mtimesec, &musec) == -1)
+            goto done;
+        time_t_to_FILE_TIME(mtimesec, 1000*musec, &mtime);
+    }
+    if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
+        /* Avoid putting the file name into the error here,
+           as that may confuse the user into believing that
+           something is wrong with the file, when it also
+           could be the time stamp that gives a problem. */
+        win32_error("utime", NULL);
+    }
+    Py_INCREF(Py_None);
+    result = Py_None;
 done:
-	CloseHandle(hFile);
-	return result;
+    CloseHandle(hFile);
+    return result;
 #else /* MS_WINDOWS */
 
-	PyObject *opath;
-	char *path;
-	long atime, mtime, ausec, musec;
-	int res;
-	PyObject* arg;
+    PyObject *opath;
+    char *path;
+    long atime, mtime, ausec, musec;
+    int res;
+    PyObject* arg;
 
 #if defined(HAVE_UTIMES)
-	struct timeval buf[2];
+    struct timeval buf[2];
 #define ATIME buf[0].tv_sec
 #define MTIME buf[1].tv_sec
 #elif defined(HAVE_UTIME_H)
 /* XXX should define struct utimbuf instead, above */
-	struct utimbuf buf;
+    struct utimbuf buf;
 #define ATIME buf.actime
 #define MTIME buf.modtime
 #define UTIME_ARG &buf
 #else /* HAVE_UTIMES */
-	time_t buf[2];
+    time_t buf[2];
 #define ATIME buf[0]
 #define MTIME buf[1]
 #define UTIME_ARG buf
 #endif /* HAVE_UTIMES */
 
 
-	if (!PyArg_ParseTuple(args, "O&O:utime",
-				  PyUnicode_FSConverter, &opath, &arg))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (arg == Py_None) {
-		/* optional time values not given */
-		Py_BEGIN_ALLOW_THREADS
-		res = utime(path, NULL);
-		Py_END_ALLOW_THREADS
-	}
-	else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
-		PyErr_SetString(PyExc_TypeError,
-				"utime() arg 2 must be a tuple (atime, mtime)");
-		Py_DECREF(opath);
-		return NULL;
-	}
-	else {
-		if (extract_time(PyTuple_GET_ITEM(arg, 0),
-				 &atime, &ausec) == -1) {
-			Py_DECREF(opath);
-			return NULL;
-		}
-		if (extract_time(PyTuple_GET_ITEM(arg, 1),
-				 &mtime, &musec) == -1) {
-			Py_DECREF(opath);
-			return NULL;
-		}
-		ATIME = atime;
-		MTIME = mtime;
+    if (!PyArg_ParseTuple(args, "O&O:utime",
+                          PyUnicode_FSConverter, &opath, &arg))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (arg == Py_None) {
+        /* optional time values not given */
+        Py_BEGIN_ALLOW_THREADS
+        res = utime(path, NULL);
+        Py_END_ALLOW_THREADS
+    }
+    else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
+        PyErr_SetString(PyExc_TypeError,
+                        "utime() arg 2 must be a tuple (atime, mtime)");
+        Py_DECREF(opath);
+        return NULL;
+    }
+    else {
+        if (extract_time(PyTuple_GET_ITEM(arg, 0),
+                         &atime, &ausec) == -1) {
+            Py_DECREF(opath);
+            return NULL;
+        }
+        if (extract_time(PyTuple_GET_ITEM(arg, 1),
+                         &mtime, &musec) == -1) {
+            Py_DECREF(opath);
+            return NULL;
+        }
+        ATIME = atime;
+        MTIME = mtime;
 #ifdef HAVE_UTIMES
-		buf[0].tv_usec = ausec;
-		buf[1].tv_usec = musec;
-		Py_BEGIN_ALLOW_THREADS
-		res = utimes(path, buf);
-		Py_END_ALLOW_THREADS
-#else
-		Py_BEGIN_ALLOW_THREADS
-		res = utime(path, UTIME_ARG);
-		Py_END_ALLOW_THREADS
+        buf[0].tv_usec = ausec;
+        buf[1].tv_usec = musec;
+        Py_BEGIN_ALLOW_THREADS
+        res = utimes(path, buf);
+        Py_END_ALLOW_THREADS
+#else
+        Py_BEGIN_ALLOW_THREADS
+        res = utime(path, UTIME_ARG);
+        Py_END_ALLOW_THREADS
 #endif /* HAVE_UTIMES */
-	}
-	if (res < 0) {
-		return posix_error_with_allocated_filename(opath);
-	}
-	Py_DECREF(opath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    }
+    if (res < 0) {
+        return posix_error_with_allocated_filename(opath);
+    }
+    Py_DECREF(opath);
+    Py_INCREF(Py_None);
+    return Py_None;
 #undef UTIME_ARG
 #undef ATIME
 #undef MTIME
@@ -2945,37 +2946,37 @@
 static PyObject *
 posix__exit(PyObject *self, PyObject *args)
 {
-	int sts;
-	if (!PyArg_ParseTuple(args, "i:_exit", &sts))
-		return NULL;
-	_exit(sts);
-	return NULL; /* Make gcc -Wall happy */
+    int sts;
+    if (!PyArg_ParseTuple(args, "i:_exit", &sts))
+        return NULL;
+    _exit(sts);
+    return NULL; /* Make gcc -Wall happy */
 }
 
 #if defined(HAVE_EXECV) || defined(HAVE_SPAWNV)
 static void
 free_string_array(char **array, Py_ssize_t count)
 {
-	Py_ssize_t i;
-	for (i = 0; i < count; i++)
-		PyMem_Free(array[i]);
-	PyMem_DEL(array);
+    Py_ssize_t i;
+    for (i = 0; i < count; i++)
+        PyMem_Free(array[i]);
+    PyMem_DEL(array);
 }
 
 static
 int fsconvert_strdup(PyObject *o, char**out)
 {
-	PyObject *bytes;
-	Py_ssize_t size;
-	if (!PyUnicode_FSConverter(o, &bytes))
-		return 0;
-	size = PyBytes_GET_SIZE(bytes);
-	*out = PyMem_Malloc(size+1);
-	if (!*out)
-		return 0;
-	memcpy(*out, PyBytes_AsString(bytes), size+1);
-	Py_DECREF(bytes);
-	return 1;
+    PyObject *bytes;
+    Py_ssize_t size;
+    if (!PyUnicode_FSConverter(o, &bytes))
+        return 0;
+    size = PyBytes_GET_SIZE(bytes);
+    *out = PyMem_Malloc(size+1);
+    if (!*out)
+        return 0;
+    memcpy(*out, PyBytes_AsString(bytes), size+1);
+    Py_DECREF(bytes);
+    return 1;
 }
 #endif
 
@@ -2985,236 +2986,236 @@
 "execv(path, args)\n\n\
 Execute an executable path with arguments, replacing current process.\n\
 \n\
-	path: path of executable file\n\
-	args: tuple or list of strings");
+    path: path of executable file\n\
+    args: tuple or list of strings");
 
 static PyObject *
 posix_execv(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	PyObject *argv;
-	char **argvlist;
-	Py_ssize_t i, argc;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-
-	/* execv has two arguments: (path, argv), where
-	   argv is a list or tuple of strings. */
-
-	if (!PyArg_ParseTuple(args, "O&O:execv",
-                              PyUnicode_FSConverter,
-                              &opath, &argv))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list");
-                Py_DECREF(opath);
-		return NULL;
-	}
-	if (argc < 1) {
-		PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty");
-                Py_DECREF(opath);
-		return NULL;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		Py_DECREF(opath);
-		return PyErr_NoMemory();
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i])) {
-			free_string_array(argvlist, i);
-			PyErr_SetString(PyExc_TypeError,
-					"execv() arg 2 must contain only strings");
-			Py_DECREF(opath);
-			return NULL;
-
-		}
-	}
-	argvlist[argc] = NULL;
-
-	execv(path, argvlist);
-
-	/* If we get here it's definitely an error */
-
-	free_string_array(argvlist, argc);
-	Py_DECREF(opath);
-	return posix_error();
+    PyObject *opath;
+    char *path;
+    PyObject *argv;
+    char **argvlist;
+    Py_ssize_t i, argc;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+
+    /* execv has two arguments: (path, argv), where
+       argv is a list or tuple of strings. */
+
+    if (!PyArg_ParseTuple(args, "O&O:execv",
+                          PyUnicode_FSConverter,
+                          &opath, &argv))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list");
+        Py_DECREF(opath);
+        return NULL;
+    }
+    if (argc < 1) {
+        PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty");
+        Py_DECREF(opath);
+        return NULL;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        Py_DECREF(opath);
+        return PyErr_NoMemory();
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i])) {
+            free_string_array(argvlist, i);
+            PyErr_SetString(PyExc_TypeError,
+                            "execv() arg 2 must contain only strings");
+            Py_DECREF(opath);
+            return NULL;
+
+        }
+    }
+    argvlist[argc] = NULL;
+
+    execv(path, argvlist);
+
+    /* If we get here it's definitely an error */
+
+    free_string_array(argvlist, argc);
+    Py_DECREF(opath);
+    return posix_error();
 }
 
 static char**
 parse_envlist(PyObject* env, Py_ssize_t *envc_ptr)
 {
-	char **envlist;
-	Py_ssize_t i, pos, envc;
-	PyObject *keys=NULL, *vals=NULL;
-	PyObject *key, *val, *key2, *val2;
-	char *p, *k, *v;
-	size_t len;
-
-	i = PyMapping_Size(env);
-	if (i < 0)
-		return NULL;
-	envlist = PyMem_NEW(char *, i + 1);
-	if (envlist == NULL) {
-		PyErr_NoMemory();
-		return NULL;
-	}
-	envc = 0;
-	keys = PyMapping_Keys(env);
-	vals = PyMapping_Values(env);
-	if (!keys || !vals)
-		goto error;
-	if (!PyList_Check(keys) || !PyList_Check(vals)) {
-		PyErr_Format(PyExc_TypeError,
-			"env.keys() or env.values() is not a list");
-		goto error;
-	}
-
-	for (pos = 0; pos < i; pos++) {
-		key = PyList_GetItem(keys, pos);
-		val = PyList_GetItem(vals, pos);
-		if (!key || !val)
-			goto error;
-
-		if (PyUnicode_FSConverter(key, &key2) == 0)
-			goto error;
-		if (PyUnicode_FSConverter(val, &val2) == 0) {
-			Py_DECREF(key2);
-			goto error;
-		}
+    char **envlist;
+    Py_ssize_t i, pos, envc;
+    PyObject *keys=NULL, *vals=NULL;
+    PyObject *key, *val, *key2, *val2;
+    char *p, *k, *v;
+    size_t len;
+
+    i = PyMapping_Size(env);
+    if (i < 0)
+        return NULL;
+    envlist = PyMem_NEW(char *, i + 1);
+    if (envlist == NULL) {
+        PyErr_NoMemory();
+        return NULL;
+    }
+    envc = 0;
+    keys = PyMapping_Keys(env);
+    vals = PyMapping_Values(env);
+    if (!keys || !vals)
+        goto error;
+    if (!PyList_Check(keys) || !PyList_Check(vals)) {
+        PyErr_Format(PyExc_TypeError,
+                     "env.keys() or env.values() is not a list");
+        goto error;
+    }
+
+    for (pos = 0; pos < i; pos++) {
+        key = PyList_GetItem(keys, pos);
+        val = PyList_GetItem(vals, pos);
+        if (!key || !val)
+            goto error;
+
+        if (PyUnicode_FSConverter(key, &key2) == 0)
+            goto error;
+        if (PyUnicode_FSConverter(val, &val2) == 0) {
+            Py_DECREF(key2);
+            goto error;
+        }
 
 #if defined(PYOS_OS2)
-		/* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */
-		if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) {
+        /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */
+        if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) {
 #endif
-		k = PyBytes_AsString(key2);
-		v = PyBytes_AsString(val2);
-		len = PyBytes_GET_SIZE(key2) + PyBytes_GET_SIZE(val2) + 2;
-
-		p = PyMem_NEW(char, len);
-		if (p == NULL) {
-			PyErr_NoMemory();
-			Py_DECREF(key2);
-			Py_DECREF(val2);
-			goto error;
-		}
-		PyOS_snprintf(p, len, "%s=%s", k, v);
-		envlist[envc++] = p;
-		Py_DECREF(key2);
-		Py_DECREF(val2);
+        k = PyBytes_AsString(key2);
+        v = PyBytes_AsString(val2);
+        len = PyBytes_GET_SIZE(key2) + PyBytes_GET_SIZE(val2) + 2;
+
+        p = PyMem_NEW(char, len);
+        if (p == NULL) {
+            PyErr_NoMemory();
+            Py_DECREF(key2);
+            Py_DECREF(val2);
+            goto error;
+        }
+        PyOS_snprintf(p, len, "%s=%s", k, v);
+        envlist[envc++] = p;
+        Py_DECREF(key2);
+        Py_DECREF(val2);
 #if defined(PYOS_OS2)
-		}
+        }
 #endif
-	}
-	Py_DECREF(vals);
-	Py_DECREF(keys);
-
-	envlist[envc] = 0;
-	*envc_ptr = envc;
-	return envlist;
+    }
+    Py_DECREF(vals);
+    Py_DECREF(keys);
+
+    envlist[envc] = 0;
+    *envc_ptr = envc;
+    return envlist;
 
 error:
-	Py_XDECREF(keys);
-	Py_XDECREF(vals);
-	while (--envc >= 0)
-		PyMem_DEL(envlist[envc]);
-	PyMem_DEL(envlist);
-	return NULL;
+    Py_XDECREF(keys);
+    Py_XDECREF(vals);
+    while (--envc >= 0)
+        PyMem_DEL(envlist[envc]);
+    PyMem_DEL(envlist);
+    return NULL;
 }
 
 PyDoc_STRVAR(posix_execve__doc__,
 "execve(path, args, env)\n\n\
 Execute a path with arguments and environment, replacing current process.\n\
 \n\
-	path: path of executable file\n\
-	args: tuple or list of arguments\n\
-	env: dictionary of strings mapping to strings");
+    path: path of executable file\n\
+    args: tuple or list of arguments\n\
+    env: dictionary of strings mapping to strings");
 
 static PyObject *
 posix_execve(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	PyObject *argv, *env;
-	char **argvlist;
-	char **envlist;
-	Py_ssize_t i, argc, envc;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-	Py_ssize_t lastarg = 0;
-
-	/* execve has three arguments: (path, argv, env), where
-	   argv is a list or tuple of strings and env is a dictionary
-	   like posix.environ. */
-
-	if (!PyArg_ParseTuple(args, "O&OO:execve",
-			      PyUnicode_FSConverter,
-			      &opath, &argv, &env))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError,
-				"execve() arg 2 must be a tuple or list");
-		goto fail_0;
-	}
-	if (!PyMapping_Check(env)) {
-		PyErr_SetString(PyExc_TypeError,
-				"execve() arg 3 must be a mapping object");
-		goto fail_0;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		PyErr_NoMemory();
-		goto fail_0;
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i]))
-		{
-			lastarg = i;
-			goto fail_1;
-		}
-	}
-	lastarg = argc;
-	argvlist[argc] = NULL;
-
-	envlist = parse_envlist(env, &envc);
-	if (envlist == NULL)
-		goto fail_1;
-
-	execve(path, argvlist, envlist);
-
-	/* If we get here it's definitely an error */
-
-	(void) posix_error();
-
-	while (--envc >= 0)
-		PyMem_DEL(envlist[envc]);
-	PyMem_DEL(envlist);
+    PyObject *opath;
+    char *path;
+    PyObject *argv, *env;
+    char **argvlist;
+    char **envlist;
+    Py_ssize_t i, argc, envc;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+    Py_ssize_t lastarg = 0;
+
+    /* execve has three arguments: (path, argv, env), where
+       argv is a list or tuple of strings and env is a dictionary
+       like posix.environ. */
+
+    if (!PyArg_ParseTuple(args, "O&OO:execve",
+                          PyUnicode_FSConverter,
+                          &opath, &argv, &env))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError,
+                        "execve() arg 2 must be a tuple or list");
+        goto fail_0;
+    }
+    if (!PyMapping_Check(env)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "execve() arg 3 must be a mapping object");
+        goto fail_0;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        PyErr_NoMemory();
+        goto fail_0;
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i]))
+        {
+            lastarg = i;
+            goto fail_1;
+        }
+    }
+    lastarg = argc;
+    argvlist[argc] = NULL;
+
+    envlist = parse_envlist(env, &envc);
+    if (envlist == NULL)
+        goto fail_1;
+
+    execve(path, argvlist, envlist);
+
+    /* If we get here it's definitely an error */
+
+    (void) posix_error();
+
+    while (--envc >= 0)
+        PyMem_DEL(envlist[envc]);
+    PyMem_DEL(envlist);
   fail_1:
-	free_string_array(argvlist, lastarg);
+    free_string_array(argvlist, lastarg);
   fail_0:
-	Py_DECREF(opath);
-	return NULL;
+    Py_DECREF(opath);
+    return NULL;
 }
 #endif /* HAVE_EXECV */
 
@@ -3224,86 +3225,86 @@
 "spawnv(mode, path, args)\n\n\
 Execute the program 'path' in a new process.\n\
 \n\
-	mode: mode of process creation\n\
-	path: path of executable file\n\
-	args: tuple or list of strings");
+    mode: mode of process creation\n\
+    path: path of executable file\n\
+    args: tuple or list of strings");
 
 static PyObject *
 posix_spawnv(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	PyObject *argv;
-	char **argvlist;
-	int mode, i;
-	Py_ssize_t argc;
-	Py_intptr_t spawnval;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-
-	/* spawnv has three arguments: (mode, path, argv), where
-	   argv is a list or tuple of strings. */
-
-	if (!PyArg_ParseTuple(args, "iO&O:spawnv", &mode,
-			      PyUnicode_FSConverter,
-			      &opath, &argv))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnv() arg 2 must be a tuple or list");
-		Py_DECREF(opath);
-		return NULL;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		Py_DECREF(opath);
-		return PyErr_NoMemory();
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i])) {
-			free_string_array(argvlist, i);
-			PyErr_SetString(
-				PyExc_TypeError,
-				"spawnv() arg 2 must contain only strings");
-			Py_DECREF(opath);
-			return NULL;
-		}
-	}
-	argvlist[argc] = NULL;
+    PyObject *opath;
+    char *path;
+    PyObject *argv;
+    char **argvlist;
+    int mode, i;
+    Py_ssize_t argc;
+    Py_intptr_t spawnval;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+
+    /* spawnv has three arguments: (mode, path, argv), where
+       argv is a list or tuple of strings. */
+
+    if (!PyArg_ParseTuple(args, "iO&O:spawnv", &mode,
+                          PyUnicode_FSConverter,
+                          &opath, &argv))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnv() arg 2 must be a tuple or list");
+        Py_DECREF(opath);
+        return NULL;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        Py_DECREF(opath);
+        return PyErr_NoMemory();
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i])) {
+            free_string_array(argvlist, i);
+            PyErr_SetString(
+                PyExc_TypeError,
+                "spawnv() arg 2 must contain only strings");
+            Py_DECREF(opath);
+            return NULL;
+        }
+    }
+    argvlist[argc] = NULL;
 
 #if defined(PYOS_OS2) && defined(PYCC_GCC)
-	Py_BEGIN_ALLOW_THREADS
-	spawnval = spawnv(mode, path, argvlist);
-	Py_END_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
+    spawnval = spawnv(mode, path, argvlist);
+    Py_END_ALLOW_THREADS
 #else
-	if (mode == _OLD_P_OVERLAY)
-		mode = _P_OVERLAY;
+    if (mode == _OLD_P_OVERLAY)
+        mode = _P_OVERLAY;
 
-	Py_BEGIN_ALLOW_THREADS
-	spawnval = _spawnv(mode, path, argvlist);
-	Py_END_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
+    spawnval = _spawnv(mode, path, argvlist);
+    Py_END_ALLOW_THREADS
 #endif
 
-	free_string_array(argvlist, argc);
-	Py_DECREF(opath);
+    free_string_array(argvlist, argc);
+    Py_DECREF(opath);
 
-	if (spawnval == -1)
-		return posix_error();
-	else
+    if (spawnval == -1)
+        return posix_error();
+    else
 #if SIZEOF_LONG == SIZEOF_VOID_P
-		return Py_BuildValue("l", (long) spawnval);
+        return Py_BuildValue("l", (long) spawnval);
 #else
-		return Py_BuildValue("L", (PY_LONG_LONG) spawnval);
+        return Py_BuildValue("L", (PY_LONG_LONG) spawnval);
 #endif
 }
 
@@ -3312,104 +3313,104 @@
 "spawnve(mode, path, args, env)\n\n\
 Execute the program 'path' in a new process.\n\
 \n\
-	mode: mode of process creation\n\
-	path: path of executable file\n\
-	args: tuple or list of arguments\n\
-	env: dictionary of strings mapping to strings");
+    mode: mode of process creation\n\
+    path: path of executable file\n\
+    args: tuple or list of arguments\n\
+    env: dictionary of strings mapping to strings");
 
 static PyObject *
 posix_spawnve(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	PyObject *argv, *env;
-	char **argvlist;
-	char **envlist;
-	PyObject *res = NULL;
-	int mode, envc;
-	Py_ssize_t argc, i;
-	Py_intptr_t spawnval;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-	Py_ssize_t lastarg = 0;
-
-	/* spawnve has four arguments: (mode, path, argv, env), where
-	   argv is a list or tuple of strings and env is a dictionary
-	   like posix.environ. */
-
-	if (!PyArg_ParseTuple(args, "iO&OO:spawnve", &mode,
-			      PyUnicode_FSConverter,
-			      &opath, &argv, &env))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnve() arg 2 must be a tuple or list");
-		goto fail_0;
-	}
-	if (!PyMapping_Check(env)) {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnve() arg 3 must be a mapping object");
-		goto fail_0;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		PyErr_NoMemory();
-		goto fail_0;
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i]))
-		{
-			lastarg = i;
-			goto fail_1;
-		}
-	}
-	lastarg = argc;
-	argvlist[argc] = NULL;
-
-	envlist = parse_envlist(env, &envc);
-	if (envlist == NULL)
-		goto fail_1;
+    PyObject *opath;
+    char *path;
+    PyObject *argv, *env;
+    char **argvlist;
+    char **envlist;
+    PyObject *res = NULL;
+    int mode, envc;
+    Py_ssize_t argc, i;
+    Py_intptr_t spawnval;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+    Py_ssize_t lastarg = 0;
+
+    /* spawnve has four arguments: (mode, path, argv, env), where
+       argv is a list or tuple of strings and env is a dictionary
+       like posix.environ. */
+
+    if (!PyArg_ParseTuple(args, "iO&OO:spawnve", &mode,
+                          PyUnicode_FSConverter,
+                          &opath, &argv, &env))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnve() arg 2 must be a tuple or list");
+        goto fail_0;
+    }
+    if (!PyMapping_Check(env)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnve() arg 3 must be a mapping object");
+        goto fail_0;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        PyErr_NoMemory();
+        goto fail_0;
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i]))
+        {
+            lastarg = i;
+            goto fail_1;
+        }
+    }
+    lastarg = argc;
+    argvlist[argc] = NULL;
+
+    envlist = parse_envlist(env, &envc);
+    if (envlist == NULL)
+        goto fail_1;
 
 #if defined(PYOS_OS2) && defined(PYCC_GCC)
-	Py_BEGIN_ALLOW_THREADS
-	spawnval = spawnve(mode, path, argvlist, envlist);
-	Py_END_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
+    spawnval = spawnve(mode, path, argvlist, envlist);
+    Py_END_ALLOW_THREADS
 #else
-	if (mode == _OLD_P_OVERLAY)
-		mode = _P_OVERLAY;
+    if (mode == _OLD_P_OVERLAY)
+        mode = _P_OVERLAY;
 
-	Py_BEGIN_ALLOW_THREADS
-	spawnval = _spawnve(mode, path, argvlist, envlist);
-	Py_END_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
+    spawnval = _spawnve(mode, path, argvlist, envlist);
+    Py_END_ALLOW_THREADS
 #endif
 
-	if (spawnval == -1)
-		(void) posix_error();
-	else
+    if (spawnval == -1)
+        (void) posix_error();
+    else
 #if SIZEOF_LONG == SIZEOF_VOID_P
-		res = Py_BuildValue("l", (long) spawnval);
+        res = Py_BuildValue("l", (long) spawnval);
 #else
-		res = Py_BuildValue("L", (PY_LONG_LONG) spawnval);
+        res = Py_BuildValue("L", (PY_LONG_LONG) spawnval);
 #endif
 
-	while (--envc >= 0)
-		PyMem_DEL(envlist[envc]);
-	PyMem_DEL(envlist);
+    while (--envc >= 0)
+        PyMem_DEL(envlist[envc]);
+    PyMem_DEL(envlist);
   fail_1:
-	free_string_array(argvlist, lastarg);
+    free_string_array(argvlist, lastarg);
   fail_0:
-	Py_DECREF(opath);
-	return res;
+    Py_DECREF(opath);
+    return res;
 }
 
 /* OS/2 supports spawnvp & spawnvpe natively */
@@ -3419,77 +3420,77 @@
 Execute the program 'file' in a new process, using the environment\n\
 search path to find the file.\n\
 \n\
-	mode: mode of process creation\n\
-	file: executable file name\n\
-	args: tuple or list of strings");
+    mode: mode of process creation\n\
+    file: executable file name\n\
+    args: tuple or list of strings");
 
 static PyObject *
 posix_spawnvp(PyObject *self, PyObject *args)
 {
-	PyObject *opath;
-	char *path;
-	PyObject *argv;
-	char **argvlist;
-	int mode, i, argc;
-	Py_intptr_t spawnval;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-
-	/* spawnvp has three arguments: (mode, path, argv), where
-	   argv is a list or tuple of strings. */
-
-	if (!PyArg_ParseTuple(args, "iO&O:spawnvp", &mode,
-			      PyUnicode_FSConverter,
-			      &opath, &argv))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnvp() arg 2 must be a tuple or list");
-		Py_DECREF(opath);
-		return NULL;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		Py_DECREF(opath);
-		return PyErr_NoMemory();
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i])) {
-			free_string_array(argvlist, i);
-			PyErr_SetString(
-				PyExc_TypeError,
-				"spawnvp() arg 2 must contain only strings");
-			Py_DECREF(opath);
-			return NULL;
-		}
-	}
-	argvlist[argc] = NULL;
+    PyObject *opath;
+    char *path;
+    PyObject *argv;
+    char **argvlist;
+    int mode, i, argc;
+    Py_intptr_t spawnval;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+
+    /* spawnvp has three arguments: (mode, path, argv), where
+       argv is a list or tuple of strings. */
+
+    if (!PyArg_ParseTuple(args, "iO&O:spawnvp", &mode,
+                          PyUnicode_FSConverter,
+                          &opath, &argv))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnvp() arg 2 must be a tuple or list");
+        Py_DECREF(opath);
+        return NULL;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        Py_DECREF(opath);
+        return PyErr_NoMemory();
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i])) {
+            free_string_array(argvlist, i);
+            PyErr_SetString(
+                PyExc_TypeError,
+                "spawnvp() arg 2 must contain only strings");
+            Py_DECREF(opath);
+            return NULL;
+        }
+    }
+    argvlist[argc] = NULL;
 
-	Py_BEGIN_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
 #if defined(PYCC_GCC)
-	spawnval = spawnvp(mode, path, argvlist);
+    spawnval = spawnvp(mode, path, argvlist);
 #else
-	spawnval = _spawnvp(mode, path, argvlist);
+    spawnval = _spawnvp(mode, path, argvlist);
 #endif
-	Py_END_ALLOW_THREADS
+    Py_END_ALLOW_THREADS
 
-	free_string_array(argvlist, argc);
-	Py_DECREF(opath);
+    free_string_array(argvlist, argc);
+    Py_DECREF(opath);
 
-	if (spawnval == -1)
-		return posix_error();
-	else
-		return Py_BuildValue("l", (long) spawnval);
+    if (spawnval == -1)
+        return posix_error();
+    else
+        return Py_BuildValue("l", (long) spawnval);
 }
 
 
@@ -3498,94 +3499,94 @@
 Execute the program 'file' in a new process, using the environment\n\
 search path to find the file.\n\
 \n\
-	mode: mode of process creation\n\
-	file: executable file name\n\
-	args: tuple or list of arguments\n\
-	env: dictionary of strings mapping to strings");
+    mode: mode of process creation\n\
+    file: executable file name\n\
+    args: tuple or list of arguments\n\
+    env: dictionary of strings mapping to strings");
 
 static PyObject *
 posix_spawnvpe(PyObject *self, PyObject *args)
 {
-	PyObject *opath
-	char *path;
-	PyObject *argv, *env;
-	char **argvlist;
-	char **envlist;
-	PyObject *res=NULL;
-	int mode, i, argc, envc;
-	Py_intptr_t spawnval;
-	PyObject *(*getitem)(PyObject *, Py_ssize_t);
-	int lastarg = 0;
-
-	/* spawnvpe has four arguments: (mode, path, argv, env), where
-	   argv is a list or tuple of strings and env is a dictionary
-	   like posix.environ. */
-
-	if (!PyArg_ParseTuple(args, "ietOO:spawnvpe", &mode,
-			      PyUnicode_FSConverter,
-			      &opath, &argv, &env))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	if (PyList_Check(argv)) {
-		argc = PyList_Size(argv);
-		getitem = PyList_GetItem;
-	}
-	else if (PyTuple_Check(argv)) {
-		argc = PyTuple_Size(argv);
-		getitem = PyTuple_GetItem;
-	}
-	else {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnvpe() arg 2 must be a tuple or list");
-		goto fail_0;
-	}
-	if (!PyMapping_Check(env)) {
-		PyErr_SetString(PyExc_TypeError,
-				"spawnvpe() arg 3 must be a mapping object");
-		goto fail_0;
-	}
-
-	argvlist = PyMem_NEW(char *, argc+1);
-	if (argvlist == NULL) {
-		PyErr_NoMemory();
-		goto fail_0;
-	}
-	for (i = 0; i < argc; i++) {
-		if (!fsconvert_strdup((*getitem)(argv, i),
-				      &argvlist[i]))
-		{
-			lastarg = i;
-			goto fail_1;
-		}
-	}
-	lastarg = argc;
-	argvlist[argc] = NULL;
-
-	envlist = parse_envlist(env, &envc);
-	if (envlist == NULL)
-		goto fail_1;
+    PyObject *opath
+    char *path;
+    PyObject *argv, *env;
+    char **argvlist;
+    char **envlist;
+    PyObject *res=NULL;
+    int mode, i, argc, envc;
+    Py_intptr_t spawnval;
+    PyObject *(*getitem)(PyObject *, Py_ssize_t);
+    int lastarg = 0;
+
+    /* spawnvpe has four arguments: (mode, path, argv, env), where
+       argv is a list or tuple of strings and env is a dictionary
+       like posix.environ. */
+
+    if (!PyArg_ParseTuple(args, "ietOO:spawnvpe", &mode,
+                          PyUnicode_FSConverter,
+                          &opath, &argv, &env))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    if (PyList_Check(argv)) {
+        argc = PyList_Size(argv);
+        getitem = PyList_GetItem;
+    }
+    else if (PyTuple_Check(argv)) {
+        argc = PyTuple_Size(argv);
+        getitem = PyTuple_GetItem;
+    }
+    else {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnvpe() arg 2 must be a tuple or list");
+        goto fail_0;
+    }
+    if (!PyMapping_Check(env)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "spawnvpe() arg 3 must be a mapping object");
+        goto fail_0;
+    }
+
+    argvlist = PyMem_NEW(char *, argc+1);
+    if (argvlist == NULL) {
+        PyErr_NoMemory();
+        goto fail_0;
+    }
+    for (i = 0; i < argc; i++) {
+        if (!fsconvert_strdup((*getitem)(argv, i),
+                              &argvlist[i]))
+        {
+            lastarg = i;
+            goto fail_1;
+        }
+    }
+    lastarg = argc;
+    argvlist[argc] = NULL;
+
+    envlist = parse_envlist(env, &envc);
+    if (envlist == NULL)
+        goto fail_1;
 
-	Py_BEGIN_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
 #if defined(PYCC_GCC)
-	spawnval = spawnvpe(mode, path, argvlist, envlist);
+    spawnval = spawnvpe(mode, path, argvlist, envlist);
 #else
-	spawnval = _spawnvpe(mode, path, argvlist, envlist);
+    spawnval = _spawnvpe(mode, path, argvlist, envlist);
 #endif
-	Py_END_ALLOW_THREADS
+    Py_END_ALLOW_THREADS
 
-	if (spawnval == -1)
-		(void) posix_error();
-	else
-		res = Py_BuildValue("l", (long) spawnval);
+    if (spawnval == -1)
+        (void) posix_error();
+    else
+        res = Py_BuildValue("l", (long) spawnval);
 
-	while (--envc >= 0)
-		PyMem_DEL(envlist[envc]);
-	PyMem_DEL(envlist);
+    while (--envc >= 0)
+        PyMem_DEL(envlist[envc]);
+    PyMem_DEL(envlist);
   fail_1:
-	free_string_array(argvlist, lastarg);
+    free_string_array(argvlist, lastarg);
   fail_0:
-	Py_DECREF(opath);
-	return res;
+    Py_DECREF(opath);
+    return res;
 }
 #endif /* PYOS_OS2 */
 #endif /* HAVE_SPAWNV */
@@ -3601,26 +3602,26 @@
 static PyObject *
 posix_fork1(PyObject *self, PyObject *noargs)
 {
-	pid_t pid;
-	int result = 0;
-	_PyImport_AcquireLock();
-	pid = fork1();
-	if (pid == 0) {
-		/* child: this clobbers and resets the import lock. */
-		PyOS_AfterFork();
-	} else {
-		/* parent: release the import lock. */
-		result = _PyImport_ReleaseLock();
-	}
-	if (pid == -1)
-		return posix_error();
-	if (result < 0) {
-		/* Don't clobber the OSError if the fork failed. */
-		PyErr_SetString(PyExc_RuntimeError,
-				"not holding the import lock");
-		return NULL;
-	}
-	return PyLong_FromPid(pid);
+    pid_t pid;
+    int result = 0;
+    _PyImport_AcquireLock();
+    pid = fork1();
+    if (pid == 0) {
+        /* child: this clobbers and resets the import lock. */
+        PyOS_AfterFork();
+    } else {
+        /* parent: release the import lock. */
+        result = _PyImport_ReleaseLock();
+    }
+    if (pid == -1)
+        return posix_error();
+    if (result < 0) {
+        /* Don't clobber the OSError if the fork failed. */
+        PyErr_SetString(PyExc_RuntimeError,
+                        "not holding the import lock");
+        return NULL;
+    }
+    return PyLong_FromPid(pid);
 }
 #endif
 
@@ -3634,26 +3635,26 @@
 static PyObject *
 posix_fork(PyObject *self, PyObject *noargs)
 {
-	pid_t pid;
-	int result = 0;
-	_PyImport_AcquireLock();
-	pid = fork();
-	if (pid == 0) {
-		/* child: this clobbers and resets the import lock. */
-		PyOS_AfterFork();
-	} else {
-		/* parent: release the import lock. */
-		result = _PyImport_ReleaseLock();
-	}
-	if (pid == -1)
-		return posix_error();
-	if (result < 0) {
-		/* Don't clobber the OSError if the fork failed. */
-		PyErr_SetString(PyExc_RuntimeError,
-				"not holding the import lock");
-		return NULL;
-	}
-	return PyLong_FromPid(pid);
+    pid_t pid;
+    int result = 0;
+    _PyImport_AcquireLock();
+    pid = fork();
+    if (pid == 0) {
+        /* child: this clobbers and resets the import lock. */
+        PyOS_AfterFork();
+    } else {
+        /* parent: release the import lock. */
+        result = _PyImport_ReleaseLock();
+    }
+    if (pid == -1)
+        return posix_error();
+    if (result < 0) {
+        /* Don't clobber the OSError if the fork failed. */
+        PyErr_SetString(PyExc_RuntimeError,
+                        "not holding the import lock");
+        return NULL;
+    }
+    return PyLong_FromPid(pid);
 }
 #endif
 
@@ -3691,60 +3692,60 @@
 static PyObject *
 posix_openpty(PyObject *self, PyObject *noargs)
 {
-	int master_fd, slave_fd;
+    int master_fd, slave_fd;
 #ifndef HAVE_OPENPTY
-	char * slave_name;
+    char * slave_name;
 #endif
 #if defined(HAVE_DEV_PTMX) && !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
-	PyOS_sighandler_t sig_saved;
+    PyOS_sighandler_t sig_saved;
 #ifdef sun
-	extern char *ptsname(int fildes);
+    extern char *ptsname(int fildes);
 #endif
 #endif
 
 #ifdef HAVE_OPENPTY
-	if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
-		return posix_error();
+    if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
+        return posix_error();
 #elif defined(HAVE__GETPTY)
-	slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
-	if (slave_name == NULL)
-		return posix_error();
-
-	slave_fd = open(slave_name, O_RDWR);
-	if (slave_fd < 0)
-		return posix_error();
-#else
-	master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */
-	if (master_fd < 0)
-		return posix_error();
-	sig_saved = PyOS_setsig(SIGCHLD, SIG_DFL);
-	/* change permission of slave */
-	if (grantpt(master_fd) < 0) {
-		PyOS_setsig(SIGCHLD, sig_saved);
-		return posix_error();
-	}
-	/* unlock slave */
-	if (unlockpt(master_fd) < 0) {
-		PyOS_setsig(SIGCHLD, sig_saved);
-		return posix_error();
-	}
-	PyOS_setsig(SIGCHLD, sig_saved);
-	slave_name = ptsname(master_fd); /* get name of slave */
-	if (slave_name == NULL)
-		return posix_error();
-	slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
-	if (slave_fd < 0)
-		return posix_error();
+    slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
+    if (slave_name == NULL)
+        return posix_error();
+
+    slave_fd = open(slave_name, O_RDWR);
+    if (slave_fd < 0)
+        return posix_error();
+#else
+    master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */
+    if (master_fd < 0)
+        return posix_error();
+    sig_saved = PyOS_setsig(SIGCHLD, SIG_DFL);
+    /* change permission of slave */
+    if (grantpt(master_fd) < 0) {
+        PyOS_setsig(SIGCHLD, sig_saved);
+        return posix_error();
+    }
+    /* unlock slave */
+    if (unlockpt(master_fd) < 0) {
+        PyOS_setsig(SIGCHLD, sig_saved);
+        return posix_error();
+    }
+    PyOS_setsig(SIGCHLD, sig_saved);
+    slave_name = ptsname(master_fd); /* get name of slave */
+    if (slave_name == NULL)
+        return posix_error();
+    slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
+    if (slave_fd < 0)
+        return posix_error();
 #if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC)
-	ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
-	ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
+    ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
+    ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
 #ifndef __hpux
-	ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */
+    ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */
 #endif /* __hpux */
 #endif /* HAVE_CYGWIN */
 #endif /* HAVE_OPENPTY */
 
-	return Py_BuildValue("(ii)", master_fd, slave_fd);
+    return Py_BuildValue("(ii)", master_fd, slave_fd);
 
 }
 #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) */
@@ -3759,27 +3760,27 @@
 static PyObject *
 posix_forkpty(PyObject *self, PyObject *noargs)
 {
-	int master_fd = -1, result = 0;
-	pid_t pid;
+    int master_fd = -1, result = 0;
+    pid_t pid;
 
-	_PyImport_AcquireLock();
-	pid = forkpty(&master_fd, NULL, NULL, NULL);
-	if (pid == 0) {
-		/* child: this clobbers and resets the import lock. */
-		PyOS_AfterFork();
-	} else {
-		/* parent: release the import lock. */
-		result = _PyImport_ReleaseLock();
-	}
-	if (pid == -1)
-		return posix_error();
-	if (result < 0) {
-		/* Don't clobber the OSError if the fork failed. */
-		PyErr_SetString(PyExc_RuntimeError,
-				"not holding the import lock");
-		return NULL;
-	}
-	return Py_BuildValue("(Ni)", PyLong_FromPid(pid), master_fd);
+    _PyImport_AcquireLock();
+    pid = forkpty(&master_fd, NULL, NULL, NULL);
+    if (pid == 0) {
+        /* child: this clobbers and resets the import lock. */
+        PyOS_AfterFork();
+    } else {
+        /* parent: release the import lock. */
+        result = _PyImport_ReleaseLock();
+    }
+    if (pid == -1)
+        return posix_error();
+    if (result < 0) {
+        /* Don't clobber the OSError if the fork failed. */
+        PyErr_SetString(PyExc_RuntimeError,
+                        "not holding the import lock");
+        return NULL;
+    }
+    return Py_BuildValue("(Ni)", PyLong_FromPid(pid), master_fd);
 }
 #endif
 
@@ -3791,7 +3792,7 @@
 static PyObject *
 posix_getegid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromLong((long)getegid());
+    return PyLong_FromLong((long)getegid());
 }
 #endif
 
@@ -3804,7 +3805,7 @@
 static PyObject *
 posix_geteuid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromLong((long)geteuid());
+    return PyLong_FromLong((long)geteuid());
 }
 #endif
 
@@ -3817,7 +3818,7 @@
 static PyObject *
 posix_getgid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromLong((long)getgid());
+    return PyLong_FromLong((long)getgid());
 }
 #endif
 
@@ -3829,7 +3830,7 @@
 static PyObject *
 posix_getpid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromPid(getpid());
+    return PyLong_FromPid(getpid());
 }
 
 
@@ -3846,30 +3847,30 @@
 #ifdef NGROUPS_MAX
 #define MAX_GROUPS NGROUPS_MAX
 #else
-        /* defined to be 16 on Solaris7, so this should be a small number */
+    /* defined to be 16 on Solaris7, so this should be a small number */
 #define MAX_GROUPS 64
 #endif
-        gid_t grouplist[MAX_GROUPS];
-        int n;
+    gid_t grouplist[MAX_GROUPS];
+    int n;
 
-        n = getgroups(MAX_GROUPS, grouplist);
-        if (n < 0)
-            posix_error();
-        else {
-            result = PyList_New(n);
-            if (result != NULL) {
-                int i;
-                for (i = 0; i < n; ++i) {
-                    PyObject *o = PyLong_FromLong((long)grouplist[i]);
-                    if (o == NULL) {
-                        Py_DECREF(result);
-                        result = NULL;
-                        break;
-                    }
-                    PyList_SET_ITEM(result, i, o);
-                }
+    n = getgroups(MAX_GROUPS, grouplist);
+    if (n < 0)
+        posix_error();
+    else {
+        result = PyList_New(n);
+        if (result != NULL) {
+        int i;
+        for (i = 0; i < n; ++i) {
+            PyObject *o = PyLong_FromLong((long)grouplist[i]);
+            if (o == NULL) {
+            Py_DECREF(result);
+            result = NULL;
+            break;
             }
+            PyList_SET_ITEM(result, i, o);
+        }
         }
+    }
 
     return result;
 }
@@ -3885,17 +3886,17 @@
 static PyObject *
 posix_initgroups(PyObject *self, PyObject *args)
 {
-	char *username;
-	long gid;
+    char *username;
+    long gid;
 
-	if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid))
+        return NULL;
 
-	if (initgroups(username, (gid_t) gid) == -1)
-		return PyErr_SetFromErrno(PyExc_OSError);
+    if (initgroups(username, (gid_t) gid) == -1)
+        return PyErr_SetFromErrno(PyExc_OSError);
 
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -3907,13 +3908,13 @@
 static PyObject *
 posix_getpgid(PyObject *self, PyObject *args)
 {
-	pid_t pid, pgid;
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID ":getpgid", &pid))
-		return NULL;
-	pgid = getpgid(pid);
-	if (pgid < 0)
-		return posix_error();
-	return PyLong_FromPid(pgid);
+    pid_t pid, pgid;
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID ":getpgid", &pid))
+        return NULL;
+    pgid = getpgid(pid);
+    if (pgid < 0)
+        return posix_error();
+    return PyLong_FromPid(pgid);
 }
 #endif /* HAVE_GETPGID */
 
@@ -3927,9 +3928,9 @@
 posix_getpgrp(PyObject *self, PyObject *noargs)
 {
 #ifdef GETPGRP_HAVE_ARG
-	return PyLong_FromPid(getpgrp(0));
+    return PyLong_FromPid(getpgrp(0));
 #else /* GETPGRP_HAVE_ARG */
-	return PyLong_FromPid(getpgrp());
+    return PyLong_FromPid(getpgrp());
 #endif /* GETPGRP_HAVE_ARG */
 }
 #endif /* HAVE_GETPGRP */
@@ -3944,13 +3945,13 @@
 posix_setpgrp(PyObject *self, PyObject *noargs)
 {
 #ifdef SETPGRP_HAVE_ARG
-	if (setpgrp(0, 0) < 0)
+    if (setpgrp(0, 0) < 0)
 #else /* SETPGRP_HAVE_ARG */
-	if (setpgrp() < 0)
+    if (setpgrp() < 0)
 #endif /* SETPGRP_HAVE_ARG */
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 #endif /* HAVE_SETPGRP */
@@ -3963,7 +3964,7 @@
 static PyObject *
 posix_getppid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromPid(getppid());
+    return PyLong_FromPid(getppid());
 }
 #endif
 
@@ -3976,22 +3977,22 @@
 static PyObject *
 posix_getlogin(PyObject *self, PyObject *noargs)
 {
-        PyObject *result = NULL;
-        char *name;
-        int old_errno = errno;
+    PyObject *result = NULL;
+    char *name;
+    int old_errno = errno;
 
-        errno = 0;
-        name = getlogin();
-        if (name == NULL) {
-            if (errno)
-                posix_error();
-            else
-                PyErr_SetString(PyExc_OSError,
-                                "unable to determine login name");
-        }
+    errno = 0;
+    name = getlogin();
+    if (name == NULL) {
+        if (errno)
+        posix_error();
         else
-            result = PyUnicode_FromString(name);
-        errno = old_errno;
+        PyErr_SetString(PyExc_OSError,
+                        "unable to determine login name");
+    }
+    else
+        result = PyUnicode_FromString(name);
+    errno = old_errno;
 
     return result;
 }
@@ -4005,7 +4006,7 @@
 static PyObject *
 posix_getuid(PyObject *self, PyObject *noargs)
 {
-	return PyLong_FromLong((long)getuid());
+    return PyLong_FromLong((long)getuid());
 }
 #endif
 
@@ -4018,10 +4019,10 @@
 static PyObject *
 posix_kill(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int sig;
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:kill", &pid, &sig))
-		return NULL;
+    pid_t pid;
+    int sig;
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:kill", &pid, &sig))
+        return NULL;
 #if defined(PYOS_OS2) && !defined(PYCC_GCC)
     if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) {
         APIRET rc;
@@ -4036,11 +4037,11 @@
     } else
         return NULL; /* Unrecognized Signal Requested */
 #else
-	if (kill(pid, sig) == -1)
-		return posix_error();
+    if (kill(pid, sig) == -1)
+        return posix_error();
 #endif
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -4052,18 +4053,18 @@
 static PyObject *
 posix_killpg(PyObject *self, PyObject *args)
 {
-	int sig;
-	pid_t pgid;
-	/* XXX some man pages make the `pgid` parameter an int, others
-	   a pid_t. Since getpgrp() returns a pid_t, we assume killpg should
-	   take the same type. Moreover, pid_t is always at least as wide as
-	   int (else compilation of this module fails), which is safe. */
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:killpg", &pgid, &sig))
-		return NULL;
-	if (killpg(pgid, sig) == -1)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int sig;
+    pid_t pgid;
+    /* XXX some man pages make the `pgid` parameter an int, others
+       a pid_t. Since getpgrp() returns a pid_t, we assume killpg should
+       take the same type. Moreover, pid_t is always at least as wide as
+       int (else compilation of this module fails), which is safe. */
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:killpg", &pgid, &sig))
+        return NULL;
+    if (killpg(pgid, sig) == -1)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -4075,42 +4076,42 @@
 static PyObject *
 win32_kill(PyObject *self, PyObject *args)
 {
-	PyObject *result, handle_obj;
-	DWORD pid, sig, err;
-	HANDLE handle;
-
-	if (!PyArg_ParseTuple(args, "kk:kill", &pid, &sig))
-		return NULL;
-
-	/* Console processes which share a common console can be sent CTRL+C or
-	   CTRL+BREAK events, provided they handle said events. */
-	if (sig == CTRL_C_EVENT || sig == CTRL_BREAK_EVENT) {
-		if (GenerateConsoleCtrlEvent(sig, pid) == 0) {
-			err = GetLastError();
-			PyErr_SetFromWindowsErr(err);
-		}
-		else
-			Py_RETURN_NONE;
-	}
-
-	/* If the signal is outside of what GenerateConsoleCtrlEvent can use,
-	   attempt to open and terminate the process. */
-	handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
-	if (handle == NULL) {
-		err = GetLastError();
-		return PyErr_SetFromWindowsErr(err);
-	}
-
-	if (TerminateProcess(handle, sig) == 0) {
-		err = GetLastError();
-		result = PyErr_SetFromWindowsErr(err);
-	} else {
-		Py_INCREF(Py_None);
-		result = Py_None;
-	}
+    PyObject *result, handle_obj;
+    DWORD pid, sig, err;
+    HANDLE handle;
+
+    if (!PyArg_ParseTuple(args, "kk:kill", &pid, &sig))
+        return NULL;
+
+    /* Console processes which share a common console can be sent CTRL+C or
+       CTRL+BREAK events, provided they handle said events. */
+    if (sig == CTRL_C_EVENT || sig == CTRL_BREAK_EVENT) {
+        if (GenerateConsoleCtrlEvent(sig, pid) == 0) {
+            err = GetLastError();
+            PyErr_SetFromWindowsErr(err);
+        }
+        else
+            Py_RETURN_NONE;
+    }
+
+    /* If the signal is outside of what GenerateConsoleCtrlEvent can use,
+       attempt to open and terminate the process. */
+    handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
+    if (handle == NULL) {
+        err = GetLastError();
+        return PyErr_SetFromWindowsErr(err);
+    }
 
-	CloseHandle(handle);
-	return result;
+    if (TerminateProcess(handle, sig) == 0) {
+        err = GetLastError();
+        result = PyErr_SetFromWindowsErr(err);
+    } else {
+        Py_INCREF(Py_None);
+        result = Py_None;
+    }
+
+    CloseHandle(handle);
+    return result;
 }
 #endif /* MS_WINDOWS */
 
@@ -4127,13 +4128,13 @@
 static PyObject *
 posix_plock(PyObject *self, PyObject *args)
 {
-	int op;
-	if (!PyArg_ParseTuple(args, "i:plock", &op))
-		return NULL;
-	if (plock(op) == -1)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int op;
+    if (!PyArg_ParseTuple(args, "i:plock", &op))
+        return NULL;
+    if (plock(op) == -1)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -4145,19 +4146,19 @@
 static PyObject *
 posix_setuid(PyObject *self, PyObject *args)
 {
-	long uid_arg;
-	uid_t uid;
-	if (!PyArg_ParseTuple(args, "l:setuid", &uid_arg))
-		return NULL;
-	uid = uid_arg;
-	if (uid != uid_arg) {
-		PyErr_SetString(PyExc_OverflowError, "user id too big");
-		return NULL;
-	}
-	if (setuid(uid) < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    long uid_arg;
+    uid_t uid;
+    if (!PyArg_ParseTuple(args, "l:setuid", &uid_arg))
+        return NULL;
+    uid = uid_arg;
+    if (uid != uid_arg) {
+        PyErr_SetString(PyExc_OverflowError, "user id too big");
+        return NULL;
+    }
+    if (setuid(uid) < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_SETUID */
 
@@ -4170,21 +4171,21 @@
 static PyObject *
 posix_seteuid (PyObject *self, PyObject *args)
 {
-	long euid_arg;
-	uid_t euid;
-	if (!PyArg_ParseTuple(args, "l", &euid_arg))
-		return NULL;
-	euid = euid_arg;
-	if (euid != euid_arg) {
-		PyErr_SetString(PyExc_OverflowError, "user id too big");
-		return NULL;
-	}
-	if (seteuid(euid) < 0) {
-		return posix_error();
-	} else {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
+    long euid_arg;
+    uid_t euid;
+    if (!PyArg_ParseTuple(args, "l", &euid_arg))
+        return NULL;
+    euid = euid_arg;
+    if (euid != euid_arg) {
+        PyErr_SetString(PyExc_OverflowError, "user id too big");
+        return NULL;
+    }
+    if (seteuid(euid) < 0) {
+        return posix_error();
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
 }
 #endif /* HAVE_SETEUID */
 
@@ -4196,21 +4197,21 @@
 static PyObject *
 posix_setegid (PyObject *self, PyObject *args)
 {
-	long egid_arg;
-	gid_t egid;
-	if (!PyArg_ParseTuple(args, "l", &egid_arg))
-		return NULL;
-	egid = egid_arg;
-	if (egid != egid_arg) {
-		PyErr_SetString(PyExc_OverflowError, "group id too big");
-		return NULL;
-	}
-	if (setegid(egid) < 0) {
-		return posix_error();
-	} else {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
+    long egid_arg;
+    gid_t egid;
+    if (!PyArg_ParseTuple(args, "l", &egid_arg))
+        return NULL;
+    egid = egid_arg;
+    if (egid != egid_arg) {
+        PyErr_SetString(PyExc_OverflowError, "group id too big");
+        return NULL;
+    }
+    if (setegid(egid) < 0) {
+        return posix_error();
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
 }
 #endif /* HAVE_SETEGID */
 
@@ -4222,29 +4223,29 @@
 static PyObject *
 posix_setreuid (PyObject *self, PyObject *args)
 {
-	long ruid_arg, euid_arg;
-	uid_t ruid, euid;
-	if (!PyArg_ParseTuple(args, "ll", &ruid_arg, &euid_arg))
-		return NULL;
-	if (ruid_arg == -1)
-		ruid = (uid_t)-1;  /* let the compiler choose how -1 fits */
-	else
-		ruid = ruid_arg;  /* otherwise, assign from our long */
-	if (euid_arg == -1)
-		euid = (uid_t)-1;
-	else
-		euid = euid_arg;
-	if ((euid_arg != -1 && euid != euid_arg) || 
-	    (ruid_arg != -1 && ruid != ruid_arg)) {
-		PyErr_SetString(PyExc_OverflowError, "user id too big");
-		return NULL;
-	}
-	if (setreuid(ruid, euid) < 0) {
-		return posix_error();
-	} else {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
+    long ruid_arg, euid_arg;
+    uid_t ruid, euid;
+    if (!PyArg_ParseTuple(args, "ll", &ruid_arg, &euid_arg))
+        return NULL;
+    if (ruid_arg == -1)
+        ruid = (uid_t)-1;  /* let the compiler choose how -1 fits */
+    else
+        ruid = ruid_arg;  /* otherwise, assign from our long */
+    if (euid_arg == -1)
+        euid = (uid_t)-1;
+    else
+        euid = euid_arg;
+    if ((euid_arg != -1 && euid != euid_arg) ||
+        (ruid_arg != -1 && ruid != ruid_arg)) {
+        PyErr_SetString(PyExc_OverflowError, "user id too big");
+        return NULL;
+    }
+    if (setreuid(ruid, euid) < 0) {
+        return posix_error();
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
 }
 #endif /* HAVE_SETREUID */
 
@@ -4256,29 +4257,29 @@
 static PyObject *
 posix_setregid (PyObject *self, PyObject *args)
 {
-	long rgid_arg, egid_arg;
-	gid_t rgid, egid;
-	if (!PyArg_ParseTuple(args, "ll", &rgid_arg, &egid_arg))
-		return NULL;
-	if (rgid_arg == -1)
-		rgid = (gid_t)-1;  /* let the compiler choose how -1 fits */
-	else
-		rgid = rgid_arg;  /* otherwise, assign from our long */
-	if (egid_arg == -1)
-		egid = (gid_t)-1;
-	else
-		egid = egid_arg;
-	if ((egid_arg != -1 && egid != egid_arg) || 
-	    (rgid_arg != -1 && rgid != rgid_arg)) {
-		PyErr_SetString(PyExc_OverflowError, "group id too big");
-		return NULL;
-	}
-	if (setregid(rgid, egid) < 0) {
-		return posix_error();
-	} else {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
+    long rgid_arg, egid_arg;
+    gid_t rgid, egid;
+    if (!PyArg_ParseTuple(args, "ll", &rgid_arg, &egid_arg))
+        return NULL;
+    if (rgid_arg == -1)
+        rgid = (gid_t)-1;  /* let the compiler choose how -1 fits */
+    else
+        rgid = rgid_arg;  /* otherwise, assign from our long */
+    if (egid_arg == -1)
+        egid = (gid_t)-1;
+    else
+        egid = egid_arg;
+    if ((egid_arg != -1 && egid != egid_arg) ||
+        (rgid_arg != -1 && rgid != rgid_arg)) {
+        PyErr_SetString(PyExc_OverflowError, "group id too big");
+        return NULL;
+    }
+    if (setregid(rgid, egid) < 0) {
+        return posix_error();
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
 }
 #endif /* HAVE_SETREGID */
 
@@ -4290,19 +4291,19 @@
 static PyObject *
 posix_setgid(PyObject *self, PyObject *args)
 {
-	long gid_arg;
-	gid_t gid;
-	if (!PyArg_ParseTuple(args, "l:setgid", &gid_arg))
-		return NULL;
-	gid = gid_arg;
-	if (gid != gid_arg) {
-		PyErr_SetString(PyExc_OverflowError, "group id too big");
-		return NULL;
-	}
-	if (setgid(gid) < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    long gid_arg;
+    gid_t gid;
+    if (!PyArg_ParseTuple(args, "l:setgid", &gid_arg))
+        return NULL;
+    gid = gid_arg;
+    if (gid != gid_arg) {
+        PyErr_SetString(PyExc_OverflowError, "group id too big");
+        return NULL;
+    }
+    if (setgid(gid) < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_SETGID */
 
@@ -4314,52 +4315,52 @@
 static PyObject *
 posix_setgroups(PyObject *self, PyObject *groups)
 {
-	int i, len;
-        gid_t grouplist[MAX_GROUPS];
+    int i, len;
+    gid_t grouplist[MAX_GROUPS];
+
+    if (!PySequence_Check(groups)) {
+        PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
+        return NULL;
+    }
+    len = PySequence_Size(groups);
+    if (len > MAX_GROUPS) {
+        PyErr_SetString(PyExc_ValueError, "too many groups");
+        return NULL;
+    }
+    for(i = 0; i < len; i++) {
+        PyObject *elem;
+        elem = PySequence_GetItem(groups, i);
+        if (!elem)
+            return NULL;
+        if (!PyLong_Check(elem)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "groups must be integers");
+            Py_DECREF(elem);
+            return NULL;
+        } else {
+            unsigned long x = PyLong_AsUnsignedLong(elem);
+            if (PyErr_Occurred()) {
+                PyErr_SetString(PyExc_TypeError,
+                                "group id too big");
+                Py_DECREF(elem);
+                return NULL;
+            }
+            grouplist[i] = x;
+            /* read back the value to see if it fitted in gid_t */
+            if (grouplist[i] != x) {
+                PyErr_SetString(PyExc_TypeError,
+                                "group id too big");
+                Py_DECREF(elem);
+                return NULL;
+            }
+        }
+        Py_DECREF(elem);
+    }
 
-	if (!PySequence_Check(groups)) {
-		PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
-		return NULL;
-	}
-	len = PySequence_Size(groups);
-	if (len > MAX_GROUPS) {
-		PyErr_SetString(PyExc_ValueError, "too many groups");
-		return NULL;
-	}
-	for(i = 0; i < len; i++) {
-		PyObject *elem;
-		elem = PySequence_GetItem(groups, i);
-		if (!elem)
-			return NULL;
-		if (!PyLong_Check(elem)) {
-			PyErr_SetString(PyExc_TypeError,
-					"groups must be integers");
-			Py_DECREF(elem);
-			return NULL;
-		} else {
-			unsigned long x = PyLong_AsUnsignedLong(elem);
-			if (PyErr_Occurred()) {
-				PyErr_SetString(PyExc_TypeError, 
-						"group id too big");
-				Py_DECREF(elem);
-				return NULL;
-			}
-			grouplist[i] = x;
-			/* read back the value to see if it fitted in gid_t */
-			if (grouplist[i] != x) {
-				PyErr_SetString(PyExc_TypeError,
-						"group id too big");
-				Py_DECREF(elem);
-				return NULL;
-			}
-		}
-		Py_DECREF(elem);
-	}
-
-	if (setgroups(len, grouplist) < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    if (setgroups(len, grouplist) < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_SETGROUPS */
 
@@ -4367,59 +4368,59 @@
 static PyObject *
 wait_helper(pid_t pid, int status, struct rusage *ru)
 {
-	PyObject *result;
-   	static PyObject *struct_rusage;
+    PyObject *result;
+    static PyObject *struct_rusage;
 
-	if (pid == -1)
-		return posix_error();
+    if (pid == -1)
+        return posix_error();
 
-	if (struct_rusage == NULL) {
-		PyObject *m = PyImport_ImportModuleNoBlock("resource");
-		if (m == NULL)
-			return NULL;
-		struct_rusage = PyObject_GetAttrString(m, "struct_rusage");
-		Py_DECREF(m);
-		if (struct_rusage == NULL)
-			return NULL;
-	}
-
-	/* XXX(nnorwitz): Copied (w/mods) from resource.c, there should be only one. */
-	result = PyStructSequence_New((PyTypeObject*) struct_rusage);
-	if (!result)
-		return NULL;
+    if (struct_rusage == NULL) {
+        PyObject *m = PyImport_ImportModuleNoBlock("resource");
+        if (m == NULL)
+            return NULL;
+        struct_rusage = PyObject_GetAttrString(m, "struct_rusage");
+        Py_DECREF(m);
+        if (struct_rusage == NULL)
+            return NULL;
+    }
+
+    /* XXX(nnorwitz): Copied (w/mods) from resource.c, there should be only one. */
+    result = PyStructSequence_New((PyTypeObject*) struct_rusage);
+    if (!result)
+        return NULL;
 
 #ifndef doubletime
 #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
 #endif
 
-	PyStructSequence_SET_ITEM(result, 0,
-			PyFloat_FromDouble(doubletime(ru->ru_utime)));
-	PyStructSequence_SET_ITEM(result, 1,
-			PyFloat_FromDouble(doubletime(ru->ru_stime)));
+    PyStructSequence_SET_ITEM(result, 0,
+                              PyFloat_FromDouble(doubletime(ru->ru_utime)));
+    PyStructSequence_SET_ITEM(result, 1,
+                              PyFloat_FromDouble(doubletime(ru->ru_stime)));
 #define SET_INT(result, index, value)\
-		PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value))
-	SET_INT(result, 2, ru->ru_maxrss);
-	SET_INT(result, 3, ru->ru_ixrss);
-	SET_INT(result, 4, ru->ru_idrss);
-	SET_INT(result, 5, ru->ru_isrss);
-	SET_INT(result, 6, ru->ru_minflt);
-	SET_INT(result, 7, ru->ru_majflt);
-	SET_INT(result, 8, ru->ru_nswap);
-	SET_INT(result, 9, ru->ru_inblock);
-	SET_INT(result, 10, ru->ru_oublock);
-	SET_INT(result, 11, ru->ru_msgsnd);
-	SET_INT(result, 12, ru->ru_msgrcv);
-	SET_INT(result, 13, ru->ru_nsignals);
-	SET_INT(result, 14, ru->ru_nvcsw);
-	SET_INT(result, 15, ru->ru_nivcsw);
+        PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value))
+    SET_INT(result, 2, ru->ru_maxrss);
+    SET_INT(result, 3, ru->ru_ixrss);
+    SET_INT(result, 4, ru->ru_idrss);
+    SET_INT(result, 5, ru->ru_isrss);
+    SET_INT(result, 6, ru->ru_minflt);
+    SET_INT(result, 7, ru->ru_majflt);
+    SET_INT(result, 8, ru->ru_nswap);
+    SET_INT(result, 9, ru->ru_inblock);
+    SET_INT(result, 10, ru->ru_oublock);
+    SET_INT(result, 11, ru->ru_msgsnd);
+    SET_INT(result, 12, ru->ru_msgrcv);
+    SET_INT(result, 13, ru->ru_nsignals);
+    SET_INT(result, 14, ru->ru_nvcsw);
+    SET_INT(result, 15, ru->ru_nivcsw);
 #undef SET_INT
 
-	if (PyErr_Occurred()) {
-		Py_DECREF(result);
-		return NULL;
-	}
+    if (PyErr_Occurred()) {
+        Py_DECREF(result);
+        return NULL;
+    }
 
-	return Py_BuildValue("NiN", PyLong_FromPid(pid), status, result);
+    return Py_BuildValue("NiN", PyLong_FromPid(pid), status, result);
 }
 #endif /* HAVE_WAIT3 || HAVE_WAIT4 */
 
@@ -4431,20 +4432,20 @@
 static PyObject *
 posix_wait3(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int options;
-	struct rusage ru;
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
-
-	if (!PyArg_ParseTuple(args, "i:wait3", &options))
-		return NULL;
-
-	Py_BEGIN_ALLOW_THREADS
-	pid = wait3(&status, options, &ru);
-	Py_END_ALLOW_THREADS
+    pid_t pid;
+    int options;
+    struct rusage ru;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
+
+    if (!PyArg_ParseTuple(args, "i:wait3", &options))
+        return NULL;
+
+    Py_BEGIN_ALLOW_THREADS
+    pid = wait3(&status, options, &ru);
+    Py_END_ALLOW_THREADS
 
-	return wait_helper(pid, WAIT_STATUS_INT(status), &ru);
+    return wait_helper(pid, WAIT_STATUS_INT(status), &ru);
 }
 #endif /* HAVE_WAIT3 */
 
@@ -4456,20 +4457,20 @@
 static PyObject *
 posix_wait4(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int options;
-	struct rusage ru;
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
-
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:wait4", &pid, &options))
-		return NULL;
-
-	Py_BEGIN_ALLOW_THREADS
-	pid = wait4(pid, &status, options, &ru);
-	Py_END_ALLOW_THREADS
+    pid_t pid;
+    int options;
+    struct rusage ru;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
+
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:wait4", &pid, &options))
+        return NULL;
 
-	return wait_helper(pid, WAIT_STATUS_INT(status), &ru);
+    Py_BEGIN_ALLOW_THREADS
+    pid = wait4(pid, &status, options, &ru);
+    Py_END_ALLOW_THREADS
+
+    return wait_helper(pid, WAIT_STATUS_INT(status), &ru);
 }
 #endif /* HAVE_WAIT4 */
 
@@ -4481,20 +4482,20 @@
 static PyObject *
 posix_waitpid(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int options;
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
-
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	pid = waitpid(pid, &status, options);
-	Py_END_ALLOW_THREADS
-	if (pid == -1)
-		return posix_error();
+    pid_t pid;
+    int options;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
+
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    pid = waitpid(pid, &status, options);
+    Py_END_ALLOW_THREADS
+    if (pid == -1)
+        return posix_error();
 
-	return Py_BuildValue("Ni", PyLong_FromPid(pid), WAIT_STATUS_INT(status));
+    return Py_BuildValue("Ni", PyLong_FromPid(pid), WAIT_STATUS_INT(status));
 }
 
 #elif defined(HAVE_CWAIT)
@@ -4507,19 +4508,19 @@
 static PyObject *
 posix_waitpid(PyObject *self, PyObject *args)
 {
-	Py_intptr_t pid;
-	int status, options;
+    Py_intptr_t pid;
+    int status, options;
 
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	pid = _cwait(&status, pid, options);
-	Py_END_ALLOW_THREADS
-	if (pid == -1)
-		return posix_error();
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    pid = _cwait(&status, pid, options);
+    Py_END_ALLOW_THREADS
+    if (pid == -1)
+        return posix_error();
 
-	/* shift the status left a byte so this is more like the POSIX waitpid */
-	return Py_BuildValue("Ni", PyLong_FromPid(pid), status << 8);
+    /* shift the status left a byte so this is more like the POSIX waitpid */
+    return Py_BuildValue("Ni", PyLong_FromPid(pid), status << 8);
 }
 #endif /* HAVE_WAITPID || HAVE_CWAIT */
 
@@ -4531,17 +4532,17 @@
 static PyObject *
 posix_wait(PyObject *self, PyObject *noargs)
 {
-	pid_t pid;
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
-
-	Py_BEGIN_ALLOW_THREADS
-	pid = wait(&status);
-	Py_END_ALLOW_THREADS
-	if (pid == -1)
-		return posix_error();
+    pid_t pid;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
+
+    Py_BEGIN_ALLOW_THREADS
+    pid = wait(&status);
+    Py_END_ALLOW_THREADS
+    if (pid == -1)
+        return posix_error();
 
-	return Py_BuildValue("Ni", PyLong_FromPid(pid), WAIT_STATUS_INT(status));
+    return Py_BuildValue("Ni", PyLong_FromPid(pid), WAIT_STATUS_INT(status));
 }
 #endif
 
@@ -4554,12 +4555,12 @@
 posix_lstat(PyObject *self, PyObject *args)
 {
 #ifdef HAVE_LSTAT
-	return posix_do_stat(self, args, "O&:lstat", lstat, NULL, NULL);
+    return posix_do_stat(self, args, "O&:lstat", lstat, NULL, NULL);
 #else /* !HAVE_LSTAT */
 #ifdef MS_WINDOWS
-	return posix_do_stat(self, args, "O&:lstat", STAT, "U:lstat", win32_wstat);
+    return posix_do_stat(self, args, "O&:lstat", STAT, "U:lstat", win32_wstat);
 #else
-	return posix_do_stat(self, args, "O&:lstat", STAT, NULL, NULL);
+    return posix_do_stat(self, args, "O&:lstat", STAT, NULL, NULL);
 #endif
 #endif /* !HAVE_LSTAT */
 }
@@ -4573,51 +4574,51 @@
 static PyObject *
 posix_readlink(PyObject *self, PyObject *args)
 {
-	PyObject* v;
-	char buf[MAXPATHLEN];
-	PyObject *opath;
-	char *path;
-	int n;
-	int arg_is_unicode = 0;
-
-	if (!PyArg_ParseTuple(args, "O&:readlink", 
-				PyUnicode_FSConverter, &opath))
-		return NULL;
-	path = PyBytes_AsString(opath);
-	v = PySequence_GetItem(args, 0);
-	if (v == NULL) {
-		Py_DECREF(opath);
-		return NULL;
-	}
-
-	if (PyUnicode_Check(v)) {
-		arg_is_unicode = 1;
-	}
-	Py_DECREF(v);
-
-	Py_BEGIN_ALLOW_THREADS
-	n = readlink(path, buf, (int) sizeof buf);
-	Py_END_ALLOW_THREADS
-	if (n < 0)
-		return posix_error_with_allocated_filename(opath);
-
-	Py_DECREF(opath);
-	v = PyBytes_FromStringAndSize(buf, n);
-	if (arg_is_unicode) {
-		PyObject *w;
-
-		w = PyUnicode_FromEncodedObject(v,
-				Py_FileSystemDefaultEncoding,
-				"surrogateescape");
-		if (w != NULL) {
-			Py_DECREF(v);
-			v = w;
-		}
-		else {
-			v = NULL;
-		}
-	}
-	return v;
+    PyObject* v;
+    char buf[MAXPATHLEN];
+    PyObject *opath;
+    char *path;
+    int n;
+    int arg_is_unicode = 0;
+
+    if (!PyArg_ParseTuple(args, "O&:readlink",
+                          PyUnicode_FSConverter, &opath))
+        return NULL;
+    path = PyBytes_AsString(opath);
+    v = PySequence_GetItem(args, 0);
+    if (v == NULL) {
+        Py_DECREF(opath);
+        return NULL;
+    }
+
+    if (PyUnicode_Check(v)) {
+        arg_is_unicode = 1;
+    }
+    Py_DECREF(v);
+
+    Py_BEGIN_ALLOW_THREADS
+    n = readlink(path, buf, (int) sizeof buf);
+    Py_END_ALLOW_THREADS
+    if (n < 0)
+        return posix_error_with_allocated_filename(opath);
+
+    Py_DECREF(opath);
+    v = PyBytes_FromStringAndSize(buf, n);
+    if (arg_is_unicode) {
+        PyObject *w;
+
+        w = PyUnicode_FromEncodedObject(v,
+                                        Py_FileSystemDefaultEncoding,
+                                        "surrogateescape");
+        if (w != NULL) {
+            Py_DECREF(v);
+            v = w;
+        }
+        else {
+            v = NULL;
+        }
+    }
+    return v;
 }
 #endif /* HAVE_READLINK */
 
@@ -4630,7 +4631,7 @@
 static PyObject *
 posix_symlink(PyObject *self, PyObject *args)
 {
-	return posix_2str(args, "O&O&:symlink", symlink);
+    return posix_2str(args, "O&O&:symlink", symlink);
 }
 #endif /* HAVE_SYMLINK */
 
@@ -4653,12 +4654,12 @@
 posix_times(PyObject *self, PyObject *noargs)
 {
     /* Currently Only Uptime is Provided -- Others Later */
-	return Py_BuildValue("ddddd",
-			     (double)0 /* t.tms_utime / HZ */,
-			     (double)0 /* t.tms_stime / HZ */,
-			     (double)0 /* t.tms_cutime / HZ */,
-			     (double)0 /* t.tms_cstime / HZ */,
-			     (double)system_uptime() / 1000);
+    return Py_BuildValue("ddddd",
+                         (double)0 /* t.tms_utime / HZ */,
+                         (double)0 /* t.tms_stime / HZ */,
+                         (double)0 /* t.tms_cutime / HZ */,
+                         (double)0 /* t.tms_cstime / HZ */,
+                         (double)system_uptime() / 1000);
 }
 #else /* not OS2 */
 #define NEED_TICKS_PER_SECOND
@@ -4666,46 +4667,46 @@
 static PyObject *
 posix_times(PyObject *self, PyObject *noargs)
 {
-	struct tms t;
-	clock_t c;
-	errno = 0;
-	c = times(&t);
-	if (c == (clock_t) -1)
-		return posix_error();
-	return Py_BuildValue("ddddd",
-			     (double)t.tms_utime / ticks_per_second,
-			     (double)t.tms_stime / ticks_per_second,
-			     (double)t.tms_cutime / ticks_per_second,
-			     (double)t.tms_cstime / ticks_per_second,
-			     (double)c / ticks_per_second);
+    struct tms t;
+    clock_t c;
+    errno = 0;
+    c = times(&t);
+    if (c == (clock_t) -1)
+        return posix_error();
+    return Py_BuildValue("ddddd",
+                         (double)t.tms_utime / ticks_per_second,
+                         (double)t.tms_stime / ticks_per_second,
+                         (double)t.tms_cutime / ticks_per_second,
+                         (double)t.tms_cstime / ticks_per_second,
+                         (double)c / ticks_per_second);
 }
 #endif /* not OS2 */
 #endif /* HAVE_TIMES */
 
 
 #ifdef MS_WINDOWS
-#define HAVE_TIMES	/* so the method table will pick it up */
+#define HAVE_TIMES      /* so the method table will pick it up */
 static PyObject *
 posix_times(PyObject *self, PyObject *noargs)
 {
-	FILETIME create, exit, kernel, user;
-	HANDLE hProc;
-	hProc = GetCurrentProcess();
-	GetProcessTimes(hProc, &create, &exit, &kernel, &user);
-	/* The fields of a FILETIME structure are the hi and lo part
-	   of a 64-bit value expressed in 100 nanosecond units.
-	   1e7 is one second in such units; 1e-7 the inverse.
-	   429.4967296 is 2**32 / 1e7 or 2**32 * 1e-7.
-	*/
-	return Py_BuildValue(
-		"ddddd",
-		(double)(user.dwHighDateTime*429.4967296 +
-		         user.dwLowDateTime*1e-7),
-		(double)(kernel.dwHighDateTime*429.4967296 +
-		         kernel.dwLowDateTime*1e-7),
-		(double)0,
-		(double)0,
-		(double)0);
+    FILETIME create, exit, kernel, user;
+    HANDLE hProc;
+    hProc = GetCurrentProcess();
+    GetProcessTimes(hProc, &create, &exit, &kernel, &user);
+    /* The fields of a FILETIME structure are the hi and lo part
+       of a 64-bit value expressed in 100 nanosecond units.
+       1e7 is one second in such units; 1e-7 the inverse.
+       429.4967296 is 2**32 / 1e7 or 2**32 * 1e-7.
+    */
+    return Py_BuildValue(
+        "ddddd",
+        (double)(user.dwHighDateTime*429.4967296 +
+                 user.dwLowDateTime*1e-7),
+        (double)(kernel.dwHighDateTime*429.4967296 +
+                 kernel.dwLowDateTime*1e-7),
+        (double)0,
+        (double)0,
+        (double)0);
 }
 #endif /* MS_WINDOWS */
 
@@ -4724,14 +4725,14 @@
 static PyObject *
 posix_getsid(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int sid;
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID ":getsid", &pid))
-		return NULL;
-	sid = getsid(pid);
-	if (sid < 0)
-		return posix_error();
-	return PyLong_FromLong((long)sid);
+    pid_t pid;
+    int sid;
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID ":getsid", &pid))
+        return NULL;
+    sid = getsid(pid);
+    if (sid < 0)
+        return posix_error();
+    return PyLong_FromLong((long)sid);
 }
 #endif /* HAVE_GETSID */
 
@@ -4744,10 +4745,10 @@
 static PyObject *
 posix_setsid(PyObject *self, PyObject *noargs)
 {
-	if (setsid() < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    if (setsid() < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_SETSID */
 
@@ -4759,14 +4760,14 @@
 static PyObject *
 posix_setpgid(PyObject *self, PyObject *args)
 {
-	pid_t pid;
-	int pgrp;
-	if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:setpgid", &pid, &pgrp))
-		return NULL;
-	if (setpgid(pid, pgrp) < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    pid_t pid;
+    int pgrp;
+    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:setpgid", &pid, &pgrp))
+        return NULL;
+    if (setpgid(pid, pgrp) < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_SETPGID */
 
@@ -4779,14 +4780,14 @@
 static PyObject *
 posix_tcgetpgrp(PyObject *self, PyObject *args)
 {
-	int fd;
-	pid_t pgid;
-	if (!PyArg_ParseTuple(args, "i:tcgetpgrp", &fd))
-		return NULL;
-	pgid = tcgetpgrp(fd);
-	if (pgid < 0)
-		return posix_error();
-	return PyLong_FromPid(pgid);
+    int fd;
+    pid_t pgid;
+    if (!PyArg_ParseTuple(args, "i:tcgetpgrp", &fd))
+        return NULL;
+    pgid = tcgetpgrp(fd);
+    if (pgid < 0)
+        return posix_error();
+    return PyLong_FromPid(pgid);
 }
 #endif /* HAVE_TCGETPGRP */
 
@@ -4799,14 +4800,14 @@
 static PyObject *
 posix_tcsetpgrp(PyObject *self, PyObject *args)
 {
-	int fd;
-	pid_t pgid;
-	if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID ":tcsetpgrp", &fd, &pgid))
-		return NULL;
-	if (tcsetpgrp(fd, pgid) < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int fd;
+    pid_t pgid;
+    if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID ":tcsetpgrp", &fd, &pgid))
+        return NULL;
+    if (tcsetpgrp(fd, pgid) < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* HAVE_TCSETPGRP */
 
@@ -4819,41 +4820,41 @@
 static PyObject *
 posix_open(PyObject *self, PyObject *args)
 {
-	PyObject *ofile;
-	char *file;
-	int flag;
-	int mode = 0777;
-	int fd;
+    PyObject *ofile;
+    char *file;
+    int flag;
+    int mode = 0777;
+    int fd;
 
 #ifdef MS_WINDOWS
-	PyUnicodeObject *po;
-	if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) {
-		Py_BEGIN_ALLOW_THREADS
-		/* PyUnicode_AS_UNICODE OK without thread
-		   lock as it is a simple dereference. */
-		fd = _wopen(PyUnicode_AS_UNICODE(po), flag, mode);
-		Py_END_ALLOW_THREADS
-		if (fd < 0)
-			return posix_error();
-		return PyLong_FromLong((long)fd);
-	}
-	/* Drop the argument parsing error as narrow strings
-	   are also valid. */
-	PyErr_Clear();
-#endif
-
-	if (!PyArg_ParseTuple(args, "O&i|i",
-	                      PyUnicode_FSConverter, &ofile,
-	                      &flag, &mode))
-		return NULL;
-	file = PyBytes_AsString(ofile);
-	Py_BEGIN_ALLOW_THREADS
-	fd = open(file, flag, mode);
-	Py_END_ALLOW_THREADS
-	if (fd < 0)
-		return posix_error_with_allocated_filename(ofile);
-	Py_DECREF(ofile);
-	return PyLong_FromLong((long)fd);
+    PyUnicodeObject *po;
+    if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) {
+        Py_BEGIN_ALLOW_THREADS
+        /* PyUnicode_AS_UNICODE OK without thread
+           lock as it is a simple dereference. */
+        fd = _wopen(PyUnicode_AS_UNICODE(po), flag, mode);
+        Py_END_ALLOW_THREADS
+        if (fd < 0)
+            return posix_error();
+        return PyLong_FromLong((long)fd);
+    }
+    /* Drop the argument parsing error as narrow strings
+       are also valid. */
+    PyErr_Clear();
+#endif
+
+    if (!PyArg_ParseTuple(args, "O&i|i",
+                          PyUnicode_FSConverter, &ofile,
+                          &flag, &mode))
+        return NULL;
+    file = PyBytes_AsString(ofile);
+    Py_BEGIN_ALLOW_THREADS
+    fd = open(file, flag, mode);
+    Py_END_ALLOW_THREADS
+    if (fd < 0)
+        return posix_error_with_allocated_filename(ofile);
+    Py_DECREF(ofile);
+    return PyLong_FromLong((long)fd);
 }
 
 
@@ -4864,37 +4865,37 @@
 static PyObject *
 posix_close(PyObject *self, PyObject *args)
 {
-	int fd, res;
-	if (!PyArg_ParseTuple(args, "i:close", &fd))
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	res = close(fd);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int fd, res;
+    if (!PyArg_ParseTuple(args, "i:close", &fd))
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    res = close(fd);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 
-PyDoc_STRVAR(posix_closerange__doc__, 
+PyDoc_STRVAR(posix_closerange__doc__,
 "closerange(fd_low, fd_high)\n\n\
 Closes all file descriptors in [fd_low, fd_high), ignoring errors.");
 
 static PyObject *
 posix_closerange(PyObject *self, PyObject *args)
 {
-	int fd_from, fd_to, i;
-	if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	for (i = fd_from; i < fd_to; i++)
-		if (_PyVerify_fd(i))
-			close(i);
-	Py_END_ALLOW_THREADS
-	Py_RETURN_NONE;
+    int fd_from, fd_to, i;
+    if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    for (i = fd_from; i < fd_to; i++)
+        if (_PyVerify_fd(i))
+            close(i);
+    Py_END_ALLOW_THREADS
+    Py_RETURN_NONE;
 }
 
 
@@ -4905,17 +4906,17 @@
 static PyObject *
 posix_dup(PyObject *self, PyObject *args)
 {
-	int fd;
-	if (!PyArg_ParseTuple(args, "i:dup", &fd))
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	fd = dup(fd);
-	Py_END_ALLOW_THREADS
-	if (fd < 0)
-		return posix_error();
-	return PyLong_FromLong((long)fd);
+    int fd;
+    if (!PyArg_ParseTuple(args, "i:dup", &fd))
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    fd = dup(fd);
+    Py_END_ALLOW_THREADS
+    if (fd < 0)
+        return posix_error();
+    return PyLong_FromLong((long)fd);
 }
 
 
@@ -4926,18 +4927,18 @@
 static PyObject *
 posix_dup2(PyObject *self, PyObject *args)
 {
-	int fd, fd2, res;
-	if (!PyArg_ParseTuple(args, "ii:dup2", &fd, &fd2))
-		return NULL;
-	if (!_PyVerify_fd_dup2(fd, fd2))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	res = dup2(fd, fd2);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    int fd, fd2, res;
+    if (!PyArg_ParseTuple(args, "ii:dup2", &fd, &fd2))
+        return NULL;
+    if (!_PyVerify_fd_dup2(fd, fd2))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    res = dup2(fd, fd2);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 
@@ -4948,49 +4949,49 @@
 static PyObject *
 posix_lseek(PyObject *self, PyObject *args)
 {
-	int fd, how;
+    int fd, how;
 #if defined(MS_WIN64) || defined(MS_WINDOWS)
-	PY_LONG_LONG pos, res;
+    PY_LONG_LONG pos, res;
 #else
-	off_t pos, res;
+    off_t pos, res;
 #endif
-	PyObject *posobj;
-	if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how))
-		return NULL;
+    PyObject *posobj;
+    if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how))
+        return NULL;
 #ifdef SEEK_SET
-	/* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
-	switch (how) {
-	case 0: how = SEEK_SET; break;
-	case 1: how = SEEK_CUR; break;
-	case 2: how = SEEK_END; break;
-	}
+    /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
+    switch (how) {
+    case 0: how = SEEK_SET; break;
+    case 1: how = SEEK_CUR; break;
+    case 2: how = SEEK_END; break;
+    }
 #endif /* SEEK_END */
 
 #if !defined(HAVE_LARGEFILE_SUPPORT)
-	pos = PyLong_AsLong(posobj);
+    pos = PyLong_AsLong(posobj);
 #else
-	pos = PyLong_Check(posobj) ?
-		PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj);
+    pos = PyLong_Check(posobj) ?
+        PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj);
 #endif
-	if (PyErr_Occurred())
-		return NULL;
+    if (PyErr_Occurred())
+        return NULL;
 
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
 #if defined(MS_WIN64) || defined(MS_WINDOWS)
-	res = _lseeki64(fd, pos, how);
+    res = _lseeki64(fd, pos, how);
 #else
-	res = lseek(fd, pos, how);
+    res = lseek(fd, pos, how);
 #endif
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
 
 #if !defined(HAVE_LARGEFILE_SUPPORT)
-	return PyLong_FromLong(res);
+    return PyLong_FromLong(res);
 #else
-	return PyLong_FromLongLong(res);
+    return PyLong_FromLongLong(res);
 #endif
 }
 
@@ -5002,30 +5003,30 @@
 static PyObject *
 posix_read(PyObject *self, PyObject *args)
 {
-	int fd, size;
-        Py_ssize_t n;
-	PyObject *buffer;
-	if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
-		return NULL;
-	if (size < 0) {
-		errno = EINVAL;
-		return posix_error();
-	}
-	buffer = PyBytes_FromStringAndSize((char *)NULL, size);
-	if (buffer == NULL)
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	n = read(fd, PyBytes_AS_STRING(buffer), size);
-	Py_END_ALLOW_THREADS
-	if (n < 0) {
-		Py_DECREF(buffer);
-		return posix_error();
-	}
-	if (n != size)
-		_PyBytes_Resize(&buffer, n);
-	return buffer;
+    int fd, size;
+    Py_ssize_t n;
+    PyObject *buffer;
+    if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
+        return NULL;
+    if (size < 0) {
+        errno = EINVAL;
+        return posix_error();
+    }
+    buffer = PyBytes_FromStringAndSize((char *)NULL, size);
+    if (buffer == NULL)
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    n = read(fd, PyBytes_AS_STRING(buffer), size);
+    Py_END_ALLOW_THREADS
+    if (n < 0) {
+        Py_DECREF(buffer);
+        return posix_error();
+    }
+    if (n != size)
+        _PyBytes_Resize(&buffer, n);
+    return buffer;
 }
 
 
@@ -5036,21 +5037,21 @@
 static PyObject *
 posix_write(PyObject *self, PyObject *args)
 {
-	Py_buffer pbuf;
-	int fd;
-	Py_ssize_t size;
-
-	if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	size = write(fd, pbuf.buf, (size_t)pbuf.len);
-	Py_END_ALLOW_THREADS
-		PyBuffer_Release(&pbuf);
-	if (size < 0)
-		return posix_error();
-	return PyLong_FromSsize_t(size);
+    Py_buffer pbuf;
+    int fd;
+    Py_ssize_t size;
+
+    if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    size = write(fd, pbuf.buf, (size_t)pbuf.len);
+    Py_END_ALLOW_THREADS
+        PyBuffer_Release(&pbuf);
+    if (size < 0)
+        return posix_error();
+    return PyLong_FromSsize_t(size);
 }
 
 
@@ -5061,29 +5062,29 @@
 static PyObject *
 posix_fstat(PyObject *self, PyObject *args)
 {
-	int fd;
-	STRUCT_STAT st;
-	int res;
-	if (!PyArg_ParseTuple(args, "i:fstat", &fd))
-		return NULL;
+    int fd;
+    STRUCT_STAT st;
+    int res;
+    if (!PyArg_ParseTuple(args, "i:fstat", &fd))
+        return NULL;
 #ifdef __VMS
-        /* on OpenVMS we must ensure that all bytes are written to the file */
-        fsync(fd);
+    /* on OpenVMS we must ensure that all bytes are written to the file */
+    fsync(fd);
 #endif
-	if (!_PyVerify_fd(fd))
-		return posix_error();
-	Py_BEGIN_ALLOW_THREADS
-	res = FSTAT(fd, &st);
-	Py_END_ALLOW_THREADS
-	if (res != 0) {
+    if (!_PyVerify_fd(fd))
+        return posix_error();
+    Py_BEGIN_ALLOW_THREADS
+    res = FSTAT(fd, &st);
+    Py_END_ALLOW_THREADS
+    if (res != 0) {
 #ifdef MS_WINDOWS
-		return win32_error("fstat", NULL);
+        return win32_error("fstat", NULL);
 #else
-		return posix_error();
+        return posix_error();
 #endif
-	}
+    }
 
-	return _pystat_fromstructstat(&st);
+    return _pystat_fromstructstat(&st);
 }
 
 PyDoc_STRVAR(posix_isatty__doc__,
@@ -5094,12 +5095,12 @@
 static PyObject *
 posix_isatty(PyObject *self, PyObject *args)
 {
-	int fd;
-	if (!PyArg_ParseTuple(args, "i:isatty", &fd))
-		return NULL;
-	if (!_PyVerify_fd(fd))
-		return PyBool_FromLong(0);
-	return PyBool_FromLong(isatty(fd));
+    int fd;
+    if (!PyArg_ParseTuple(args, "i:isatty", &fd))
+        return NULL;
+    if (!_PyVerify_fd(fd))
+        return PyBool_FromLong(0);
+    return PyBool_FromLong(isatty(fd));
 }
 
 #ifdef HAVE_PIPE
@@ -5114,35 +5115,35 @@
     HFILE read, write;
     APIRET rc;
 
-	Py_BEGIN_ALLOW_THREADS
+    Py_BEGIN_ALLOW_THREADS
     rc = DosCreatePipe( &read, &write, 4096);
-	Py_END_ALLOW_THREADS
+    Py_END_ALLOW_THREADS
     if (rc != NO_ERROR)
         return os2_error(rc);
 
     return Py_BuildValue("(ii)", read, write);
 #else
 #if !defined(MS_WINDOWS)
-	int fds[2];
-	int res;
-	Py_BEGIN_ALLOW_THREADS
-	res = pipe(fds);
-	Py_END_ALLOW_THREADS
-	if (res != 0)
-		return posix_error();
-	return Py_BuildValue("(ii)", fds[0], fds[1]);
+    int fds[2];
+    int res;
+    Py_BEGIN_ALLOW_THREADS
+    res = pipe(fds);
+    Py_END_ALLOW_THREADS
+    if (res != 0)
+        return posix_error();
+    return Py_BuildValue("(ii)", fds[0], fds[1]);
 #else /* MS_WINDOWS */
-	HANDLE read, write;
-	int read_fd, write_fd;
-	BOOL ok;
-	Py_BEGIN_ALLOW_THREADS
-	ok = CreatePipe(&read, &write, NULL, 0);
-	Py_END_ALLOW_THREADS
-	if (!ok)
-		return win32_error("CreatePipe", NULL);
-	read_fd = _open_osfhandle((Py_intptr_t)read, 0);
-	write_fd = _open_osfhandle((Py_intptr_t)write, 1);
-	return Py_BuildValue("(ii)", read_fd, write_fd);
+    HANDLE read, write;
+    int read_fd, write_fd;
+    BOOL ok;
+    Py_BEGIN_ALLOW_THREADS
+    ok = CreatePipe(&read, &write, NULL, 0);
+    Py_END_ALLOW_THREADS
+    if (!ok)
+        return win32_error("CreatePipe", NULL);
+    read_fd = _open_osfhandle((Py_intptr_t)read, 0);
+    write_fd = _open_osfhandle((Py_intptr_t)write, 1);
+    return Py_BuildValue("(ii)", read_fd, write_fd);
 #endif /* MS_WINDOWS */
 #endif
 }
@@ -5157,18 +5158,18 @@
 static PyObject *
 posix_mkfifo(PyObject *self, PyObject *args)
 {
-	char *filename;
-	int mode = 0666;
-	int res;
-	if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = mkfifo(filename, mode);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    char *filename;
+    int mode = 0666;
+    int res;
+    if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = mkfifo(filename, mode);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -5187,19 +5188,19 @@
 static PyObject *
 posix_mknod(PyObject *self, PyObject *args)
 {
-	char *filename;
-	int mode = 0600;
-	int device = 0;
-	int res;
-	if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = mknod(filename, mode, device);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    char *filename;
+    int mode = 0600;
+    int device = 0;
+    int res;
+    if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = mknod(filename, mode, device);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -5211,10 +5212,10 @@
 static PyObject *
 posix_major(PyObject *self, PyObject *args)
 {
-	int device;
-	if (!PyArg_ParseTuple(args, "i:major", &device))
-		return NULL;
-	return PyLong_FromLong((long)major(device));
+    int device;
+    if (!PyArg_ParseTuple(args, "i:major", &device))
+        return NULL;
+    return PyLong_FromLong((long)major(device));
 }
 
 PyDoc_STRVAR(posix_minor__doc__,
@@ -5224,10 +5225,10 @@
 static PyObject *
 posix_minor(PyObject *self, PyObject *args)
 {
-	int device;
-	if (!PyArg_ParseTuple(args, "i:minor", &device))
-		return NULL;
-	return PyLong_FromLong((long)minor(device));
+    int device;
+    if (!PyArg_ParseTuple(args, "i:minor", &device))
+        return NULL;
+    return PyLong_FromLong((long)minor(device));
 }
 
 PyDoc_STRVAR(posix_makedev__doc__,
@@ -5237,10 +5238,10 @@
 static PyObject *
 posix_makedev(PyObject *self, PyObject *args)
 {
-	int major, minor;
-	if (!PyArg_ParseTuple(args, "ii:makedev", &major, &minor))
-		return NULL;
-	return PyLong_FromLong((long)makedev(major, minor));
+    int major, minor;
+    if (!PyArg_ParseTuple(args, "ii:makedev", &major, &minor))
+        return NULL;
+    return PyLong_FromLong((long)makedev(major, minor));
 }
 #endif /* device macros */
 
@@ -5253,30 +5254,30 @@
 static PyObject *
 posix_ftruncate(PyObject *self, PyObject *args)
 {
-	int fd;
-	off_t length;
-	int res;
-	PyObject *lenobj;
+    int fd;
+    off_t length;
+    int res;
+    PyObject *lenobj;
 
-	if (!PyArg_ParseTuple(args, "iO:ftruncate", &fd, &lenobj))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "iO:ftruncate", &fd, &lenobj))
+        return NULL;
 
 #if !defined(HAVE_LARGEFILE_SUPPORT)
-	length = PyLong_AsLong(lenobj);
+    length = PyLong_AsLong(lenobj);
 #else
-	length = PyLong_Check(lenobj) ?
-		PyLong_AsLongLong(lenobj) : PyLong_AsLong(lenobj);
+    length = PyLong_Check(lenobj) ?
+        PyLong_AsLongLong(lenobj) : PyLong_AsLong(lenobj);
 #endif
-	if (PyErr_Occurred())
-		return NULL;
+    if (PyErr_Occurred())
+        return NULL;
 
-	Py_BEGIN_ALLOW_THREADS
-	res = ftruncate(fd, length);
-	Py_END_ALLOW_THREADS
-	if (res < 0)
-		return posix_error();
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_BEGIN_ALLOW_THREADS
+    res = ftruncate(fd, length);
+    Py_END_ALLOW_THREADS
+    if (res < 0)
+        return posix_error();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -5293,29 +5294,29 @@
 posix_putenv(PyObject *self, PyObject *args)
 {
 #ifdef MS_WINDOWS
-        wchar_t *s1, *s2;
-        wchar_t *newenv;
+    wchar_t *s1, *s2;
+    wchar_t *newenv;
 #else
-	PyObject *os1, *os2;
-        char *s1, *s2;
-        char *newenv;
+    PyObject *os1, *os2;
+    char *s1, *s2;
+    char *newenv;
 #endif
-	PyObject *newstr;
-	size_t len;
+    PyObject *newstr;
+    size_t len;
 
 #ifdef MS_WINDOWS
-	if (!PyArg_ParseTuple(args,
-			      "uu:putenv",
-			      &s1, &s2))
-		return NULL;
-#else
-	if (!PyArg_ParseTuple(args,
-			      "O&O&:putenv",
-			      PyUnicode_FSConverter, &os1, 
-			      PyUnicode_FSConverter, &os2))
-		return NULL;
-	s1 = PyBytes_AsString(os1);
-	s2 = PyBytes_AsString(os2);
+    if (!PyArg_ParseTuple(args,
+                          "uu:putenv",
+                          &s1, &s2))
+        return NULL;
+#else
+    if (!PyArg_ParseTuple(args,
+                          "O&O&:putenv",
+                          PyUnicode_FSConverter, &os1,
+                          PyUnicode_FSConverter, &os2))
+        return NULL;
+    s1 = PyBytes_AsString(os1);
+    s2 = PyBytes_AsString(os2);
 #endif
 
 #if defined(PYOS_OS2)
@@ -5334,59 +5335,59 @@
             return os2_error(rc);
     } else {
 #endif
-	/* XXX This can leak memory -- not easy to fix :-( */
-	/* len includes space for a trailing \0; the size arg to
-	   PyBytes_FromStringAndSize does not count that */
+    /* XXX This can leak memory -- not easy to fix :-( */
+    /* len includes space for a trailing \0; the size arg to
+       PyBytes_FromStringAndSize does not count that */
 #ifdef MS_WINDOWS
-	len = wcslen(s1) + wcslen(s2) + 2;
-	newstr = PyUnicode_FromUnicode(NULL, (int)len - 1);
+    len = wcslen(s1) + wcslen(s2) + 2;
+    newstr = PyUnicode_FromUnicode(NULL, (int)len - 1);
 #else
-	len = strlen(s1) + strlen(s2) + 2;
-	newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
+    len = strlen(s1) + strlen(s2) + 2;
+    newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
 #endif
-	if (newstr == NULL)
-		return PyErr_NoMemory();
+    if (newstr == NULL)
+        return PyErr_NoMemory();
 #ifdef MS_WINDOWS
-	newenv = PyUnicode_AsUnicode(newstr);
-	_snwprintf(newenv, len, L"%s=%s", s1, s2);
-	if (_wputenv(newenv)) {
-                Py_DECREF(newstr);
-                posix_error();
-                return NULL;
-	}
+    newenv = PyUnicode_AsUnicode(newstr);
+    _snwprintf(newenv, len, L"%s=%s", s1, s2);
+    if (_wputenv(newenv)) {
+        Py_DECREF(newstr);
+        posix_error();
+        return NULL;
+    }
 #else
-	newenv = PyBytes_AS_STRING(newstr);
-	PyOS_snprintf(newenv, len, "%s=%s", s1, s2);
-	if (putenv(newenv)) {
-                Py_DECREF(newstr);
-		Py_DECREF(os1);
-		Py_DECREF(os2);
-                posix_error();
-                return NULL;
-	}
+    newenv = PyBytes_AS_STRING(newstr);
+    PyOS_snprintf(newenv, len, "%s=%s", s1, s2);
+    if (putenv(newenv)) {
+        Py_DECREF(newstr);
+        Py_DECREF(os1);
+        Py_DECREF(os2);
+        posix_error();
+        return NULL;
+    }
 #endif
-	/* Install the first arg and newstr in posix_putenv_garbage;
-	 * this will cause previous value to be collected.  This has to
-	 * happen after the real putenv() call because the old value
-	 * was still accessible until then. */
-	if (PyDict_SetItem(posix_putenv_garbage,
-			   PyTuple_GET_ITEM(args, 0), newstr)) {
-		/* really not much we can do; just leak */
-		PyErr_Clear();
-	}
-	else {
-		Py_DECREF(newstr);
-	}
+    /* Install the first arg and newstr in posix_putenv_garbage;
+     * this will cause previous value to be collected.  This has to
+     * happen after the real putenv() call because the old value
+     * was still accessible until then. */
+    if (PyDict_SetItem(posix_putenv_garbage,
+                       PyTuple_GET_ITEM(args, 0), newstr)) {
+        /* really not much we can do; just leak */
+        PyErr_Clear();
+    }
+    else {
+        Py_DECREF(newstr);
+    }
 
 #if defined(PYOS_OS2)
     }
 #endif
 #ifndef MS_WINDOWS
-	Py_DECREF(os1);
-	Py_DECREF(os2);
+    Py_DECREF(os1);
+    Py_DECREF(os2);
 #endif
-	Py_INCREF(Py_None);
-        return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* putenv */
 
@@ -5398,26 +5399,26 @@
 static PyObject *
 posix_unsetenv(PyObject *self, PyObject *args)
 {
-        char *s1;
+    char *s1;
 
-	if (!PyArg_ParseTuple(args, "s:unsetenv", &s1))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "s:unsetenv", &s1))
+        return NULL;
 
-	unsetenv(s1);
+    unsetenv(s1);
 
-	/* Remove the key from posix_putenv_garbage;
-	 * this will cause it to be collected.  This has to
-	 * happen after the real unsetenv() call because the
-	 * old value was still accessible until then.
-	 */
-	if (PyDict_DelItem(posix_putenv_garbage,
-		PyTuple_GET_ITEM(args, 0))) {
-		/* really not much we can do; just leak */
-		PyErr_Clear();
-	}
+    /* Remove the key from posix_putenv_garbage;
+     * this will cause it to be collected.  This has to
+     * happen after the real unsetenv() call because the
+     * old value was still accessible until then.
+     */
+    if (PyDict_DelItem(posix_putenv_garbage,
+                       PyTuple_GET_ITEM(args, 0))) {
+        /* really not much we can do; just leak */
+        PyErr_Clear();
+    }
 
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif /* unsetenv */
 
@@ -5428,17 +5429,17 @@
 static PyObject *
 posix_strerror(PyObject *self, PyObject *args)
 {
-	int code;
-	char *message;
-	if (!PyArg_ParseTuple(args, "i:strerror", &code))
-		return NULL;
-	message = strerror(code);
-	if (message == NULL) {
-		PyErr_SetString(PyExc_ValueError,
-				"strerror() argument out of range");
-		return NULL;
-	}
-	return PyUnicode_FromString(message);
+    int code;
+    char *message;
+    if (!PyArg_ParseTuple(args, "i:strerror", &code))
+        return NULL;
+    message = strerror(code);
+    if (message == NULL) {
+        PyErr_SetString(PyExc_ValueError,
+                        "strerror() argument out of range");
+        return NULL;
+    }
+    return PyUnicode_FromString(message);
 }
 
 
@@ -5452,13 +5453,13 @@
 static PyObject *
 posix_WCOREDUMP(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WCOREDUMP", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WCOREDUMP", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return PyBool_FromLong(WCOREDUMP(status));
+    return PyBool_FromLong(WCOREDUMP(status));
 }
 #endif /* WCOREDUMP */
 
@@ -5471,13 +5472,13 @@
 static PyObject *
 posix_WIFCONTINUED(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WCONTINUED", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WCONTINUED", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return PyBool_FromLong(WIFCONTINUED(status));
+    return PyBool_FromLong(WIFCONTINUED(status));
 }
 #endif /* WIFCONTINUED */
 
@@ -5489,13 +5490,13 @@
 static PyObject *
 posix_WIFSTOPPED(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WIFSTOPPED", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WIFSTOPPED", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return PyBool_FromLong(WIFSTOPPED(status));
+    return PyBool_FromLong(WIFSTOPPED(status));
 }
 #endif /* WIFSTOPPED */
 
@@ -5507,13 +5508,13 @@
 static PyObject *
 posix_WIFSIGNALED(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WIFSIGNALED", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WIFSIGNALED", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return PyBool_FromLong(WIFSIGNALED(status));
+    return PyBool_FromLong(WIFSIGNALED(status));
 }
 #endif /* WIFSIGNALED */
 
@@ -5526,13 +5527,13 @@
 static PyObject *
 posix_WIFEXITED(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WIFEXITED", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WIFEXITED", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return PyBool_FromLong(WIFEXITED(status));
+    return PyBool_FromLong(WIFEXITED(status));
 }
 #endif /* WIFEXITED */
 
@@ -5544,13 +5545,13 @@
 static PyObject *
 posix_WEXITSTATUS(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WEXITSTATUS", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WEXITSTATUS", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return Py_BuildValue("i", WEXITSTATUS(status));
+    return Py_BuildValue("i", WEXITSTATUS(status));
 }
 #endif /* WEXITSTATUS */
 
@@ -5563,13 +5564,13 @@
 static PyObject *
 posix_WTERMSIG(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WTERMSIG", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WTERMSIG", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return Py_BuildValue("i", WTERMSIG(status));
+    return Py_BuildValue("i", WTERMSIG(status));
 }
 #endif /* WTERMSIG */
 
@@ -5582,13 +5583,13 @@
 static PyObject *
 posix_WSTOPSIG(PyObject *self, PyObject *args)
 {
-	WAIT_TYPE status;
-	WAIT_STATUS_INT(status) = 0;
+    WAIT_TYPE status;
+    WAIT_STATUS_INT(status) = 0;
 
-	if (!PyArg_ParseTuple(args, "i:WSTOPSIG", &WAIT_STATUS_INT(status)))
-		return NULL;
+    if (!PyArg_ParseTuple(args, "i:WSTOPSIG", &WAIT_STATUS_INT(status)))
+        return NULL;
 
-	return Py_BuildValue("i", WSTOPSIG(status));
+    return Py_BuildValue("i", WSTOPSIG(status));
 }
 #endif /* WSTOPSIG */
 
@@ -5605,41 +5606,41 @@
 
 static PyObject*
 _pystatvfs_fromstructstatvfs(struct statvfs st) {
-        PyObject *v = PyStructSequence_New(&StatVFSResultType);
-	if (v == NULL)
-		return NULL;
+    PyObject *v = PyStructSequence_New(&StatVFSResultType);
+    if (v == NULL)
+        return NULL;
 
 #if !defined(HAVE_LARGEFILE_SUPPORT)
-        PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize));
-        PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize));
-        PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long) st.f_blocks));
-        PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long) st.f_bfree));
-        PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long) st.f_bavail));
-        PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long) st.f_files));
-        PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong((long) st.f_ffree));
-        PyStructSequence_SET_ITEM(v, 7, PyLong_FromLong((long) st.f_favail));
-        PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
-        PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
-#else
-        PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize));
-        PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize));
-        PyStructSequence_SET_ITEM(v, 2,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_blocks));
-        PyStructSequence_SET_ITEM(v, 3,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_bfree));
-        PyStructSequence_SET_ITEM(v, 4,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_bavail));
-        PyStructSequence_SET_ITEM(v, 5,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_files));
-        PyStructSequence_SET_ITEM(v, 6,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_ffree));
-        PyStructSequence_SET_ITEM(v, 7,
-			       PyLong_FromLongLong((PY_LONG_LONG) st.f_favail));
-        PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
-        PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
+    PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize));
+    PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize));
+    PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long) st.f_blocks));
+    PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long) st.f_bfree));
+    PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long) st.f_bavail));
+    PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long) st.f_files));
+    PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong((long) st.f_ffree));
+    PyStructSequence_SET_ITEM(v, 7, PyLong_FromLong((long) st.f_favail));
+    PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
+    PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
+#else
+    PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize));
+    PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize));
+    PyStructSequence_SET_ITEM(v, 2,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_blocks));
+    PyStructSequence_SET_ITEM(v, 3,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_bfree));
+    PyStructSequence_SET_ITEM(v, 4,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_bavail));
+    PyStructSequence_SET_ITEM(v, 5,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_files));
+    PyStructSequence_SET_ITEM(v, 6,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_ffree));
+    PyStructSequence_SET_ITEM(v, 7,
+                              PyLong_FromLongLong((PY_LONG_LONG) st.f_favail));
+    PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
+    PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
 #endif
 
-        return v;
+    return v;
 }
 
 PyDoc_STRVAR(posix_fstatvfs__doc__,
@@ -5649,18 +5650,18 @@
 static PyObject *
 posix_fstatvfs(PyObject *self, PyObject *args)
 {
-	int fd, res;
-	struct statvfs st;
+    int fd, res;
+    struct statvfs st;
 
-	if (!PyArg_ParseTuple(args, "i:fstatvfs", &fd))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = fstatvfs(fd, &st);
-	Py_END_ALLOW_THREADS
-	if (res != 0)
-		return posix_error();
+    if (!PyArg_ParseTuple(args, "i:fstatvfs", &fd))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = fstatvfs(fd, &st);
+    Py_END_ALLOW_THREADS
+    if (res != 0)
+        return posix_error();
 
-        return _pystatvfs_fromstructstatvfs(st);
+    return _pystatvfs_fromstructstatvfs(st);
 }
 #endif /* HAVE_FSTATVFS && HAVE_SYS_STATVFS_H */
 
@@ -5675,18 +5676,18 @@
 static PyObject *
 posix_statvfs(PyObject *self, PyObject *args)
 {
-	char *path;
-	int res;
-	struct statvfs st;
-	if (!PyArg_ParseTuple(args, "s:statvfs", &path))
-		return NULL;
-	Py_BEGIN_ALLOW_THREADS
-	res = statvfs(path, &st);
-	Py_END_ALLOW_THREADS
-	if (res != 0)
-		return posix_error_with_filename(path);
+    char *path;
+    int res;
+    struct statvfs st;
+    if (!PyArg_ParseTuple(args, "s:statvfs", &path))
+        return NULL;
+    Py_BEGIN_ALLOW_THREADS
+    res = statvfs(path, &st);
+    Py_END_ALLOW_THREADS
+    if (res != 0)
+        return posix_error_with_filename(path);
 
-        return _pystatvfs_fromstructstatvfs(st);
+    return _pystatvfs_fromstructstatvfs(st);
 }
 #endif /* HAVE_STATVFS */
 
@@ -5711,38 +5712,38 @@
               size_t tablesize)
 {
     if (PyLong_Check(arg)) {
-        *valuep = PyLong_AS_LONG(arg);
-        return 1;
+    *valuep = PyLong_AS_LONG(arg);
+    return 1;
     }
     else {
-        /* look up the value in the table using a binary search */
-        size_t lo = 0;
-        size_t mid;
-        size_t hi = tablesize;
-        int cmp;
-        const char *confname;
-        if (!PyUnicode_Check(arg)) {
-            PyErr_SetString(PyExc_TypeError,
-                            "configuration names must be strings or integers");
-            return 0;
-        }
-        confname = _PyUnicode_AsString(arg);
-        if (confname == NULL)
-            return 0;
-        while (lo < hi) {
-            mid = (lo + hi) / 2;
-            cmp = strcmp(confname, table[mid].name);
-            if (cmp < 0)
-                hi = mid;
-            else if (cmp > 0)
-                lo = mid + 1;
-            else {
-                *valuep = table[mid].value;
-                return 1;
-            }
-        }
-        PyErr_SetString(PyExc_ValueError, "unrecognized configuration name");
+    /* look up the value in the table using a binary search */
+    size_t lo = 0;
+    size_t mid;
+    size_t hi = tablesize;
+    int cmp;
+    const char *confname;
+    if (!PyUnicode_Check(arg)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "configuration names must be strings or integers");
+        return 0;
+    }
+    confname = _PyUnicode_AsString(arg);
+    if (confname == NULL)
         return 0;
+    while (lo < hi) {
+        mid = (lo + hi) / 2;
+        cmp = strcmp(confname, table[mid].name);
+        if (cmp < 0)
+        hi = mid;
+        else if (cmp > 0)
+        lo = mid + 1;
+        else {
+        *valuep = table[mid].value;
+        return 1;
+        }
+    }
+    PyErr_SetString(PyExc_ValueError, "unrecognized configuration name");
+    return 0;
     }
 }
 
@@ -5750,55 +5751,55 @@
 #if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF)
 static struct constdef  posix_constants_pathconf[] = {
 #ifdef _PC_ABI_AIO_XFER_MAX
-    {"PC_ABI_AIO_XFER_MAX",	_PC_ABI_AIO_XFER_MAX},
+    {"PC_ABI_AIO_XFER_MAX",     _PC_ABI_AIO_XFER_MAX},
 #endif
 #ifdef _PC_ABI_ASYNC_IO
-    {"PC_ABI_ASYNC_IO",	_PC_ABI_ASYNC_IO},
+    {"PC_ABI_ASYNC_IO", _PC_ABI_ASYNC_IO},
 #endif
 #ifdef _PC_ASYNC_IO
-    {"PC_ASYNC_IO",	_PC_ASYNC_IO},
+    {"PC_ASYNC_IO",     _PC_ASYNC_IO},
 #endif
 #ifdef _PC_CHOWN_RESTRICTED
-    {"PC_CHOWN_RESTRICTED",	_PC_CHOWN_RESTRICTED},
+    {"PC_CHOWN_RESTRICTED",     _PC_CHOWN_RESTRICTED},
 #endif
 #ifdef _PC_FILESIZEBITS
-    {"PC_FILESIZEBITS",	_PC_FILESIZEBITS},
+    {"PC_FILESIZEBITS", _PC_FILESIZEBITS},
 #endif
 #ifdef _PC_LAST
-    {"PC_LAST",	_PC_LAST},
+    {"PC_LAST", _PC_LAST},
 #endif
 #ifdef _PC_LINK_MAX
-    {"PC_LINK_MAX",	_PC_LINK_MAX},
+    {"PC_LINK_MAX",     _PC_LINK_MAX},
 #endif
 #ifdef _PC_MAX_CANON
-    {"PC_MAX_CANON",	_PC_MAX_CANON},
+    {"PC_MAX_CANON",    _PC_MAX_CANON},
 #endif
 #ifdef _PC_MAX_INPUT
-    {"PC_MAX_INPUT",	_PC_MAX_INPUT},
+    {"PC_MAX_INPUT",    _PC_MAX_INPUT},
 #endif
 #ifdef _PC_NAME_MAX
-    {"PC_NAME_MAX",	_PC_NAME_MAX},
+    {"PC_NAME_MAX",     _PC_NAME_MAX},
 #endif
 #ifdef _PC_NO_TRUNC
-    {"PC_NO_TRUNC",	_PC_NO_TRUNC},
+    {"PC_NO_TRUNC",     _PC_NO_TRUNC},
 #endif
 #ifdef _PC_PATH_MAX
-    {"PC_PATH_MAX",	_PC_PATH_MAX},
+    {"PC_PATH_MAX",     _PC_PATH_MAX},
 #endif
 #ifdef _PC_PIPE_BUF
-    {"PC_PIPE_BUF",	_PC_PIPE_BUF},
+    {"PC_PIPE_BUF",     _PC_PIPE_BUF},
 #endif
 #ifdef _PC_PRIO_IO
-    {"PC_PRIO_IO",	_PC_PRIO_IO},
+    {"PC_PRIO_IO",      _PC_PRIO_IO},
 #endif
 #ifdef _PC_SOCK_MAXBUF
-    {"PC_SOCK_MAXBUF",	_PC_SOCK_MAXBUF},
+    {"PC_SOCK_MAXBUF",  _PC_SOCK_MAXBUF},
 #endif
 #ifdef _PC_SYNC_IO
-    {"PC_SYNC_IO",	_PC_SYNC_IO},
+    {"PC_SYNC_IO",      _PC_SYNC_IO},
 #endif
 #ifdef _PC_VDISABLE
-    {"PC_VDISABLE",	_PC_VDISABLE},
+    {"PC_VDISABLE",     _PC_VDISABLE},
 #endif
 };
 
@@ -5825,14 +5826,14 @@
 
     if (PyArg_ParseTuple(args, "iO&:fpathconf", &fd,
                          conv_path_confname, &name)) {
-        long limit;
+    long limit;
 
-        errno = 0;
-        limit = fpathconf(fd, name);
-        if (limit == -1 && errno != 0)
-            posix_error();
-        else
-            result = PyLong_FromLong(limit);
+    errno = 0;
+    limit = fpathconf(fd, name);
+    if (limit == -1 && errno != 0)
+        posix_error();
+    else
+        result = PyLong_FromLong(limit);
     }
     return result;
 }
@@ -5854,19 +5855,19 @@
 
     if (PyArg_ParseTuple(args, "sO&:pathconf", &path,
                          conv_path_confname, &name)) {
-        long limit;
+    long limit;
 
-        errno = 0;
-        limit = pathconf(path, name);
-        if (limit == -1 && errno != 0) {
-            if (errno == EINVAL)
-                /* could be a path or name problem */
-                posix_error();
-            else
-                posix_error_with_filename(path);
-        }
+    errno = 0;
+    limit = pathconf(path, name);
+    if (limit == -1 && errno != 0) {
+        if (errno == EINVAL)
+        /* could be a path or name problem */
+        posix_error();
         else
-            result = PyLong_FromLong(limit);
+        posix_error_with_filename(path);
+    }
+    else
+        result = PyLong_FromLong(limit);
     }
     return result;
 }
@@ -5875,154 +5876,154 @@
 #ifdef HAVE_CONFSTR
 static struct constdef posix_constants_confstr[] = {
 #ifdef _CS_ARCHITECTURE
-    {"CS_ARCHITECTURE",	_CS_ARCHITECTURE},
+    {"CS_ARCHITECTURE", _CS_ARCHITECTURE},
 #endif
 #ifdef _CS_GNU_LIBC_VERSION
-    {"CS_GNU_LIBC_VERSION",	_CS_GNU_LIBC_VERSION},
+    {"CS_GNU_LIBC_VERSION",     _CS_GNU_LIBC_VERSION},
 #endif
 #ifdef _CS_GNU_LIBPTHREAD_VERSION
-    {"CS_GNU_LIBPTHREAD_VERSION",	_CS_GNU_LIBPTHREAD_VERSION},
+    {"CS_GNU_LIBPTHREAD_VERSION",       _CS_GNU_LIBPTHREAD_VERSION},
 #endif
 #ifdef _CS_HOSTNAME
-    {"CS_HOSTNAME",	_CS_HOSTNAME},
+    {"CS_HOSTNAME",     _CS_HOSTNAME},
 #endif
 #ifdef _CS_HW_PROVIDER
-    {"CS_HW_PROVIDER",	_CS_HW_PROVIDER},
+    {"CS_HW_PROVIDER",  _CS_HW_PROVIDER},
 #endif
 #ifdef _CS_HW_SERIAL
-    {"CS_HW_SERIAL",	_CS_HW_SERIAL},
+    {"CS_HW_SERIAL",    _CS_HW_SERIAL},
 #endif
 #ifdef _CS_INITTAB_NAME
-    {"CS_INITTAB_NAME",	_CS_INITTAB_NAME},
+    {"CS_INITTAB_NAME", _CS_INITTAB_NAME},
 #endif
 #ifdef _CS_LFS64_CFLAGS
-    {"CS_LFS64_CFLAGS",	_CS_LFS64_CFLAGS},
+    {"CS_LFS64_CFLAGS", _CS_LFS64_CFLAGS},
 #endif
 #ifdef _CS_LFS64_LDFLAGS
-    {"CS_LFS64_LDFLAGS",	_CS_LFS64_LDFLAGS},
+    {"CS_LFS64_LDFLAGS",        _CS_LFS64_LDFLAGS},
 #endif
 #ifdef _CS_LFS64_LIBS
-    {"CS_LFS64_LIBS",	_CS_LFS64_LIBS},
+    {"CS_LFS64_LIBS",   _CS_LFS64_LIBS},
 #endif
 #ifdef _CS_LFS64_LINTFLAGS
-    {"CS_LFS64_LINTFLAGS",	_CS_LFS64_LINTFLAGS},
+    {"CS_LFS64_LINTFLAGS",      _CS_LFS64_LINTFLAGS},
 #endif
 #ifdef _CS_LFS_CFLAGS
-    {"CS_LFS_CFLAGS",	_CS_LFS_CFLAGS},
+    {"CS_LFS_CFLAGS",   _CS_LFS_CFLAGS},
 #endif
 #ifdef _CS_LFS_LDFLAGS
-    {"CS_LFS_LDFLAGS",	_CS_LFS_LDFLAGS},
+    {"CS_LFS_LDFLAGS",  _CS_LFS_LDFLAGS},
 #endif
 #ifdef _CS_LFS_LIBS
-    {"CS_LFS_LIBS",	_CS_LFS_LIBS},
+    {"CS_LFS_LIBS",     _CS_LFS_LIBS},
 #endif
 #ifdef _CS_LFS_LINTFLAGS
-    {"CS_LFS_LINTFLAGS",	_CS_LFS_LINTFLAGS},
+    {"CS_LFS_LINTFLAGS",        _CS_LFS_LINTFLAGS},
 #endif
 #ifdef _CS_MACHINE
-    {"CS_MACHINE",	_CS_MACHINE},
+    {"CS_MACHINE",      _CS_MACHINE},
 #endif
 #ifdef _CS_PATH
-    {"CS_PATH",	_CS_PATH},
+    {"CS_PATH", _CS_PATH},
 #endif
 #ifdef _CS_RELEASE
-    {"CS_RELEASE",	_CS_RELEASE},
+    {"CS_RELEASE",      _CS_RELEASE},
 #endif
 #ifdef _CS_SRPC_DOMAIN
-    {"CS_SRPC_DOMAIN",	_CS_SRPC_DOMAIN},
+    {"CS_SRPC_DOMAIN",  _CS_SRPC_DOMAIN},
 #endif
 #ifdef _CS_SYSNAME
-    {"CS_SYSNAME",	_CS_SYSNAME},
+    {"CS_SYSNAME",      _CS_SYSNAME},
 #endif
 #ifdef _CS_VERSION
-    {"CS_VERSION",	_CS_VERSION},
+    {"CS_VERSION",      _CS_VERSION},
 #endif
 #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
-    {"CS_XBS5_ILP32_OFF32_CFLAGS",	_CS_XBS5_ILP32_OFF32_CFLAGS},
+    {"CS_XBS5_ILP32_OFF32_CFLAGS",      _CS_XBS5_ILP32_OFF32_CFLAGS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
-    {"CS_XBS5_ILP32_OFF32_LDFLAGS",	_CS_XBS5_ILP32_OFF32_LDFLAGS},
+    {"CS_XBS5_ILP32_OFF32_LDFLAGS",     _CS_XBS5_ILP32_OFF32_LDFLAGS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFF32_LIBS
-    {"CS_XBS5_ILP32_OFF32_LIBS",	_CS_XBS5_ILP32_OFF32_LIBS},
+    {"CS_XBS5_ILP32_OFF32_LIBS",        _CS_XBS5_ILP32_OFF32_LIBS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
-    {"CS_XBS5_ILP32_OFF32_LINTFLAGS",	_CS_XBS5_ILP32_OFF32_LINTFLAGS},
+    {"CS_XBS5_ILP32_OFF32_LINTFLAGS",   _CS_XBS5_ILP32_OFF32_LINTFLAGS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
-    {"CS_XBS5_ILP32_OFFBIG_CFLAGS",	_CS_XBS5_ILP32_OFFBIG_CFLAGS},
+    {"CS_XBS5_ILP32_OFFBIG_CFLAGS",     _CS_XBS5_ILP32_OFFBIG_CFLAGS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
-    {"CS_XBS5_ILP32_OFFBIG_LDFLAGS",	_CS_XBS5_ILP32_OFFBIG_LDFLAGS},
+    {"CS_XBS5_ILP32_OFFBIG_LDFLAGS",    _CS_XBS5_ILP32_OFFBIG_LDFLAGS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
-    {"CS_XBS5_ILP32_OFFBIG_LIBS",	_CS_XBS5_ILP32_OFFBIG_LIBS},
+    {"CS_XBS5_ILP32_OFFBIG_LIBS",       _CS_XBS5_ILP32_OFFBIG_LIBS},
 #endif
 #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
-    {"CS_XBS5_ILP32_OFFBIG_LINTFLAGS",	_CS_XBS5_ILP32_OFFBIG_LINTFLAGS},
+    {"CS_XBS5_ILP32_OFFBIG_LINTFLAGS",  _CS_XBS5_ILP32_OFFBIG_LINTFLAGS},
 #endif
 #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
-    {"CS_XBS5_LP64_OFF64_CFLAGS",	_CS_XBS5_LP64_OFF64_CFLAGS},
+    {"CS_XBS5_LP64_OFF64_CFLAGS",       _CS_XBS5_LP64_OFF64_CFLAGS},
 #endif
 #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
-    {"CS_XBS5_LP64_OFF64_LDFLAGS",	_CS_XBS5_LP64_OFF64_LDFLAGS},
+    {"CS_XBS5_LP64_OFF64_LDFLAGS",      _CS_XBS5_LP64_OFF64_LDFLAGS},
 #endif
 #ifdef _CS_XBS5_LP64_OFF64_LIBS
-    {"CS_XBS5_LP64_OFF64_LIBS",	_CS_XBS5_LP64_OFF64_LIBS},
+    {"CS_XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS},
 #endif
 #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
-    {"CS_XBS5_LP64_OFF64_LINTFLAGS",	_CS_XBS5_LP64_OFF64_LINTFLAGS},
+    {"CS_XBS5_LP64_OFF64_LINTFLAGS",    _CS_XBS5_LP64_OFF64_LINTFLAGS},
 #endif
 #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
-    {"CS_XBS5_LPBIG_OFFBIG_CFLAGS",	_CS_XBS5_LPBIG_OFFBIG_CFLAGS},
+    {"CS_XBS5_LPBIG_OFFBIG_CFLAGS",     _CS_XBS5_LPBIG_OFFBIG_CFLAGS},
 #endif
 #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
-    {"CS_XBS5_LPBIG_OFFBIG_LDFLAGS",	_CS_XBS5_LPBIG_OFFBIG_LDFLAGS},
+    {"CS_XBS5_LPBIG_OFFBIG_LDFLAGS",    _CS_XBS5_LPBIG_OFFBIG_LDFLAGS},
 #endif
 #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
-    {"CS_XBS5_LPBIG_OFFBIG_LIBS",	_CS_XBS5_LPBIG_OFFBIG_LIBS},
+    {"CS_XBS5_LPBIG_OFFBIG_LIBS",       _CS_XBS5_LPBIG_OFFBIG_LIBS},
 #endif
 #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
-    {"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS",	_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS},
+    {"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS",  _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS},
 #endif
 #ifdef _MIPS_CS_AVAIL_PROCESSORS
-    {"MIPS_CS_AVAIL_PROCESSORS",	_MIPS_CS_AVAIL_PROCESSORS},
+    {"MIPS_CS_AVAIL_PROCESSORS",        _MIPS_CS_AVAIL_PROCESSORS},
 #endif
 #ifdef _MIPS_CS_BASE
-    {"MIPS_CS_BASE",	_MIPS_CS_BASE},
+    {"MIPS_CS_BASE",    _MIPS_CS_BASE},
 #endif
 #ifdef _MIPS_CS_HOSTID
-    {"MIPS_CS_HOSTID",	_MIPS_CS_HOSTID},
+    {"MIPS_CS_HOSTID",  _MIPS_CS_HOSTID},
 #endif
 #ifdef _MIPS_CS_HW_NAME
-    {"MIPS_CS_HW_NAME",	_MIPS_CS_HW_NAME},
+    {"MIPS_CS_HW_NAME", _MIPS_CS_HW_NAME},
 #endif
 #ifdef _MIPS_CS_NUM_PROCESSORS
-    {"MIPS_CS_NUM_PROCESSORS",	_MIPS_CS_NUM_PROCESSORS},
+    {"MIPS_CS_NUM_PROCESSORS",  _MIPS_CS_NUM_PROCESSORS},
 #endif
 #ifdef _MIPS_CS_OSREL_MAJ
-    {"MIPS_CS_OSREL_MAJ",	_MIPS_CS_OSREL_MAJ},
+    {"MIPS_CS_OSREL_MAJ",       _MIPS_CS_OSREL_MAJ},
 #endif
 #ifdef _MIPS_CS_OSREL_MIN
-    {"MIPS_CS_OSREL_MIN",	_MIPS_CS_OSREL_MIN},
+    {"MIPS_CS_OSREL_MIN",       _MIPS_CS_OSREL_MIN},
 #endif
 #ifdef _MIPS_CS_OSREL_PATCH
-    {"MIPS_CS_OSREL_PATCH",	_MIPS_CS_OSREL_PATCH},
+    {"MIPS_CS_OSREL_PATCH",     _MIPS_CS_OSREL_PATCH},
 #endif
 #ifdef _MIPS_CS_OS_NAME
-    {"MIPS_CS_OS_NAME",	_MIPS_CS_OS_NAME},
+    {"MIPS_CS_OS_NAME", _MIPS_CS_OS_NAME},
 #endif
 #ifdef _MIPS_CS_OS_PROVIDER
-    {"MIPS_CS_OS_PROVIDER",	_MIPS_CS_OS_PROVIDER},
+    {"MIPS_CS_OS_PROVIDER",     _MIPS_CS_OS_PROVIDER},
 #endif
 #ifdef _MIPS_CS_PROCESSORS
-    {"MIPS_CS_PROCESSORS",	_MIPS_CS_PROCESSORS},
+    {"MIPS_CS_PROCESSORS",      _MIPS_CS_PROCESSORS},
 #endif
 #ifdef _MIPS_CS_SERIAL
-    {"MIPS_CS_SERIAL",	_MIPS_CS_SERIAL},
+    {"MIPS_CS_SERIAL",  _MIPS_CS_SERIAL},
 #endif
 #ifdef _MIPS_CS_VENDOR
-    {"MIPS_CS_VENDOR",	_MIPS_CS_VENDOR},
+    {"MIPS_CS_VENDOR",  _MIPS_CS_VENDOR},
 #endif
 };
 
@@ -6046,21 +6047,21 @@
     char buffer[256];
 
     if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
-	int len;
+        int len;
 
         errno = 0;
-	len = confstr(name, buffer, sizeof(buffer));
-	if (len == 0) {
-	    if (errno) {
-		posix_error();
-	    }
-	    else {
-		result = Py_None;
-		Py_INCREF(Py_None);
-	    }
+        len = confstr(name, buffer, sizeof(buffer));
+        if (len == 0) {
+            if (errno) {
+                posix_error();
+            }
+            else {
+                result = Py_None;
+                Py_INCREF(Py_None);
+            }
         }
         else {
-	    if ((unsigned int)len >= sizeof(buffer)) {
+            if ((unsigned int)len >= sizeof(buffer)) {
                 result = PyUnicode_FromStringAndSize(NULL, len-1);
                 if (result != NULL)
                     confstr(name, _PyUnicode_AsString(result), len);
@@ -6077,496 +6078,496 @@
 #ifdef HAVE_SYSCONF
 static struct constdef posix_constants_sysconf[] = {
 #ifdef _SC_2_CHAR_TERM
-    {"SC_2_CHAR_TERM",	_SC_2_CHAR_TERM},
+    {"SC_2_CHAR_TERM",  _SC_2_CHAR_TERM},
 #endif
 #ifdef _SC_2_C_BIND
-    {"SC_2_C_BIND",	_SC_2_C_BIND},
+    {"SC_2_C_BIND",     _SC_2_C_BIND},
 #endif
 #ifdef _SC_2_C_DEV
-    {"SC_2_C_DEV",	_SC_2_C_DEV},
+    {"SC_2_C_DEV",      _SC_2_C_DEV},
 #endif
 #ifdef _SC_2_C_VERSION
-    {"SC_2_C_VERSION",	_SC_2_C_VERSION},
+    {"SC_2_C_VERSION",  _SC_2_C_VERSION},
 #endif
 #ifdef _SC_2_FORT_DEV
-    {"SC_2_FORT_DEV",	_SC_2_FORT_DEV},
+    {"SC_2_FORT_DEV",   _SC_2_FORT_DEV},
 #endif
 #ifdef _SC_2_FORT_RUN
-    {"SC_2_FORT_RUN",	_SC_2_FORT_RUN},
+    {"SC_2_FORT_RUN",   _SC_2_FORT_RUN},
 #endif
 #ifdef _SC_2_LOCALEDEF
-    {"SC_2_LOCALEDEF",	_SC_2_LOCALEDEF},
+    {"SC_2_LOCALEDEF",  _SC_2_LOCALEDEF},
 #endif
 #ifdef _SC_2_SW_DEV
-    {"SC_2_SW_DEV",	_SC_2_SW_DEV},
+    {"SC_2_SW_DEV",     _SC_2_SW_DEV},
 #endif
 #ifdef _SC_2_UPE
-    {"SC_2_UPE",	_SC_2_UPE},
+    {"SC_2_UPE",        _SC_2_UPE},
 #endif
 #ifdef _SC_2_VERSION
-    {"SC_2_VERSION",	_SC_2_VERSION},
+    {"SC_2_VERSION",    _SC_2_VERSION},
 #endif
 #ifdef _SC_ABI_ASYNCHRONOUS_IO
-    {"SC_ABI_ASYNCHRONOUS_IO",	_SC_ABI_ASYNCHRONOUS_IO},
+    {"SC_ABI_ASYNCHRONOUS_IO",  _SC_ABI_ASYNCHRONOUS_IO},
 #endif
 #ifdef _SC_ACL
-    {"SC_ACL",	_SC_ACL},
+    {"SC_ACL",  _SC_ACL},
 #endif
 #ifdef _SC_AIO_LISTIO_MAX
-    {"SC_AIO_LISTIO_MAX",	_SC_AIO_LISTIO_MAX},
+    {"SC_AIO_LISTIO_MAX",       _SC_AIO_LISTIO_MAX},
 #endif
 #ifdef _SC_AIO_MAX
-    {"SC_AIO_MAX",	_SC_AIO_MAX},
+    {"SC_AIO_MAX",      _SC_AIO_MAX},
 #endif
 #ifdef _SC_AIO_PRIO_DELTA_MAX
-    {"SC_AIO_PRIO_DELTA_MAX",	_SC_AIO_PRIO_DELTA_MAX},
+    {"SC_AIO_PRIO_DELTA_MAX",   _SC_AIO_PRIO_DELTA_MAX},
 #endif
 #ifdef _SC_ARG_MAX
-    {"SC_ARG_MAX",	_SC_ARG_MAX},
+    {"SC_ARG_MAX",      _SC_ARG_MAX},
 #endif
 #ifdef _SC_ASYNCHRONOUS_IO
-    {"SC_ASYNCHRONOUS_IO",	_SC_ASYNCHRONOUS_IO},
+    {"SC_ASYNCHRONOUS_IO",      _SC_ASYNCHRONOUS_IO},
 #endif
 #ifdef _SC_ATEXIT_MAX
-    {"SC_ATEXIT_MAX",	_SC_ATEXIT_MAX},
+    {"SC_ATEXIT_MAX",   _SC_ATEXIT_MAX},
 #endif
 #ifdef _SC_AUDIT
-    {"SC_AUDIT",	_SC_AUDIT},
+    {"SC_AUDIT",        _SC_AUDIT},
 #endif
 #ifdef _SC_AVPHYS_PAGES
-    {"SC_AVPHYS_PAGES",	_SC_AVPHYS_PAGES},
+    {"SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES},
 #endif
 #ifdef _SC_BC_BASE_MAX
-    {"SC_BC_BASE_MAX",	_SC_BC_BASE_MAX},
+    {"SC_BC_BASE_MAX",  _SC_BC_BASE_MAX},
 #endif
 #ifdef _SC_BC_DIM_MAX
-    {"SC_BC_DIM_MAX",	_SC_BC_DIM_MAX},
+    {"SC_BC_DIM_MAX",   _SC_BC_DIM_MAX},
 #endif
 #ifdef _SC_BC_SCALE_MAX
-    {"SC_BC_SCALE_MAX",	_SC_BC_SCALE_MAX},
+    {"SC_BC_SCALE_MAX", _SC_BC_SCALE_MAX},
 #endif
 #ifdef _SC_BC_STRING_MAX
-    {"SC_BC_STRING_MAX",	_SC_BC_STRING_MAX},
+    {"SC_BC_STRING_MAX",        _SC_BC_STRING_MAX},
 #endif
 #ifdef _SC_CAP
-    {"SC_CAP",	_SC_CAP},
+    {"SC_CAP",  _SC_CAP},
 #endif
 #ifdef _SC_CHARCLASS_NAME_MAX
-    {"SC_CHARCLASS_NAME_MAX",	_SC_CHARCLASS_NAME_MAX},
+    {"SC_CHARCLASS_NAME_MAX",   _SC_CHARCLASS_NAME_MAX},
 #endif
 #ifdef _SC_CHAR_BIT
-    {"SC_CHAR_BIT",	_SC_CHAR_BIT},
+    {"SC_CHAR_BIT",     _SC_CHAR_BIT},
 #endif
 #ifdef _SC_CHAR_MAX
-    {"SC_CHAR_MAX",	_SC_CHAR_MAX},
+    {"SC_CHAR_MAX",     _SC_CHAR_MAX},
 #endif
 #ifdef _SC_CHAR_MIN
-    {"SC_CHAR_MIN",	_SC_CHAR_MIN},
+    {"SC_CHAR_MIN",     _SC_CHAR_MIN},
 #endif
 #ifdef _SC_CHILD_MAX
-    {"SC_CHILD_MAX",	_SC_CHILD_MAX},
+    {"SC_CHILD_MAX",    _SC_CHILD_MAX},
 #endif
 #ifdef _SC_CLK_TCK
-    {"SC_CLK_TCK",	_SC_CLK_TCK},
+    {"SC_CLK_TCK",      _SC_CLK_TCK},
 #endif
 #ifdef _SC_COHER_BLKSZ
-    {"SC_COHER_BLKSZ",	_SC_COHER_BLKSZ},
+    {"SC_COHER_BLKSZ",  _SC_COHER_BLKSZ},
 #endif
 #ifdef _SC_COLL_WEIGHTS_MAX
-    {"SC_COLL_WEIGHTS_MAX",	_SC_COLL_WEIGHTS_MAX},
+    {"SC_COLL_WEIGHTS_MAX",     _SC_COLL_WEIGHTS_MAX},
 #endif
 #ifdef _SC_DCACHE_ASSOC
-    {"SC_DCACHE_ASSOC",	_SC_DCACHE_ASSOC},
+    {"SC_DCACHE_ASSOC", _SC_DCACHE_ASSOC},
 #endif
 #ifdef _SC_DCACHE_BLKSZ
-    {"SC_DCACHE_BLKSZ",	_SC_DCACHE_BLKSZ},
+    {"SC_DCACHE_BLKSZ", _SC_DCACHE_BLKSZ},
 #endif
 #ifdef _SC_DCACHE_LINESZ
-    {"SC_DCACHE_LINESZ",	_SC_DCACHE_LINESZ},
+    {"SC_DCACHE_LINESZ",        _SC_DCACHE_LINESZ},
 #endif
 #ifdef _SC_DCACHE_SZ
-    {"SC_DCACHE_SZ",	_SC_DCACHE_SZ},
+    {"SC_DCACHE_SZ",    _SC_DCACHE_SZ},
 #endif
 #ifdef _SC_DCACHE_TBLKSZ
-    {"SC_DCACHE_TBLKSZ",	_SC_DCACHE_TBLKSZ},
+    {"SC_DCACHE_TBLKSZ",        _SC_DCACHE_TBLKSZ},
 #endif
 #ifdef _SC_DELAYTIMER_MAX
-    {"SC_DELAYTIMER_MAX",	_SC_DELAYTIMER_MAX},
+    {"SC_DELAYTIMER_MAX",       _SC_DELAYTIMER_MAX},
 #endif
 #ifdef _SC_EQUIV_CLASS_MAX
-    {"SC_EQUIV_CLASS_MAX",	_SC_EQUIV_CLASS_MAX},
+    {"SC_EQUIV_CLASS_MAX",      _SC_EQUIV_CLASS_MAX},
 #endif
 #ifdef _SC_EXPR_NEST_MAX
-    {"SC_EXPR_NEST_MAX",	_SC_EXPR_NEST_MAX},
+    {"SC_EXPR_NEST_MAX",        _SC_EXPR_NEST_MAX},
 #endif
 #ifdef _SC_FSYNC
-    {"SC_FSYNC",	_SC_FSYNC},
+    {"SC_FSYNC",        _SC_FSYNC},
 #endif
 #ifdef _SC_GETGR_R_SIZE_MAX
-    {"SC_GETGR_R_SIZE_MAX",	_SC_GETGR_R_SIZE_MAX},
+    {"SC_GETGR_R_SIZE_MAX",     _SC_GETGR_R_SIZE_MAX},
 #endif
 #ifdef _SC_GETPW_R_SIZE_MAX
-    {"SC_GETPW_R_SIZE_MAX",	_SC_GETPW_R_SIZE_MAX},
+    {"SC_GETPW_R_SIZE_MAX",     _SC_GETPW_R_SIZE_MAX},
 #endif
 #ifdef _SC_ICACHE_ASSOC
-    {"SC_ICACHE_ASSOC",	_SC_ICACHE_ASSOC},
+    {"SC_ICACHE_ASSOC", _SC_ICACHE_ASSOC},
 #endif
 #ifdef _SC_ICACHE_BLKSZ
-    {"SC_ICACHE_BLKSZ",	_SC_ICACHE_BLKSZ},
+    {"SC_ICACHE_BLKSZ", _SC_ICACHE_BLKSZ},
 #endif
 #ifdef _SC_ICACHE_LINESZ
-    {"SC_ICACHE_LINESZ",	_SC_ICACHE_LINESZ},
+    {"SC_ICACHE_LINESZ",        _SC_ICACHE_LINESZ},
 #endif
 #ifdef _SC_ICACHE_SZ
-    {"SC_ICACHE_SZ",	_SC_ICACHE_SZ},
+    {"SC_ICACHE_SZ",    _SC_ICACHE_SZ},
 #endif
 #ifdef _SC_INF
-    {"SC_INF",	_SC_INF},
+    {"SC_INF",  _SC_INF},
 #endif
 #ifdef _SC_INT_MAX
-    {"SC_INT_MAX",	_SC_INT_MAX},
+    {"SC_INT_MAX",      _SC_INT_MAX},
 #endif
 #ifdef _SC_INT_MIN
-    {"SC_INT_MIN",	_SC_INT_MIN},
+    {"SC_INT_MIN",      _SC_INT_MIN},
 #endif
 #ifdef _SC_IOV_MAX
-    {"SC_IOV_MAX",	_SC_IOV_MAX},
+    {"SC_IOV_MAX",      _SC_IOV_MAX},
 #endif
 #ifdef _SC_IP_SECOPTS
-    {"SC_IP_SECOPTS",	_SC_IP_SECOPTS},
+    {"SC_IP_SECOPTS",   _SC_IP_SECOPTS},
 #endif
 #ifdef _SC_JOB_CONTROL
-    {"SC_JOB_CONTROL",	_SC_JOB_CONTROL},
+    {"SC_JOB_CONTROL",  _SC_JOB_CONTROL},
 #endif
 #ifdef _SC_KERN_POINTERS
-    {"SC_KERN_POINTERS",	_SC_KERN_POINTERS},
+    {"SC_KERN_POINTERS",        _SC_KERN_POINTERS},
 #endif
 #ifdef _SC_KERN_SIM
-    {"SC_KERN_SIM",	_SC_KERN_SIM},
+    {"SC_KERN_SIM",     _SC_KERN_SIM},
 #endif
 #ifdef _SC_LINE_MAX
-    {"SC_LINE_MAX",	_SC_LINE_MAX},
+    {"SC_LINE_MAX",     _SC_LINE_MAX},
 #endif
 #ifdef _SC_LOGIN_NAME_MAX
-    {"SC_LOGIN_NAME_MAX",	_SC_LOGIN_NAME_MAX},
+    {"SC_LOGIN_NAME_MAX",       _SC_LOGIN_NAME_MAX},
 #endif
 #ifdef _SC_LOGNAME_MAX
-    {"SC_LOGNAME_MAX",	_SC_LOGNAME_MAX},
+    {"SC_LOGNAME_MAX",  _SC_LOGNAME_MAX},
 #endif
 #ifdef _SC_LONG_BIT
-    {"SC_LONG_BIT",	_SC_LONG_BIT},
+    {"SC_LONG_BIT",     _SC_LONG_BIT},
 #endif
 #ifdef _SC_MAC
-    {"SC_MAC",	_SC_MAC},
+    {"SC_MAC",  _SC_MAC},
 #endif
 #ifdef _SC_MAPPED_FILES
-    {"SC_MAPPED_FILES",	_SC_MAPPED_FILES},
+    {"SC_MAPPED_FILES", _SC_MAPPED_FILES},
 #endif
 #ifdef _SC_MAXPID
-    {"SC_MAXPID",	_SC_MAXPID},
+    {"SC_MAXPID",       _SC_MAXPID},
 #endif
 #ifdef _SC_MB_LEN_MAX
-    {"SC_MB_LEN_MAX",	_SC_MB_LEN_MAX},
+    {"SC_MB_LEN_MAX",   _SC_MB_LEN_MAX},
 #endif
 #ifdef _SC_MEMLOCK
-    {"SC_MEMLOCK",	_SC_MEMLOCK},
+    {"SC_MEMLOCK",      _SC_MEMLOCK},
 #endif
 #ifdef _SC_MEMLOCK_RANGE
-    {"SC_MEMLOCK_RANGE",	_SC_MEMLOCK_RANGE},
+    {"SC_MEMLOCK_RANGE",        _SC_MEMLOCK_RANGE},
 #endif
 #ifdef _SC_MEMORY_PROTECTION
-    {"SC_MEMORY_PROTECTION",	_SC_MEMORY_PROTECTION},
+    {"SC_MEMORY_PROTECTION",    _SC_MEMORY_PROTECTION},
 #endif
 #ifdef _SC_MESSAGE_PASSING
-    {"SC_MESSAGE_PASSING",	_SC_MESSAGE_PASSING},
+    {"SC_MESSAGE_PASSING",      _SC_MESSAGE_PASSING},
 #endif
 #ifdef _SC_MMAP_FIXED_ALIGNMENT
-    {"SC_MMAP_FIXED_ALIGNMENT",	_SC_MMAP_FIXED_ALIGNMENT},
+    {"SC_MMAP_FIXED_ALIGNMENT", _SC_MMAP_FIXED_ALIGNMENT},
 #endif
 #ifdef _SC_MQ_OPEN_MAX
-    {"SC_MQ_OPEN_MAX",	_SC_MQ_OPEN_MAX},
+    {"SC_MQ_OPEN_MAX",  _SC_MQ_OPEN_MAX},
 #endif
 #ifdef _SC_MQ_PRIO_MAX
-    {"SC_MQ_PRIO_MAX",	_SC_MQ_PRIO_MAX},
+    {"SC_MQ_PRIO_MAX",  _SC_MQ_PRIO_MAX},
 #endif
 #ifdef _SC_NACLS_MAX
-    {"SC_NACLS_MAX",	_SC_NACLS_MAX},
+    {"SC_NACLS_MAX",    _SC_NACLS_MAX},
 #endif
 #ifdef _SC_NGROUPS_MAX
-    {"SC_NGROUPS_MAX",	_SC_NGROUPS_MAX},
+    {"SC_NGROUPS_MAX",  _SC_NGROUPS_MAX},
 #endif
 #ifdef _SC_NL_ARGMAX
-    {"SC_NL_ARGMAX",	_SC_NL_ARGMAX},
+    {"SC_NL_ARGMAX",    _SC_NL_ARGMAX},
 #endif
 #ifdef _SC_NL_LANGMAX
-    {"SC_NL_LANGMAX",	_SC_NL_LANGMAX},
+    {"SC_NL_LANGMAX",   _SC_NL_LANGMAX},
 #endif
 #ifdef _SC_NL_MSGMAX
-    {"SC_NL_MSGMAX",	_SC_NL_MSGMAX},
+    {"SC_NL_MSGMAX",    _SC_NL_MSGMAX},
 #endif
 #ifdef _SC_NL_NMAX
-    {"SC_NL_NMAX",	_SC_NL_NMAX},
+    {"SC_NL_NMAX",      _SC_NL_NMAX},
 #endif
 #ifdef _SC_NL_SETMAX
-    {"SC_NL_SETMAX",	_SC_NL_SETMAX},
+    {"SC_NL_SETMAX",    _SC_NL_SETMAX},
 #endif
 #ifdef _SC_NL_TEXTMAX
-    {"SC_NL_TEXTMAX",	_SC_NL_TEXTMAX},
+    {"SC_NL_TEXTMAX",   _SC_NL_TEXTMAX},
 #endif
 #ifdef _SC_NPROCESSORS_CONF
-    {"SC_NPROCESSORS_CONF",	_SC_NPROCESSORS_CONF},
+    {"SC_NPROCESSORS_CONF",     _SC_NPROCESSORS_CONF},
 #endif
 #ifdef _SC_NPROCESSORS_ONLN
-    {"SC_NPROCESSORS_ONLN",	_SC_NPROCESSORS_ONLN},
+    {"SC_NPROCESSORS_ONLN",     _SC_NPROCESSORS_ONLN},
 #endif
 #ifdef _SC_NPROC_CONF
-    {"SC_NPROC_CONF",	_SC_NPROC_CONF},
+    {"SC_NPROC_CONF",   _SC_NPROC_CONF},
 #endif
 #ifdef _SC_NPROC_ONLN
-    {"SC_NPROC_ONLN",	_SC_NPROC_ONLN},
+    {"SC_NPROC_ONLN",   _SC_NPROC_ONLN},
 #endif
 #ifdef _SC_NZERO
-    {"SC_NZERO",	_SC_NZERO},
+    {"SC_NZERO",        _SC_NZERO},
 #endif
 #ifdef _SC_OPEN_MAX
-    {"SC_OPEN_MAX",	_SC_OPEN_MAX},
+    {"SC_OPEN_MAX",     _SC_OPEN_MAX},
 #endif
 #ifdef _SC_PAGESIZE
-    {"SC_PAGESIZE",	_SC_PAGESIZE},
+    {"SC_PAGESIZE",     _SC_PAGESIZE},
 #endif
 #ifdef _SC_PAGE_SIZE
-    {"SC_PAGE_SIZE",	_SC_PAGE_SIZE},
+    {"SC_PAGE_SIZE",    _SC_PAGE_SIZE},
 #endif
 #ifdef _SC_PASS_MAX
-    {"SC_PASS_MAX",	_SC_PASS_MAX},
+    {"SC_PASS_MAX",     _SC_PASS_MAX},
 #endif
 #ifdef _SC_PHYS_PAGES
-    {"SC_PHYS_PAGES",	_SC_PHYS_PAGES},
+    {"SC_PHYS_PAGES",   _SC_PHYS_PAGES},
 #endif
 #ifdef _SC_PII
-    {"SC_PII",	_SC_PII},
+    {"SC_PII",  _SC_PII},
 #endif
 #ifdef _SC_PII_INTERNET
-    {"SC_PII_INTERNET",	_SC_PII_INTERNET},
+    {"SC_PII_INTERNET", _SC_PII_INTERNET},
 #endif
 #ifdef _SC_PII_INTERNET_DGRAM
-    {"SC_PII_INTERNET_DGRAM",	_SC_PII_INTERNET_DGRAM},
+    {"SC_PII_INTERNET_DGRAM",   _SC_PII_INTERNET_DGRAM},
 #endif
 #ifdef _SC_PII_INTERNET_STREAM
-    {"SC_PII_INTERNET_STREAM",	_SC_PII_INTERNET_STREAM},
+    {"SC_PII_INTERNET_STREAM",  _SC_PII_INTERNET_STREAM},
 #endif
 #ifdef _SC_PII_OSI
-    {"SC_PII_OSI",	_SC_PII_OSI},
+    {"SC_PII_OSI",      _SC_PII_OSI},
 #endif
 #ifdef _SC_PII_OSI_CLTS
-    {"SC_PII_OSI_CLTS",	_SC_PII_OSI_CLTS},
+    {"SC_PII_OSI_CLTS", _SC_PII_OSI_CLTS},
 #endif
 #ifdef _SC_PII_OSI_COTS
-    {"SC_PII_OSI_COTS",	_SC_PII_OSI_COTS},
+    {"SC_PII_OSI_COTS", _SC_PII_OSI_COTS},
 #endif
 #ifdef _SC_PII_OSI_M
-    {"SC_PII_OSI_M",	_SC_PII_OSI_M},
+    {"SC_PII_OSI_M",    _SC_PII_OSI_M},
 #endif
 #ifdef _SC_PII_SOCKET
-    {"SC_PII_SOCKET",	_SC_PII_SOCKET},
+    {"SC_PII_SOCKET",   _SC_PII_SOCKET},
 #endif
 #ifdef _SC_PII_XTI
-    {"SC_PII_XTI",	_SC_PII_XTI},
+    {"SC_PII_XTI",      _SC_PII_XTI},
 #endif
 #ifdef _SC_POLL
-    {"SC_POLL",	_SC_POLL},
+    {"SC_POLL", _SC_POLL},
 #endif
 #ifdef _SC_PRIORITIZED_IO
-    {"SC_PRIORITIZED_IO",	_SC_PRIORITIZED_IO},
+    {"SC_PRIORITIZED_IO",       _SC_PRIORITIZED_IO},
 #endif
 #ifdef _SC_PRIORITY_SCHEDULING
-    {"SC_PRIORITY_SCHEDULING",	_SC_PRIORITY_SCHEDULING},
+    {"SC_PRIORITY_SCHEDULING",  _SC_PRIORITY_SCHEDULING},
 #endif
 #ifdef _SC_REALTIME_SIGNALS
-    {"SC_REALTIME_SIGNALS",	_SC_REALTIME_SIGNALS},
+    {"SC_REALTIME_SIGNALS",     _SC_REALTIME_SIGNALS},
 #endif
 #ifdef _SC_RE_DUP_MAX
-    {"SC_RE_DUP_MAX",	_SC_RE_DUP_MAX},
+    {"SC_RE_DUP_MAX",   _SC_RE_DUP_MAX},
 #endif
 #ifdef _SC_RTSIG_MAX
-    {"SC_RTSIG_MAX",	_SC_RTSIG_MAX},
+    {"SC_RTSIG_MAX",    _SC_RTSIG_MAX},
 #endif
 #ifdef _SC_SAVED_IDS
-    {"SC_SAVED_IDS",	_SC_SAVED_IDS},
+    {"SC_SAVED_IDS",    _SC_SAVED_IDS},
 #endif
 #ifdef _SC_SCHAR_MAX
-    {"SC_SCHAR_MAX",	_SC_SCHAR_MAX},
+    {"SC_SCHAR_MAX",    _SC_SCHAR_MAX},
 #endif
 #ifdef _SC_SCHAR_MIN
-    {"SC_SCHAR_MIN",	_SC_SCHAR_MIN},
+    {"SC_SCHAR_MIN",    _SC_SCHAR_MIN},
 #endif
 #ifdef _SC_SELECT
-    {"SC_SELECT",	_SC_SELECT},
+    {"SC_SELECT",       _SC_SELECT},
 #endif
 #ifdef _SC_SEMAPHORES
-    {"SC_SEMAPHORES",	_SC_SEMAPHORES},
+    {"SC_SEMAPHORES",   _SC_SEMAPHORES},
 #endif
 #ifdef _SC_SEM_NSEMS_MAX
-    {"SC_SEM_NSEMS_MAX",	_SC_SEM_NSEMS_MAX},
+    {"SC_SEM_NSEMS_MAX",        _SC_SEM_NSEMS_MAX},
 #endif
 #ifdef _SC_SEM_VALUE_MAX
-    {"SC_SEM_VALUE_MAX",	_SC_SEM_VALUE_MAX},
+    {"SC_SEM_VALUE_MAX",        _SC_SEM_VALUE_MAX},
 #endif
 #ifdef _SC_SHARED_MEMORY_OBJECTS
-    {"SC_SHARED_MEMORY_OBJECTS",	_SC_SHARED_MEMORY_OBJECTS},
+    {"SC_SHARED_MEMORY_OBJECTS",        _SC_SHARED_MEMORY_OBJECTS},
 #endif
 #ifdef _SC_SHRT_MAX
-    {"SC_SHRT_MAX",	_SC_SHRT_MAX},
+    {"SC_SHRT_MAX",     _SC_SHRT_MAX},
 #endif
 #ifdef _SC_SHRT_MIN
-    {"SC_SHRT_MIN",	_SC_SHRT_MIN},
+    {"SC_SHRT_MIN",     _SC_SHRT_MIN},
 #endif
 #ifdef _SC_SIGQUEUE_MAX
-    {"SC_SIGQUEUE_MAX",	_SC_SIGQUEUE_MAX},
+    {"SC_SIGQUEUE_MAX", _SC_SIGQUEUE_MAX},
 #endif
 #ifdef _SC_SIGRT_MAX
-    {"SC_SIGRT_MAX",	_SC_SIGRT_MAX},
+    {"SC_SIGRT_MAX",    _SC_SIGRT_MAX},
 #endif
 #ifdef _SC_SIGRT_MIN
-    {"SC_SIGRT_MIN",	_SC_SIGRT_MIN},
+    {"SC_SIGRT_MIN",    _SC_SIGRT_MIN},
 #endif
 #ifdef _SC_SOFTPOWER
-    {"SC_SOFTPOWER",	_SC_SOFTPOWER},
+    {"SC_SOFTPOWER",    _SC_SOFTPOWER},
 #endif
 #ifdef _SC_SPLIT_CACHE
-    {"SC_SPLIT_CACHE",	_SC_SPLIT_CACHE},
+    {"SC_SPLIT_CACHE",  _SC_SPLIT_CACHE},
 #endif
 #ifdef _SC_SSIZE_MAX
-    {"SC_SSIZE_MAX",	_SC_SSIZE_MAX},
+    {"SC_SSIZE_MAX",    _SC_SSIZE_MAX},
 #endif
 #ifdef _SC_STACK_PROT
-    {"SC_STACK_PROT",	_SC_STACK_PROT},
+    {"SC_STACK_PROT",   _SC_STACK_PROT},
 #endif
 #ifdef _SC_STREAM_MAX
-    {"SC_STREAM_MAX",	_SC_STREAM_MAX},
+    {"SC_STREAM_MAX",   _SC_STREAM_MAX},
 #endif
 #ifdef _SC_SYNCHRONIZED_IO
-    {"SC_SYNCHRONIZED_IO",	_SC_SYNCHRONIZED_IO},
+    {"SC_SYNCHRONIZED_IO",      _SC_SYNCHRONIZED_IO},
 #endif
 #ifdef _SC_THREADS
-    {"SC_THREADS",	_SC_THREADS},
+    {"SC_THREADS",      _SC_THREADS},
 #endif
 #ifdef _SC_THREAD_ATTR_STACKADDR
-    {"SC_THREAD_ATTR_STACKADDR",	_SC_THREAD_ATTR_STACKADDR},
+    {"SC_THREAD_ATTR_STACKADDR",        _SC_THREAD_ATTR_STACKADDR},
 #endif
 #ifdef _SC_THREAD_ATTR_STACKSIZE
-    {"SC_THREAD_ATTR_STACKSIZE",	_SC_THREAD_ATTR_STACKSIZE},
+    {"SC_THREAD_ATTR_STACKSIZE",        _SC_THREAD_ATTR_STACKSIZE},
 #endif
 #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
-    {"SC_THREAD_DESTRUCTOR_ITERATIONS",	_SC_THREAD_DESTRUCTOR_ITERATIONS},
+    {"SC_THREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS},
 #endif
 #ifdef _SC_THREAD_KEYS_MAX
-    {"SC_THREAD_KEYS_MAX",	_SC_THREAD_KEYS_MAX},
+    {"SC_THREAD_KEYS_MAX",      _SC_THREAD_KEYS_MAX},
 #endif
 #ifdef _SC_THREAD_PRIORITY_SCHEDULING
-    {"SC_THREAD_PRIORITY_SCHEDULING",	_SC_THREAD_PRIORITY_SCHEDULING},
+    {"SC_THREAD_PRIORITY_SCHEDULING",   _SC_THREAD_PRIORITY_SCHEDULING},
 #endif
 #ifdef _SC_THREAD_PRIO_INHERIT
-    {"SC_THREAD_PRIO_INHERIT",	_SC_THREAD_PRIO_INHERIT},
+    {"SC_THREAD_PRIO_INHERIT",  _SC_THREAD_PRIO_INHERIT},
 #endif
 #ifdef _SC_THREAD_PRIO_PROTECT
-    {"SC_THREAD_PRIO_PROTECT",	_SC_THREAD_PRIO_PROTECT},
+    {"SC_THREAD_PRIO_PROTECT",  _SC_THREAD_PRIO_PROTECT},
 #endif
 #ifdef _SC_THREAD_PROCESS_SHARED
-    {"SC_THREAD_PROCESS_SHARED",	_SC_THREAD_PROCESS_SHARED},
+    {"SC_THREAD_PROCESS_SHARED",        _SC_THREAD_PROCESS_SHARED},
 #endif
 #ifdef _SC_THREAD_SAFE_FUNCTIONS
-    {"SC_THREAD_SAFE_FUNCTIONS",	_SC_THREAD_SAFE_FUNCTIONS},
+    {"SC_THREAD_SAFE_FUNCTIONS",        _SC_THREAD_SAFE_FUNCTIONS},
 #endif
 #ifdef _SC_THREAD_STACK_MIN
-    {"SC_THREAD_STACK_MIN",	_SC_THREAD_STACK_MIN},
+    {"SC_THREAD_STACK_MIN",     _SC_THREAD_STACK_MIN},
 #endif
 #ifdef _SC_THREAD_THREADS_MAX
-    {"SC_THREAD_THREADS_MAX",	_SC_THREAD_THREADS_MAX},
+    {"SC_THREAD_THREADS_MAX",   _SC_THREAD_THREADS_MAX},
 #endif
 #ifdef _SC_TIMERS
-    {"SC_TIMERS",	_SC_TIMERS},
+    {"SC_TIMERS",       _SC_TIMERS},
 #endif
 #ifdef _SC_TIMER_MAX
-    {"SC_TIMER_MAX",	_SC_TIMER_MAX},
+    {"SC_TIMER_MAX",    _SC_TIMER_MAX},
 #endif
 #ifdef _SC_TTY_NAME_MAX
-    {"SC_TTY_NAME_MAX",	_SC_TTY_NAME_MAX},
+    {"SC_TTY_NAME_MAX", _SC_TTY_NAME_MAX},
 #endif
 #ifdef _SC_TZNAME_MAX
-    {"SC_TZNAME_MAX",	_SC_TZNAME_MAX},
+    {"SC_TZNAME_MAX",   _SC_TZNAME_MAX},
 #endif
 #ifdef _SC_T_IOV_MAX
-    {"SC_T_IOV_MAX",	_SC_T_IOV_MAX},
+    {"SC_T_IOV_MAX",    _SC_T_IOV_MAX},
 #endif
 #ifdef _SC_UCHAR_MAX
-    {"SC_UCHAR_MAX",	_SC_UCHAR_MAX},
+    {"SC_UCHAR_MAX",    _SC_UCHAR_MAX},
 #endif
 #ifdef _SC_UINT_MAX
-    {"SC_UINT_MAX",	_SC_UINT_MAX},
+    {"SC_UINT_MAX",     _SC_UINT_MAX},
 #endif
 #ifdef _SC_UIO_MAXIOV
-    {"SC_UIO_MAXIOV",	_SC_UIO_MAXIOV},
+    {"SC_UIO_MAXIOV",   _SC_UIO_MAXIOV},
 #endif
 #ifdef _SC_ULONG_MAX
-    {"SC_ULONG_MAX",	_SC_ULONG_MAX},
+    {"SC_ULONG_MAX",    _SC_ULONG_MAX},
 #endif
 #ifdef _SC_USHRT_MAX
-    {"SC_USHRT_MAX",	_SC_USHRT_MAX},
+    {"SC_USHRT_MAX",    _SC_USHRT_MAX},
 #endif
 #ifdef _SC_VERSION
-    {"SC_VERSION",	_SC_VERSION},
+    {"SC_VERSION",      _SC_VERSION},
 #endif
 #ifdef _SC_WORD_BIT
-    {"SC_WORD_BIT",	_SC_WORD_BIT},
+    {"SC_WORD_BIT",     _SC_WORD_BIT},
 #endif
 #ifdef _SC_XBS5_ILP32_OFF32
-    {"SC_XBS5_ILP32_OFF32",	_SC_XBS5_ILP32_OFF32},
+    {"SC_XBS5_ILP32_OFF32",     _SC_XBS5_ILP32_OFF32},
 #endif
 #ifdef _SC_XBS5_ILP32_OFFBIG
-    {"SC_XBS5_ILP32_OFFBIG",	_SC_XBS5_ILP32_OFFBIG},
+    {"SC_XBS5_ILP32_OFFBIG",    _SC_XBS5_ILP32_OFFBIG},
 #endif
 #ifdef _SC_XBS5_LP64_OFF64
-    {"SC_XBS5_LP64_OFF64",	_SC_XBS5_LP64_OFF64},
+    {"SC_XBS5_LP64_OFF64",      _SC_XBS5_LP64_OFF64},
 #endif
 #ifdef _SC_XBS5_LPBIG_OFFBIG
-    {"SC_XBS5_LPBIG_OFFBIG",	_SC_XBS5_LPBIG_OFFBIG},
+    {"SC_XBS5_LPBIG_OFFBIG",    _SC_XBS5_LPBIG_OFFBIG},
 #endif
 #ifdef _SC_XOPEN_CRYPT
-    {"SC_XOPEN_CRYPT",	_SC_XOPEN_CRYPT},
+    {"SC_XOPEN_CRYPT",  _SC_XOPEN_CRYPT},
 #endif
 #ifdef _SC_XOPEN_ENH_I18N
-    {"SC_XOPEN_ENH_I18N",	_SC_XOPEN_ENH_I18N},
+    {"SC_XOPEN_ENH_I18N",       _SC_XOPEN_ENH_I18N},
 #endif
 #ifdef _SC_XOPEN_LEGACY
-    {"SC_XOPEN_LEGACY",	_SC_XOPEN_LEGACY},
+    {"SC_XOPEN_LEGACY", _SC_XOPEN_LEGACY},
 #endif
 #ifdef _SC_XOPEN_REALTIME
-    {"SC_XOPEN_REALTIME",	_SC_XOPEN_REALTIME},
+    {"SC_XOPEN_REALTIME",       _SC_XOPEN_REALTIME},
 #endif
 #ifdef _SC_XOPEN_REALTIME_THREADS
-    {"SC_XOPEN_REALTIME_THREADS",	_SC_XOPEN_REALTIME_THREADS},
+    {"SC_XOPEN_REALTIME_THREADS",       _SC_XOPEN_REALTIME_THREADS},
 #endif
 #ifdef _SC_XOPEN_SHM
-    {"SC_XOPEN_SHM",	_SC_XOPEN_SHM},
+    {"SC_XOPEN_SHM",    _SC_XOPEN_SHM},
 #endif
 #ifdef _SC_XOPEN_UNIX
-    {"SC_XOPEN_UNIX",	_SC_XOPEN_UNIX},
+    {"SC_XOPEN_UNIX",   _SC_XOPEN_UNIX},
 #endif
 #ifdef _SC_XOPEN_VERSION
-    {"SC_XOPEN_VERSION",	_SC_XOPEN_VERSION},
+    {"SC_XOPEN_VERSION",        _SC_XOPEN_VERSION},
 #endif
 #ifdef _SC_XOPEN_XCU_VERSION
-    {"SC_XOPEN_XCU_VERSION",	_SC_XOPEN_XCU_VERSION},
+    {"SC_XOPEN_XCU_VERSION",    _SC_XOPEN_XCU_VERSION},
 #endif
 #ifdef _SC_XOPEN_XPG2
-    {"SC_XOPEN_XPG2",	_SC_XOPEN_XPG2},
+    {"SC_XOPEN_XPG2",   _SC_XOPEN_XPG2},
 #endif
 #ifdef _SC_XOPEN_XPG3
-    {"SC_XOPEN_XPG3",	_SC_XOPEN_XPG3},
+    {"SC_XOPEN_XPG3",   _SC_XOPEN_XPG3},
 #endif
 #ifdef _SC_XOPEN_XPG4
-    {"SC_XOPEN_XPG4",	_SC_XOPEN_XPG4},
+    {"SC_XOPEN_XPG4",   _SC_XOPEN_XPG4},
 #endif
 };
 
@@ -6617,16 +6618,16 @@
 cmp_constdefs(const void *v1,  const void *v2)
 {
     const struct constdef *c1 =
-        (const struct constdef *) v1;
+    (const struct constdef *) v1;
     const struct constdef *c2 =
-        (const struct constdef *) v2;
+    (const struct constdef *) v2;
 
     return strcmp(c1->name, c2->name);
 }
 
 static int
 setup_confname_table(struct constdef *table, size_t tablesize,
-		     char *tablename, PyObject *module)
+                     char *tablename, PyObject *module)
 {
     PyObject *d = NULL;
     size_t i;
@@ -6634,16 +6635,16 @@
     qsort(table, tablesize, sizeof(struct constdef), cmp_constdefs);
     d = PyDict_New();
     if (d == NULL)
-	    return -1;
+        return -1;
 
     for (i=0; i < tablesize; ++i) {
-            PyObject *o = PyLong_FromLong(table[i].value);
-            if (o == NULL || PyDict_SetItemString(d, table[i].name, o) == -1) {
-		    Py_XDECREF(o);
-		    Py_DECREF(d);
-		    return -1;
-            }
-	    Py_DECREF(o);
+        PyObject *o = PyLong_FromLong(table[i].value);
+        if (o == NULL || PyDict_SetItemString(d, table[i].name, o) == -1) {
+            Py_XDECREF(o);
+            Py_DECREF(d);
+            return -1;
+        }
+        Py_DECREF(o);
     }
     return PyModule_AddObject(module, tablename, d);
 }
@@ -6657,21 +6658,21 @@
                              sizeof(posix_constants_pathconf)
                                / sizeof(struct constdef),
                              "pathconf_names", module))
-        return -1;
+    return -1;
 #endif
 #ifdef HAVE_CONFSTR
     if (setup_confname_table(posix_constants_confstr,
                              sizeof(posix_constants_confstr)
                                / sizeof(struct constdef),
                              "confstr_names", module))
-        return -1;
+    return -1;
 #endif
 #ifdef HAVE_SYSCONF
     if (setup_confname_table(posix_constants_sysconf,
                              sizeof(posix_constants_sysconf)
                                / sizeof(struct constdef),
                              "sysconf_names", module))
-        return -1;
+    return -1;
 #endif
     return 0;
 }
@@ -6714,61 +6715,61 @@
 static PyObject *
 win32_startfile(PyObject *self, PyObject *args)
 {
-	PyObject *ofilepath;
-	char *filepath;
-	char *operation = NULL;
-	HINSTANCE rc;
-
-	PyObject *unipath, *woperation = NULL;
-	if (!PyArg_ParseTuple(args, "U|s:startfile",
-			      &unipath, &operation)) {
-		PyErr_Clear();
-		goto normal;
-	}
-
-	if (operation) {
-		woperation = PyUnicode_DecodeASCII(operation, 
-						   strlen(operation), NULL);
-		if (!woperation) {
-			PyErr_Clear();
-			operation = NULL;
-			goto normal;
-		}
-	}
-		
-	Py_BEGIN_ALLOW_THREADS
-	rc = ShellExecuteW((HWND)0, woperation ? PyUnicode_AS_UNICODE(woperation) : 0,
-		PyUnicode_AS_UNICODE(unipath),
-		NULL, NULL, SW_SHOWNORMAL);
-	Py_END_ALLOW_THREADS
-
-	Py_XDECREF(woperation);
-	if (rc <= (HINSTANCE)32) {
-		PyObject *errval = win32_error_unicode("startfile",
-					PyUnicode_AS_UNICODE(unipath));
-		return errval;
-	}
-	Py_INCREF(Py_None);
-	return Py_None;
+    PyObject *ofilepath;
+    char *filepath;
+    char *operation = NULL;
+    HINSTANCE rc;
+
+    PyObject *unipath, *woperation = NULL;
+    if (!PyArg_ParseTuple(args, "U|s:startfile",
+                          &unipath, &operation)) {
+        PyErr_Clear();
+        goto normal;
+    }
+
+    if (operation) {
+        woperation = PyUnicode_DecodeASCII(operation,
+                                           strlen(operation), NULL);
+        if (!woperation) {
+            PyErr_Clear();
+            operation = NULL;
+            goto normal;
+        }
+    }
+
+    Py_BEGIN_ALLOW_THREADS
+    rc = ShellExecuteW((HWND)0, woperation ? PyUnicode_AS_UNICODE(woperation) : 0,
+        PyUnicode_AS_UNICODE(unipath),
+        NULL, NULL, SW_SHOWNORMAL);
+    Py_END_ALLOW_THREADS
+
+    Py_XDECREF(woperation);
+    if (rc <= (HINSTANCE)32) {
+        PyObject *errval = win32_error_unicode("startfile",
+                                               PyUnicode_AS_UNICODE(unipath));
+        return errval;
+    }
+    Py_INCREF(Py_None);
+    return Py_None;
 
 normal:
-	if (!PyArg_ParseTuple(args, "O&|s:startfile", 
-			      PyUnicode_FSConverter, &ofilepath, 
-			      &operation))
-		return NULL;
-	filepath = PyBytes_AsString(ofilepath);
-	Py_BEGIN_ALLOW_THREADS
-	rc = ShellExecute((HWND)0, operation, filepath, 
-			  NULL, NULL, SW_SHOWNORMAL);
-	Py_END_ALLOW_THREADS
-	if (rc <= (HINSTANCE)32) {
-		PyObject *errval = win32_error("startfile", filepath);
-		Py_DECREF(ofilepath);
-		return errval;
-	}
-	Py_DECREF(ofilepath);
-	Py_INCREF(Py_None);
-	return Py_None;
+    if (!PyArg_ParseTuple(args, "O&|s:startfile",
+                          PyUnicode_FSConverter, &ofilepath,
+                          &operation))
+        return NULL;
+    filepath = PyBytes_AsString(ofilepath);
+    Py_BEGIN_ALLOW_THREADS
+    rc = ShellExecute((HWND)0, operation, filepath,
+                      NULL, NULL, SW_SHOWNORMAL);
+    Py_END_ALLOW_THREADS
+    if (rc <= (HINSTANCE)32) {
+        PyObject *errval = win32_error("startfile", filepath);
+        Py_DECREF(ofilepath);
+        return errval;
+    }
+    Py_DECREF(ofilepath);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 #endif
 
@@ -6784,10 +6785,10 @@
 {
     double loadavg[3];
     if (getloadavg(loadavg, 3)!=3) {
-        PyErr_SetString(PyExc_OSError, "Load averages are unobtainable");
-        return NULL;
+    PyErr_SetString(PyExc_OSError, "Load averages are unobtainable");
+    return NULL;
     } else
-        return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]);
+    return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]);
 }
 #endif
 
@@ -6811,59 +6812,59 @@
 static PyObject*
 win32_urandom(PyObject *self, PyObject *args)
 {
-	int howMany;
-	PyObject* result;
+    int howMany;
+    PyObject* result;
+
+    /* Read arguments */
+    if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
+        return NULL;
+    if (howMany < 0)
+        return PyErr_Format(PyExc_ValueError,
+                            "negative argument not allowed");
+
+    if (hCryptProv == 0) {
+        HINSTANCE hAdvAPI32 = NULL;
+        CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL;
+
+        /* Obtain handle to the DLL containing CryptoAPI
+           This should not fail         */
+        hAdvAPI32 = GetModuleHandle("advapi32.dll");
+        if(hAdvAPI32 == NULL)
+            return win32_error("GetModuleHandle", NULL);
+
+        /* Obtain pointers to the CryptoAPI functions
+           This will fail on some early versions of Win95 */
+        pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress(
+                                        hAdvAPI32,
+                                        "CryptAcquireContextA");
+        if (pCryptAcquireContext == NULL)
+            return PyErr_Format(PyExc_NotImplementedError,
+                                "CryptAcquireContextA not found");
+
+        pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress(
+                                        hAdvAPI32, "CryptGenRandom");
+        if (pCryptGenRandom == NULL)
+            return PyErr_Format(PyExc_NotImplementedError,
+                                "CryptGenRandom not found");
+
+        /* Acquire context */
+        if (! pCryptAcquireContext(&hCryptProv, NULL, NULL,
+                                   PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+            return win32_error("CryptAcquireContext", NULL);
+    }
 
-	/* Read arguments */
-	if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
-		return NULL;
-	if (howMany < 0)
-		return PyErr_Format(PyExc_ValueError,
-				    "negative argument not allowed");
-
-	if (hCryptProv == 0) {
-		HINSTANCE hAdvAPI32 = NULL;
-		CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL;
-
-		/* Obtain handle to the DLL containing CryptoAPI
-		   This should not fail	*/
-		hAdvAPI32 = GetModuleHandle("advapi32.dll");
-		if(hAdvAPI32 == NULL)
-			return win32_error("GetModuleHandle", NULL);
-
-		/* Obtain pointers to the CryptoAPI functions
-		   This will fail on some early versions of Win95 */
-		pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress(
-						hAdvAPI32,
-						"CryptAcquireContextA");
-		if (pCryptAcquireContext == NULL)
-			return PyErr_Format(PyExc_NotImplementedError,
-					    "CryptAcquireContextA not found");
-
-		pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress(
-						hAdvAPI32, "CryptGenRandom");
-		if (pCryptGenRandom == NULL)
-			return PyErr_Format(PyExc_NotImplementedError,
-					    "CryptGenRandom not found");
-
-		/* Acquire context */
-		if (! pCryptAcquireContext(&hCryptProv, NULL, NULL,
-					   PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
-			return win32_error("CryptAcquireContext", NULL);
-	}
-
-	/* Allocate bytes */
-	result = PyBytes_FromStringAndSize(NULL, howMany);
-	if (result != NULL) {
-		/* Get random data */
-		memset(PyBytes_AS_STRING(result), 0, howMany); /* zero seed */
-		if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
-				      PyBytes_AS_STRING(result))) {
-			Py_DECREF(result);
-			return win32_error("CryptGenRandom", NULL);
-		}
-	}
-	return result;
+    /* Allocate bytes */
+    result = PyBytes_FromStringAndSize(NULL, howMany);
+    if (result != NULL) {
+        /* Get random data */
+        memset(PyBytes_AS_STRING(result), 0, howMany); /* zero seed */
+        if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
+                              PyBytes_AS_STRING(result))) {
+            Py_DECREF(result);
+            return win32_error("CryptGenRandom", NULL);
+        }
+    }
+    return result;
 }
 #endif
 
@@ -6875,33 +6876,33 @@
 static PyObject *
 device_encoding(PyObject *self, PyObject *args)
 {
-	int fd;
-	if (!PyArg_ParseTuple(args, "i:device_encoding", &fd))
-		return NULL;
-	if (!_PyVerify_fd(fd) || !isatty(fd)) {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
+    int fd;
+    if (!PyArg_ParseTuple(args, "i:device_encoding", &fd))
+        return NULL;
+    if (!_PyVerify_fd(fd) || !isatty(fd)) {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
 #if defined(MS_WINDOWS) || defined(MS_WIN64)
-	if (fd == 0) {
-		char buf[100];
-		sprintf(buf, "cp%d", GetConsoleCP());
-		return PyUnicode_FromString(buf);
-	}
-	if (fd == 1 || fd == 2) {
-		char buf[100];
-		sprintf(buf, "cp%d", GetConsoleOutputCP());
-		return PyUnicode_FromString(buf);
-	}
+    if (fd == 0) {
+        char buf[100];
+        sprintf(buf, "cp%d", GetConsoleCP());
+        return PyUnicode_FromString(buf);
+    }
+    if (fd == 1 || fd == 2) {
+        char buf[100];
+        sprintf(buf, "cp%d", GetConsoleOutputCP());
+        return PyUnicode_FromString(buf);
+    }
 #elif defined(CODESET)
-	{
-		char *codeset = nl_langinfo(CODESET);
-		if (codeset != NULL && codeset[0] != 0)
-			return PyUnicode_FromString(codeset);
-	}
+    {
+        char *codeset = nl_langinfo(CODESET);
+        if (codeset != NULL && codeset[0] != 0)
+            return PyUnicode_FromString(codeset);
+    }
 #endif
-	Py_INCREF(Py_None);
-	return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 #ifdef __VMS
@@ -6914,29 +6915,29 @@
 static PyObject*
 vms_urandom(PyObject *self, PyObject *args)
 {
-	int howMany;
-	PyObject* result;
+    int howMany;
+    PyObject* result;
 
-	/* Read arguments */
-	if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
-		return NULL;
-	if (howMany < 0)
-		return PyErr_Format(PyExc_ValueError,
-				    "negative argument not allowed");
-
-	/* Allocate bytes */
-	result = PyBytes_FromStringAndSize(NULL, howMany);
-	if (result != NULL) {
-		/* Get random data */
-		if (RAND_pseudo_bytes((unsigned char*)
-				      PyBytes_AS_STRING(result),
-				      howMany) < 0) {
-			Py_DECREF(result);
-			return PyErr_Format(PyExc_ValueError,
-					    "RAND_pseudo_bytes");
-		}
-	}
-	return result;
+    /* Read arguments */
+    if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
+        return NULL;
+    if (howMany < 0)
+        return PyErr_Format(PyExc_ValueError,
+                            "negative argument not allowed");
+
+    /* Allocate bytes */
+    result = PyBytes_FromStringAndSize(NULL, howMany);
+    if (result != NULL) {
+        /* Get random data */
+        if (RAND_pseudo_bytes((unsigned char*)
+                              PyBytes_AS_STRING(result),
+                              howMany) < 0) {
+            Py_DECREF(result);
+            return PyErr_Format(PyExc_ValueError,
+                                "RAND_pseudo_bytes");
+        }
+    }
+    return result;
 }
 #endif
 
@@ -6948,13 +6949,13 @@
 static PyObject*
 posix_setresuid (PyObject *self, PyObject *args)
 {
-	/* We assume uid_t is no larger than a long. */
-	long ruid, euid, suid;
-	if (!PyArg_ParseTuple(args, "lll", &ruid, &euid, &suid))
-		return NULL;
-	if (setresuid(ruid, euid, suid) < 0)
-		return posix_error();
-	Py_RETURN_NONE;
+    /* We assume uid_t is no larger than a long. */
+    long ruid, euid, suid;
+    if (!PyArg_ParseTuple(args, "lll", &ruid, &euid, &suid))
+        return NULL;
+    if (setresuid(ruid, euid, suid) < 0)
+        return posix_error();
+    Py_RETURN_NONE;
 }
 #endif
 
@@ -6966,13 +6967,13 @@
 static PyObject*
 posix_setresgid (PyObject *self, PyObject *args)
 {
-	/* We assume uid_t is no larger than a long. */
-	long rgid, egid, sgid;
-	if (!PyArg_ParseTuple(args, "lll", &rgid, &egid, &sgid))
-		return NULL;
-	if (setresgid(rgid, egid, sgid) < 0)
-		return posix_error();
-	Py_RETURN_NONE;
+    /* We assume uid_t is no larger than a long. */
+    long rgid, egid, sgid;
+    if (!PyArg_ParseTuple(args, "lll", &rgid, &egid, &sgid))
+        return NULL;
+    if (setresgid(rgid, egid, sgid) < 0)
+        return posix_error();
+    Py_RETURN_NONE;
 }
 #endif
 
@@ -6984,15 +6985,15 @@
 static PyObject*
 posix_getresuid (PyObject *self, PyObject *noargs)
 {
-	uid_t ruid, euid, suid;
-	long l_ruid, l_euid, l_suid;
-	if (getresuid(&ruid, &euid, &suid) < 0)
-		return posix_error();
-	/* Force the values into long's as we don't know the size of uid_t. */
-	l_ruid = ruid;
-	l_euid = euid;
-	l_suid = suid;
-	return Py_BuildValue("(lll)", l_ruid, l_euid, l_suid);
+    uid_t ruid, euid, suid;
+    long l_ruid, l_euid, l_suid;
+    if (getresuid(&ruid, &euid, &suid) < 0)
+        return posix_error();
+    /* Force the values into long's as we don't know the size of uid_t. */
+    l_ruid = ruid;
+    l_euid = euid;
+    l_suid = suid;
+    return Py_BuildValue("(lll)", l_ruid, l_euid, l_suid);
 }
 #endif
 
@@ -7004,332 +7005,332 @@
 static PyObject*
 posix_getresgid (PyObject *self, PyObject *noargs)
 {
-	uid_t rgid, egid, sgid;
-	long l_rgid, l_egid, l_sgid;
-	if (getresgid(&rgid, &egid, &sgid) < 0)
-		return posix_error();
-	/* Force the values into long's as we don't know the size of uid_t. */
-	l_rgid = rgid;
-	l_egid = egid;
-	l_sgid = sgid;
-	return Py_BuildValue("(lll)", l_rgid, l_egid, l_sgid);
+    uid_t rgid, egid, sgid;
+    long l_rgid, l_egid, l_sgid;
+    if (getresgid(&rgid, &egid, &sgid) < 0)
+        return posix_error();
+    /* Force the values into long's as we don't know the size of uid_t. */
+    l_rgid = rgid;
+    l_egid = egid;
+    l_sgid = sgid;
+    return Py_BuildValue("(lll)", l_rgid, l_egid, l_sgid);
 }
 #endif
 
 static PyMethodDef posix_methods[] = {
-	{"access",	posix_access, METH_VARARGS, posix_access__doc__},
+    {"access",          posix_access, METH_VARARGS, posix_access__doc__},
 #ifdef HAVE_TTYNAME
-	{"ttyname",	posix_ttyname, METH_VARARGS, posix_ttyname__doc__},
+    {"ttyname",         posix_ttyname, METH_VARARGS, posix_ttyname__doc__},
 #endif
-	{"chdir",	posix_chdir, METH_VARARGS, posix_chdir__doc__},
+    {"chdir",           posix_chdir, METH_VARARGS, posix_chdir__doc__},
 #ifdef HAVE_CHFLAGS
-	{"chflags",	posix_chflags, METH_VARARGS, posix_chflags__doc__},
+    {"chflags",         posix_chflags, METH_VARARGS, posix_chflags__doc__},
 #endif /* HAVE_CHFLAGS */
-	{"chmod",	posix_chmod, METH_VARARGS, posix_chmod__doc__},
+    {"chmod",           posix_chmod, METH_VARARGS, posix_chmod__doc__},
 #ifdef HAVE_FCHMOD
-	{"fchmod",	posix_fchmod, METH_VARARGS, posix_fchmod__doc__},
+    {"fchmod",          posix_fchmod, METH_VARARGS, posix_fchmod__doc__},
 #endif /* HAVE_FCHMOD */
 #ifdef HAVE_CHOWN
-	{"chown",	posix_chown, METH_VARARGS, posix_chown__doc__},
+    {"chown",           posix_chown, METH_VARARGS, posix_chown__doc__},
 #endif /* HAVE_CHOWN */
 #ifdef HAVE_LCHMOD
-	{"lchmod",	posix_lchmod, METH_VARARGS, posix_lchmod__doc__},
+    {"lchmod",          posix_lchmod, METH_VARARGS, posix_lchmod__doc__},
 #endif /* HAVE_LCHMOD */
 #ifdef HAVE_FCHOWN
-	{"fchown",	posix_fchown, METH_VARARGS, posix_fchown__doc__},
+    {"fchown",          posix_fchown, METH_VARARGS, posix_fchown__doc__},
 #endif /* HAVE_FCHOWN */
 #ifdef HAVE_LCHFLAGS
-	{"lchflags",	posix_lchflags, METH_VARARGS, posix_lchflags__doc__},
+    {"lchflags",        posix_lchflags, METH_VARARGS, posix_lchflags__doc__},
 #endif /* HAVE_LCHFLAGS */
 #ifdef HAVE_LCHOWN
-	{"lchown",	posix_lchown, METH_VARARGS, posix_lchown__doc__},
+    {"lchown",          posix_lchown, METH_VARARGS, posix_lchown__doc__},
 #endif /* HAVE_LCHOWN */
 #ifdef HAVE_CHROOT
-	{"chroot",	posix_chroot, METH_VARARGS, posix_chroot__doc__},
+    {"chroot",          posix_chroot, METH_VARARGS, posix_chroot__doc__},
 #endif
 #ifdef HAVE_CTERMID
-	{"ctermid",	posix_ctermid, METH_NOARGS, posix_ctermid__doc__},
+    {"ctermid",         posix_ctermid, METH_NOARGS, posix_ctermid__doc__},
 #endif
 #ifdef HAVE_GETCWD
-	{"getcwd",	(PyCFunction)posix_getcwd_unicode,
-	METH_NOARGS, posix_getcwd__doc__},
-	{"getcwdb",	(PyCFunction)posix_getcwd_bytes,
-	METH_NOARGS, posix_getcwdb__doc__},
+    {"getcwd",          (PyCFunction)posix_getcwd_unicode,
+    METH_NOARGS, posix_getcwd__doc__},
+    {"getcwdb",         (PyCFunction)posix_getcwd_bytes,
+    METH_NOARGS, posix_getcwdb__doc__},
 #endif
 #ifdef HAVE_LINK
-	{"link",	posix_link, METH_VARARGS, posix_link__doc__},
+    {"link",            posix_link, METH_VARARGS, posix_link__doc__},
 #endif /* HAVE_LINK */
-	{"listdir",	posix_listdir, METH_VARARGS, posix_listdir__doc__},
-	{"lstat",	posix_lstat, METH_VARARGS, posix_lstat__doc__},
-	{"mkdir",	posix_mkdir, METH_VARARGS, posix_mkdir__doc__},
+    {"listdir",         posix_listdir, METH_VARARGS, posix_listdir__doc__},
+    {"lstat",           posix_lstat, METH_VARARGS, posix_lstat__doc__},
+    {"mkdir",           posix_mkdir, METH_VARARGS, posix_mkdir__doc__},
 #ifdef HAVE_NICE
-	{"nice",	posix_nice, METH_VARARGS, posix_nice__doc__},
+    {"nice",            posix_nice, METH_VARARGS, posix_nice__doc__},
 #endif /* HAVE_NICE */
 #ifdef HAVE_READLINK
-	{"readlink",	posix_readlink, METH_VARARGS, posix_readlink__doc__},
+    {"readlink",        posix_readlink, METH_VARARGS, posix_readlink__doc__},
 #endif /* HAVE_READLINK */
-	{"rename",	posix_rename, METH_VARARGS, posix_rename__doc__},
-	{"rmdir",	posix_rmdir, METH_VARARGS, posix_rmdir__doc__},
-	{"stat",	posix_stat, METH_VARARGS, posix_stat__doc__},
-	{"stat_float_times", stat_float_times, METH_VARARGS, stat_float_times__doc__},
+    {"rename",          posix_rename, METH_VARARGS, posix_rename__doc__},
+    {"rmdir",           posix_rmdir, METH_VARARGS, posix_rmdir__doc__},
+    {"stat",            posix_stat, METH_VARARGS, posix_stat__doc__},
+    {"stat_float_times", stat_float_times, METH_VARARGS, stat_float_times__doc__},
 #ifdef HAVE_SYMLINK
-	{"symlink",	posix_symlink, METH_VARARGS, posix_symlink__doc__},
+    {"symlink",         posix_symlink, METH_VARARGS, posix_symlink__doc__},
 #endif /* HAVE_SYMLINK */
 #ifdef HAVE_SYSTEM
-	{"system",	posix_system, METH_VARARGS, posix_system__doc__},
+    {"system",          posix_system, METH_VARARGS, posix_system__doc__},
 #endif
-	{"umask",	posix_umask, METH_VARARGS, posix_umask__doc__},
+    {"umask",           posix_umask, METH_VARARGS, posix_umask__doc__},
 #ifdef HAVE_UNAME
-	{"uname",	posix_uname, METH_NOARGS, posix_uname__doc__},
+    {"uname",           posix_uname, METH_NOARGS, posix_uname__doc__},
 #endif /* HAVE_UNAME */
-	{"unlink",	posix_unlink, METH_VARARGS, posix_unlink__doc__},
-	{"remove",	posix_unlink, METH_VARARGS, posix_remove__doc__},
-	{"utime",	posix_utime, METH_VARARGS, posix_utime__doc__},
+    {"unlink",          posix_unlink, METH_VARARGS, posix_unlink__doc__},
+    {"remove",          posix_unlink, METH_VARARGS, posix_remove__doc__},
+    {"utime",           posix_utime, METH_VARARGS, posix_utime__doc__},
 #ifdef HAVE_TIMES
-	{"times",	posix_times, METH_NOARGS, posix_times__doc__},
+    {"times",           posix_times, METH_NOARGS, posix_times__doc__},
 #endif /* HAVE_TIMES */
-	{"_exit",	posix__exit, METH_VARARGS, posix__exit__doc__},
+    {"_exit",           posix__exit, METH_VARARGS, posix__exit__doc__},
 #ifdef HAVE_EXECV
-	{"execv",	posix_execv, METH_VARARGS, posix_execv__doc__},
-	{"execve",	posix_execve, METH_VARARGS, posix_execve__doc__},
+    {"execv",           posix_execv, METH_VARARGS, posix_execv__doc__},
+    {"execve",          posix_execve, METH_VARARGS, posix_execve__doc__},
 #endif /* HAVE_EXECV */
 #ifdef HAVE_SPAWNV
-	{"spawnv",	posix_spawnv, METH_VARARGS, posix_spawnv__doc__},
-	{"spawnve",	posix_spawnve, METH_VARARGS, posix_spawnve__doc__},
+    {"spawnv",          posix_spawnv, METH_VARARGS, posix_spawnv__doc__},
+    {"spawnve",         posix_spawnve, METH_VARARGS, posix_spawnve__doc__},
 #if defined(PYOS_OS2)
-	{"spawnvp",	posix_spawnvp, METH_VARARGS, posix_spawnvp__doc__},
-	{"spawnvpe",	posix_spawnvpe, METH_VARARGS, posix_spawnvpe__doc__},
+    {"spawnvp",         posix_spawnvp, METH_VARARGS, posix_spawnvp__doc__},
+    {"spawnvpe",        posix_spawnvpe, METH_VARARGS, posix_spawnvpe__doc__},
 #endif /* PYOS_OS2 */
 #endif /* HAVE_SPAWNV */
 #ifdef HAVE_FORK1
-	{"fork1",       posix_fork1, METH_NOARGS, posix_fork1__doc__},
+    {"fork1",       posix_fork1, METH_NOARGS, posix_fork1__doc__},
 #endif /* HAVE_FORK1 */
 #ifdef HAVE_FORK
-	{"fork",	posix_fork, METH_NOARGS, posix_fork__doc__},
+    {"fork",            posix_fork, METH_NOARGS, posix_fork__doc__},
 #endif /* HAVE_FORK */
 #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
-	{"openpty",	posix_openpty, METH_NOARGS, posix_openpty__doc__},
+    {"openpty",         posix_openpty, METH_NOARGS, posix_openpty__doc__},
 #endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */
 #ifdef HAVE_FORKPTY
-	{"forkpty",	posix_forkpty, METH_NOARGS, posix_forkpty__doc__},
+    {"forkpty",         posix_forkpty, METH_NOARGS, posix_forkpty__doc__},
 #endif /* HAVE_FORKPTY */
 #ifdef HAVE_GETEGID
-	{"getegid",	posix_getegid, METH_NOARGS, posix_getegid__doc__},
+    {"getegid",         posix_getegid, METH_NOARGS, posix_getegid__doc__},
 #endif /* HAVE_GETEGID */
 #ifdef HAVE_GETEUID
-	{"geteuid",	posix_geteuid, METH_NOARGS, posix_geteuid__doc__},
+    {"geteuid",         posix_geteuid, METH_NOARGS, posix_geteuid__doc__},
 #endif /* HAVE_GETEUID */
 #ifdef HAVE_GETGID
-	{"getgid",	posix_getgid, METH_NOARGS, posix_getgid__doc__},
+    {"getgid",          posix_getgid, METH_NOARGS, posix_getgid__doc__},
 #endif /* HAVE_GETGID */
 #ifdef HAVE_GETGROUPS
-	{"getgroups",	posix_getgroups, METH_NOARGS, posix_getgroups__doc__},
+    {"getgroups",       posix_getgroups, METH_NOARGS, posix_getgroups__doc__},
 #endif
-	{"getpid",	posix_getpid, METH_NOARGS, posix_getpid__doc__},
+    {"getpid",          posix_getpid, METH_NOARGS, posix_getpid__doc__},
 #ifdef HAVE_GETPGRP
-	{"getpgrp",	posix_getpgrp, METH_NOARGS, posix_getpgrp__doc__},
+    {"getpgrp",         posix_getpgrp, METH_NOARGS, posix_getpgrp__doc__},
 #endif /* HAVE_GETPGRP */
 #ifdef HAVE_GETPPID
-	{"getppid",	posix_getppid, METH_NOARGS, posix_getppid__doc__},
+    {"getppid",         posix_getppid, METH_NOARGS, posix_getppid__doc__},
 #endif /* HAVE_GETPPID */
 #ifdef HAVE_GETUID
-	{"getuid",	posix_getuid, METH_NOARGS, posix_getuid__doc__},
+    {"getuid",          posix_getuid, METH_NOARGS, posix_getuid__doc__},
 #endif /* HAVE_GETUID */
 #ifdef HAVE_GETLOGIN
-	{"getlogin",	posix_getlogin, METH_NOARGS, posix_getlogin__doc__},
+    {"getlogin",        posix_getlogin, METH_NOARGS, posix_getlogin__doc__},
 #endif
 #ifdef HAVE_KILL
-	{"kill",	posix_kill, METH_VARARGS, posix_kill__doc__},
+    {"kill",            posix_kill, METH_VARARGS, posix_kill__doc__},
 #endif /* HAVE_KILL */
 #ifdef HAVE_KILLPG
-	{"killpg",	posix_killpg, METH_VARARGS, posix_killpg__doc__},
+    {"killpg",          posix_killpg, METH_VARARGS, posix_killpg__doc__},
 #endif /* HAVE_KILLPG */
 #ifdef HAVE_PLOCK
-	{"plock",	posix_plock, METH_VARARGS, posix_plock__doc__},
+    {"plock",           posix_plock, METH_VARARGS, posix_plock__doc__},
 #endif /* HAVE_PLOCK */
 #ifdef MS_WINDOWS
-	{"startfile",	win32_startfile, METH_VARARGS, win32_startfile__doc__},
-	{"kill",    win32_kill, METH_VARARGS, win32_kill__doc__},
+    {"startfile",       win32_startfile, METH_VARARGS, win32_startfile__doc__},
+    {"kill",    win32_kill, METH_VARARGS, win32_kill__doc__},
 #endif
 #ifdef HAVE_SETUID
-	{"setuid",	posix_setuid, METH_VARARGS, posix_setuid__doc__},
+    {"setuid",          posix_setuid, METH_VARARGS, posix_setuid__doc__},
 #endif /* HAVE_SETUID */
 #ifdef HAVE_SETEUID
-	{"seteuid",	posix_seteuid, METH_VARARGS, posix_seteuid__doc__},
+    {"seteuid",         posix_seteuid, METH_VARARGS, posix_seteuid__doc__},
 #endif /* HAVE_SETEUID */
 #ifdef HAVE_SETEGID
-	{"setegid",	posix_setegid, METH_VARARGS, posix_setegid__doc__},
+    {"setegid",         posix_setegid, METH_VARARGS, posix_setegid__doc__},
 #endif /* HAVE_SETEGID */
 #ifdef HAVE_SETREUID
-	{"setreuid",	posix_setreuid, METH_VARARGS, posix_setreuid__doc__},
+    {"setreuid",        posix_setreuid, METH_VARARGS, posix_setreuid__doc__},
 #endif /* HAVE_SETREUID */
 #ifdef HAVE_SETREGID
-	{"setregid",	posix_setregid,	METH_VARARGS, posix_setregid__doc__},
+    {"setregid",        posix_setregid, METH_VARARGS, posix_setregid__doc__},
 #endif /* HAVE_SETREGID */
 #ifdef HAVE_SETGID
-	{"setgid",	posix_setgid, METH_VARARGS, posix_setgid__doc__},
+    {"setgid",          posix_setgid, METH_VARARGS, posix_setgid__doc__},
 #endif /* HAVE_SETGID */
 #ifdef HAVE_SETGROUPS
-	{"setgroups",	posix_setgroups, METH_O, posix_setgroups__doc__},
+    {"setgroups",       posix_setgroups, METH_O, posix_setgroups__doc__},
 #endif /* HAVE_SETGROUPS */
 #ifdef HAVE_INITGROUPS
-	{"initgroups",	posix_initgroups, METH_VARARGS, posix_initgroups__doc__},
+    {"initgroups",      posix_initgroups, METH_VARARGS, posix_initgroups__doc__},
 #endif /* HAVE_INITGROUPS */
 #ifdef HAVE_GETPGID
-	{"getpgid",	posix_getpgid, METH_VARARGS, posix_getpgid__doc__},
+    {"getpgid",         posix_getpgid, METH_VARARGS, posix_getpgid__doc__},
 #endif /* HAVE_GETPGID */
 #ifdef HAVE_SETPGRP
-	{"setpgrp",	posix_setpgrp, METH_NOARGS, posix_setpgrp__doc__},
+    {"setpgrp",         posix_setpgrp, METH_NOARGS, posix_setpgrp__doc__},
 #endif /* HAVE_SETPGRP */
 #ifdef HAVE_WAIT
-	{"wait",	posix_wait, METH_NOARGS, posix_wait__doc__},
+    {"wait",            posix_wait, METH_NOARGS, posix_wait__doc__},
 #endif /* HAVE_WAIT */
 #ifdef HAVE_WAIT3
-        {"wait3",	posix_wait3, METH_VARARGS, posix_wait3__doc__},
+    {"wait3",           posix_wait3, METH_VARARGS, posix_wait3__doc__},
 #endif /* HAVE_WAIT3 */
 #ifdef HAVE_WAIT4
-        {"wait4",	posix_wait4, METH_VARARGS, posix_wait4__doc__},
+    {"wait4",           posix_wait4, METH_VARARGS, posix_wait4__doc__},
 #endif /* HAVE_WAIT4 */
 #if defined(HAVE_WAITPID) || defined(HAVE_CWAIT)
-	{"waitpid",	posix_waitpid, METH_VARARGS, posix_waitpid__doc__},
+    {"waitpid",         posix_waitpid, METH_VARARGS, posix_waitpid__doc__},
 #endif /* HAVE_WAITPID */
 #ifdef HAVE_GETSID
-	{"getsid",	posix_getsid, METH_VARARGS, posix_getsid__doc__},
+    {"getsid",          posix_getsid, METH_VARARGS, posix_getsid__doc__},
 #endif /* HAVE_GETSID */
 #ifdef HAVE_SETSID
-	{"setsid",	posix_setsid, METH_NOARGS, posix_setsid__doc__},
+    {"setsid",          posix_setsid, METH_NOARGS, posix_setsid__doc__},
 #endif /* HAVE_SETSID */
 #ifdef HAVE_SETPGID
-	{"setpgid",	posix_setpgid, METH_VARARGS, posix_setpgid__doc__},
+    {"setpgid",         posix_setpgid, METH_VARARGS, posix_setpgid__doc__},
 #endif /* HAVE_SETPGID */
 #ifdef HAVE_TCGETPGRP
-	{"tcgetpgrp",	posix_tcgetpgrp, METH_VARARGS, posix_tcgetpgrp__doc__},
+    {"tcgetpgrp",       posix_tcgetpgrp, METH_VARARGS, posix_tcgetpgrp__doc__},
 #endif /* HAVE_TCGETPGRP */
 #ifdef HAVE_TCSETPGRP
-	{"tcsetpgrp",	posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__},
+    {"tcsetpgrp",       posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__},
 #endif /* HAVE_TCSETPGRP */
-	{"open",	posix_open, METH_VARARGS, posix_open__doc__},
-	{"close",	posix_close, METH_VARARGS, posix_close__doc__},
-	{"closerange",	posix_closerange, METH_VARARGS, posix_closerange__doc__},
-	{"device_encoding", device_encoding, METH_VARARGS, device_encoding__doc__},
-	{"dup",		posix_dup, METH_VARARGS, posix_dup__doc__},
-	{"dup2",	posix_dup2, METH_VARARGS, posix_dup2__doc__},
-	{"lseek",	posix_lseek, METH_VARARGS, posix_lseek__doc__},
-	{"read",	posix_read, METH_VARARGS, posix_read__doc__},
-	{"write",	posix_write, METH_VARARGS, posix_write__doc__},
-	{"fstat",	posix_fstat, METH_VARARGS, posix_fstat__doc__},
-	{"isatty",	posix_isatty, METH_VARARGS, posix_isatty__doc__},
+    {"open",            posix_open, METH_VARARGS, posix_open__doc__},
+    {"close",           posix_close, METH_VARARGS, posix_close__doc__},
+    {"closerange",      posix_closerange, METH_VARARGS, posix_closerange__doc__},
+    {"device_encoding", device_encoding, METH_VARARGS, device_encoding__doc__},
+    {"dup",             posix_dup, METH_VARARGS, posix_dup__doc__},
+    {"dup2",            posix_dup2, METH_VARARGS, posix_dup2__doc__},
+    {"lseek",           posix_lseek, METH_VARARGS, posix_lseek__doc__},
+    {"read",            posix_read, METH_VARARGS, posix_read__doc__},
+    {"write",           posix_write, METH_VARARGS, posix_write__doc__},
+    {"fstat",           posix_fstat, METH_VARARGS, posix_fstat__doc__},
+    {"isatty",          posix_isatty, METH_VARARGS, posix_isatty__doc__},
 #ifdef HAVE_PIPE
-	{"pipe",	posix_pipe, METH_NOARGS, posix_pipe__doc__},
+    {"pipe",            posix_pipe, METH_NOARGS, posix_pipe__doc__},
 #endif
 #ifdef HAVE_MKFIFO
-	{"mkfifo",	posix_mkfifo, METH_VARARGS, posix_mkfifo__doc__},
+    {"mkfifo",          posix_mkfifo, METH_VARARGS, posix_mkfifo__doc__},
 #endif
 #if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)
-	{"mknod",	posix_mknod, METH_VARARGS, posix_mknod__doc__},
+    {"mknod",           posix_mknod, METH_VARARGS, posix_mknod__doc__},
 #endif
 #ifdef HAVE_DEVICE_MACROS
-	{"major",	posix_major, METH_VARARGS, posix_major__doc__},
-	{"minor",	posix_minor, METH_VARARGS, posix_minor__doc__},
-	{"makedev",	posix_makedev, METH_VARARGS, posix_makedev__doc__},
+    {"major",           posix_major, METH_VARARGS, posix_major__doc__},
+    {"minor",           posix_minor, METH_VARARGS, posix_minor__doc__},
+    {"makedev",         posix_makedev, METH_VARARGS, posix_makedev__doc__},
 #endif
 #ifdef HAVE_FTRUNCATE
-	{"ftruncate",	posix_ftruncate, METH_VARARGS, posix_ftruncate__doc__},
+    {"ftruncate",       posix_ftruncate, METH_VARARGS, posix_ftruncate__doc__},
 #endif
 #ifdef HAVE_PUTENV
-	{"putenv",	posix_putenv, METH_VARARGS, posix_putenv__doc__},
+    {"putenv",          posix_putenv, METH_VARARGS, posix_putenv__doc__},
 #endif
 #ifdef HAVE_UNSETENV
-	{"unsetenv",	posix_unsetenv, METH_VARARGS, posix_unsetenv__doc__},
+    {"unsetenv",        posix_unsetenv, METH_VARARGS, posix_unsetenv__doc__},
 #endif
-	{"strerror",	posix_strerror, METH_VARARGS, posix_strerror__doc__},
+    {"strerror",        posix_strerror, METH_VARARGS, posix_strerror__doc__},
 #ifdef HAVE_FCHDIR
-	{"fchdir",	posix_fchdir, METH_O, posix_fchdir__doc__},
+    {"fchdir",          posix_fchdir, METH_O, posix_fchdir__doc__},
 #endif
 #ifdef HAVE_FSYNC
-	{"fsync",       posix_fsync, METH_O, posix_fsync__doc__},
+    {"fsync",       posix_fsync, METH_O, posix_fsync__doc__},
 #endif
 #ifdef HAVE_FDATASYNC
-	{"fdatasync",   posix_fdatasync,  METH_O, posix_fdatasync__doc__},
+    {"fdatasync",   posix_fdatasync,  METH_O, posix_fdatasync__doc__},
 #endif
 #ifdef HAVE_SYS_WAIT_H
 #ifdef WCOREDUMP
-        {"WCOREDUMP",	posix_WCOREDUMP, METH_VARARGS, posix_WCOREDUMP__doc__},
+    {"WCOREDUMP",       posix_WCOREDUMP, METH_VARARGS, posix_WCOREDUMP__doc__},
 #endif /* WCOREDUMP */
 #ifdef WIFCONTINUED
-        {"WIFCONTINUED",posix_WIFCONTINUED, METH_VARARGS, posix_WIFCONTINUED__doc__},
+    {"WIFCONTINUED",posix_WIFCONTINUED, METH_VARARGS, posix_WIFCONTINUED__doc__},
 #endif /* WIFCONTINUED */
 #ifdef WIFSTOPPED
-        {"WIFSTOPPED",	posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__},
+    {"WIFSTOPPED",      posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__},
 #endif /* WIFSTOPPED */
 #ifdef WIFSIGNALED
-        {"WIFSIGNALED",	posix_WIFSIGNALED, METH_VARARGS, posix_WIFSIGNALED__doc__},
+    {"WIFSIGNALED",     posix_WIFSIGNALED, METH_VARARGS, posix_WIFSIGNALED__doc__},
 #endif /* WIFSIGNALED */
 #ifdef WIFEXITED
-        {"WIFEXITED",	posix_WIFEXITED, METH_VARARGS, posix_WIFEXITED__doc__},
+    {"WIFEXITED",       posix_WIFEXITED, METH_VARARGS, posix_WIFEXITED__doc__},
 #endif /* WIFEXITED */
 #ifdef WEXITSTATUS
-        {"WEXITSTATUS",	posix_WEXITSTATUS, METH_VARARGS, posix_WEXITSTATUS__doc__},
+    {"WEXITSTATUS",     posix_WEXITSTATUS, METH_VARARGS, posix_WEXITSTATUS__doc__},
 #endif /* WEXITSTATUS */
 #ifdef WTERMSIG
-        {"WTERMSIG",	posix_WTERMSIG, METH_VARARGS, posix_WTERMSIG__doc__},
+    {"WTERMSIG",        posix_WTERMSIG, METH_VARARGS, posix_WTERMSIG__doc__},
 #endif /* WTERMSIG */
 #ifdef WSTOPSIG
-        {"WSTOPSIG",	posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__},
+    {"WSTOPSIG",        posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__},
 #endif /* WSTOPSIG */
 #endif /* HAVE_SYS_WAIT_H */
 #if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)
-	{"fstatvfs",	posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__},
+    {"fstatvfs",        posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__},
 #endif
 #if defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)
-	{"statvfs",	posix_statvfs, METH_VARARGS, posix_statvfs__doc__},
+    {"statvfs",         posix_statvfs, METH_VARARGS, posix_statvfs__doc__},
 #endif
 #ifdef HAVE_CONFSTR
-	{"confstr",	posix_confstr, METH_VARARGS, posix_confstr__doc__},
+    {"confstr",         posix_confstr, METH_VARARGS, posix_confstr__doc__},
 #endif
 #ifdef HAVE_SYSCONF
-	{"sysconf",	posix_sysconf, METH_VARARGS, posix_sysconf__doc__},
+    {"sysconf",         posix_sysconf, METH_VARARGS, posix_sysconf__doc__},
 #endif
 #ifdef HAVE_FPATHCONF
-	{"fpathconf",	posix_fpathconf, METH_VARARGS, posix_fpathconf__doc__},
+    {"fpathconf",       posix_fpathconf, METH_VARARGS, posix_fpathconf__doc__},
 #endif
 #ifdef HAVE_PATHCONF
-	{"pathconf",	posix_pathconf, METH_VARARGS, posix_pathconf__doc__},
+    {"pathconf",        posix_pathconf, METH_VARARGS, posix_pathconf__doc__},
 #endif
-	{"abort",	posix_abort, METH_NOARGS, posix_abort__doc__},
+    {"abort",           posix_abort, METH_NOARGS, posix_abort__doc__},
 #ifdef MS_WINDOWS
-	{"_getfullpathname",	posix__getfullpathname, METH_VARARGS, NULL},
+    {"_getfullpathname",        posix__getfullpathname, METH_VARARGS, NULL},
 #endif
 #ifdef HAVE_GETLOADAVG
-	{"getloadavg",	posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
+    {"getloadavg",      posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
 #endif
  #ifdef MS_WINDOWS
- 	{"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
+    {"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
  #endif
  #ifdef __VMS
- 	{"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__},
+    {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__},
  #endif
 #ifdef HAVE_SETRESUID
-        {"setresuid",	posix_setresuid, METH_VARARGS, posix_setresuid__doc__},
+    {"setresuid",       posix_setresuid, METH_VARARGS, posix_setresuid__doc__},
 #endif
 #ifdef HAVE_SETRESGID
-        {"setresgid",	posix_setresgid, METH_VARARGS, posix_setresgid__doc__},
+    {"setresgid",       posix_setresgid, METH_VARARGS, posix_setresgid__doc__},
 #endif
 #ifdef HAVE_GETRESUID
-        {"getresuid",	posix_getresuid, METH_NOARGS, posix_getresuid__doc__},
+    {"getresuid",       posix_getresuid, METH_NOARGS, posix_getresuid__doc__},
 #endif
 #ifdef HAVE_GETRESGID
-        {"getresgid",	posix_getresgid, METH_NOARGS, posix_getresgid__doc__},
+    {"getresgid",       posix_getresgid, METH_NOARGS, posix_getresgid__doc__},
 #endif
 
-	{NULL,		NULL}		 /* Sentinel */
+    {NULL,              NULL}            /* Sentinel */
 };
 
 
 static int
 ins(PyObject *module, char *symbol, long value)
 {
-        return PyModule_AddIntConstant(module, symbol, value);
+    return PyModule_AddIntConstant(module, symbol, value);
 }
 
 #if defined(PYOS_OS2)
@@ -7367,7 +7368,7 @@
     case 50: ver = "5.00"; break;
     default:
         PyOS_snprintf(tmp, sizeof(tmp),
-        	      "%d-%d", values[QSV_VERSION_MAJOR],
+                      "%d-%d", values[QSV_VERSION_MAJOR],
                       values[QSV_VERSION_MINOR]);
         ver = &tmp[0];
     }
@@ -7389,221 +7390,221 @@
 all_ins(PyObject *d)
 {
 #ifdef F_OK
-        if (ins(d, "F_OK", (long)F_OK)) return -1;
+    if (ins(d, "F_OK", (long)F_OK)) return -1;
 #endif
 #ifdef R_OK
-        if (ins(d, "R_OK", (long)R_OK)) return -1;
+    if (ins(d, "R_OK", (long)R_OK)) return -1;
 #endif
 #ifdef W_OK
-        if (ins(d, "W_OK", (long)W_OK)) return -1;
+    if (ins(d, "W_OK", (long)W_OK)) return -1;
 #endif
 #ifdef X_OK
-        if (ins(d, "X_OK", (long)X_OK)) return -1;
+    if (ins(d, "X_OK", (long)X_OK)) return -1;
 #endif
 #ifdef NGROUPS_MAX
-        if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
+    if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
 #endif
 #ifdef TMP_MAX
-        if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
+    if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
 #endif
 #ifdef WCONTINUED
-        if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
+    if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
 #endif
 #ifdef WNOHANG
-        if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
+    if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
 #endif
 #ifdef WUNTRACED
-        if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
+    if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
 #endif
 #ifdef O_RDONLY
-        if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
+    if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
 #endif
 #ifdef O_WRONLY
-        if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
+    if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
 #endif
 #ifdef O_RDWR
-        if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
+    if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
 #endif
 #ifdef O_NDELAY
-        if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
+    if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
 #endif
 #ifdef O_NONBLOCK
-        if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
+    if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
 #endif
 #ifdef O_APPEND
-        if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
+    if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
 #endif
 #ifdef O_DSYNC
-        if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
+    if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
 #endif
 #ifdef O_RSYNC
-        if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
+    if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
 #endif
 #ifdef O_SYNC
-        if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
+    if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
 #endif
 #ifdef O_NOCTTY
-        if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
+    if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
 #endif
 #ifdef O_CREAT
-        if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
+    if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
 #endif
 #ifdef O_EXCL
-        if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
+    if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
 #endif
 #ifdef O_TRUNC
-        if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
+    if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
 #endif
 #ifdef O_BINARY
-        if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
+    if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
 #endif
 #ifdef O_TEXT
-        if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
+    if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
 #endif
 #ifdef O_LARGEFILE
-        if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
+    if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
 #endif
 #ifdef O_SHLOCK
-        if (ins(d, "O_SHLOCK", (long)O_SHLOCK)) return -1;
+    if (ins(d, "O_SHLOCK", (long)O_SHLOCK)) return -1;
 #endif
 #ifdef O_EXLOCK
-        if (ins(d, "O_EXLOCK", (long)O_EXLOCK)) return -1;
+    if (ins(d, "O_EXLOCK", (long)O_EXLOCK)) return -1;
 #endif
 
 /* MS Windows */
 #ifdef O_NOINHERIT
-	/* Don't inherit in child processes. */
-        if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1;
+    /* Don't inherit in child processes. */
+    if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1;
 #endif
 #ifdef _O_SHORT_LIVED
-	/* Optimize for short life (keep in memory). */
-	/* MS forgot to define this one with a non-underscore form too. */
-        if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1;
+    /* Optimize for short life (keep in memory). */
+    /* MS forgot to define this one with a non-underscore form too. */
+    if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1;
 #endif
 #ifdef O_TEMPORARY
-	/* Automatically delete when last handle is closed. */
-        if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1;
+    /* Automatically delete when last handle is closed. */
+    if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1;
 #endif
 #ifdef O_RANDOM
-	/* Optimize for random access. */
-        if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1;
+    /* Optimize for random access. */
+    if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1;
 #endif
 #ifdef O_SEQUENTIAL
-	/* Optimize for sequential access. */
-        if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1;
+    /* Optimize for sequential access. */
+    if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1;
 #endif
 
 /* GNU extensions. */
 #ifdef O_ASYNC
-        /* Send a SIGIO signal whenever input or output 
-           becomes available on file descriptor */
-        if (ins(d, "O_ASYNC", (long)O_ASYNC)) return -1;
+    /* Send a SIGIO signal whenever input or output
+       becomes available on file descriptor */
+    if (ins(d, "O_ASYNC", (long)O_ASYNC)) return -1;
 #endif
 #ifdef O_DIRECT
-        /* Direct disk access. */
-        if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
+    /* Direct disk access. */
+    if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
 #endif
 #ifdef O_DIRECTORY
-        /* Must be a directory.	 */
-        if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
+    /* Must be a directory.      */
+    if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
 #endif
 #ifdef O_NOFOLLOW
-        /* Do not follow links.	 */
-        if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
+    /* Do not follow links.      */
+    if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
 #endif
 #ifdef O_NOATIME
-	/* Do not update the access time. */
-	if (ins(d, "O_NOATIME", (long)O_NOATIME)) return -1;
+    /* Do not update the access time. */
+    if (ins(d, "O_NOATIME", (long)O_NOATIME)) return -1;
 #endif
 
-	/* These come from sysexits.h */
+    /* These come from sysexits.h */
 #ifdef EX_OK
-	if (ins(d, "EX_OK", (long)EX_OK)) return -1;
+    if (ins(d, "EX_OK", (long)EX_OK)) return -1;
 #endif /* EX_OK */
 #ifdef EX_USAGE
-	if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1;
+    if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1;
 #endif /* EX_USAGE */
 #ifdef EX_DATAERR
-	if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1;
+    if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1;
 #endif /* EX_DATAERR */
 #ifdef EX_NOINPUT
-	if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1;
+    if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1;
 #endif /* EX_NOINPUT */
 #ifdef EX_NOUSER
-	if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1;
+    if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1;
 #endif /* EX_NOUSER */
 #ifdef EX_NOHOST
-	if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1;
+    if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1;
 #endif /* EX_NOHOST */
 #ifdef EX_UNAVAILABLE
-	if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1;
+    if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1;
 #endif /* EX_UNAVAILABLE */
 #ifdef EX_SOFTWARE
-	if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1;
+    if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1;
 #endif /* EX_SOFTWARE */
 #ifdef EX_OSERR
-	if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1;
+    if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1;
 #endif /* EX_OSERR */
 #ifdef EX_OSFILE
-	if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1;
+    if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1;
 #endif /* EX_OSFILE */
 #ifdef EX_CANTCREAT
-	if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1;
+    if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1;
 #endif /* EX_CANTCREAT */
 #ifdef EX_IOERR
-	if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1;
+    if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1;
 #endif /* EX_IOERR */
 #ifdef EX_TEMPFAIL
-	if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1;
+    if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1;
 #endif /* EX_TEMPFAIL */
 #ifdef EX_PROTOCOL
-	if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1;
+    if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1;
 #endif /* EX_PROTOCOL */
 #ifdef EX_NOPERM
-	if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1;
+    if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1;
 #endif /* EX_NOPERM */
 #ifdef EX_CONFIG
-	if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1;
+    if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1;
 #endif /* EX_CONFIG */
 #ifdef EX_NOTFOUND
-	if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1;
+    if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1;
 #endif /* EX_NOTFOUND */
 
 #ifdef HAVE_SPAWNV
 #if defined(PYOS_OS2) && defined(PYCC_GCC)
-	if (ins(d, "P_WAIT", (long)P_WAIT)) return -1;
-	if (ins(d, "P_NOWAIT", (long)P_NOWAIT)) return -1;
-	if (ins(d, "P_OVERLAY", (long)P_OVERLAY)) return -1;
-	if (ins(d, "P_DEBUG", (long)P_DEBUG)) return -1;
-	if (ins(d, "P_SESSION", (long)P_SESSION)) return -1;
-	if (ins(d, "P_DETACH", (long)P_DETACH)) return -1;
-	if (ins(d, "P_PM", (long)P_PM)) return -1;
-	if (ins(d, "P_DEFAULT", (long)P_DEFAULT)) return -1;
-	if (ins(d, "P_MINIMIZE", (long)P_MINIMIZE)) return -1;
-	if (ins(d, "P_MAXIMIZE", (long)P_MAXIMIZE)) return -1;
-	if (ins(d, "P_FULLSCREEN", (long)P_FULLSCREEN)) return -1;
-	if (ins(d, "P_WINDOWED", (long)P_WINDOWED)) return -1;
-	if (ins(d, "P_FOREGROUND", (long)P_FOREGROUND)) return -1;
-	if (ins(d, "P_BACKGROUND", (long)P_BACKGROUND)) return -1;
-	if (ins(d, "P_NOCLOSE", (long)P_NOCLOSE)) return -1;
-	if (ins(d, "P_NOSESSION", (long)P_NOSESSION)) return -1;
-	if (ins(d, "P_QUOTE", (long)P_QUOTE)) return -1;
-	if (ins(d, "P_TILDE", (long)P_TILDE)) return -1;
-	if (ins(d, "P_UNRELATED", (long)P_UNRELATED)) return -1;
-	if (ins(d, "P_DEBUGDESC", (long)P_DEBUGDESC)) return -1;
-#else
-        if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
-        if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
-        if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
-        if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
-        if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
+    if (ins(d, "P_WAIT", (long)P_WAIT)) return -1;
+    if (ins(d, "P_NOWAIT", (long)P_NOWAIT)) return -1;
+    if (ins(d, "P_OVERLAY", (long)P_OVERLAY)) return -1;
+    if (ins(d, "P_DEBUG", (long)P_DEBUG)) return -1;
+    if (ins(d, "P_SESSION", (long)P_SESSION)) return -1;
+    if (ins(d, "P_DETACH", (long)P_DETACH)) return -1;
+    if (ins(d, "P_PM", (long)P_PM)) return -1;
+    if (ins(d, "P_DEFAULT", (long)P_DEFAULT)) return -1;
+    if (ins(d, "P_MINIMIZE", (long)P_MINIMIZE)) return -1;
+    if (ins(d, "P_MAXIMIZE", (long)P_MAXIMIZE)) return -1;
+    if (ins(d, "P_FULLSCREEN", (long)P_FULLSCREEN)) return -1;
+    if (ins(d, "P_WINDOWED", (long)P_WINDOWED)) return -1;
+    if (ins(d, "P_FOREGROUND", (long)P_FOREGROUND)) return -1;
+    if (ins(d, "P_BACKGROUND", (long)P_BACKGROUND)) return -1;
+    if (ins(d, "P_NOCLOSE", (long)P_NOCLOSE)) return -1;
+    if (ins(d, "P_NOSESSION", (long)P_NOSESSION)) return -1;
+    if (ins(d, "P_QUOTE", (long)P_QUOTE)) return -1;
+    if (ins(d, "P_TILDE", (long)P_TILDE)) return -1;
+    if (ins(d, "P_UNRELATED", (long)P_UNRELATED)) return -1;
+    if (ins(d, "P_DEBUGDESC", (long)P_DEBUGDESC)) return -1;
+#else
+    if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
+    if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
+    if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
+    if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
+    if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
 #endif
 #endif
 
 #if defined(PYOS_OS2)
-        if (insertvalues(d)) return -1;
+    if (insertvalues(d)) return -1;
 #endif
-        return 0;
+    return 0;
 }
 
 
@@ -7621,114 +7622,114 @@
 #endif
 
 static struct PyModuleDef posixmodule = {
-	PyModuleDef_HEAD_INIT,
-	MODNAME,
-	posix__doc__,
-	-1,
-	posix_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
+    PyModuleDef_HEAD_INIT,
+    MODNAME,
+    posix__doc__,
+    -1,
+    posix_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
 };
 
 
 PyMODINIT_FUNC
 INITFUNC(void)
 {
-	PyObject *m, *v;
+    PyObject *m, *v;
 
-	m = PyModule_Create(&posixmodule);
-	if (m == NULL)
-    		return NULL;
-
-	/* Initialize environ dictionary */
-	v = convertenviron();
-	Py_XINCREF(v);
-	if (v == NULL || PyModule_AddObject(m, "environ", v) != 0)
-		return NULL;
-	Py_DECREF(v);
+    m = PyModule_Create(&posixmodule);
+    if (m == NULL)
+        return NULL;
 
-        if (all_ins(m))
-                return NULL;
+    /* Initialize environ dictionary */
+    v = convertenviron();
+    Py_XINCREF(v);
+    if (v == NULL || PyModule_AddObject(m, "environ", v) != 0)
+        return NULL;
+    Py_DECREF(v);
 
-        if (setup_confname_tables(m))
-                return NULL;
+    if (all_ins(m))
+        return NULL;
+
+    if (setup_confname_tables(m))
+        return NULL;
 
-	Py_INCREF(PyExc_OSError);
-	PyModule_AddObject(m, "error", PyExc_OSError);
+    Py_INCREF(PyExc_OSError);
+    PyModule_AddObject(m, "error", PyExc_OSError);
 
 #ifdef HAVE_PUTENV
-	if (posix_putenv_garbage == NULL)
-		posix_putenv_garbage = PyDict_New();
+    if (posix_putenv_garbage == NULL)
+        posix_putenv_garbage = PyDict_New();
 #endif
 
-	if (!initialized) {
-		stat_result_desc.name = MODNAME ".stat_result";
-		stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
-		stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
-		stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
-		PyStructSequence_InitType(&StatResultType, &stat_result_desc);
-		structseq_new = StatResultType.tp_new;
-		StatResultType.tp_new = statresult_new;
+    if (!initialized) {
+        stat_result_desc.name = MODNAME ".stat_result";
+        stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
+        stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
+        stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
+        PyStructSequence_InitType(&StatResultType, &stat_result_desc);
+        structseq_new = StatResultType.tp_new;
+        StatResultType.tp_new = statresult_new;
 
-		statvfs_result_desc.name = MODNAME ".statvfs_result";
-		PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
+        statvfs_result_desc.name = MODNAME ".statvfs_result";
+        PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
 #ifdef NEED_TICKS_PER_SECOND
 #  if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
-		ticks_per_second = sysconf(_SC_CLK_TCK);
+        ticks_per_second = sysconf(_SC_CLK_TCK);
 #  elif defined(HZ)
-		ticks_per_second = HZ;
+        ticks_per_second = HZ;
 #  else
-		ticks_per_second = 60; /* magic fallback value; may be bogus */
+        ticks_per_second = 60; /* magic fallback value; may be bogus */
 #  endif
 #endif
-	}
-	Py_INCREF((PyObject*) &StatResultType);
-	PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
-	Py_INCREF((PyObject*) &StatVFSResultType);
-	PyModule_AddObject(m, "statvfs_result",
-			   (PyObject*) &StatVFSResultType);
-	initialized = 1;
+    }
+    Py_INCREF((PyObject*) &StatResultType);
+    PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
+    Py_INCREF((PyObject*) &StatVFSResultType);
+    PyModule_AddObject(m, "statvfs_result",
+                       (PyObject*) &StatVFSResultType);
+    initialized = 1;
 
 #ifdef __APPLE__
-	/*
-	 * Step 2 of weak-linking support on Mac OS X.
-	 *
-	 * The code below removes functions that are not available on the
-	 * currently active platform. 
-	 *
-	 * This block allow one to use a python binary that was build on
-	 * OSX 10.4 on OSX 10.3, without loosing access to new APIs on 
-	 * OSX 10.4.
-	 */
+    /*
+     * Step 2 of weak-linking support on Mac OS X.
+     *
+     * The code below removes functions that are not available on the
+     * currently active platform.
+     *
+     * This block allow one to use a python binary that was build on
+     * OSX 10.4 on OSX 10.3, without loosing access to new APIs on
+     * OSX 10.4.
+     */
 #ifdef HAVE_FSTATVFS
-	if (fstatvfs == NULL) {
-		if (PyObject_DelAttrString(m, "fstatvfs") == -1) {
-			return NULL;
-		}
-	}
+    if (fstatvfs == NULL) {
+        if (PyObject_DelAttrString(m, "fstatvfs") == -1) {
+            return NULL;
+        }
+    }
 #endif /* HAVE_FSTATVFS */
 
 #ifdef HAVE_STATVFS
-	if (statvfs == NULL) {
-		if (PyObject_DelAttrString(m, "statvfs") == -1) {
-			return NULL;
-		}
-	}
+    if (statvfs == NULL) {
+        if (PyObject_DelAttrString(m, "statvfs") == -1) {
+            return NULL;
+        }
+    }
 #endif /* HAVE_STATVFS */
 
 # ifdef HAVE_LCHOWN
-	if (lchown == NULL) {
-		if (PyObject_DelAttrString(m, "lchown") == -1) {
-			return NULL;
-		}
-	}
+    if (lchown == NULL) {
+        if (PyObject_DelAttrString(m, "lchown") == -1) {
+            return NULL;
+        }
+    }
 #endif /* HAVE_LCHOWN */
 
 
 #endif /* __APPLE__ */
-	return m;
+    return m;
 
 }
 

Modified: python/branches/py3k-jit/PCbuild/_ctypes.vcproj
==============================================================================
--- python/branches/py3k-jit/PCbuild/_ctypes.vcproj	(original)
+++ python/branches/py3k-jit/PCbuild/_ctypes.vcproj	Thu May  6 23:49:27 2010
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9.00"
+	Version="9,00"
 	Name="_ctypes"
 	ProjectGUID="{0E9791DB-593A-465F-98BC-681011311618}"
 	RootNamespace="_ctypes"
@@ -42,7 +42,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN32"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -103,7 +104,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN64"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -164,7 +166,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN32"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -228,7 +231,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN64"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -291,7 +295,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN32"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -355,7 +360,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN64"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -419,7 +425,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN32"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -483,7 +490,8 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc"
+				AdditionalIncludeDirectories="..\Modules\_ctypes\libffi_msvc;..\Modules\_ctypes\libffi\include;..\Modules\_ctypes\libffi\src\x86"
+				PreprocessorDefinitions="X86_WIN64"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -543,7 +551,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\ffi_common.h"
+				RelativePath="..\Modules\_ctypes\libffi\include\ffi_common.h"
 				>
 			</File>
 			<File
@@ -551,7 +559,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\ffitarget.h"
+				RelativePath="..\Modules\_ctypes\libffi\src\x86\ffitarget.h"
 				>
 			</File>
 		</Filter>
@@ -575,15 +583,23 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\ffi.c"
+				RelativePath="..\Modules\_ctypes\libffi\src\x86\ffi.c"
 				>
+				<FileConfiguration
+					Name="Debug|x64"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PreprocessorDefinitions="X86_WIN64"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\Modules\_ctypes\malloc_closure.c"
 				>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\prep_cif.c"
+				RelativePath="..\Modules\_ctypes\libffi\src\prep_cif.c"
 				>
 			</File>
 			<File
@@ -591,14 +607,32 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\win32.c"
+				RelativePath="..\Modules\_ctypes\libffi\src\x86\win32.S"
 				>
 				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml /nologo /Zi /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
-						Name="VCCLCompilerTool"
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml /nologo /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -606,7 +640,16 @@
 					ExcludedFromBuild="true"
 					>
 					<Tool
-						Name="VCCLCompilerTool"
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="PGInstrument|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml /nologo /Zi /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -614,7 +657,16 @@
 					ExcludedFromBuild="true"
 					>
 					<Tool
-						Name="VCCLCompilerTool"
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="PGUpdate|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml /nologo /Zi /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -622,12 +674,12 @@
 					ExcludedFromBuild="true"
 					>
 					<Tool
-						Name="VCCLCompilerTool"
+						Name="VCCustomBuildTool"
 					/>
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\Modules\_ctypes\libffi_msvc\win64.asm"
+				RelativePath="..\Modules\_ctypes\libffi\src\x86\win64.S"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -642,8 +694,8 @@
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						CommandLine="ml64 /nologo /c /Zi /Fo &quot;$(IntDir)\win64.obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\win64.obj"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml64 /Zi /nologo /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -659,8 +711,8 @@
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						CommandLine="ml64 /nologo /c /Fo &quot;$(IntDir)\win64.obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\win64.obj"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml64 /nologo /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -676,8 +728,8 @@
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						CommandLine="ml64 /nologo /c /Fo &quot;$(IntDir)\win64.obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\win64.obj"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml64 /nologo /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
@@ -693,8 +745,8 @@
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						CommandLine="ml64 /nologo /c /Fo &quot;$(IntDir)\win64.obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\win64.obj"
+						CommandLine="cl /nologo /EP /I ..\Modules\_ctypes\libffi_msvc /I ..\Modules\_ctypes\libffi\src\x86 $(InputPath) &gt; $(IntDir)$(InputName).asm&#x0D;&#x0A;ml64 /nologo /c /Fo $(IntDir)$(InputName).obj $(IntDir)$(InputName).asm&#x0D;&#x0A;"
+						Outputs="$(IntDir)$(InputName).obj"
 					/>
 				</FileConfiguration>
 			</File>

Modified: python/branches/py3k-jit/Tools/scripts/serve.py
==============================================================================
--- python/branches/py3k-jit/Tools/scripts/serve.py	(original)
+++ python/branches/py3k-jit/Tools/scripts/serve.py	Thu May  6 23:49:27 2010
@@ -28,4 +28,5 @@
     path = sys.argv[1]
     port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
     httpd = simple_server.make_server('', port, app)
+    print("Serving {} on port {}".format(path, port))
     httpd.serve_forever()

Modified: python/branches/py3k-jit/Tools/webchecker/wcgui.py
==============================================================================
--- python/branches/py3k-jit/Tools/webchecker/wcgui.py	(original)
+++ python/branches/py3k-jit/Tools/webchecker/wcgui.py	Thu May  6 23:49:27 2010
@@ -64,12 +64,6 @@
 import tktools
 import webchecker
 
-# Override some for a weaker platform
-if sys.platform == 'mac':
-    webchecker.DEFROOT = "http://grail.cnri.reston.va.us/"
-    webchecker.MAXPAGE = 50000
-    webchecker.verbose = 4
-
 def main():
     try:
         opts, args = getopt.getopt(sys.argv[1:], 't:m:qva')

Modified: python/branches/py3k-jit/Tools/webchecker/websucker.py
==============================================================================
--- python/branches/py3k-jit/Tools/webchecker/websucker.py	(original)
+++ python/branches/py3k-jit/Tools/webchecker/websucker.py	Thu May  6 23:49:27 2010
@@ -97,8 +97,6 @@
             path = path + "index.html"
         if os.sep != "/":
             path = os.sep.join(path.split("/"))
-            if os.name == "mac":
-                path = os.sep + path
         path = os.path.join(host, path)
         return path
 

Modified: python/branches/py3k-jit/configure
==============================================================================
--- python/branches/py3k-jit/configure	(original)
+++ python/branches/py3k-jit/configure	Thu May  6 23:49:27 2010
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 80666 .
+# From configure.in Revision: 80728 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for python 3.2.
 #
@@ -5288,7 +5288,7 @@
 	    if test "$Py_DEBUG" = 'true' ; then
 		# Optimization messes up debuggers, so turn it off for
 		# debug builds.
-		OPT="-g -Wall $STRICT_PROTO"
+		OPT="-g -O0 -Wall $STRICT_PROTO"
 	    else
 		OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
 	    fi
@@ -13553,13 +13553,14 @@
 
 
 
-
 case $ac_sys_system in
   OSF*) as_fn_error "OSF* systems are deprecated unless somebody volunteers. Check http://bugs.python.org/issue8606" "$LINENO" 5 ;;
 esac
 
 
 
+
+
 for h in `(cd $srcdir;echo Python/thread_*.h)`
 do
   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"

Modified: python/branches/py3k-jit/configure.in
==============================================================================
--- python/branches/py3k-jit/configure.in	(original)
+++ python/branches/py3k-jit/configure.in	Thu May  6 23:49:27 2010
@@ -875,7 +875,7 @@
 	    if test "$Py_DEBUG" = 'true' ; then
 		# Optimization messes up debuggers, so turn it off for
 		# debug builds.
-		OPT="-g -Wall $STRICT_PROTO"
+		OPT="-g -O0 -Wall $STRICT_PROTO"
 	    else
 		OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
 	    fi

Modified: python/branches/py3k-jit/setup.py
==============================================================================
--- python/branches/py3k-jit/setup.py	(original)
+++ python/branches/py3k-jit/setup.py	Thu May  6 23:49:27 2010
@@ -150,22 +150,21 @@
             if ext.name in sys.builtin_module_names:
                 self.extensions.remove(ext)
 
-        if platform != 'mac':
-            # Parse Modules/Setup and Modules/Setup.local to figure out which
-            # modules are turned on in the file.
-            remove_modules = []
-            for filename in ('Modules/Setup', 'Modules/Setup.local'):
-                input = text_file.TextFile(filename, join_lines=1)
-                while 1:
-                    line = input.readline()
-                    if not line: break
-                    line = line.split()
-                    remove_modules.append(line[0])
-                input.close()
-
-            for ext in self.extensions[:]:
-                if ext.name in remove_modules:
-                    self.extensions.remove(ext)
+        # Parse Modules/Setup and Modules/Setup.local to figure out which
+        # modules are turned on in the file.
+        remove_modules = []
+        for filename in ('Modules/Setup', 'Modules/Setup.local'):
+            input = text_file.TextFile(filename, join_lines=1)
+            while 1:
+                line = input.readline()
+                if not line: break
+                line = line.split()
+                remove_modules.append(line[0])
+            input.close()
+
+        for ext in self.extensions[:]:
+            if ext.name in remove_modules:
+                self.extensions.remove(ext)
 
         # When you run "make CC=altcc" or something similar, you really want
         # those environment variables passed into the setup.py phase.  Here's
@@ -381,7 +380,7 @@
 
         # Check for MacOS X, which doesn't need libm.a at all
         math_libs = ['m']
-        if platform in ['darwin', 'mac']:
+        if platform == 'darwin':
             math_libs = []
 
         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -441,19 +440,16 @@
 
         # fcntl(2) and ioctl(2)
         exts.append( Extension('fcntl', ['fcntlmodule.c']) )
-        if platform not in ['mac']:
-            # pwd(3)
-            exts.append( Extension('pwd', ['pwdmodule.c']) )
-            # grp(3)
-            exts.append( Extension('grp', ['grpmodule.c']) )
-            # spwd, shadow passwords
-            if (config_h_vars.get('HAVE_GETSPNAM', False) or
-                    config_h_vars.get('HAVE_GETSPENT', False)):
-                exts.append( Extension('spwd', ['spwdmodule.c']) )
-            else:
-                missing.append('spwd')
+        # pwd(3)
+        exts.append( Extension('pwd', ['pwdmodule.c']) )
+        # grp(3)
+        exts.append( Extension('grp', ['grpmodule.c']) )
+        # spwd, shadow passwords
+        if (config_h_vars.get('HAVE_GETSPNAM', False) or
+                config_h_vars.get('HAVE_GETSPENT', False)):
+            exts.append( Extension('spwd', ['spwdmodule.c']) )
         else:
-            missing.extend(['pwd', 'grp', 'spwd'])
+            missing.append('spwd')
 
         # select(2); not on ancient System V
         exts.append( Extension('select', ['selectmodule.c']) )
@@ -462,17 +458,11 @@
         exts.append( Extension('parser', ['parsermodule.c']) )
 
         # Memory-mapped files (also works on Win32).
-        if platform not in ['mac']:
-            exts.append( Extension('mmap', ['mmapmodule.c']) )
-        else:
-            missing.append('mmap')
+        exts.append( Extension('mmap', ['mmapmodule.c']) )
 
         # Lance Ellinghaus's syslog module
-        if platform not in ['mac']:
-            # syslog daemon interface
-            exts.append( Extension('syslog', ['syslogmodule.c']) )
-        else:
-            missing.append('syslog')
+        # syslog daemon interface
+        exts.append( Extension('syslog', ['syslogmodule.c']) )
 
         #
         # Here ends the simple stuff.  From here on, modules need certain
@@ -532,16 +522,13 @@
         else:
             missing.append('readline')
 
-        if platform not in ['mac']:
-            # crypt module.
+        # crypt module.
 
-            if self.compiler_obj.find_library_file(lib_dirs, 'crypt'):
-                libs = ['crypt']
-            else:
-                libs = []
-            exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
+        if self.compiler_obj.find_library_file(lib_dirs, 'crypt'):
+            libs = ['crypt']
         else:
-            missing.append('crypt')
+            libs = []
+        exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
 
         # CSV files
         exts.append( Extension('_csv', ['_csv.c']) )
@@ -986,7 +973,7 @@
             missing.append('_gdbm')
 
         # Unix-only modules
-        if platform not in ['mac', 'win32']:
+        if platform != 'win32':
             # Steen Lumholt's termios module
             exts.append( Extension('termios', ['termios.c']) )
             # Jeremy Hylton's rlimit interface


More information about the Python-checkins mailing list