[Python-checkins] r81349 - in python/branches/py3k-cdecimal: Doc/distutils/sourcedist.rst Doc/library/os.rst Doc/library/ssl.rst Doc/library/tarfile.rst Doc/library/test.rst Doc/library/urllib.request.rst Lib/asyncore.py Lib/distutils/command/sdist.py Lib/distutils/tests/test_sdist.py Lib/importlib/_bootstrap.py Lib/importlib/test/source/test_file_loader.py Lib/os.py Lib/ssl.py Lib/subprocess.py Lib/tarfile.py Lib/test/capath Lib/test/list_tests.py Lib/test/test_asyncore.py Lib/test/test_getargs2.py Lib/test/test_import.py Lib/test/test_os.py Lib/test/test_ssl.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_tarfile.py Lib/test/testtar.tar Lib/urllib/parse.py Lib/urllib/request.py Misc/NEWS Modules/_cursesmodule.c Modules/_io/textio.c Modules/_sqlite/connection.c Modules/_sqlite/cursor.c Modules/_sqlite/row.c Modules/_sqlite/statement.c Modules/_ssl.c Modules/_testcapimodule.c Modules/main.c Objects/moduleobject.c Objects/object.c Objects/typeobject.c Parser/asdl.py Parser/printgrammar.c Python/bltinmodule.c Python/getargs.c Python/graminit.c Python/pythonrun.c

stefan.krah python-checkins at python.org
Wed May 19 17:30:17 CEST 2010


Author: stefan.krah
Date: Wed May 19 17:30:16 2010
New Revision: 81349

Log:
Merged revisions 81214-81215,81218-81219,81222,81226,81231,81233-81237,81239,81242,81246-81247,81249-81253,81257-81258,81263,81266-81267,81269-81273,81276,81281,81283,81288,81290-81292,81299,81314,81319-81325 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81214 | brett.cannon | 2010-05-16 00:20:16 +0200 (Sun, 16 May 2010) | 2 lines
  
  A test was not guaranteeing cleanup in the face of an exception.
................
  r81215 | victor.stinner | 2010-05-16 00:23:53 +0200 (Sun, 16 May 2010) | 12 lines
  
  Recorded merge of revisions 81213 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81213 | victor.stinner | 2010-05-16 00:19:27 +0200 (dim., 16 mai 2010) | 5 lines
    
    reindent _cursesmodule.c
    
    Use untabify.py + emacs (python3 mode) + manual editions for
    Py_BEGIN_ALLOW_THREADS / Py_END_ALLOW_THREADS
  ........
................
  r81218 | brett.cannon | 2010-05-16 00:51:45 +0200 (Sun, 16 May 2010) | 1 line
  
  Fix a comment to state the right thing.
................
  r81219 | brett.cannon | 2010-05-16 00:53:24 +0200 (Sun, 16 May 2010) | 4 lines
  
  Make test_module_with_large_stack as an expected failure because of a change in
  importlib that is causing it to fail. Work to fix it is being tracked in issue
  8727.
................
  r81222 | victor.stinner | 2010-05-16 01:00:51 +0200 (Sun, 16 May 2010) | 11 lines
  
  Merged revisions 81220 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81220 | victor.stinner | 2010-05-16 00:55:28 +0200 (dim., 16 mai 2010) | 4 lines
    
    Use 4-spaces for indentation (instead of tabs) in pgen outputs
    
    Regenerate (reindent) Python/graminit.c
  ........
................
  r81226 | victor.stinner | 2010-05-16 02:36:38 +0200 (Sun, 16 May 2010) | 11 lines
  
  Merged revisions 81224 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81224 | victor.stinner | 2010-05-16 02:34:40 +0200 (dim., 16 mai 2010) | 4 lines
    
    Use with open() as fo: ... instead of try: fo = open(...) finally: fo.close()
    
    fo is not set if the open() fails.
  ........
................
  r81231 | antoine.pitrou | 2010-05-16 16:19:41 +0200 (Sun, 16 May 2010) | 9 lines
  
  Merged revisions 81229 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81229 | antoine.pitrou | 2010-05-16 16:16:56 +0200 (dim., 16 mai 2010) | 3 lines
    
    Document that SSL v2 is insecure.
  ........
................
  r81233 | antoine.pitrou | 2010-05-16 20:19:27 +0200 (Sun, 16 May 2010) | 3 lines
  
  Issue #8550: Add first class `SSLContext` objects to the ssl module.
................
  r81234 | antoine.pitrou | 2010-05-16 21:22:44 +0200 (Sun, 16 May 2010) | 3 lines
  
  Followup on r81233: fix test_ssl with OpenSSL < 1.0.0.
................
  r81235 | antoine.pitrou | 2010-05-16 21:56:32 +0200 (Sun, 16 May 2010) | 3 lines
  
  Fix (hopefully) the remaining test_ssl buildbot failures
................
  r81236 | antoine.pitrou | 2010-05-16 22:35:03 +0200 (Sun, 16 May 2010) | 3 lines
  
  Do not fail if ssl fails to import
................
  r81237 | victor.stinner | 2010-05-16 23:23:48 +0200 (Sun, 16 May 2010) | 3 lines
  
  Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
  for the filename
................
  r81239 | victor.stinner | 2010-05-16 23:36:37 +0200 (Sun, 16 May 2010) | 2 lines
  
  Issue #8477: ssl.RAND_egd() supports str with surrogates and bytes for the path
................
  r81242 | antoine.pitrou | 2010-05-17 01:14:22 +0200 (Mon, 17 May 2010) | 10 lines
  
  Merged revisions 81241 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81241 | antoine.pitrou | 2010-05-17 01:11:46 +0200 (lun., 17 mai 2010) | 4 lines
    
    Clear the OpenSSL error queue each time an error is signalled.
    When the error queue is not emptied, strange things can happen on the next SSL call, depending on the OpenSSL version.
  ........
................
  r81246 | antoine.pitrou | 2010-05-17 01:46:26 +0200 (Mon, 17 May 2010) | 3 lines
  
  "xyzzy" is not a silly enough name for some OpenSSL versions to report an error
................
  r81247 | victor.stinner | 2010-05-17 02:14:53 +0200 (Mon, 17 May 2010) | 9 lines
  
  test_os: cleanup test_internal_execvpe() and os._execvpe() mockup
  
   * Replace os.defpath instead of os.get_exec_path() to test also
     os.get_exec_path()
   * Use contextlib.contextmanager, move the mockup outside the class, and
     the mockup returns directly the call list object
   * Use two different contexts for the two tests
   * Use more revelant values and names
................
  r81249 | victor.stinner | 2010-05-17 02:18:34 +0200 (Mon, 17 May 2010) | 2 lines
  
  Oops, my patch on subprocess is not merged yet: fix my previous commit on test_os
................
  r81250 | victor.stinner | 2010-05-17 03:13:37 +0200 (Mon, 17 May 2010) | 2 lines
  
  Issue #6697: Fix a crash if code of "python -c code" contains surrogates
................
  r81251 | victor.stinner | 2010-05-17 03:26:01 +0200 (Mon, 17 May 2010) | 3 lines
  
  PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead
  of strict) error handler to escape surrogates
................
  r81252 | victor.stinner | 2010-05-17 10:58:51 +0200 (Mon, 17 May 2010) | 6 lines
  
  handle_system_exit() flushs files to warranty the output order
  
  PyObject_Print() writes into the C object stderr, whereas PySys_WriteStderr()
  writes into the Python object sys.stderr. Each object has its own buffer, so
  call sys.stderr.flush() and fflush(stderr).
................
  r81253 | victor.stinner | 2010-05-17 11:33:42 +0200 (Mon, 17 May 2010) | 6 lines
  
  Fix refleak in internal_print() introduced by myself in r81251
  
  _PyUnicode_AsDefaultEncodedString() uses a magical PyUnicode attribute to
  automatically destroy PyUnicode_EncodeUTF8() result when the unicode string is
  destroyed.
................
  r81257 | antoine.pitrou | 2010-05-17 12:30:00 +0200 (Mon, 17 May 2010) | 3 lines
  
  Try to fix buildbot failures with old OpenSSLs.
................
  r81258 | tarek.ziade | 2010-05-17 12:38:53 +0200 (Mon, 17 May 2010) | 9 lines
  
  Merged revisions 81255 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81255 | tarek.ziade | 2010-05-17 12:06:20 +0200 (Mon, 17 May 2010) | 1 line
    
    Fixed #8688: Distutils now recalculates MANIFEST everytime.
  ........
................
  r81263 | tarek.ziade | 2010-05-17 13:01:57 +0200 (Mon, 17 May 2010) | 9 lines
  
  Merged revisions 81261 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81261 | tarek.ziade | 2010-05-17 12:54:43 +0200 (Mon, 17 May 2010) | 1 line
    
    upgraded distutils docs w.r.t. the manifest regeneration
  ........
................
  r81266 | antoine.pitrou | 2010-05-17 16:13:10 +0200 (Mon, 17 May 2010) | 3 lines
  
  Typo (thanks Arfrever)
................
  r81267 | victor.stinner | 2010-05-17 16:36:43 +0200 (Mon, 17 May 2010) | 2 lines
  
  Improve test_exit() error message to analyze sparc failures
................
  r81269 | jeffrey.yasskin | 2010-05-17 18:59:23 +0200 (Mon, 17 May 2010) | 4 lines
  
  Fix test_capi in !pydebug mode, where my original attempt segfaulted without
  producing the expected error message.  The test only tests what it's supposed
  to test in pydebug mode though.  Fixes issue 8726.
................
  r81270 | florent.xicluna | 2010-05-17 19:24:07 +0200 (Mon, 17 May 2010) | 9 lines
  
  Merged revision 81259 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81259 | florent.xicluna | 2010-05-17 12:39:07 +0200 (lun, 17 mai 2010) | 2 lines
    
    Slight style cleanup.
  ........
................
  r81271 | florent.xicluna | 2010-05-17 19:33:07 +0200 (Mon, 17 May 2010) | 11 lines
  
  Issue #1285086: Speed up urllib.parse functions: quote, quote_from_bytes, unquote, unquote_to_bytes.
  
  Recorded merge of revisions 81265 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81265 | florent.xicluna | 2010-05-17 15:35:09 +0200 (lun, 17 mai 2010) | 2 lines
    
    Issue #1285086: Speed up urllib.quote and urllib.unquote for simple cases.
  ........
................
  r81272 | florent.xicluna | 2010-05-17 20:01:22 +0200 (Mon, 17 May 2010) | 2 lines
  
  Inadvertently removed part of the comment in r81271.
................
  r81273 | lars.gustaebel | 2010-05-17 20:02:50 +0200 (Mon, 17 May 2010) | 15 lines
  
  Issue #8633: Support for POSIX.1-2008 binary pax headers.
  
  tarfile is now able to read and write pax headers with a
  "hdrcharset=BINARY" record. This record was introduced in
  POSIX.1-2008 as a method to store unencoded binary strings that
  cannot be translated to UTF-8. In practice, this is just a workaround
  that allows a tar implementation to store filenames that do not
  comply with the current filesystem encoding and thus cannot be
  decoded correctly.
  Additionally, tarfile works around a bug in current versions of GNU
  tar: undecodable filenames are stored as-is in a pax header without a
  "hdrcharset" record being added. Technically, these headers are
  invalid, but tarfile manages to read them correctly anyway.
................
  r81276 | victor.stinner | 2010-05-17 21:57:40 +0200 (Mon, 17 May 2010) | 4 lines
  
  Fix test_main_invalid_unicode() of test_sys for ASCII locale encoding
  
  It should fix sparc 3.x and 3.1 failures.
................
  r81281 | senthil.kumaran | 2010-05-18 05:26:11 +0200 (Tue, 18 May 2010) | 9 lines
  
  Merged revisions 81279 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81279 | senthil.kumaran | 2010-05-18 08:50:43 +0530 (Tue, 18 May 2010) | 3 lines
    
    Fix minor typo.
  ........
................
  r81283 | senthil.kumaran | 2010-05-18 05:58:36 +0200 (Tue, 18 May 2010) | 3 lines
  
  Removing the reference in the docs for overriding _urlopener global value. See Issue8619 for details.
................
  r81288 | senthil.kumaran | 2010-05-18 15:48:45 +0200 (Tue, 18 May 2010) | 9 lines
  
  Merged revisions 81286 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81286 | senthil.kumaran | 2010-05-18 19:10:23 +0530 (Tue, 18 May 2010) | 3 lines
    
    Doc Fix. Correct link to Zephyr ASDL Abstract page.
  ........
................
  r81290 | barry.warsaw | 2010-05-18 16:15:20 +0200 (Tue, 18 May 2010) | 2 lines
  
  Repair test failure.  Bug 8727.
................
  r81291 | victor.stinner | 2010-05-18 19:17:23 +0200 (Tue, 18 May 2010) | 5 lines
  
  Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
  subprocess.Popen() and os._execvpe() support bytes program name. Add
  os.supports_bytes_environ flag: True if the native OS type of the environment
  is bytes (eg. False on Windows).
................
  r81292 | victor.stinner | 2010-05-18 19:24:09 +0200 (Tue, 18 May 2010) | 2 lines
  
  Add versionadded (3.2) tag to os.supports_bytes_environ documentation
................
  r81299 | giampaolo.rodola | 2010-05-18 22:11:58 +0200 (Tue, 18 May 2010) | 9 lines
  
  Merged revisions 81294 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81294 | giampaolo.rodola | 2010-05-18 22:04:31 +0200 (mar, 18 mag 2010) | 1 line
    
    Fix issue #8573 (asyncore._strerror bug): fixed os.strerror typo; included NameError in the tuple of expected exception; added test case for asyncore._strerror.
  ........
................
  r81314 | victor.stinner | 2010-05-19 02:03:09 +0200 (Wed, 19 May 2010) | 2 lines
  
  Issue #6697: Fix a crash if a module attribute name contains a surrogate
................
  r81319 | victor.stinner | 2010-05-19 02:34:15 +0200 (Wed, 19 May 2010) | 2 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL
................
  r81320 | victor.stinner | 2010-05-19 02:54:06 +0200 (Wed, 19 May 2010) | 2 lines
  
  Issue #6697: Fix a crash if a keyword contains a surrogate
................
  r81321 | victor.stinner | 2010-05-19 03:06:22 +0200 (Wed, 19 May 2010) | 4 lines
  
  Issue #6697: Fix a crash if sys.stdin or sys.stdout encoding contain a surrogate
  
  This is *very* unlikely :-)
................
  r81322 | victor.stinner | 2010-05-19 03:17:01 +0200 (Wed, 19 May 2010) | 5 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in textio.c
  
  The bug may occurs if locale.getpreferredencoding() returns an encoding with a
  surrogate (very unlikely!).
................
  r81323 | victor.stinner | 2010-05-19 03:27:23 +0200 (Wed, 19 May 2010) | 4 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
  
  Strip also some trailing spaces
................
  r81324 | victor.stinner | 2010-05-19 03:42:46 +0200 (Wed, 19 May 2010) | 5 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in typeobject
  
  Type name and slots are already checked for surrogates somewhere else, but it's
  better to ensure that the result is not NULL.
................
  r81325 | victor.stinner | 2010-05-19 03:50:45 +0200 (Wed, 19 May 2010) | 4 lines
  
  Ooops, add missing ";" in my previous commit (r81324, typeobject.c)
  
  It's time to go to bed...
................


Added:
   python/branches/py3k-cdecimal/Lib/test/capath/
      - copied from r81325, /python/branches/py3k/Lib/test/capath/
Modified:
   python/branches/py3k-cdecimal/   (props changed)
   python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst
   python/branches/py3k-cdecimal/Doc/library/os.rst
   python/branches/py3k-cdecimal/Doc/library/ssl.rst
   python/branches/py3k-cdecimal/Doc/library/tarfile.rst
   python/branches/py3k-cdecimal/Doc/library/test.rst
   python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
   python/branches/py3k-cdecimal/Lib/asyncore.py
   python/branches/py3k-cdecimal/Lib/distutils/command/sdist.py
   python/branches/py3k-cdecimal/Lib/distutils/tests/test_sdist.py
   python/branches/py3k-cdecimal/Lib/importlib/_bootstrap.py
   python/branches/py3k-cdecimal/Lib/importlib/test/source/test_file_loader.py
   python/branches/py3k-cdecimal/Lib/os.py
   python/branches/py3k-cdecimal/Lib/ssl.py
   python/branches/py3k-cdecimal/Lib/subprocess.py
   python/branches/py3k-cdecimal/Lib/tarfile.py
   python/branches/py3k-cdecimal/Lib/test/list_tests.py
   python/branches/py3k-cdecimal/Lib/test/test_asyncore.py
   python/branches/py3k-cdecimal/Lib/test/test_getargs2.py
   python/branches/py3k-cdecimal/Lib/test/test_import.py
   python/branches/py3k-cdecimal/Lib/test/test_os.py
   python/branches/py3k-cdecimal/Lib/test/test_ssl.py
   python/branches/py3k-cdecimal/Lib/test/test_subprocess.py
   python/branches/py3k-cdecimal/Lib/test/test_sys.py
   python/branches/py3k-cdecimal/Lib/test/test_tarfile.py
   python/branches/py3k-cdecimal/Lib/test/testtar.tar
   python/branches/py3k-cdecimal/Lib/urllib/parse.py
   python/branches/py3k-cdecimal/Lib/urllib/request.py
   python/branches/py3k-cdecimal/Misc/NEWS
   python/branches/py3k-cdecimal/Modules/_cursesmodule.c
   python/branches/py3k-cdecimal/Modules/_io/textio.c
   python/branches/py3k-cdecimal/Modules/_sqlite/connection.c
   python/branches/py3k-cdecimal/Modules/_sqlite/cursor.c
   python/branches/py3k-cdecimal/Modules/_sqlite/row.c
   python/branches/py3k-cdecimal/Modules/_sqlite/statement.c
   python/branches/py3k-cdecimal/Modules/_ssl.c
   python/branches/py3k-cdecimal/Modules/_testcapimodule.c
   python/branches/py3k-cdecimal/Modules/main.c
   python/branches/py3k-cdecimal/Objects/moduleobject.c
   python/branches/py3k-cdecimal/Objects/object.c
   python/branches/py3k-cdecimal/Objects/typeobject.c
   python/branches/py3k-cdecimal/Parser/asdl.py
   python/branches/py3k-cdecimal/Parser/printgrammar.c
   python/branches/py3k-cdecimal/Python/bltinmodule.c
   python/branches/py3k-cdecimal/Python/getargs.c
   python/branches/py3k-cdecimal/Python/graminit.c
   python/branches/py3k-cdecimal/Python/pythonrun.c

Modified: python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/distutils/sourcedist.rst	Wed May 19 17:30:16 2010
@@ -137,20 +137,12 @@
 :option:`--no-defaults` and :option:`--no-prune` to disable the standard
 "include" and "exclude" sets.
 
-Second, you might want to force the manifest to be regenerated---for example, if
-you have added or removed files or directories that match an existing pattern in
-the manifest template, you should regenerate the manifest::
-
-   python setup.py sdist --force-manifest
-
-Or, you might just want to (re)generate the manifest, but not create a source
-distribution::
+Second, you might just want to (re)generate the manifest, but not create a
+source distribution::
 
    python setup.py sdist --manifest-only
 
-:option:`--manifest-only` implies :option:`--force-manifest`. :option:`-o` is a
-shortcut for :option:`--manifest-only`, and :option:`-f` for
-:option:`--force-manifest`.
+:option:`-o` is a sortcut for :option:`--manifest-only`.
 
 .. _manifest_template:
 

Modified: python/branches/py3k-cdecimal/Doc/library/os.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/os.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/os.rst	Wed May 19 17:30:16 2010
@@ -142,7 +142,8 @@
    synchronized (modify :data:`environb` updates :data:`environ`, and vice
    versa).
 
-   Availability: Unix.
+   :data:`environb` is only available if :data:`supports_bytes_environ` is
+   True.
 
    .. versionadded:: 3.2
 
@@ -457,6 +458,14 @@
    Availability: Unix, Windows.
 
 
+.. data:: supports_bytes_environ
+
+   True if the native OS type of the environment is bytes (eg. False on
+   Windows).
+
+   .. versionadded:: 3.2
+
+
 .. function:: umask(mask)
 
    Set the current numeric umask and return the previous umask.

Modified: python/branches/py3k-cdecimal/Doc/library/ssl.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/ssl.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/ssl.rst	Wed May 19 17:30:16 2010
@@ -36,6 +36,11 @@
 connection, and a method, :meth:`cipher`, to retrieve the cipher being used for
 the secure connection.
 
+For more sophisticated applications, the :class:`ssl.SSLContext` class
+helps manage settings and certificates, which can then be inherited
+by SSL sockets created through the :meth:`SSLContext.wrap_socket` method.
+
+
 Functions, Constants, and Exceptions
 ------------------------------------
 
@@ -64,19 +69,6 @@
    connection.  See the discussion of :ref:`ssl-certificates` for more
    information on how the certificate is stored in the ``certfile``.
 
-   Often the private key is stored in the same file as the certificate; in this
-   case, only the ``certfile`` parameter need be passed.  If the private key is
-   stored in a separate file, both parameters must be used.  If the private key
-   is stored in the ``certfile``, it should come before the first certificate in
-   the certificate chain::
-
-      -----BEGIN RSA PRIVATE KEY-----
-      ... (private key in base64 encoding) ...
-      -----END RSA PRIVATE KEY-----
-      -----BEGIN CERTIFICATE-----
-      ... (certificate in base64 PEM encoding) ...
-      -----END CERTIFICATE-----
-
    The parameter ``server_side`` is a boolean which identifies whether
    server-side or client-side behavior is desired from this socket.
 
@@ -208,29 +200,45 @@
 
 .. data:: CERT_NONE
 
-   Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when no
-   certificates will be required or validated from the other side of the socket
-   connection.
+   Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs``
+   parameter to :func:`wrap_socket`.  In this mode (the default), no
+   certificates will be required from the other side of the socket connection.
+   If a certificate is received from the other end, no attempt to validate it
+   is made.
+
+   See the discussion of :ref:`ssl-security` below.
 
 .. data:: CERT_OPTIONAL
 
-   Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when no
-   certificates will be required from the other side of the socket connection,
-   but if they are provided, will be validated.  Note that use of this setting
-   requires a valid certificate validation file also be passed as a value of the
-   ``ca_certs`` parameter.
+   Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs``
+   parameter to :func:`wrap_socket`.  In this mode no certificates will be
+   required from the other side of the socket connection; but if they
+   are provided, validation will be attempted and an :class:`SSLError`
+   will be raised on failure.
+
+   Use of this setting requires a valid set of CA certificates to
+   be passed, either to :meth:`SSLContext.load_verify_locations` or as a
+   value of the ``ca_certs`` parameter to :func:`wrap_socket`.
 
 .. data:: CERT_REQUIRED
 
-   Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when
-   certificates will be required from the other side of the socket connection.
-   Note that use of this setting requires a valid certificate validation file
-   also be passed as a value of the ``ca_certs`` parameter.
+   Possible value for :attr:`SSLContext.verify_mode`, or the ``cert_reqs``
+   parameter to :func:`wrap_socket`.  In this mode, certificates are
+   required from the other side of the socket connection; an :class:`SSLError`
+   will be raised if no certificate is provided, or if its validation fails.
+
+   Use of this setting requires a valid set of CA certificates to
+   be passed, either to :meth:`SSLContext.load_verify_locations` or as a
+   value of the ``ca_certs`` parameter to :func:`wrap_socket`.
 
 .. data:: PROTOCOL_SSLv2
 
    Selects SSL version 2 as the channel encryption protocol.
 
+   .. warning::
+
+      SSL version 2 is insecure.  Its use is highly discouraged.
+
 .. data:: PROTOCOL_SSLv23
 
    Selects SSL version 2 or 3 as the channel encryption protocol.  This is a
@@ -280,8 +288,8 @@
    .. versionadded:: 3.2
 
 
-SSLSocket Objects
------------------
+SSL Sockets
+-----------
 
 .. method:: SSLSocket.read(nbytes=1024, buffer=None)
 
@@ -367,6 +375,83 @@
    returned socket should always be used for further communication with the
    other side of the connection, rather than the original socket.
 
+
+SSL Contexts
+------------
+
+.. class:: SSLContext(protocol)
+
+   An object holding various data longer-lived than single SSL connections,
+   such as SSL configuration options, certificate(s) and private key(s).
+   You must pass *protocol* which must be one of the ``PROTOCOL_*`` constants
+   defined in this module.  :data:`PROTOCOL_SSLv23` is recommended for
+   maximum interoperability.
+
+:class:`SSLContext` objects have the following methods and attributes:
+
+.. method:: SSLContext.load_cert_chain(certfile, keyfile=None)
+
+   Load a private key and the corresponding certificate.  The *certfile*
+   string must be the path to a single file in PEM format containing the
+   certificate as well as any number of CA certificates needed to establish
+   the certificate's authenticity.  The *keyfile* string, if present, must
+   point to a file containing the private key in.  Otherwise the private
+   key will be taken from *certfile* as well.  See the discussion of
+   :ref:`ssl-certificates` for more information on how the certificate
+   is stored in the *certfile*.
+
+   An :class:`SSLError` is raised if the private key doesn't
+   match with the certificate.
+
+.. method:: SSLContext.load_verify_locations(cafile=None, capath=None)
+
+   Load a set of "certification authority" (CA) certificates used to validate
+   other peers' certificates when :data:`verify_mode` is other than
+   :data:`CERT_NONE`.  At least one of *cafile* or *capath* must be specified.
+
+   The *cafile* string, if present, is the path to a file of concatenated
+   CA certificates in PEM format. See the discussion of
+   :ref:`ssl-certificates` for more information about how to arrange the
+   certificates in this file.
+
+   The *capath* string, if present, is
+   the path to a directory containing several CA certificates in PEM format,
+   following an `OpenSSL specific layout
+   <http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html>`_.
+
+.. method:: SSLContext.set_ciphers(ciphers)
+
+   Set the available ciphers for sockets created with this context.
+   It should be a string in the `OpenSSL cipher list format
+   <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT>`_.
+   If no cipher can be selected (because compile-time options or other
+   configuration forbids use of all the specified ciphers), an
+   :class:`SSLError` will be raised.
+
+   .. note::
+      when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
+      give the currently selected cipher.
+
+.. method:: SSLContext.wrap_socket(sock, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True)
+
+   Wrap an existing Python socket *sock* and return an :class:`SSLSocket`
+   object.  The SSL socket is tied to the context, its settings and
+   certificates.  The parameters *server_side*, *do_handshake_on_connect*
+   and *suppress_ragged_eofs* have the same meaning as in the top-level
+   :func:`wrap_socket` function.
+
+.. attribute:: SSLContext.protocol
+
+   The protocol version chosen when constructing the context.  This attribute
+   is read-only.
+
+.. attribute:: SSLContext.verify_mode
+
+   Whether to try to verify other peers' certificates and how to behave
+   if verification fails.  This attribute must be one of
+   :data:`CERT_NONE`, :data:`CERT_OPTIONAL` or :data:`CERT_REQUIRED`.
+
+
 .. index:: single: certificates
 
 .. index:: single: X509 certificate
@@ -412,6 +497,9 @@
       ... (certificate in base64 PEM encoding) ...
       -----END CERTIFICATE-----
 
+Certificate chains
+^^^^^^^^^^^^^^^^^^
+
 The Python files which contain certificates can contain a sequence of
 certificates, sometimes called a *certificate chain*.  This chain should start
 with the specific certificate for the principal who "is" the client or server,
@@ -435,6 +523,9 @@
       ... (the root certificate for the CA's issuer)...
       -----END CERTIFICATE-----
 
+CA certificates
+^^^^^^^^^^^^^^^
+
 If you are going to require validation of the other side of the connection's
 certificate, you need to provide a "CA certs" file, filled with the certificate
 chains for each issuer you are willing to trust.  Again, this file just contains
@@ -454,6 +545,25 @@
 certificate to a root certificate.  See :rfc:`4158` for more discussion of the
 way in which certification chains can be built.
 
+Combined key and certificate
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Often the private key is stored in the same file as the certificate; in this
+case, only the ``certfile`` parameter to :meth:`SSLContext.load_cert_chain`
+and :func:`wrap_socket` needs to be passed.  If the private key is stored
+with the certificate, it should come before the first certificate in
+the certificate chain::
+
+   -----BEGIN RSA PRIVATE KEY-----
+   ... (private key in base64 encoding) ...
+   -----END RSA PRIVATE KEY-----
+   -----BEGIN CERTIFICATE-----
+   ... (certificate in base64 PEM encoding) ...
+   -----END CERTIFICATE-----
+
+Self-signed certificates
+^^^^^^^^^^^^^^^^^^^^^^^^
+
 If you are going to create a server that provides SSL-encrypted connection
 services, you will need to acquire a certificate for that service.  There are
 many ways of acquiring appropriate certificates, such as buying one from a
@@ -526,8 +636,7 @@
    print(pprint.pformat(ssl_sock.getpeercert()))
 
    # Set a simple HTTP request -- use http.client in actual code.
-   ssl_sock.write("""GET / HTTP/1.0\r
-   Host: www.verisign.com\r\n\r\n""")
+   ssl_sock.write(b"GET / HTTP/1.0\r\nHost: www.verisign.com\r\n\r\n")
 
    # Read a chunk of data.  Will not necessarily
    # read all the data returned by the server.
@@ -557,39 +666,91 @@
 
 which is a fairly poorly-formed ``subject`` field.
 
+This other example first creates an SSL context, instructs it to verify
+certificates sent by peers, and feeds it a set of recognized certificate
+authorities (CA)::
+
+   >>> context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+   >>> context.verify_mode = ssl.CERT_OPTIONAL
+   >>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")
+
+(it is assumed your operating system places a bundle of all CA certificates
+in ``/etc/ssl/certs/ca-bundle.crt``; if not, you'll get an error and have
+to adjust the location)
+
+When you use the context to connect to a server, :const:`CERT_OPTIONAL`
+validates the server certificate: it ensures that the server certificate
+was signed with one of the CA certificates, and checks the signature for
+correctness::
+
+   >>> conn = context.wrap_socket(socket.socket(socket.AF_INET))
+   >>> conn.connect(("linuxfr.org", 443))
+
+You should then fetch the certificate and check its fields for conformity.
+Here, the ``commonName`` field in the ``subject`` matches the desired HTTPS
+host ``linuxfr.org``::
+
+   >>> pprint.pprint(conn.getpeercert())
+   {'notAfter': 'Jun 26 21:41:46 2011 GMT',
+    'subject': ((('commonName', 'linuxfr.org'),),),
+    'subjectAltName': (('DNS', 'linuxfr.org'), ('othername', '<unsupported>'))}
+
+Now that you are assured of its authenticity, you can proceed to talk with
+the server::
+
+   >>> conn.write(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n")
+   38
+   >>> pprint.pprint(conn.read().split(b"\r\n"))
+   [b'HTTP/1.1 302 Found',
+    b'Date: Sun, 16 May 2010 13:43:28 GMT',
+    b'Server: Apache/2.2',
+    b'Location: https://linuxfr.org/pub/',
+    b'Vary: Accept-Encoding',
+    b'Connection: close',
+    b'Content-Type: text/html; charset=iso-8859-1',
+    b'',
+    b'']
+
+
+See the discussion of :ref:`ssl-security` below.
+
+
 Server-side operation
 ^^^^^^^^^^^^^^^^^^^^^
 
-For server operation, typically you'd need to have a server certificate, and
-private key, each in a file.  You'd open a socket, bind it to a port, call
-:meth:`listen` on it, then start waiting for clients to connect::
+For server operation, typically you'll need to have a server certificate, and
+private key, each in a file.  You'll first create a context holding the key
+and the certificate, so that clients can check your authenticity.  Then
+you'll open a socket, bind it to a port, call :meth:`listen` on it, and start
+waiting for clients to connect::
 
    import socket, ssl
 
+   context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+   context.load_cert_chain(certfile="mycertfile", keyfile="mykeyfile")
+
    bindsocket = socket.socket()
    bindsocket.bind(('myaddr.mydomain.com', 10023))
    bindsocket.listen(5)
 
-When one did, you'd call :meth:`accept` on the socket to get the new socket from
-the other end, and use :func:`wrap_socket` to create a server-side SSL context
-for it::
+When a client connects, you'll call :meth:`accept` on the socket to get the
+new socket from the other end, and use the context's :meth:`SSLContext.wrap_socket`
+method to create a server-side SSL socket for the connection::
 
    while True:
       newsocket, fromaddr = bindsocket.accept()
-      connstream = ssl.wrap_socket(newsocket,
-                                   server_side=True,
-                                   certfile="mycertfile",
-                                   keyfile="mykeyfile",
-                                   ssl_version=ssl.PROTOCOL_TLSv1)
-      deal_with_client(connstream)
+      connstream = context.wrap_socket(newsocket, server_side=True)
+      try:
+         deal_with_client(connstream)
+      finally:
+         connstream.close()
 
-Then you'd read data from the ``connstream`` and do something with it till you
+Then you'll read data from the ``connstream`` and do something with it till you
 are finished with the client (or the client is finished with you)::
 
    def deal_with_client(connstream):
-
       data = connstream.read()
-      # null data means the client is finished with us
+      # empty data means the client is finished with us
       while data:
          if not do_something(connstream, data):
             # we'll assume do_something returns False
@@ -597,9 +758,41 @@
             break
          data = connstream.read()
       # finished with client
-      connstream.close()
 
-And go back to listening for new client connections.
+And go back to listening for new client connections (of course, a real server
+would probably handle each client connection in a separate thread, or put
+the sockets in non-blocking mode and use an event loop).
+
+
+.. _ssl-security:
+
+Security considerations
+-----------------------
+
+Verifying certificates
+^^^^^^^^^^^^^^^^^^^^^^
+
+:const:`CERT_NONE` is the default.  Since it does not authenticate the other
+peer, it can be insecure, especially in client mode where most of time you
+would like to ensure the authenticity of the server you're talking to.
+Therefore, when in client mode, it is highly recommended to use
+:const:`CERT_REQUIRED`.  However, it is in itself not sufficient; you also
+have to check that the server certificate (obtained with
+:meth:`SSLSocket.getpeercert`) matches the desired service.  The exact way
+of doing so depends on the higher-level protocol used; for example, with
+HTTPS, you'll check that the host name in the URL matches either the
+``commonName`` field in the ``subjectName``, or one of the ``DNS`` fields
+in the ``subjectAltName``.
+
+In server mode, if you want to authenticate your clients using the SSL layer
+(rather than using a higher-level authentication mechanism), you'll also have
+to specify :const:`CERT_REQUIRED` and similarly check the client certificate.
+
+   .. note::
+
+      In client mode, :const:`CERT_OPTIONAL` and :const:`CERT_REQUIRED` are
+      equivalent unless anonymous ciphers are enabled (they are disabled
+      by default).
 
 
 .. seealso::

Modified: python/branches/py3k-cdecimal/Doc/library/tarfile.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/tarfile.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/tarfile.rst	Wed May 19 17:30:16 2010
@@ -711,6 +711,8 @@
 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*. Storing surrogate characters is not
-possible and will raise a :exc:`UnicodeEncodeError`.
+In case of :const:`PAX_FORMAT` archives, *encoding* is generally not needed
+because all the metadata is stored using *UTF-8*. *encoding* is only used in
+the rare cases when binary pax headers are decoded or when strings with
+surrogate characters are stored.
+

Modified: python/branches/py3k-cdecimal/Doc/library/test.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/test.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/test.rst	Wed May 19 17:30:16 2010
@@ -340,7 +340,7 @@
 
 .. function:: captured_stdout()
 
-   This is a context manager than runs the :keyword:`with` statement body using
+   This is a context manager that runs the :keyword:`with` statement body using
    a :class:`StringIO.StringIO` object as sys.stdout.  That object can be
    retrieved using the ``as`` clause of the :keyword:`with` statement.
 

Modified: python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	Wed May 19 17:30:16 2010
@@ -126,26 +126,6 @@
    of the data it has downloaded, and just returns it.  In this case you just have
    to assume that the download was successful.
 
-
-.. data:: _urlopener
-
-   The public functions :func:`urlopen` and :func:`urlretrieve` create an instance
-   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.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.request._urlopener = AppURLopener()
-
-
 .. function:: urlcleanup()
 
    Clear the cache that may have been built up by previous calls to

Modified: python/branches/py3k-cdecimal/Lib/asyncore.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/asyncore.py	(original)
+++ python/branches/py3k-cdecimal/Lib/asyncore.py	Wed May 19 17:30:16 2010
@@ -63,8 +63,8 @@
 
 def _strerror(err):
     try:
-        return strerror(err)
-    except (ValueError, OverflowError):
+        return os.strerror(err)
+    except (ValueError, OverflowError, NameError):
         if err in errorcode:
             return errorcode[err]
         return "Unknown error %s" %err

Modified: python/branches/py3k-cdecimal/Lib/distutils/command/sdist.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/command/sdist.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/command/sdist.py	Wed May 19 17:30:16 2010
@@ -63,7 +63,8 @@
          "just regenerate the manifest and then stop "
          "(implies --force-manifest)"),
         ('force-manifest', 'f',
-         "forcibly regenerate the manifest and carry on as usual"),
+         "forcibly regenerate the manifest and carry on as usual. "
+         "Deprecated: now the manifest is always regenerated."),
         ('formats=', None,
          "formats for source distribution (comma-separated list)"),
         ('keep-temp', 'k',
@@ -179,66 +180,34 @@
         distribution, and put it in 'self.filelist'.  This might involve
         reading the manifest template (and writing the manifest), or just
         reading the manifest, or just using the default file set -- it all
-        depends on the user's options and the state of the filesystem.
+        depends on the user's options.
         """
-        # If we have a manifest template, see if it's newer than the
-        # manifest; if so, we'll regenerate the manifest.
+        # new behavior:
+        # the file list is recalculated everytime because
+        # even if MANIFEST.in or setup.py are not changed
+        # the user might have added some files in the tree that
+        # need to be included.
+        #
+        #  This makes --force the default and only behavior.
         template_exists = os.path.isfile(self.template)
+        if not template_exists:
+            self.warn(("manifest template '%s' does not exist " +
+                        "(using default file list)") %
+                        self.template)
+        self.filelist.findall()
+
+        if self.use_defaults:
+            self.add_defaults()
+
         if template_exists:
-            template_newer = dep_util.newer(self.template, self.manifest)
+            self.read_template()
 
-        # The contents of the manifest file almost certainly depend on the
-        # setup script as well as the manifest template -- so if the setup
-        # script is newer than the manifest, we'll regenerate the manifest
-        # from the template.  (Well, not quite: if we already have a
-        # manifest, but there's no template -- which will happen if the
-        # developer elects to generate a manifest some other way -- then we
-        # can't regenerate the manifest, so we don't.)
-        self.debug_print("checking if %s newer than %s" %
-                         (self.distribution.script_name, self.manifest))
-        setup_newer = dep_util.newer(self.distribution.script_name,
-                                     self.manifest)
-
-        # cases:
-        #   1) no manifest, template exists: generate manifest
-        #      (covered by 2a: no manifest == template newer)
-        #   2) manifest & template exist:
-        #      2a) template or setup script newer than manifest:
-        #          regenerate manifest
-        #      2b) manifest newer than both:
-        #          do nothing (unless --force or --manifest-only)
-        #   3) manifest exists, no template:
-        #      do nothing (unless --force or --manifest-only)
-        #   4) no manifest, no template: generate w/ warning ("defaults only")
-
-        manifest_outofdate = (template_exists and
-                              (template_newer or setup_newer))
-        force_regen = self.force_manifest or self.manifest_only
-        manifest_exists = os.path.isfile(self.manifest)
-        neither_exists = (not template_exists and not manifest_exists)
-
-        # Regenerate the manifest if necessary (or if explicitly told to)
-        if manifest_outofdate or neither_exists or force_regen:
-            if not template_exists:
-                self.warn("manifest template '%s' does not exist "
-                          "(using default file list)"
-                          % self.template)
-            self.filelist.findall()
-
-            if self.use_defaults:
-                self.add_defaults()
-            if template_exists:
-                self.read_template()
-            if self.prune:
-                self.prune_file_list()
-
-            self.filelist.sort()
-            self.filelist.remove_duplicates()
-            self.write_manifest()
+        if self.prune:
+            self.prune_file_list()
 
-        # Don't regenerate the manifest, just read it in.
-        else:
-            self.read_manifest()
+        self.filelist.sort()
+        self.filelist.remove_duplicates()
+        self.write_manifest()
 
     def add_defaults(self):
         """Add all the default files to self.filelist:

Modified: python/branches/py3k-cdecimal/Lib/distutils/tests/test_sdist.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/tests/test_sdist.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/tests/test_sdist.py	Wed May 19 17:30:16 2010
@@ -346,6 +346,47 @@
         finally:
             archive.close()
 
+    def test_get_file_list(self):
+        # make sure MANIFEST is recalculated
+        dist, cmd = self.get_cmd()
+
+        # filling data_files by pointing files in package_data
+        dist.package_data = {'somecode': ['*.txt']}
+        self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
+        cmd.ensure_finalized()
+        cmd.run()
+
+        f = open(cmd.manifest)
+        try:
+            manifest = [line.strip() for line in f.read().split('\n')
+                        if line.strip() != '']
+        finally:
+            f.close()
+
+        self.assertEquals(len(manifest), 4)
+
+        # adding a file
+        self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
+
+        # make sure build_py is reinitinialized, like a fresh run
+        build_py = dist.get_command_obj('build_py')
+        build_py.finalized = False
+        build_py.ensure_finalized()
+
+        cmd.run()
+
+        f = open(cmd.manifest)
+        try:
+            manifest2 = [line.strip() for line in f.read().split('\n')
+                         if line.strip() != '']
+        finally:
+            f.close()
+
+        # do we have the new file in MANIFEST ?
+        self.assertEquals(len(manifest2), 5)
+        self.assertIn('doc2.txt', manifest2[-1])
+
+
 def test_suite():
     return unittest.makeSuite(SDistTestCase)
 

Modified: python/branches/py3k-cdecimal/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/importlib/_bootstrap.py	(original)
+++ python/branches/py3k-cdecimal/Lib/importlib/_bootstrap.py	Wed May 19 17:30:16 2010
@@ -494,8 +494,16 @@
         if ext_type == imp.PY_COMPILED:
             # We don't really care what the extension on self._base_path is,
             # as long as it has exactly one dot.
-            bytecode_path = imp.cache_from_source(self._base_path + '.py')
-            return (bytecode_path if _path_exists(bytecode_path) else None)
+            source_path = self._base_path + '.py'
+            pycache_path = imp.cache_from_source(source_path)
+            legacy_path = self._base_path + '.pyc'
+            # The rule is: if the source file exists, then Python always uses
+            # the __pycache__/foo.<tag>.pyc file.  If the source file does not
+            # exist, then Python uses the legacy path.
+            pyc_path = (pycache_path
+                        if _path_exists(source_path)
+                        else legacy_path)
+            return (pyc_path if _path_exists(pyc_path) else None)
         return super()._find_path(ext_type)
 
     @_check_name

Modified: python/branches/py3k-cdecimal/Lib/importlib/test/source/test_file_loader.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/importlib/test/source/test_file_loader.py	(original)
+++ python/branches/py3k-cdecimal/Lib/importlib/test/source/test_file_loader.py	Wed May 19 17:30:16 2010
@@ -10,6 +10,8 @@
 import sys
 import unittest
 
+from test.support import make_legacy_pyc
+
 
 class SimpleTest(unittest.TestCase):
 
@@ -136,6 +138,7 @@
                 file.write(new_bc)
         if del_source:
             os.unlink(mapping[name])
+            make_legacy_pyc(mapping[name])
         return bytecode_path
 
     @source_util.writes_bytecode_files

Modified: python/branches/py3k-cdecimal/Lib/os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/os.py	Wed May 19 17:30:16 2010
@@ -355,7 +355,11 @@
         return
     last_exc = saved_exc = None
     saved_tb = None
-    for dir in get_exec_path(env):
+    path_list = get_exec_path(env)
+    if name != 'nt':
+        file = fsencode(file)
+        path_list = map(fsencode, path_list)
+    for dir in path_list:
         fullname = path.join(dir, file)
         try:
             exec_func(fullname, *argrest)
@@ -380,7 +384,30 @@
     """
     if env is None:
         env = environ
-    return env.get('PATH', defpath).split(pathsep)
+
+    try:
+        path_list = env.get('PATH')
+    except TypeError:
+        path_list = None
+
+    if supports_bytes_environ:
+        try:
+            path_listb = env[b'PATH']
+        except (KeyError, TypeError):
+            pass
+        else:
+            if path_list is not None:
+                raise ValueError(
+                    "env cannot contain 'PATH' and b'PATH' keys")
+            path_list = path_listb
+
+        if path_list is not None and isinstance(path_list, bytes):
+            path_list = path_list.decode(sys.getfilesystemencoding(),
+                                         'surrogateescape')
+
+    if path_list is None:
+        path_list = defpath
+    return path_list.split(pathsep)
 
 
 # Change environ to automatically call putenv(), unsetenv if they exist.
@@ -482,9 +509,11 @@
     The optional second argument can specify an alternate default.
     key, default and the result are str."""
     return environ.get(key, default)
-__all__.append("getenv")
 
-if name not in ('os2', 'nt'):
+supports_bytes_environ = name not in ('os2', 'nt')
+__all__.extend(("getenv", "supports_bytes_environ"))
+
+if supports_bytes_environ:
     def _check_bytes(value):
         if not isinstance(value, bytes):
             raise TypeError("bytes expected, not %s" % type(value).__name__)

Modified: python/branches/py3k-cdecimal/Lib/ssl.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/ssl.py	(original)
+++ python/branches/py3k-cdecimal/Lib/ssl.py	Wed May 19 17:30:16 2010
@@ -59,7 +59,7 @@
 import _ssl             # if we can't import it, let the error propagate
 
 from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
-from _ssl import SSLError
+from _ssl import _SSLContext, SSLError
 from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
 from _ssl import (PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23,
                   PROTOCOL_TLSv1)
@@ -84,8 +84,29 @@
 import traceback
 import errno
 
-class SSLSocket(socket):
 
+class SSLContext(_SSLContext):
+    """An SSLContext holds various SSL-related configuration options and
+    data, such as certificates and possibly a private key."""
+
+    __slots__ = ('protocol',)
+
+    def __new__(cls, protocol, *args, **kwargs):
+        return _SSLContext.__new__(cls, protocol)
+
+    def __init__(self, protocol):
+        self.protocol = protocol
+
+    def wrap_socket(self, sock, server_side=False,
+                    do_handshake_on_connect=True,
+                    suppress_ragged_eofs=True):
+        return SSLSocket(sock=sock, server_side=server_side,
+                         do_handshake_on_connect=do_handshake_on_connect,
+                         suppress_ragged_eofs=suppress_ragged_eofs,
+                         _context=self)
+
+
+class SSLSocket(socket):
     """This class implements a subtype of socket.socket that wraps
     the underlying OS socket in an SSL context when necessary, and
     provides read and write methods over that channel."""
@@ -95,8 +116,31 @@
                  ssl_version=PROTOCOL_SSLv23, ca_certs=None,
                  do_handshake_on_connect=True,
                  family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
-                 suppress_ragged_eofs=True, ciphers=None):
+                 suppress_ragged_eofs=True, ciphers=None,
+                 _context=None):
+
+        if _context:
+            self.context = _context
+        else:
+            if certfile and not keyfile:
+                keyfile = certfile
+            self.context = SSLContext(ssl_version)
+            self.context.verify_mode = cert_reqs
+            if ca_certs:
+                self.context.load_verify_locations(ca_certs)
+            if certfile:
+                self.context.load_cert_chain(certfile, keyfile)
+            if ciphers:
+                self.context.set_ciphers(ciphers)
+            self.keyfile = keyfile
+            self.certfile = certfile
+            self.cert_reqs = cert_reqs
+            self.ssl_version = ssl_version
+            self.ca_certs = ca_certs
+            self.ciphers = ciphers
 
+        self.do_handshake_on_connect = do_handshake_on_connect
+        self.suppress_ragged_eofs = suppress_ragged_eofs
         connected = False
         if sock is not None:
             socket.__init__(self,
@@ -119,18 +163,12 @@
         else:
             socket.__init__(self, family=family, type=type, proto=proto)
 
-        if certfile and not keyfile:
-            keyfile = certfile
-
         self._closed = False
         self._sslobj = None
         if connected:
             # create the SSL object
             try:
-                self._sslobj = _ssl.sslwrap(self, server_side,
-                                            keyfile, certfile,
-                                            cert_reqs, ssl_version, ca_certs,
-                                            ciphers)
+                self._sslobj = self.context._wrap_socket(self, server_side)
                 if do_handshake_on_connect:
                     timeout = self.gettimeout()
                     if timeout == 0.0:
@@ -142,15 +180,6 @@
                 self.close()
                 raise x
 
-        self.keyfile = keyfile
-        self.certfile = certfile
-        self.cert_reqs = cert_reqs
-        self.ssl_version = ssl_version
-        self.ca_certs = ca_certs
-        self.ciphers = ciphers
-        self.do_handshake_on_connect = do_handshake_on_connect
-        self.suppress_ragged_eofs = suppress_ragged_eofs
-
     def dup(self):
         raise NotImplemented("Can't dup() %s instances" %
                              self.__class__.__name__)
@@ -331,9 +360,7 @@
         if self._sslobj:
             raise ValueError("attempt to connect already-connected SSLSocket!")
         socket.connect(self, addr)
-        self._sslobj = _ssl.sslwrap(self, False, self.keyfile, self.certfile,
-                                    self.cert_reqs, self.ssl_version,
-                                    self.ca_certs, self.ciphers)
+        self._sslobj = self.context._wrap_socket(self, False)
         try:
             if self.do_handshake_on_connect:
                 self.do_handshake()

Modified: python/branches/py3k-cdecimal/Lib/subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/subprocess.py	Wed May 19 17:30:16 2010
@@ -1096,15 +1096,14 @@
                                         for k, v in env.items()]
                         else:
                             env_list = None  # Use execv instead of execve.
+                        executable = os.fsencode(executable)
                         if os.path.dirname(executable):
-                            executable_list = (os.fsencode(executable),)
+                            executable_list = (executable,)
                         else:
                             # This matches the behavior of os._execvpe().
-                            path_list = os.get_exec_path(env)
-                            executable_list = (os.path.join(dir, executable)
-                                               for dir in path_list)
-                            executable_list = tuple(os.fsencode(exe)
-                                                    for exe in executable_list)
+                            executable_list = tuple(
+                                os.path.join(os.fsencode(dir), executable)
+                                for dir in os.get_exec_path(env))
                         self.pid = _posixsubprocess.fork_exec(
                                 args, executable_list,
                                 close_fds, cwd, env_list,

Modified: python/branches/py3k-cdecimal/Lib/tarfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tarfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tarfile.py	Wed May 19 17:30:16 2010
@@ -118,6 +118,9 @@
 PAX_FIELDS = ("path", "linkpath", "size", "mtime",
               "uid", "gid", "uname", "gname")
 
+# Fields from a pax header that are affected by hdrcharset.
+PAX_NAME_FIELDS = {"path", "linkpath", "uname", "gname"}
+
 # Fields in a pax header that are numbers, all other fields
 # are treated as strings.
 PAX_NUMBER_FIELDS = {
@@ -988,7 +991,7 @@
         elif format == GNU_FORMAT:
             return self.create_gnu_header(info, encoding, errors)
         elif format == PAX_FORMAT:
-            return self.create_pax_header(info)
+            return self.create_pax_header(info, encoding)
         else:
             raise ValueError("invalid format")
 
@@ -1019,7 +1022,7 @@
 
         return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
 
-    def create_pax_header(self, info):
+    def create_pax_header(self, info, encoding):
         """Return the object as a ustar header block. If it cannot be
            represented this way, prepend a pax extended header sequence
            with supplement information.
@@ -1062,7 +1065,7 @@
 
         # Create a pax extended header if necessary.
         if pax_headers:
-            buf = self._create_pax_generic_header(pax_headers, XHDTYPE)
+            buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
         else:
             buf = b""
 
@@ -1072,7 +1075,7 @@
     def create_pax_global_header(cls, pax_headers):
         """Return the object as a pax global header block sequence.
         """
-        return cls._create_pax_generic_header(pax_headers, XGLTYPE)
+        return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf8")
 
     def _posix_split_name(self, name):
         """Split a name longer than 100 chars into a prefix
@@ -1145,15 +1148,35 @@
                 cls._create_payload(name)
 
     @classmethod
-    def _create_pax_generic_header(cls, pax_headers, type):
-        """Return a POSIX.1-2001 extended or global header sequence
+    def _create_pax_generic_header(cls, pax_headers, type, encoding):
+        """Return a POSIX.1-2008 extended or global header sequence
            that contains a list of keyword, value pairs. The values
            must be strings.
         """
+        # Check if one of the fields contains surrogate characters and thereby
+        # forces hdrcharset=BINARY, see _proc_pax() for more information.
+        binary = False
+        for keyword, value in pax_headers.items():
+            try:
+                value.encode("utf8", "strict")
+            except UnicodeEncodeError:
+                binary = True
+                break
+
         records = b""
+        if binary:
+            # Put the hdrcharset field at the beginning of the header.
+            records += b"21 hdrcharset=BINARY\n"
+
         for keyword, value in pax_headers.items():
             keyword = keyword.encode("utf8")
-            value = value.encode("utf8")
+            if binary:
+                # Try to restore the original byte representation of `value'.
+                # Needless to say, that the encoding must match the string.
+                value = value.encode(encoding, "surrogateescape")
+            else:
+                value = value.encode("utf8")
+
             l = len(keyword) + len(value) + 3   # ' ' + '=' + '\n'
             n = p = 0
             while True:
@@ -1354,7 +1377,7 @@
 
     def _proc_pax(self, tarfile):
         """Process an extended or global header as described in
-           POSIX.1-2001.
+           POSIX.1-2008.
         """
         # Read the header information.
         buf = tarfile.fileobj.read(self._block(self.size))
@@ -1367,6 +1390,24 @@
         else:
             pax_headers = tarfile.pax_headers.copy()
 
+        # Check if the pax header contains a hdrcharset field. This tells us
+        # the encoding of the path, linkpath, uname and gname fields. Normally,
+        # these fields are UTF-8 encoded but since POSIX.1-2008 tar
+        # implementations are allowed to store them as raw binary strings if
+        # the translation to UTF-8 fails.
+        match = re.search(br"\d+ hdrcharset=([^\n]+)\n", buf)
+        if match is not None:
+            pax_headers["hdrcharset"] = match.group(1).decode("utf8")
+
+        # For the time being, we don't care about anything other than "BINARY".
+        # The only other value that is currently allowed by the standard is
+        # "ISO-IR 10646 2000 UTF-8" in other words UTF-8.
+        hdrcharset = pax_headers.get("hdrcharset")
+        if hdrcharset == "BINARY":
+            encoding = tarfile.encoding
+        else:
+            encoding = "utf8"
+
         # Parse pax header information. A record looks like that:
         # "%d %s=%s\n" % (length, keyword, value). length is the size
         # of the complete record including the length field itself and
@@ -1382,8 +1423,21 @@
             length = int(length)
             value = buf[match.end(2) + 1:match.start(1) + length - 1]
 
-            keyword = keyword.decode("utf8")
-            value = value.decode("utf8")
+            # Normally, we could just use "utf8" as the encoding and "strict"
+            # as the error handler, but we better not take the risk. For
+            # example, GNU tar <= 1.23 is known to store filenames it cannot
+            # translate to UTF-8 as raw strings (unfortunately without a
+            # hdrcharset=BINARY header).
+            # We first try the strict standard encoding, and if that fails we
+            # fall back on the user's encoding and error handler.
+            keyword = self._decode_pax_field(keyword, "utf8", "utf8",
+                    tarfile.errors)
+            if keyword in PAX_NAME_FIELDS:
+                value = self._decode_pax_field(value, encoding, tarfile.encoding,
+                        tarfile.errors)
+            else:
+                value = self._decode_pax_field(value, "utf8", "utf8",
+                        tarfile.errors)
 
             pax_headers[keyword] = value
             pos += length
@@ -1431,6 +1485,14 @@
 
         self.pax_headers = pax_headers.copy()
 
+    def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
+        """Decode a single field from a pax record.
+        """
+        try:
+            return value.decode(encoding, "strict")
+        except UnicodeDecodeError:
+            return value.decode(fallback_encoding, fallback_errors)
+
     def _block(self, count):
         """Round up a byte count by BLOCKSIZE and return it,
            e.g. _block(834) => 1024.

Modified: python/branches/py3k-cdecimal/Lib/test/list_tests.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/list_tests.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/list_tests.py	Wed May 19 17:30:16 2010
@@ -66,13 +66,11 @@
         d.append(d)
         d.append(400)
         try:
-            fo = open(support.TESTFN, "w")
-            fo.write(str(d))
-            fo.close()
-            fo = open(support.TESTFN, "r")
-            self.assertEqual(fo.read(), repr(d))
+            with open(support.TESTFN, "w") as fo:
+                fo.write(str(d))
+            with open(support.TESTFN, "r") as fo:
+                self.assertEqual(fo.read(), repr(d))
         finally:
-            fo.close()
             os.remove(support.TESTFN)
 
     def test_set_subscript(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_asyncore.py	Wed May 19 17:30:16 2010
@@ -6,6 +6,7 @@
 import sys
 import time
 import warnings
+import errno
 
 from test import support
 from test.support import TESTFN, run_unittest, unlink
@@ -324,6 +325,14 @@
             self.assertTrue(len(w) == 1)
             self.assertTrue(issubclass(w[0].category, DeprecationWarning))
 
+    def test_strerror(self):
+        # refers to bug #8573
+        err = asyncore._strerror(errno.EPERM)
+        if hasattr(os, 'strerror'):
+            self.assertEqual(err, os.strerror(errno.EPERM))
+        err = asyncore._strerror(-1)
+        self.assertTrue("unknown error" in err.lower())
+
 
 class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
     def readable(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_getargs2.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_getargs2.py	Wed May 19 17:30:16 2010
@@ -252,24 +252,28 @@
             getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), 10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_mixed_args(self):
         # positional and keyword args
         self.assertEquals(
             getargs_keywords((1,2), 3, (4,(5,6)), arg4=(7,8,9), arg5=10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_keyword_args(self):
         # all keywords
         self.assertEquals(
             getargs_keywords(arg1=(1,2), arg2=3, arg3=(4,(5,6)), arg4=(7,8,9), arg5=10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_optional_args(self):
         # missing optional keyword args, skipping tuples
         self.assertEquals(
             getargs_keywords(arg1=(1,2), arg2=3, arg5=10),
             (1, 2, 3, -1, -1, -1, -1, -1, -1, 10)
             )
+
     def test_required_args(self):
         # required arg missing
         try:
@@ -278,6 +282,7 @@
             self.assertEquals(str(err), "Required argument 'arg2' (pos 2) not found")
         else:
             self.fail('TypeError should have been raised')
+
     def test_too_many_args(self):
         try:
             getargs_keywords((1,2),3,(4,(5,6)),(7,8,9),10,111)
@@ -285,6 +290,7 @@
             self.assertEquals(str(err), "function takes at most 5 arguments (6 given)")
         else:
             self.fail('TypeError should have been raised')
+
     def test_invalid_keyword(self):
         # extraneous keyword arg
         try:
@@ -294,6 +300,14 @@
         else:
             self.fail('TypeError should have been raised')
 
+    def test_surrogate_keyword(self):
+        try:
+            getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), **{'\uDC80': 10})
+        except TypeError as err:
+            self.assertEquals(str(err), "'\udc80' is an invalid keyword argument for this function")
+        else:
+            self.fail('TypeError should have been raised')
+
 def test_main():
     tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase]
     try:

Modified: python/branches/py3k-cdecimal/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_import.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_import.py	Wed May 19 17:30:16 2010
@@ -153,23 +153,23 @@
                 f.write('"",\n')
             f.write(']')
 
-        # Compile & remove .py file, we only need .pyc (or .pyo), but that
-        # must be relocated to the PEP 3147 bytecode-only location.
-        with open(filename, 'r') as f:
-            py_compile.compile(filename)
+        # Compile & remove .py file; we only need .pyc (or .pyo).
+        # Bytecode must be relocated from the PEP 3147 bytecode-only location.
+        py_compile.compile(filename)
         unlink(filename)
         make_legacy_pyc(filename)
 
         # Need to be able to load from current dir.
         sys.path.append('')
 
-        # This used to crash.
-        exec('import ' + module)
-
-        # Cleanup.
-        del sys.path[-1]
-        unlink(filename + 'c')
-        unlink(filename + 'o')
+        try:
+            # This used to crash.
+            exec('import ' + module)
+        finally:
+            # Cleanup.
+            del sys.path[-1]
+            unlink(filename + 'c')
+            unlink(filename + 'o')
 
     def test_failing_import_sticks(self):
         source = TESTFN + ".py"

Modified: python/branches/py3k-cdecimal/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_os.py	Wed May 19 17:30:16 2010
@@ -12,6 +12,7 @@
 import time
 import shutil
 from test import support
+import contextlib
 
 # Detect whether we're on a Linux system that uses the (now outdated
 # and unmaintained) linuxthreads threading library.  There's an issue
@@ -369,7 +370,7 @@
 
     def setUp(self):
         self.__save = dict(os.environ)
-        if os.name not in ('os2', 'nt'):
+        if os.supports_bytes_environ:
             self.__saveb = dict(os.environb)
         for key, value in self._reference().items():
             os.environ[key] = value
@@ -377,7 +378,7 @@
     def tearDown(self):
         os.environ.clear()
         os.environ.update(self.__save)
-        if os.name not in ('os2', 'nt'):
+        if os.supports_bytes_environ:
             os.environb.clear()
             os.environb.update(self.__saveb)
 
@@ -444,7 +445,21 @@
         # Supplied PATH environment variable
         self.assertSequenceEqual(test_path, os.get_exec_path(test_env))
 
-    @unittest.skipIf(sys.platform == "win32", "POSIX specific test")
+        if os.supports_bytes_environ:
+            # env cannot contain 'PATH' and b'PATH' keys
+            self.assertRaises(ValueError,
+                os.get_exec_path, {'PATH': '1', b'PATH': b'2'})
+
+            # bytes key and/or value
+            self.assertSequenceEqual(os.get_exec_path({b'PATH': b'abc'}),
+                ['abc'])
+            self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}),
+                ['abc'])
+            self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}),
+                ['abc'])
+
+    @unittest.skipUnless(os.supports_bytes_environ,
+                         "os.environb required for this test.")
     def test_environb(self):
         # os.environ -> os.environb
         value = 'euro\u20ac'
@@ -623,6 +638,39 @@
         except NotImplementedError:
             pass
 
+ at contextlib.contextmanager
+def _execvpe_mockup(defpath=None):
+    """
+    Stubs out execv and execve functions when used as context manager.
+    Records exec calls. The mock execv and execve functions always raise an
+    exception as they would normally never return.
+    """
+    # A list of tuples containing (function name, first arg, args)
+    # of calls to execv or execve that have been made.
+    calls = []
+
+    def mock_execv(name, *args):
+        calls.append(('execv', name, args))
+        raise RuntimeError("execv called")
+
+    def mock_execve(name, *args):
+        calls.append(('execve', name, args))
+        raise OSError(errno.ENOTDIR, "execve called")
+
+    try:
+        orig_execv = os.execv
+        orig_execve = os.execve
+        orig_defpath = os.defpath
+        os.execv = mock_execv
+        os.execve = mock_execve
+        if defpath is not None:
+            os.defpath = defpath
+        yield calls
+    finally:
+        os.execv = orig_execv
+        os.execve = orig_execve
+        os.defpath = orig_defpath
+
 class ExecTests(unittest.TestCase):
     @unittest.skipIf(USING_LINUXTHREADS,
                      "avoid triggering a linuxthreads bug: see issue #4970")
@@ -633,57 +681,57 @@
     def test_execvpe_with_bad_arglist(self):
         self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
 
-    class _stub_out_for_execvpe_test(object):
-        """
-        Stubs out execv, execve and get_exec_path functions when
-        used as context manager.  Records exec calls.  The mock execv
-        and execve functions always raise an exception as they would
-        normally never return.
-        """
-        def __init__(self):
-            # A list of tuples containing (function name, first arg, args)
-            # of calls to execv or execve that have been made.
-            self.calls = []
-        def _mock_execv(self, name, *args):
-            self.calls.append(('execv', name, args))
-            raise RuntimeError("execv called")
-
-        def _mock_execve(self, name, *args):
-            self.calls.append(('execve', name, args))
-            raise OSError(errno.ENOTDIR, "execve called")
-
-        def _mock_get_exec_path(self, env=None):
-            return [os.sep+'p', os.sep+'pp']
-
-        def __enter__(self):
-            self.orig_execv = os.execv
-            self.orig_execve = os.execve
-            self.orig_get_exec_path = os.get_exec_path
-            os.execv = self._mock_execv
-            os.execve = self._mock_execve
-            os.get_exec_path = self._mock_get_exec_path
-
-        def __exit__(self, type, value, tb):
-            os.execv = self.orig_execv
-            os.execve = self.orig_execve
-            os.get_exec_path = self.orig_get_exec_path
-
     @unittest.skipUnless(hasattr(os, '_execvpe'),
                          "No internal os._execvpe function to test.")
-    def test_internal_execvpe(self):
-        exec_stubbed = self._stub_out_for_execvpe_test()
-        with exec_stubbed:
-            self.assertRaises(RuntimeError, os._execvpe, os.sep+'f', ['-a'])
-            self.assertEqual([('execv', os.sep+'f', (['-a'],))],
-                             exec_stubbed.calls)
-            exec_stubbed.calls = []
-            self.assertRaises(OSError, os._execvpe, 'f', ['-a'],
-                              env={'spam': 'beans'})
-            self.assertEqual([('execve', os.sep+'p'+os.sep+'f',
-                               (['-a'], {'spam': 'beans'})),
-                              ('execve', os.sep+'pp'+os.sep+'f',
-                               (['-a'], {'spam': 'beans'}))],
-                             exec_stubbed.calls)
+    def _test_internal_execvpe(self, test_type):
+        program_path = os.sep + 'absolutepath'
+        if test_type is bytes:
+            program = b'executable'
+            fullpath = os.path.join(os.fsencode(program_path), program)
+            native_fullpath = fullpath
+            arguments = [b'progname', 'arg1', 'arg2']
+        else:
+            program = 'executable'
+            arguments = ['progname', 'arg1', 'arg2']
+            fullpath = os.path.join(program_path, program)
+            if os.name != "nt":
+                native_fullpath = os.fsencode(fullpath)
+            else:
+                native_fullpath = fullpath
+        env = {'spam': 'beans'}
+
+        # test os._execvpe() with an absolute path
+        with _execvpe_mockup() as calls:
+            self.assertRaises(RuntimeError,
+                os._execvpe, fullpath, arguments)
+            self.assertEqual(len(calls), 1)
+            self.assertEqual(calls[0], ('execv', fullpath, (arguments,)))
+
+        # test os._execvpe() with a relative path:
+        # os.get_exec_path() returns defpath
+        with _execvpe_mockup(defpath=program_path) as calls:
+            self.assertRaises(OSError,
+                os._execvpe, program, arguments, env=env)
+            self.assertEqual(len(calls), 1)
+            self.assertSequenceEqual(calls[0],
+                ('execve', native_fullpath, (arguments, env)))
+
+        # test os._execvpe() with a relative path:
+        # os.get_exec_path() reads the 'PATH' variable
+        with _execvpe_mockup() as calls:
+            env_path = env.copy()
+            env_path['PATH'] = program_path
+            self.assertRaises(OSError,
+                os._execvpe, program, arguments, env=env_path)
+            self.assertEqual(len(calls), 1)
+            self.assertSequenceEqual(calls[0],
+                ('execve', native_fullpath, (arguments, env_path)))
+
+    def test_internal_execvpe_str(self):
+        self._test_internal_execvpe(str)
+        if os.name != "nt":
+            self._test_internal_execvpe(bytes)
+
 
 class Win32ErrorTests(unittest.TestCase):
     def test_rename(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_ssl.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_ssl.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_ssl.py	Wed May 19 17:30:16 2010
@@ -10,6 +10,7 @@
 import os
 import errno
 import pprint
+import tempfile
 import urllib.parse, urllib.request
 import traceback
 import asyncore
@@ -23,10 +24,33 @@
     import ssl
 except ImportError:
     skip_expected = True
+else:
+    PROTOCOLS = [
+        ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3,
+        ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1
+    ]
 
 HOST = support.HOST
-CERTFILE = None
-SVN_PYTHON_ORG_ROOT_CERT = None
+
+data_file = lambda name: os.path.join(os.path.dirname(__file__), name)
+fsencode = lambda name: name.encode(sys.getfilesystemencoding(), "surrogateescape")
+
+CERTFILE = data_file("keycert.pem")
+BYTES_CERTFILE = fsencode(CERTFILE)
+ONLYCERT = data_file("ssl_cert.pem")
+ONLYKEY = data_file("ssl_key.pem")
+BYTES_ONLYCERT = fsencode(ONLYCERT)
+BYTES_ONLYKEY = fsencode(ONLYKEY)
+CAPATH = data_file("capath")
+BYTES_CAPATH = fsencode(CAPATH)
+
+SVN_PYTHON_ORG_ROOT_CERT = data_file("https_svn_python_org_root.pem")
+
+EMPTYCERT = data_file("nullcert.pem")
+BADCERT = data_file("badcert.pem")
+WRONGCERT = data_file("XXXnonexisting.pem")
+BADKEY = data_file("badkey.pem")
+
 
 def handle_error(prefix):
     exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
@@ -34,7 +58,7 @@
         sys.stdout.write(prefix + exc_format)
 
 
-class BasicTests(unittest.TestCase):
+class BasicSocketTests(unittest.TestCase):
 
     def test_constants(self):
         ssl.PROTOCOL_SSLv2
@@ -116,11 +140,10 @@
         s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                             cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
         s.connect(remote)
-        # Error checking occurs when connecting, because the SSL context
-        # isn't created before.
-        s = ssl.wrap_socket(socket.socket(socket.AF_INET),
-                            cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
+        # Error checking can happen at instantiation or when connecting
         with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+            s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+                                cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
             s.connect(remote)
 
     @support.cpython_only
@@ -143,33 +166,166 @@
             self.assertEqual(timeout, ss.gettimeout())
 
 
+class ContextTests(unittest.TestCase):
+
+    def test_constructor(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv2)
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv3)
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        self.assertRaises(TypeError, ssl.SSLContext)
+        self.assertRaises(ValueError, ssl.SSLContext, -1)
+        self.assertRaises(ValueError, ssl.SSLContext, 42)
+
+    def test_protocol(self):
+        for proto in PROTOCOLS:
+            ctx = ssl.SSLContext(proto)
+            self.assertEqual(ctx.protocol, proto)
+
+    def test_ciphers(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        ctx.set_ciphers("ALL")
+        ctx.set_ciphers("DEFAULT")
+        with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+            ctx.set_ciphers("^$:,;?*'dorothyx")
+
+    def test_verify(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        # Default value
+        self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+        ctx.verify_mode = ssl.CERT_OPTIONAL
+        self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL)
+        ctx.verify_mode = ssl.CERT_REQUIRED
+        self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
+        ctx.verify_mode = ssl.CERT_NONE
+        self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+        with self.assertRaises(TypeError):
+            ctx.verify_mode = None
+        with self.assertRaises(ValueError):
+            ctx.verify_mode = 42
+
+    def test_load_cert_chain(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        # Combined key and cert in a single file
+        ctx.load_cert_chain(CERTFILE)
+        ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE)
+        self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE)
+        with self.assertRaisesRegexp(ssl.SSLError, "system lib"):
+            ctx.load_cert_chain(WRONGCERT)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_cert_chain(BADCERT)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_cert_chain(EMPTYCERT)
+        # Separate key and cert
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        ctx.load_cert_chain(ONLYCERT, ONLYKEY)
+        ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY)
+        ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_cert_chain(ONLYCERT)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_cert_chain(ONLYKEY)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT)
+        # Mismatching key and cert
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        with self.assertRaisesRegexp(ssl.SSLError, "key values mismatch"):
+            ctx.load_cert_chain(CERTFILE, ONLYKEY)
+
+    def test_load_verify_locations(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        ctx.load_verify_locations(CERTFILE)
+        ctx.load_verify_locations(cafile=CERTFILE, capath=None)
+        ctx.load_verify_locations(BYTES_CERTFILE)
+        ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None)
+        self.assertRaises(TypeError, ctx.load_verify_locations)
+        self.assertRaises(TypeError, ctx.load_verify_locations, None, None)
+        with self.assertRaisesRegexp(ssl.SSLError, "system lib"):
+            ctx.load_verify_locations(WRONGCERT)
+        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+            ctx.load_verify_locations(BADCERT)
+        ctx.load_verify_locations(CERTFILE, CAPATH)
+        ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
+
+
 class NetworkedTests(unittest.TestCase):
 
     def test_connect(self):
         s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                             cert_reqs=ssl.CERT_NONE)
-        s.connect(("svn.python.org", 443))
-        c = s.getpeercert()
-        if c:
-            self.fail("Peer cert %s shouldn't be here!")
-        s.close()
-
-        # this should fail because we have no verification certs
-        s = ssl.wrap_socket(socket.socket(socket.AF_INET),
-                            cert_reqs=ssl.CERT_REQUIRED)
         try:
             s.connect(("svn.python.org", 443))
-        except ssl.SSLError:
-            pass
+            self.assertEqual({}, s.getpeercert())
         finally:
             s.close()
 
+        # this should fail because we have no verification certs
+        s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+                            cert_reqs=ssl.CERT_REQUIRED)
+        self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
+                                s.connect, ("svn.python.org", 443))
+        s.close()
+
         # this should succeed because we specify the root cert
         s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                             cert_reqs=ssl.CERT_REQUIRED,
                             ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
         try:
             s.connect(("svn.python.org", 443))
+            self.assertTrue(s.getpeercert())
+        finally:
+            s.close()
+
+    def test_connect_with_context(self):
+        # Same as test_connect, but with a separately created context
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+        s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+        s.connect(("svn.python.org", 443))
+        try:
+            self.assertEqual({}, s.getpeercert())
+        finally:
+            s.close()
+        # This should fail because we have no verification certs
+        ctx.verify_mode = ssl.CERT_REQUIRED
+        s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+        self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
+                                s.connect, ("svn.python.org", 443))
+        s.close()
+        # This should succeed because we specify the root cert
+        ctx.load_verify_locations(SVN_PYTHON_ORG_ROOT_CERT)
+        s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+        s.connect(("svn.python.org", 443))
+        try:
+            cert = s.getpeercert()
+            self.assertTrue(cert)
+        finally:
+            s.close()
+
+    def test_connect_capath(self):
+        # Verify server certificates using the `capath` argument
+        # NOTE: the subject hashing algorithm has been changed between
+        # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
+        # contain both versions of each certificate (same content, different
+        # filename) for this test to be portable across OpenSSL releases.
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+        ctx.verify_mode = ssl.CERT_REQUIRED
+        ctx.load_verify_locations(capath=CAPATH)
+        s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+        s.connect(("svn.python.org", 443))
+        try:
+            cert = s.getpeercert()
+            self.assertTrue(cert)
+        finally:
+            s.close()
+        # Same with a bytes `capath` argument
+        ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+        ctx.verify_mode = ssl.CERT_REQUIRED
+        ctx.load_verify_locations(capath=BYTES_CAPATH)
+        s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+        s.connect(("svn.python.org", 443))
+        try:
+            cert = s.getpeercert()
+            self.assertTrue(cert)
         finally:
             s.close()
 
@@ -1227,18 +1383,14 @@
     if skip_expected:
         raise unittest.SkipTest("No SSL support")
 
-    global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
-    CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
-                            "keycert.pem")
-    SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
-        os.path.dirname(__file__) or os.curdir,
-        "https_svn_python_org_root.pem")
-
-    if (not os.path.exists(CERTFILE) or
-        not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
-        raise support.TestFailed("Can't read certificate files!")
+    for filename in [
+        CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE,
+        ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
+        BADCERT, BADKEY, EMPTYCERT]:
+        if not os.path.exists(filename):
+            raise support.TestFailed("Can't read certificate file %r" % filename)
 
-    tests = [BasicTests]
+    tests = [ContextTests, BasicSocketTests]
 
     if support.is_resource_enabled('network'):
         tests.append(NetworkedTests)

Modified: python/branches/py3k-cdecimal/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	Wed May 19 17:30:16 2010
@@ -825,6 +825,27 @@
             stdout = stdout.rstrip(b'\n\r')
             self.assertEquals(stdout.decode('ascii'), repr(value))
 
+    def test_bytes_program(self):
+        abs_program = os.fsencode(sys.executable)
+        path, program = os.path.split(sys.executable)
+        program = os.fsencode(program)
+
+        # absolute bytes path
+        exitcode = subprocess.call([abs_program, "-c", "pass"])
+        self.assertEquals(exitcode, 0)
+
+        # bytes program, unicode PATH
+        env = os.environ.copy()
+        env["PATH"] = path
+        exitcode = subprocess.call([program, "-c", "pass"], env=env)
+        self.assertEquals(exitcode, 0)
+
+        # bytes program, bytes PATH
+        envb = os.environb.copy()
+        envb[b"PATH"] = os.fsencode(path)
+        exitcode = subprocess.call([program, "-c", "pass"], env=envb)
+        self.assertEquals(exitcode, 0)
+
 
 @unittest.skipUnless(mswindows, "Windows specific tests")
 class Win32ProcessTestCase(BaseTestCase):

Modified: python/branches/py3k-cdecimal/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_sys.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_sys.py	Wed May 19 17:30:16 2010
@@ -86,6 +86,8 @@
     # Python/pythonrun.c::PyErr_PrintEx() is tricky.
 
     def test_exit(self):
+        import subprocess
+
         self.assertRaises(TypeError, sys.exit, 42, 42)
 
         # call without argument
@@ -140,11 +142,30 @@
             self.fail("no exception")
 
         # test that the exit machinery handles SystemExits properly
-        import subprocess
         rc = subprocess.call([sys.executable, "-c",
                               "raise SystemExit(47)"])
         self.assertEqual(rc, 47)
 
+        def check_exit_message(code, expected):
+            process = subprocess.Popen([sys.executable, "-c", code],
+                                       stderr=subprocess.PIPE)
+            stdout, stderr = process.communicate()
+            self.assertEqual(process.returncode, 1)
+            self.assertTrue(stderr.startswith(expected),
+                "%s doesn't start with %s" % (ascii(stderr), ascii(expected)))
+
+        # test that stderr buffer if flushed before the exit message is written
+        # into stderr
+        check_exit_message(
+            r'import sys; sys.stderr.write("unflushed,"); sys.exit("message")',
+            b"unflushed,message")
+
+        # test that the exit message is written with backslashreplace error
+        # handler to stderr
+        check_exit_message(
+            r'import sys; sys.exit("surrogates:\uDCFF")',
+            b"surrogates:\\udcff")
+
     def test_getdefaultencoding(self):
         self.assertRaises(TypeError, sys.getdefaultencoding, 42)
         # can't check more than the type, as the user might have changed it
@@ -449,6 +470,23 @@
 
         self.assertRaises(TypeError, sys.intern, S("abc"))
 
+    def test_main_invalid_unicode(self):
+        import locale
+        non_decodable = b"\xff"
+        encoding = locale.getpreferredencoding()
+        try:
+            non_decodable.decode(encoding)
+        except UnicodeDecodeError:
+            pass
+        else:
+            self.skipTest('%r is decodable with encoding %s'
+                % (non_decodable, encoding))
+        code = b'print("' + non_decodable + b'")'
+        p = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE)
+        stdout, stderr = p.communicate()
+        self.assertEqual(p.returncode, 1)
+        self.assert_(b"UnicodeEncodeError:" in stderr,
+            "%r not in %s" % (b"UniodeEncodeError:", ascii(stderr)))
 
     def test_sys_flags(self):
         self.assertTrue(sys.flags)

Modified: python/branches/py3k-cdecimal/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_tarfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_tarfile.py	Wed May 19 17:30:16 2010
@@ -1126,11 +1126,32 @@
 
     format = tarfile.GNU_FORMAT
 
+    def test_bad_pax_header(self):
+        # Test for issue #8633. GNU tar <= 1.23 creates raw binary fields
+        # without a hdrcharset=BINARY header.
+        for encoding, name in (("utf8", "pax/bad-pax-\udce4\udcf6\udcfc"),
+                ("iso8859-1", "pax/bad-pax-\xe4\xf6\xfc"),):
+            with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+                try:
+                    t = tar.getmember(name)
+                except KeyError:
+                    self.fail("unable to read bad GNU tar pax header")
+
 
 class PAXUnicodeTest(UstarUnicodeTest):
 
     format = tarfile.PAX_FORMAT
 
+    def test_binary_header(self):
+        # Test a POSIX.1-2008 compatible header with a hdrcharset=BINARY field.
+        for encoding, name in (("utf8", "pax/hdrcharset-\udce4\udcf6\udcfc"),
+                ("iso8859-1", "pax/hdrcharset-\xe4\xf6\xfc"),):
+            with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+                try:
+                    t = tar.getmember(name)
+                except KeyError:
+                    self.fail("unable to read POSIX.1-2008 binary header")
+
 
 class AppendTest(unittest.TestCase):
     # Test append mode (cp. patch #1652681).

Modified: python/branches/py3k-cdecimal/Lib/test/testtar.tar
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k-cdecimal/Lib/urllib/parse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/urllib/parse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/urllib/parse.py	Wed May 19 17:30:16 2010
@@ -41,7 +41,7 @@
 uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
                'imap', 'wais', 'file', 'mms', 'https', 'shttp',
                'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
-               'svn', 'svn+ssh', 'sftp', 'nfs',' git', 'git+ssh']
+               'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh']
 non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
                     'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
 uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
@@ -307,17 +307,20 @@
     """unquote_to_bytes('abc%20def') -> b'abc def'."""
     # Note: strings are encoded as UTF-8. This is only an issue if it contains
     # unescaped non-ASCII characters, which URIs should not.
+    if not string:
+        return b''
     if isinstance(string, str):
         string = string.encode('utf-8')
     res = string.split(b'%')
-    res[0] = res[0]
-    for i in range(1, len(res)):
-        item = res[i]
+    if len(res) == 1:
+        return string
+    string = res[0]
+    for item in res[1:]:
         try:
-            res[i] = bytes([int(item[:2], 16)]) + item[2:]
+            string += bytes([int(item[:2], 16)]) + item[2:]
         except ValueError:
-            res[i] = b'%' + item
-    return b''.join(res)
+            string += b'%' + item
+    return string
 
 def unquote(string, encoding='utf-8', errors='replace'):
     """Replace %xx escapes by their single-character equivalent. The optional
@@ -329,36 +332,39 @@
 
     unquote('abc%20def') -> 'abc def'.
     """
-    if encoding is None: encoding = 'utf-8'
-    if errors is None: errors = 'replace'
-    # pct_sequence: contiguous sequence of percent-encoded bytes, decoded
-    # (list of single-byte bytes objects)
-    pct_sequence = []
+    if not string:
+        return string
     res = string.split('%')
-    for i in range(1, len(res)):
-        item = res[i]
+    if len(res) == 1:
+        return string
+    if encoding is None:
+        encoding = 'utf-8'
+    if errors is None:
+        errors = 'replace'
+    # pct_sequence: contiguous sequence of percent-encoded bytes, decoded
+    pct_sequence = b''
+    string = res[0]
+    for item in res[1:]:
         try:
-            if not item: raise ValueError
-            pct_sequence.append(bytes.fromhex(item[:2]))
+            if not item:
+                raise ValueError
+            pct_sequence += bytes.fromhex(item[:2])
             rest = item[2:]
+            if not rest:
+                # This segment was just a single percent-encoded character.
+                # May be part of a sequence of code units, so delay decoding.
+                # (Stored in pct_sequence).
+                continue
         except ValueError:
             rest = '%' + item
-        if not rest:
-            # This segment was just a single percent-encoded character.
-            # May be part of a sequence of code units, so delay decoding.
-            # (Stored in pct_sequence).
-            res[i] = ''
-        else:
-            # Encountered non-percent-encoded characters. Flush the current
-            # pct_sequence.
-            res[i] = b''.join(pct_sequence).decode(encoding, errors) + rest
-            pct_sequence = []
+        # Encountered non-percent-encoded characters. Flush the current
+        # pct_sequence.
+        string += pct_sequence.decode(encoding, errors) + rest
+        pct_sequence = b''
     if pct_sequence:
         # Flush the final pct_sequence
-        # res[-1] will always be empty if pct_sequence != []
-        assert not res[-1], "string=%r, res=%r" % (string, res)
-        res[-1] = b''.join(pct_sequence).decode(encoding, errors)
-    return ''.join(res)
+        string += pct_sequence.decode(encoding, errors)
+    return string
 
 def parse_qs(qs, keep_blank_values=False, strict_parsing=False):
     """Parse a query given as a string argument.
@@ -439,7 +445,8 @@
                          b'abcdefghijklmnopqrstuvwxyz'
                          b'0123456789'
                          b'_.-')
-_safe_quoters= {}
+_ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE)
+_safe_quoters = {}
 
 class Quoter(collections.defaultdict):
     """A mapping from bytes (in range(0,256)) to strings.
@@ -451,7 +458,7 @@
     # of cached keys don't call Python code at all).
     def __init__(self, safe):
         """safe: bytes object."""
-        self.safe = _ALWAYS_SAFE.union(c for c in safe if c < 128)
+        self.safe = _ALWAYS_SAFE.union(safe)
 
     def __repr__(self):
         # Without this, will just display as a defaultdict
@@ -459,7 +466,7 @@
 
     def __missing__(self, b):
         # Handle a cache miss. Store quoted string in cache and return.
-        res = b in self.safe and chr(b) or ('%%%02X' % b)
+        res = chr(b) if b in self.safe else '%{:02X}'.format(b)
         self[b] = res
         return res
 
@@ -493,6 +500,8 @@
     errors='strict' (unsupported characters raise a UnicodeEncodeError).
     """
     if isinstance(string, str):
+        if not string:
+            return string
         if encoding is None:
             encoding = 'utf-8'
         if errors is None:
@@ -527,18 +536,22 @@
     not perform string-to-bytes encoding.  It always returns an ASCII string.
     quote_from_bytes(b'abc def\xab') -> 'abc%20def%AB'
     """
+    if not isinstance(bs, (bytes, bytearray)):
+        raise TypeError("quote_from_bytes() expected bytes")
+    if not bs:
+        return ''
     if isinstance(safe, str):
         # Normalize 'safe' by converting to bytes and removing non-ASCII chars
         safe = safe.encode('ascii', 'ignore')
-    cachekey = bytes(safe)  # In case it was a bytearray
-    if not (isinstance(bs, bytes) or isinstance(bs, bytearray)):
-        raise TypeError("quote_from_bytes() expected a bytes")
+    else:
+        safe = bytes([c for c in safe if c < 128])
+    if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe):
+        return bs.decode()
     try:
-        quoter = _safe_quoters[cachekey]
+        quoter = _safe_quoters[safe]
     except KeyError:
-        quoter = Quoter(safe)
-        _safe_quoters[cachekey] = quoter
-    return ''.join([quoter[char] for char in bs])
+        _safe_quoters[safe] = quoter = Quoter(safe).__getitem__
+    return ''.join([quoter(char) for char in bs])
 
 def urlencode(query, doseq=False):
     """Encode a sequence of two-element tuples or dictionary into a URL query string.

Modified: python/branches/py3k-cdecimal/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/urllib/request.py	(original)
+++ python/branches/py3k-cdecimal/Lib/urllib/request.py	Wed May 19 17:30:16 2010
@@ -1965,7 +1965,7 @@
         else:
             return self.open(newurl, data)
 
-    def get_user_passwd(self, host, realm, clear_cache = 0):
+    def get_user_passwd(self, host, realm, clear_cache=0):
         key = realm + '@' + host.lower()
         if key in self.auth_cache:
             if clear_cache:

Modified: python/branches/py3k-cdecimal/Misc/NEWS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/NEWS	(original)
+++ python/branches/py3k-cdecimal/Misc/NEWS	Wed May 19 17:30:16 2010
@@ -12,6 +12,9 @@
 Core and Builtins
 -----------------
 
+- PyObject_Dump() encodes unicode objects to utf8 with backslashreplace
+  (instead of strict) error handler to escape surrogates
+
 - Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
   object to Py_FileSystemDefaultEncoding with the "surrogateescape" error
   handler, and return bytes. If Py_FileSystemDefaultEncoding is not set, fall
@@ -363,6 +366,24 @@
 Library
 -------
 
+- Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
+  subprocess.Popen() and os._execvpe() support bytes program name. Add
+  os.supports_bytes_environ flag: True if the native OS type of the environment
+  is bytes (eg. False on Windows).
+
+- Issue #8633: tarfile is now able to read and write archives with "raw" binary
+  pax headers as described in POSIX.1-2008.
+
+- Issue #1285086: Speed up urllib.parse functions: quote, quote_from_bytes,
+  unquote, unquote_to_bytes.
+
+- Issue #8688: Distutils now recalculates MANIFEST everytime.
+
+- Issue #8477: ssl.RAND_egd() and ssl._test_decode_cert() support str with
+  surrogates and bytes for the filename
+
+- Issue #8550: Add first class ``SSLContext`` objects to the ssl module.
+
 - Issue #8681: Make the zlib module's error messages more informative when
   the zlib itself doesn't give any detailed explanation.
 

Modified: python/branches/py3k-cdecimal/Modules/_cursesmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_cursesmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_cursesmodule.c	Wed May 19 17:30:16 2010
@@ -33,66 +33,66 @@
 
 /*
 
-A number of SysV or ncurses functions don't have wrappers yet; if you
-need a given function, add it and send a patch.  See
-http://www.python.org/dev/patches/ for instructions on how to submit
-patches to Python.
-
-Here's a list of currently unsupported functions:
-
-	addchnstr addchstr color_set define_key
-	del_curterm delscreen dupwin inchnstr inchstr innstr keyok
-	mcprint mvaddchnstr mvaddchstr mvcur mvinchnstr
-	mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr 
-	mvwinchnstr mvwinchstr mvwinnstr newterm
-	restartterm ripoffline scr_dump
-	scr_init scr_restore scr_set scrl set_curterm set_term setterm
-	tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
-	vidattr vidputs waddchnstr waddchstr
-	wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl
-
-Low-priority: 
-	slk_attr slk_attr_off slk_attr_on slk_attr_set slk_attroff
-	slk_attron slk_attrset slk_clear slk_color slk_init slk_label
-	slk_noutrefresh slk_refresh slk_restore slk_set slk_touch
-
-Menu extension (ncurses and probably SYSV):
-	current_item free_item free_menu item_count item_description
-	item_index item_init item_name item_opts item_opts_off
-	item_opts_on item_term item_userptr item_value item_visible
-	menu_back menu_driver menu_fore menu_format menu_grey
-	menu_init menu_items menu_mark menu_opts menu_opts_off
-	menu_opts_on menu_pad menu_pattern menu_request_by_name
-	menu_request_name menu_spacing menu_sub menu_term menu_userptr
-	menu_win new_item new_menu pos_menu_cursor post_menu
-	scale_menu set_current_item set_item_init set_item_opts
-	set_item_term set_item_userptr set_item_value set_menu_back
-	set_menu_fore set_menu_format set_menu_grey set_menu_init
-	set_menu_items set_menu_mark set_menu_opts set_menu_pad
-	set_menu_pattern set_menu_spacing set_menu_sub set_menu_term
-	set_menu_userptr set_menu_win set_top_row top_row unpost_menu
-
-Form extension (ncurses and probably SYSV):
-	current_field data_ahead data_behind dup_field
-	dynamic_fieldinfo field_arg field_back field_buffer
-	field_count field_fore field_index field_info field_init
-	field_just field_opts field_opts_off field_opts_on field_pad
-	field_status field_term field_type field_userptr form_driver
-	form_fields form_init form_opts form_opts_off form_opts_on
-	form_page form_request_by_name form_request_name form_sub
-	form_term form_userptr form_win free_field free_form
-	link_field link_fieldtype move_field new_field new_form
-	new_page pos_form_cursor post_form scale_form
-	set_current_field set_field_back set_field_buffer
-	set_field_fore set_field_init set_field_just set_field_opts
-	set_field_pad set_field_status set_field_term set_field_type
-	set_field_userptr set_fieldtype_arg set_fieldtype_choice
-	set_form_fields set_form_init set_form_opts set_form_page
-	set_form_sub set_form_term set_form_userptr set_form_win
-	set_max_field set_new_page unpost_form
+  A number of SysV or ncurses functions don't have wrappers yet; if you
+  need a given function, add it and send a patch.  See
+  http://www.python.org/dev/patches/ for instructions on how to submit
+  patches to Python.
+
+  Here's a list of currently unsupported functions:
+
+  addchnstr addchstr color_set define_key
+  del_curterm delscreen dupwin inchnstr inchstr innstr keyok
+  mcprint mvaddchnstr mvaddchstr mvcur mvinchnstr
+  mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr
+  mvwinchnstr mvwinchstr mvwinnstr newterm
+  restartterm ripoffline scr_dump
+  scr_init scr_restore scr_set scrl set_curterm set_term setterm
+  tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
+  vidattr vidputs waddchnstr waddchstr
+  wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl
+
+  Low-priority:
+  slk_attr slk_attr_off slk_attr_on slk_attr_set slk_attroff
+  slk_attron slk_attrset slk_clear slk_color slk_init slk_label
+  slk_noutrefresh slk_refresh slk_restore slk_set slk_touch
+
+  Menu extension (ncurses and probably SYSV):
+  current_item free_item free_menu item_count item_description
+  item_index item_init item_name item_opts item_opts_off
+  item_opts_on item_term item_userptr item_value item_visible
+  menu_back menu_driver menu_fore menu_format menu_grey
+  menu_init menu_items menu_mark menu_opts menu_opts_off
+  menu_opts_on menu_pad menu_pattern menu_request_by_name
+  menu_request_name menu_spacing menu_sub menu_term menu_userptr
+  menu_win new_item new_menu pos_menu_cursor post_menu
+  scale_menu set_current_item set_item_init set_item_opts
+  set_item_term set_item_userptr set_item_value set_menu_back
+  set_menu_fore set_menu_format set_menu_grey set_menu_init
+  set_menu_items set_menu_mark set_menu_opts set_menu_pad
+  set_menu_pattern set_menu_spacing set_menu_sub set_menu_term
+  set_menu_userptr set_menu_win set_top_row top_row unpost_menu
+
+  Form extension (ncurses and probably SYSV):
+  current_field data_ahead data_behind dup_field
+  dynamic_fieldinfo field_arg field_back field_buffer
+  field_count field_fore field_index field_info field_init
+  field_just field_opts field_opts_off field_opts_on field_pad
+  field_status field_term field_type field_userptr form_driver
+  form_fields form_init form_opts form_opts_off form_opts_on
+  form_page form_request_by_name form_request_name form_sub
+  form_term form_userptr form_win free_field free_form
+  link_field link_fieldtype move_field new_field new_form
+  new_page pos_form_cursor post_form scale_form
+  set_current_field set_field_back set_field_buffer
+  set_field_fore set_field_init set_field_just set_field_opts
+  set_field_pad set_field_status set_field_term set_field_type
+  set_field_userptr set_fieldtype_arg set_fieldtype_choice
+  set_form_fields set_form_init set_form_opts set_form_page
+  set_form_sub set_form_term set_form_userptr set_form_win
+  set_max_field set_new_page unpost_form
 
 
- */
+*/
 
 /* Release Number */
 
@@ -116,9 +116,9 @@
 #define CURSES_MODULE
 #include "py_curses.h"
 
-/*  These prototypes are in <term.h>, but including this header 
-    #defines many common symbols (such as "lines") which breaks the 
-    curses module in other ways.  So the code will just specify 
+/*  These prototypes are in <term.h>, but including this header
+    #defines many common symbols (such as "lines") which breaks the
+    curses module in other ways.  So the code will just specify
     explicit prototypes here. */
 extern int setupterm(char *,int,int *);
 #ifdef __sgi
@@ -148,23 +148,23 @@
 static int initialisedcolors = FALSE;
 
 /* Utility Macros */
-#define PyCursesSetupTermCalled \
-  if (initialised_setupterm != TRUE) { \
-                  PyErr_SetString(PyCursesError, \
-                                  "must call (at least) setupterm() first"); \
-                  return 0; }
-
-#define PyCursesInitialised \
-  if (initialised != TRUE) { \
-                  PyErr_SetString(PyCursesError, \
-                                  "must call initscr() first"); \
-                  return 0; }
-
-#define PyCursesInitialisedColor \
-  if (initialisedcolors != TRUE) { \
-                  PyErr_SetString(PyCursesError, \
-                                  "must call start_color() first"); \
-                  return 0; }
+#define PyCursesSetupTermCalled                                         \
+    if (initialised_setupterm != TRUE) {                                \
+        PyErr_SetString(PyCursesError,                                  \
+                        "must call (at least) setupterm() first");      \
+        return 0; }
+
+#define PyCursesInitialised                             \
+    if (initialised != TRUE) {                          \
+        PyErr_SetString(PyCursesError,                  \
+                        "must call initscr() first");   \
+        return 0; }
+
+#define PyCursesInitialisedColor                                \
+    if (initialisedcolors != TRUE) {                            \
+        PyErr_SetString(PyCursesError,                          \
+                        "must call start_color() first");       \
+        return 0; }
 
 #ifndef MIN
 #define MIN(x,y) ((x) < (y) ? (x) : (y))
@@ -173,51 +173,51 @@
 /* Utility Functions */
 
 /*
- * Check the return code from a curses function and return None 
+ * Check the return code from a curses function and return None
  * or raise an exception as appropriate.  These are exported using the
- * capsule API. 
+ * capsule API.
  */
 
 static PyObject *
 PyCursesCheckERR(int code, char *fname)
 {
-  if (code != ERR) {
-    Py_INCREF(Py_None);
-    return Py_None;
-  } else {
-    if (fname == NULL) {
-      PyErr_SetString(PyCursesError, catchall_ERR);
+    if (code != ERR) {
+        Py_INCREF(Py_None);
+        return Py_None;
     } else {
-      PyErr_Format(PyCursesError, "%s() returned ERR", fname);
+        if (fname == NULL) {
+            PyErr_SetString(PyCursesError, catchall_ERR);
+        } else {
+            PyErr_Format(PyCursesError, "%s() returned ERR", fname);
+        }
+        return NULL;
     }
-    return NULL;
-  }
 }
 
-static int 
+static int
 PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
 {
-  if (PyLong_CheckExact(obj)) {
-    int overflow;
-    /* XXX should the truncation by the cast also be reported
-       as an error? */
-    *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow);
-    if (overflow)
-      return 0;
-  } else if(PyBytes_Check(obj) 
-	    && (PyBytes_Size(obj) == 1)) {
-    *ch = (chtype) *PyBytes_AsString(obj);
-  } else if (PyUnicode_Check(obj) && PyUnicode_GetSize(obj) == 1) {
-    *ch = (chtype) *PyUnicode_AS_UNICODE(obj);
-  } else {
-    return 0;
-  }
-  return 1;
+    if (PyLong_CheckExact(obj)) {
+        int overflow;
+        /* XXX should the truncation by the cast also be reported
+           as an error? */
+        *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow);
+        if (overflow)
+            return 0;
+    } else if(PyBytes_Check(obj)
+              && (PyBytes_Size(obj) == 1)) {
+        *ch = (chtype) *PyBytes_AsString(obj);
+    } else if (PyUnicode_Check(obj) && PyUnicode_GetSize(obj) == 1) {
+        *ch = (chtype) *PyUnicode_AS_UNICODE(obj);
+    } else {
+        return 0;
+    }
+    return 1;
 }
 
 /* Function versions of the 3 functions for testing whether curses has been
    initialised or not. */
-   
+
 static int func_PyCursesSetupTermCalled(void)
 {
     PyCursesSetupTermCalled;
@@ -250,56 +250,56 @@
    TYPE - parameter Type
    ERGSTR - format string for construction of the return value
    PARSESTR - format string for argument parsing
-   */
+*/
 
-#define Window_NoArgNoReturnFunction(X) \
-static PyObject *PyCursesWindow_ ## X \
-(PyCursesWindowObject *self, PyObject *args) \
-{ return PyCursesCheckERR(X(self->win), # X); }
-
-#define Window_NoArgTrueFalseFunction(X) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self) \
-{ \
-  if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
-  else { Py_INCREF(Py_True); return Py_True; } }
-
-#define Window_NoArgNoReturnVoidFunction(X) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self) \
-{ \
-  X(self->win); Py_INCREF(Py_None); return Py_None; }
-
-#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self) \
-{ \
-  TYPE arg1, arg2; \
-  X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); } 
-
-#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self, PyObject *args) \
-{ \
-  TYPE arg1; \
-  if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \
-  X(self->win,arg1); Py_INCREF(Py_None); return Py_None; }
-
-#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self, PyObject *args) \
-{ \
-  TYPE arg1; \
-  if (!PyArg_ParseTuple(args,PARSESTR, &arg1)) return NULL; \
-  return PyCursesCheckERR(X(self->win, arg1), # X); }
-
-#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \
-static PyObject * PyCursesWindow_ ## X \
-(PyCursesWindowObject *self, PyObject *args) \
-{ \
-  TYPE arg1, arg2; \
-  if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) return NULL; \
-  return PyCursesCheckERR(X(self->win, arg1, arg2), # X); }
+#define Window_NoArgNoReturnFunction(X)                 \
+    static PyObject *PyCursesWindow_ ## X               \
+    (PyCursesWindowObject *self, PyObject *args)        \
+    { return PyCursesCheckERR(X(self->win), # X); }
+
+#define Window_NoArgTrueFalseFunction(X)                                \
+    static PyObject * PyCursesWindow_ ## X                              \
+    (PyCursesWindowObject *self)                                        \
+    {                                                                   \
+        if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
+        else { Py_INCREF(Py_True); return Py_True; } }
+
+#define Window_NoArgNoReturnVoidFunction(X)                     \
+    static PyObject * PyCursesWindow_ ## X                      \
+    (PyCursesWindowObject *self)                                \
+    {                                                           \
+        X(self->win); Py_INCREF(Py_None); return Py_None; }
+
+#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR)               \
+    static PyObject * PyCursesWindow_ ## X                              \
+    (PyCursesWindowObject *self)                                        \
+    {                                                                   \
+        TYPE arg1, arg2;                                                \
+        X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); }
+
+#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR)            \
+    static PyObject * PyCursesWindow_ ## X                              \
+    (PyCursesWindowObject *self, PyObject *args)                        \
+    {                                                                   \
+        TYPE arg1;                                                      \
+        if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL;      \
+        X(self->win,arg1); Py_INCREF(Py_None); return Py_None; }
+
+#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR)                \
+    static PyObject * PyCursesWindow_ ## X                              \
+    (PyCursesWindowObject *self, PyObject *args)                        \
+    {                                                                   \
+        TYPE arg1;                                                      \
+        if (!PyArg_ParseTuple(args,PARSESTR, &arg1)) return NULL;       \
+        return PyCursesCheckERR(X(self->win, arg1), # X); }
+
+#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR)                \
+    static PyObject * PyCursesWindow_ ## X                              \
+    (PyCursesWindowObject *self, PyObject *args)                        \
+    {                                                                   \
+        TYPE arg1, arg2;                                                \
+        if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) return NULL; \
+        return PyCursesCheckERR(X(self->win, arg1, arg2), # X); }
 
 /* ------------- WINDOW routines --------------- */
 
@@ -360,19 +360,19 @@
 static PyObject *
 PyCursesWindow_New(WINDOW *win)
 {
-	PyCursesWindowObject *wo;
+    PyCursesWindowObject *wo;
 
-	wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type);
-	if (wo == NULL) return NULL;
-	wo->win = win;
-	return (PyObject *)wo;
+    wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type);
+    if (wo == NULL) return NULL;
+    wo->win = win;
+    return (PyObject *)wo;
 }
 
 static void
 PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
 {
-  if (wo->win != stdscr) delwin(wo->win);
-  PyObject_DEL(wo);
+    if (wo->win != stdscr) delwin(wo->win);
+    PyObject_DEL(wo);
 }
 
 /* Addch, Addstr, Addnstr */
@@ -380,287 +380,287 @@
 static PyObject *
 PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn, x, y, use_xy = FALSE;
-  PyObject *temp;
-  chtype ch = 0;
-  attr_t attr = A_NORMAL;
-  long lattr;
-  
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
-	  return NULL;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", 
-		     &y, &x, &temp, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments");
-    return NULL;
-  }
-
-  if (!PyCurses_ConvertToChtype(temp, &ch)) {
-    PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
-    return NULL;
-  }
-  
-  if (use_xy == TRUE)
-    rtn = mvwaddch(self->win,y,x, ch | attr);
-  else {
-    rtn = waddch(self->win, ch | attr);
-  }
-  return PyCursesCheckERR(rtn, "addch");
+    int rtn, x, y, use_xy = FALSE;
+    PyObject *temp;
+    chtype ch = 0;
+    attr_t attr = A_NORMAL;
+    long lattr;
+
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
+            return NULL;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr",
+                              &y, &x, &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments");
+        return NULL;
+    }
+
+    if (!PyCurses_ConvertToChtype(temp, &ch)) {
+        PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
+        return NULL;
+    }
+
+    if (use_xy == TRUE)
+        rtn = mvwaddch(self->win,y,x, ch | attr);
+    else {
+        rtn = waddch(self->win, ch | attr);
+    }
+    return PyCursesCheckERR(rtn, "addch");
 }
 
 static PyObject *
 PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn;
-  int x, y;
-  char *str;
-  attr_t attr = A_NORMAL , attr_old = A_NORMAL;
-  long lattr;
-  int use_xy = FALSE, use_attr = FALSE;
-
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"s;str", &str))
-      return NULL;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
-      return NULL;
-    attr = lattr;
-    use_attr = TRUE;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iis;int,int,str", &y, &x, &str))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = use_attr = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments");
-    return NULL;
-  }
-
-  if (use_attr == TRUE) {
-    attr_old = getattrs(self->win);
-    (void)wattrset(self->win,attr);
-  }
-  if (use_xy == TRUE)
-    rtn = mvwaddstr(self->win,y,x,str);
-  else
-    rtn = waddstr(self->win,str);
-  if (use_attr == TRUE)
-    (void)wattrset(self->win,attr_old);
-  return PyCursesCheckERR(rtn, "addstr");
+    int rtn;
+    int x, y;
+    char *str;
+    attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+    long lattr;
+    int use_xy = FALSE, use_attr = FALSE;
+
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"s;str", &str))
+            return NULL;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
+            return NULL;
+        attr = lattr;
+        use_attr = TRUE;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iis;int,int,str", &y, &x, &str))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = use_attr = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments");
+        return NULL;
+    }
+
+    if (use_attr == TRUE) {
+        attr_old = getattrs(self->win);
+        (void)wattrset(self->win,attr);
+    }
+    if (use_xy == TRUE)
+        rtn = mvwaddstr(self->win,y,x,str);
+    else
+        rtn = waddstr(self->win,str);
+    if (use_attr == TRUE)
+        (void)wattrset(self->win,attr_old);
+    return PyCursesCheckERR(rtn, "addstr");
 }
 
 static PyObject *
 PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn, x, y, n;
-  char *str;
-  attr_t attr = A_NORMAL , attr_old = A_NORMAL;
-  long lattr;
-  int use_xy = FALSE, use_attr = FALSE;
-
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"si;str,n", &str, &n))
-      return NULL;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    use_attr = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 5:
-    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = use_attr = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments");
-    return NULL;
-  }
-
-  if (use_attr == TRUE) {
-    attr_old = getattrs(self->win);
-    (void)wattrset(self->win,attr);
-  }
-  if (use_xy == TRUE)
-    rtn = mvwaddnstr(self->win,y,x,str,n);
-  else
-    rtn = waddnstr(self->win,str,n);
-  if (use_attr == TRUE)
-    (void)wattrset(self->win,attr_old);
-  return PyCursesCheckERR(rtn, "addnstr");
+    int rtn, x, y, n;
+    char *str;
+    attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+    long lattr;
+    int use_xy = FALSE, use_attr = FALSE;
+
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"si;str,n", &str, &n))
+            return NULL;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        use_attr = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 5:
+        if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = use_attr = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments");
+        return NULL;
+    }
+
+    if (use_attr == TRUE) {
+        attr_old = getattrs(self->win);
+        (void)wattrset(self->win,attr);
+    }
+    if (use_xy == TRUE)
+        rtn = mvwaddnstr(self->win,y,x,str,n);
+    else
+        rtn = waddnstr(self->win,str,n);
+    if (use_attr == TRUE)
+        (void)wattrset(self->win,attr_old);
+    return PyCursesCheckERR(rtn, "addnstr");
 }
 
 static PyObject *
 PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype bkgd;
-  attr_t attr = A_NORMAL;
-  long lattr;
+    PyObject *temp;
+    chtype bkgd;
+    attr_t attr = A_NORMAL;
+    long lattr;
 
-  switch (PyTuple_Size(args)) {
+    switch (PyTuple_Size(args)) {
     case 1:
-      if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
-        return NULL;
-      break;
+        if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
+            return NULL;
+        break;
     case 2:
-      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
-        return NULL;
-      attr = lattr;
-      break;
+        if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
     default:
-      PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
-      return NULL;
-  }
+        PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
+        return NULL;
+    }
 
-  if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
-    PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
-    return NULL;
-  }
+    if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
+        PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
+        return NULL;
+    }
 
-  return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd");
+    return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd");
 }
 
 static PyObject *
 PyCursesWindow_AttrOff(PyCursesWindowObject *self, PyObject *args)
 {
-  long lattr;
-  if (!PyArg_ParseTuple(args,"l;attr", &lattr))
-    return NULL;
-  return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr), "attroff");
+    long lattr;
+    if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+        return NULL;
+    return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr), "attroff");
 }
 
 static PyObject *
 PyCursesWindow_AttrOn(PyCursesWindowObject *self, PyObject *args)
 {
-  long lattr;
-  if (!PyArg_ParseTuple(args,"l;attr", &lattr))
-    return NULL;
-  return PyCursesCheckERR(wattron(self->win, (attr_t)lattr), "attron");
+    long lattr;
+    if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+        return NULL;
+    return PyCursesCheckERR(wattron(self->win, (attr_t)lattr), "attron");
 }
 
 static PyObject *
 PyCursesWindow_AttrSet(PyCursesWindowObject *self, PyObject *args)
 {
-  long lattr;
-  if (!PyArg_ParseTuple(args,"l;attr", &lattr))
-    return NULL;
-  return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr), "attrset");
+    long lattr;
+    if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+        return NULL;
+    return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr), "attrset");
 }
 
 static PyObject *
 PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype bkgd;
-  attr_t attr = A_NORMAL;
-  long lattr;
+    PyObject *temp;
+    chtype bkgd;
+    attr_t attr = A_NORMAL;
+    long lattr;
 
-  switch (PyTuple_Size(args)) {
+    switch (PyTuple_Size(args)) {
     case 1:
-      if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
-        return NULL;
-      break;
+        if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
+            return NULL;
+        break;
     case 2:
-      if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
-        return NULL;
-      attr = lattr;
-      break;
+        if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
     default:
-      PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
-      return NULL;
-  }
+        PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
+        return NULL;
+    }
 
-  if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
-    PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
-    return NULL;
-  }
+    if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
+        PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
+        return NULL;
+    }
 
-  wbkgdset(self->win, bkgd | attr);
-  return PyCursesCheckERR(0, "bkgdset");
+    wbkgdset(self->win, bkgd | attr);
+    return PyCursesCheckERR(0, "bkgdset");
 }
 
 static PyObject *
 PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp[8];
-  chtype ch[8];
-  int i;
-
-  /* Clear the array of parameters */
-  for(i=0; i<8; i++) {
-       temp[i] = NULL;
-       ch[i] = 0;
-  }    
-  
-  if (!PyArg_ParseTuple(args,"|OOOOOOOO;ls,rs,ts,bs,tl,tr,bl,br",
-                        &temp[0], &temp[1], &temp[2], &temp[3],
-                        &temp[4], &temp[5], &temp[6], &temp[7]))
-    return NULL;
-
-  for(i=0; i<8; i++) {
-      if (temp[i] != NULL && !PyCurses_ConvertToChtype(temp[i], &ch[i])) {
-          PyErr_Format(PyExc_TypeError,
-                       "argument %i must be a ch or an int", i+1);
-          return NULL;
-      }
-  }
-  
-  wborder(self->win,
-          ch[0], ch[1], ch[2], ch[3],
-          ch[4], ch[5], ch[6], ch[7]);
-  Py_INCREF(Py_None);
-  return Py_None;
+    PyObject *temp[8];
+    chtype ch[8];
+    int i;
+
+    /* Clear the array of parameters */
+    for(i=0; i<8; i++) {
+        temp[i] = NULL;
+        ch[i] = 0;
+    }
+
+    if (!PyArg_ParseTuple(args,"|OOOOOOOO;ls,rs,ts,bs,tl,tr,bl,br",
+                          &temp[0], &temp[1], &temp[2], &temp[3],
+                          &temp[4], &temp[5], &temp[6], &temp[7]))
+        return NULL;
+
+    for(i=0; i<8; i++) {
+        if (temp[i] != NULL && !PyCurses_ConvertToChtype(temp[i], &ch[i])) {
+            PyErr_Format(PyExc_TypeError,
+                         "argument %i must be a ch or an int", i+1);
+            return NULL;
+        }
+    }
+
+    wborder(self->win,
+            ch[0], ch[1], ch[2], ch[3],
+            ch[4], ch[5], ch[6], ch[7]);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args)
 {
-  chtype ch1=0,ch2=0;
-  switch(PyTuple_Size(args)){
-  case 0: break;
-  default:
-    if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2))
-      return NULL;
-  }
-  box(self->win,ch1,ch2);
-  Py_INCREF(Py_None);
-  return Py_None;
+    chtype ch1=0,ch2=0;
+    switch(PyTuple_Size(args)){
+    case 0: break;
+    default:
+        if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2))
+            return NULL;
+    }
+    box(self->win,ch1,ch2);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 #if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION)
@@ -668,10 +668,10 @@
 #else
 int py_mvwdelch(WINDOW *w, int y, int x)
 {
-  mvwdelch(w,y,x);
-  /* On HP/UX, mvwdelch already returns. On other systems,
-     we may well run into this return statement. */
-  return 0;
+    mvwdelch(w,y,x);
+    /* On HP/UX, mvwdelch already returns. On other systems,
+       we may well run into this return statement. */
+    return 0;
 }
 #endif
 
@@ -680,603 +680,603 @@
 static PyObject *
 PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn;
-  int x, y;
-  int num = -1;
-  short color;
-  attr_t attr = A_NORMAL;
-  long lattr;
-  int use_xy = FALSE;
+    int rtn;
+    int x, y;
+    int num = -1;
+    short color;
+    attr_t attr = A_NORMAL;
+    long lattr;
+    int use_xy = FALSE;
 
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"l;attr", &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"il;n,attr", &num, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iil;int,int,attr", &y, &x, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iiil;int,int,n,attr", &y, &x, &num, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "chgat requires 1 to 4 arguments");
-    return NULL;
-  }
-
-  color = (short)((attr >> 8) & 0xff);
-  attr = attr - (color << 8);
-
-  if (use_xy == TRUE) {
-    rtn = mvwchgat(self->win,y,x,num,attr,color,NULL);
-    touchline(self->win,y,1);
-  } else {
-    getyx(self->win,y,x);
-    rtn = wchgat(self->win,num,attr,color,NULL);
-    touchline(self->win,y,1);
-  }
-  return PyCursesCheckERR(rtn, "chgat");
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"l;attr", &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"il;n,attr", &num, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iil;int,int,attr", &y, &x, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iiil;int,int,n,attr", &y, &x, &num, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "chgat requires 1 to 4 arguments");
+        return NULL;
+    }
+
+    color = (short)((attr >> 8) & 0xff);
+    attr = attr - (color << 8);
+
+    if (use_xy == TRUE) {
+        rtn = mvwchgat(self->win,y,x,num,attr,color,NULL);
+        touchline(self->win,y,1);
+    } else {
+        getyx(self->win,y,x);
+        rtn = wchgat(self->win,num,attr,color,NULL);
+        touchline(self->win,y,1);
+    }
+    return PyCursesCheckERR(rtn, "chgat");
 }
 
 
 static PyObject *
 PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn;
-  int x, y;
+    int rtn;
+    int x, y;
 
-  switch (PyTuple_Size(args)) {
-  case 0:
-    rtn = wdelch(self->win);
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x))
-      return NULL;
-    rtn = py_mvwdelch(self->win,y,x);
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments");
-    return NULL;
-  }
-  return PyCursesCheckERR(rtn, "[mv]wdelch");
+    switch (PyTuple_Size(args)) {
+    case 0:
+        rtn = wdelch(self->win);
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x))
+            return NULL;
+        rtn = py_mvwdelch(self->win,y,x);
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments");
+        return NULL;
+    }
+    return PyCursesCheckERR(rtn, "[mv]wdelch");
 }
 
 static PyObject *
 PyCursesWindow_DerWin(PyCursesWindowObject *self, PyObject *args)
 {
-  WINDOW *win;
-  int nlines, ncols, begin_y, begin_x;
+    WINDOW *win;
+    int nlines, ncols, begin_y, begin_x;
 
-  nlines = 0;
-  ncols  = 0;
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
-      return NULL;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
-		   &nlines,&ncols,&begin_y,&begin_x))
-      return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "derwin requires 2 or 4 arguments");
-    return NULL;
-  }
-
-  win = derwin(self->win,nlines,ncols,begin_y,begin_x);
-
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
+    nlines = 0;
+    ncols  = 0;
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
+            return NULL;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
+                              &nlines,&ncols,&begin_y,&begin_x))
+            return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "derwin requires 2 or 4 arguments");
+        return NULL;
+    }
 
-  return (PyObject *)PyCursesWindow_New(win);
+    win = derwin(self->win,nlines,ncols,begin_y,begin_x);
+
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
+
+    return (PyObject *)PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype ch;
-  attr_t attr = A_NORMAL;
-  long lattr;
-
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"O;ch or int", &temp))
-      return NULL;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments");
-
-
-    return NULL;
-  }
-
-  if (!PyCurses_ConvertToChtype(temp, &ch)) {
-    PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
-    return NULL;
-  }
-  
+    PyObject *temp;
+    chtype ch;
+    attr_t attr = A_NORMAL;
+    long lattr;
+
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"O;ch or int", &temp))
+            return NULL;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments");
+
+
+        return NULL;
+    }
+
+    if (!PyCurses_ConvertToChtype(temp, &ch)) {
+        PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
+        return NULL;
+    }
+
 #ifdef WINDOW_HAS_FLAGS
-  if (self->win->_flags & _ISPAD)
-    return PyCursesCheckERR(pechochar(self->win, ch | attr), 
-			    "echochar");
-  else
+    if (self->win->_flags & _ISPAD)
+        return PyCursesCheckERR(pechochar(self->win, ch | attr),
+                                "echochar");
+    else
 #endif
-    return PyCursesCheckERR(wechochar(self->win, ch | attr), 
-			    "echochar");
+        return PyCursesCheckERR(wechochar(self->win, ch | attr),
+                                "echochar");
 }
 
 #ifdef NCURSES_MOUSE_VERSION
 static PyObject *
 PyCursesWindow_Enclose(PyCursesWindowObject *self, PyObject *args)
 {
-	int x, y;
-	if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x))
-		return NULL;
+    int x, y;
+    if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x))
+        return NULL;
 
-	return PyLong_FromLong( wenclose(self->win,y,x) );
+    return PyLong_FromLong( wenclose(self->win,y,x) );
 }
 #endif
 
 static PyObject *
 PyCursesWindow_GetBkgd(PyCursesWindowObject *self)
 {
-  return PyLong_FromLong((long) getbkgd(self->win));
+    return PyLong_FromLong((long) getbkgd(self->win));
 }
 
 static PyObject *
 PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y;
-  int rtn;
+    int x, y;
+    int rtn;
 
-  switch (PyTuple_Size(args)) {
-  case 0:
-    Py_BEGIN_ALLOW_THREADS
-    rtn = wgetch(self->win);
-    Py_END_ALLOW_THREADS
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
-      return NULL;
-    Py_BEGIN_ALLOW_THREADS
-    rtn = mvwgetch(self->win,y,x);
-    Py_END_ALLOW_THREADS
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments");
-    return NULL;
-  }
-  return PyLong_FromLong((long)rtn);
+    switch (PyTuple_Size(args)) {
+    case 0:
+        Py_BEGIN_ALLOW_THREADS
+        rtn = wgetch(self->win);
+        Py_END_ALLOW_THREADS
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+            return NULL;
+        Py_BEGIN_ALLOW_THREADS
+        rtn = mvwgetch(self->win,y,x);
+        Py_END_ALLOW_THREADS
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments");
+        return NULL;
+    }
+    return PyLong_FromLong((long)rtn);
 }
 
 static PyObject *
 PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y;
-  int rtn;
+    int x, y;
+    int rtn;
 
-  switch (PyTuple_Size(args)) {
-  case 0:
-    Py_BEGIN_ALLOW_THREADS
-    rtn = wgetch(self->win);
-    Py_END_ALLOW_THREADS
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
-      return NULL;
-    Py_BEGIN_ALLOW_THREADS
-    rtn = mvwgetch(self->win,y,x);
-    Py_END_ALLOW_THREADS
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments");
-    return NULL;
-  }
-  if (rtn == ERR) {
-    /* getch() returns ERR in nodelay mode */
-    PyErr_SetString(PyCursesError, "no input");
-    return NULL;
-  } else if (rtn<=255) {
-    return Py_BuildValue("C", rtn);
-  } else {
-    const char *knp;
+    switch (PyTuple_Size(args)) {
+    case 0:
+        Py_BEGIN_ALLOW_THREADS
+        rtn = wgetch(self->win);
+        Py_END_ALLOW_THREADS
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+            return NULL;
+        Py_BEGIN_ALLOW_THREADS
+        rtn = mvwgetch(self->win,y,x);
+        Py_END_ALLOW_THREADS
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments");
+        return NULL;
+    }
+    if (rtn == ERR) {
+        /* getch() returns ERR in nodelay mode */
+        PyErr_SetString(PyCursesError, "no input");
+        return NULL;
+    } else if (rtn<=255) {
+        return Py_BuildValue("C", rtn);
+    } else {
+        const char *knp;
 #if defined(__NetBSD__)
-    knp = unctrl(rtn);
+        knp = unctrl(rtn);
 #else
-    knp = keyname(rtn);
+        knp = keyname(rtn);
 #endif
-    return PyUnicode_FromString((knp == NULL) ? "" : knp);
-  }
+        return PyUnicode_FromString((knp == NULL) ? "" : knp);
+    }
 }
 
 static PyObject *
 PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y, n;
-  char rtn[1024]; /* This should be big enough.. I hope */
-  int rtn2;
-
-  switch (PyTuple_Size(args)) {
-  case 0:
-    Py_BEGIN_ALLOW_THREADS
-    rtn2 = wgetnstr(self->win,rtn, 1023);
-    Py_END_ALLOW_THREADS
-    break;
-  case 1:
-    if (!PyArg_ParseTuple(args,"i;n", &n))
-      return NULL;
-    Py_BEGIN_ALLOW_THREADS
-    rtn2 = wgetnstr(self->win,rtn,MIN(n, 1023));
-    Py_END_ALLOW_THREADS
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
-      return NULL;
-    Py_BEGIN_ALLOW_THREADS
+    int x, y, n;
+    char rtn[1024]; /* This should be big enough.. I hope */
+    int rtn2;
+
+    switch (PyTuple_Size(args)) {
+    case 0:
+        Py_BEGIN_ALLOW_THREADS
+        rtn2 = wgetnstr(self->win,rtn, 1023);
+        Py_END_ALLOW_THREADS
+        break;
+    case 1:
+        if (!PyArg_ParseTuple(args,"i;n", &n))
+            return NULL;
+        Py_BEGIN_ALLOW_THREADS
+        rtn2 = wgetnstr(self->win,rtn,MIN(n, 1023));
+        Py_END_ALLOW_THREADS
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+            return NULL;
+        Py_BEGIN_ALLOW_THREADS
 #ifdef STRICT_SYSV_CURSES
-    rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, 1023);
+        rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, 1023);
 #else
-    rtn2 = mvwgetnstr(self->win,y,x,rtn, 1023);
+        rtn2 = mvwgetnstr(self->win,y,x,rtn, 1023);
 #endif
-    Py_END_ALLOW_THREADS
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n))
-      return NULL;
+        Py_END_ALLOW_THREADS
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n))
+            return NULL;
 #ifdef STRICT_SYSV_CURSES
-    Py_BEGIN_ALLOW_THREADS
-    rtn2 = wmove(self->win,y,x)==ERR ? ERR :
-      wgetnstr(self->win, rtn, MIN(n, 1023));
-    Py_END_ALLOW_THREADS
+        Py_BEGIN_ALLOW_THREADS
+        rtn2 = wmove(self->win,y,x)==ERR ? ERR :
+        wgetnstr(self->win, rtn, MIN(n, 1023));
+        Py_END_ALLOW_THREADS
 #else
-    Py_BEGIN_ALLOW_THREADS
-    rtn2 = mvwgetnstr(self->win, y, x, rtn, MIN(n, 1023));
-    Py_END_ALLOW_THREADS
-#endif
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 3 arguments");
-    return NULL;
-  }
-  if (rtn2 == ERR)
-    rtn[0] = 0;
-  return PyBytes_FromString(rtn);
+        Py_BEGIN_ALLOW_THREADS
+        rtn2 = mvwgetnstr(self->win, y, x, rtn, MIN(n, 1023));
+        Py_END_ALLOW_THREADS
+#endif
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 3 arguments");
+        return NULL;
+    }
+    if (rtn2 == ERR)
+        rtn[0] = 0;
+    return PyBytes_FromString(rtn);
 }
 
 static PyObject *
 PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype ch;
-  int n, x, y, code = OK;
-  attr_t attr = A_NORMAL;
-  long lattr;
-
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n))
-      return NULL;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
-      return NULL;
-    code = wmove(self->win, y, x);
-    break;
-  case 5:
-    if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", 
-		     &y, &x, &temp, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    code = wmove(self->win, y, x);
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments");
-    return NULL;
-  }
+    PyObject *temp;
+    chtype ch;
+    int n, x, y, code = OK;
+    attr_t attr = A_NORMAL;
+    long lattr;
 
-  if (code != ERR) {
-    if (!PyCurses_ConvertToChtype(temp, &ch)) {
-      PyErr_SetString(PyExc_TypeError, 
-		      "argument 1 or 3 must be a ch or an int");
-      return NULL;
-    }
-    return PyCursesCheckERR(whline(self->win, ch | attr, n), "hline");
-  } else 
-    return PyCursesCheckERR(code, "wmove");
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n))
+            return NULL;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
+            return NULL;
+        code = wmove(self->win, y, x);
+        break;
+    case 5:
+        if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
+                              &y, &x, &temp, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        code = wmove(self->win, y, x);
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments");
+        return NULL;
+    }
+
+    if (code != ERR) {
+        if (!PyCurses_ConvertToChtype(temp, &ch)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "argument 1 or 3 must be a ch or an int");
+            return NULL;
+        }
+        return PyCursesCheckERR(whline(self->win, ch | attr, n), "hline");
+    } else
+        return PyCursesCheckERR(code, "wmove");
 }
 
 static PyObject *
 PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn, x, y, use_xy = FALSE;
-  PyObject *temp;
-  chtype ch = 0;
-  attr_t attr = A_NORMAL;
-  long lattr;
-  
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
-      return NULL;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments");
-    return NULL;
-  }
-
-  if (!PyCurses_ConvertToChtype(temp, &ch)) {
-    PyErr_SetString(PyExc_TypeError, 
-		    "argument 1 or 3 must be a ch or an int");
-    return NULL;
-  }
-  
-  if (use_xy == TRUE)
-    rtn = mvwinsch(self->win,y,x, ch | attr);
-  else {
-    rtn = winsch(self->win, ch | attr);
-  }
-  return PyCursesCheckERR(rtn, "insch");
+    int rtn, x, y, use_xy = FALSE;
+    PyObject *temp;
+    chtype ch = 0;
+    attr_t attr = A_NORMAL;
+    long lattr;
+
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args, "O;ch or int", &temp))
+            return NULL;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments");
+        return NULL;
+    }
+
+    if (!PyCurses_ConvertToChtype(temp, &ch)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "argument 1 or 3 must be a ch or an int");
+        return NULL;
+    }
+
+    if (use_xy == TRUE)
+        rtn = mvwinsch(self->win,y,x, ch | attr);
+    else {
+        rtn = winsch(self->win, ch | attr);
+    }
+    return PyCursesCheckERR(rtn, "insch");
 }
 
 static PyObject *
 PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y, rtn;
+    int x, y, rtn;
 
-  switch (PyTuple_Size(args)) {
-  case 0:
-    rtn = winch(self->win);
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
-      return NULL;
-    rtn = mvwinch(self->win,y,x);
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments");
-    return NULL;
-  }
-  return PyLong_FromLong((long) rtn);
+    switch (PyTuple_Size(args)) {
+    case 0:
+        rtn = winch(self->win);
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+            return NULL;
+        rtn = mvwinch(self->win,y,x);
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments");
+        return NULL;
+    }
+    return PyLong_FromLong((long) rtn);
 }
 
 static PyObject *
 PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y, n;
-  char rtn[1024]; /* This should be big enough.. I hope */
-  int rtn2;
-
-  switch (PyTuple_Size(args)) {
-  case 0:
-    rtn2 = winnstr(self->win,rtn, 1023);
-    break;
-  case 1:
-    if (!PyArg_ParseTuple(args,"i;n", &n))
-      return NULL;
-    rtn2 = winnstr(self->win,rtn,MIN(n,1023));
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
-      return NULL;
-    rtn2 = mvwinnstr(self->win,y,x,rtn,1023);
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n))
-      return NULL;
-    rtn2 = mvwinnstr(self->win, y, x, rtn, MIN(n,1023));
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "instr requires 0 or 3 arguments");
-    return NULL;
-  }
-  if (rtn2 == ERR)
-    rtn[0] = 0;
-  return PyBytes_FromString(rtn);
+    int x, y, n;
+    char rtn[1024]; /* This should be big enough.. I hope */
+    int rtn2;
+
+    switch (PyTuple_Size(args)) {
+    case 0:
+        rtn2 = winnstr(self->win,rtn, 1023);
+        break;
+    case 1:
+        if (!PyArg_ParseTuple(args,"i;n", &n))
+            return NULL;
+        rtn2 = winnstr(self->win,rtn,MIN(n,1023));
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+            return NULL;
+        rtn2 = mvwinnstr(self->win,y,x,rtn,1023);
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n))
+            return NULL;
+        rtn2 = mvwinnstr(self->win, y, x, rtn, MIN(n,1023));
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "instr requires 0 or 3 arguments");
+        return NULL;
+    }
+    if (rtn2 == ERR)
+        rtn[0] = 0;
+    return PyBytes_FromString(rtn);
 }
 
 static PyObject *
 PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn;
-  int x, y;
-  char *str;
-  attr_t attr = A_NORMAL , attr_old = A_NORMAL;
-  long lattr;
-  int use_xy = FALSE, use_attr = FALSE;
-
-  switch (PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"s;str", &str))
-      return NULL;
-    break;
-  case 2:
-    if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
-      return NULL;
-    attr = lattr;
-    use_attr = TRUE;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"iis;y,x,str", &y, &x, &str))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = use_attr = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments");
-    return NULL;
-  }
-
-  if (use_attr == TRUE) {
-    attr_old = getattrs(self->win);
-    (void)wattrset(self->win,attr);
-  }
-  if (use_xy == TRUE)
-    rtn = mvwinsstr(self->win,y,x,str);
-  else
-    rtn = winsstr(self->win,str);
-  if (use_attr == TRUE)
-    (void)wattrset(self->win,attr_old);
-  return PyCursesCheckERR(rtn, "insstr");
+    int rtn;
+    int x, y;
+    char *str;
+    attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+    long lattr;
+    int use_xy = FALSE, use_attr = FALSE;
+
+    switch (PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"s;str", &str))
+            return NULL;
+        break;
+    case 2:
+        if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
+            return NULL;
+        attr = lattr;
+        use_attr = TRUE;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"iis;y,x,str", &y, &x, &str))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = use_attr = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments");
+        return NULL;
+    }
+
+    if (use_attr == TRUE) {
+        attr_old = getattrs(self->win);
+        (void)wattrset(self->win,attr);
+    }
+    if (use_xy == TRUE)
+        rtn = mvwinsstr(self->win,y,x,str);
+    else
+        rtn = winsstr(self->win,str);
+    if (use_attr == TRUE)
+        (void)wattrset(self->win,attr_old);
+    return PyCursesCheckERR(rtn, "insstr");
 }
 
 static PyObject *
 PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args)
 {
-  int rtn, x, y, n;
-  char *str;
-  attr_t attr = A_NORMAL , attr_old = A_NORMAL;
-  long lattr;
-  int use_xy = FALSE, use_attr = FALSE;
-
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"si;str,n", &str, &n))
-      return NULL;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    use_attr = TRUE;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n))
-      return NULL;
-    use_xy = TRUE;
-    break;
-  case 5:
-    if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    use_xy = use_attr = TRUE;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments");
-    return NULL;
-  }
-
-  if (use_attr == TRUE) {
-    attr_old = getattrs(self->win);
-    (void)wattrset(self->win,attr);
-  }
-  if (use_xy == TRUE)
-    rtn = mvwinsnstr(self->win,y,x,str,n);
-  else
-    rtn = winsnstr(self->win,str,n);
-  if (use_attr == TRUE)
-    (void)wattrset(self->win,attr_old);
-  return PyCursesCheckERR(rtn, "insnstr");
+    int rtn, x, y, n;
+    char *str;
+    attr_t attr = A_NORMAL , attr_old = A_NORMAL;
+    long lattr;
+    int use_xy = FALSE, use_attr = FALSE;
+
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"si;str,n", &str, &n))
+            return NULL;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        use_attr = TRUE;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n))
+            return NULL;
+        use_xy = TRUE;
+        break;
+    case 5:
+        if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        use_xy = use_attr = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments");
+        return NULL;
+    }
+
+    if (use_attr == TRUE) {
+        attr_old = getattrs(self->win);
+        (void)wattrset(self->win,attr);
+    }
+    if (use_xy == TRUE)
+        rtn = mvwinsnstr(self->win,y,x,str,n);
+    else
+        rtn = winsnstr(self->win,str,n);
+    if (use_attr == TRUE)
+        (void)wattrset(self->win,attr_old);
+    return PyCursesCheckERR(rtn, "insnstr");
 }
 
 static PyObject *
 PyCursesWindow_Is_LineTouched(PyCursesWindowObject *self, PyObject *args)
 {
-  int line, erg;
-  if (!PyArg_ParseTuple(args,"i;line", &line))
-    return NULL;
-  erg = is_linetouched(self->win, line);
-  if (erg == ERR) {
-    PyErr_SetString(PyExc_TypeError, 
-		    "is_linetouched: line number outside of boundaries");
-    return NULL;
-  } else 
-    if (erg == FALSE) {
-      Py_INCREF(Py_False);
-      return Py_False;
-    } else {
-      Py_INCREF(Py_True);
-      return Py_True;
-    }
+    int line, erg;
+    if (!PyArg_ParseTuple(args,"i;line", &line))
+        return NULL;
+    erg = is_linetouched(self->win, line);
+    if (erg == ERR) {
+        PyErr_SetString(PyExc_TypeError,
+                        "is_linetouched: line number outside of boundaries");
+        return NULL;
+    } else
+        if (erg == FALSE) {
+            Py_INCREF(Py_False);
+            return Py_False;
+        } else {
+            Py_INCREF(Py_True);
+            return Py_True;
+        }
 }
 
 static PyObject *
 PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args)
 {
-  int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
-  int rtn;
+    int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
+    int rtn;
 
 #ifndef WINDOW_HAS_FLAGS
-  if (0)
+    if (0)
 #else
-  if (self->win->_flags & _ISPAD)
+        if (self->win->_flags & _ISPAD)
 #endif
-    {
-    switch(PyTuple_Size(args)) {
-    case 6:
-      if (!PyArg_ParseTuple(args, 
-		       "iiiiii;" \
-		       "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", 
-		       &pminrow, &pmincol, &sminrow, 
-		       &smincol, &smaxrow, &smaxcol))
-	return NULL;
-      Py_BEGIN_ALLOW_THREADS
-      rtn = pnoutrefresh(self->win,
-			 pminrow, pmincol, sminrow, 
-			 smincol, smaxrow, smaxcol);
-      Py_END_ALLOW_THREADS
-      return PyCursesCheckERR(rtn, "pnoutrefresh");
-    default:
-      PyErr_SetString(PyCursesError, 
-		      "noutrefresh() called for a pad " 
-		      "requires 6 arguments");
-      return NULL;
-    }
-  } else {
-    if (!PyArg_ParseTuple(args, ":noutrefresh"))
-      return NULL;    
-
-    Py_BEGIN_ALLOW_THREADS
-    rtn = wnoutrefresh(self->win);
-    Py_END_ALLOW_THREADS
-    return PyCursesCheckERR(rtn, "wnoutrefresh");
-  }
+        {
+            switch(PyTuple_Size(args)) {
+            case 6:
+                if (!PyArg_ParseTuple(args,
+                                      "iiiiii;" \
+                                      "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol",
+                                      &pminrow, &pmincol, &sminrow,
+                                      &smincol, &smaxrow, &smaxcol))
+                    return NULL;
+                Py_BEGIN_ALLOW_THREADS
+                rtn = pnoutrefresh(self->win,
+                                   pminrow, pmincol, sminrow,
+                                   smincol, smaxrow, smaxcol);
+                Py_END_ALLOW_THREADS
+                return PyCursesCheckERR(rtn, "pnoutrefresh");
+            default:
+                PyErr_SetString(PyCursesError,
+                                "noutrefresh() called for a pad "
+                                "requires 6 arguments");
+                return NULL;
+            }
+        } else {
+            if (!PyArg_ParseTuple(args, ":noutrefresh"))
+                return NULL;
+
+            Py_BEGIN_ALLOW_THREADS
+            rtn = wnoutrefresh(self->win);
+            Py_END_ALLOW_THREADS
+            return PyCursesCheckERR(rtn, "wnoutrefresh");
+        }
 }
 
 static PyObject *
@@ -1286,34 +1286,34 @@
     int use_copywin = FALSE;
     int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
     int rtn;
-    
+
     switch (PyTuple_Size(args)) {
     case 1:
-	if (!PyArg_ParseTuple(args, "O!;window object",
-			      &PyCursesWindow_Type, &temp))
-	    return NULL;
-	break;
+        if (!PyArg_ParseTuple(args, "O!;window object",
+                              &PyCursesWindow_Type, &temp))
+            return NULL;
+        break;
     case 7:
-	if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int",
-			      &PyCursesWindow_Type, &temp, &sminrow, &smincol,
-			      &dminrow, &dmincol, &dmaxrow, &dmaxcol))
-	    return NULL;
-	use_copywin = TRUE;
-	break;
-    default:
-	PyErr_SetString(PyExc_TypeError,
-			"overlay requires one or seven arguments");
-	return NULL;
+        if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int",
+                              &PyCursesWindow_Type, &temp, &sminrow, &smincol,
+                              &dminrow, &dmincol, &dmaxrow, &dmaxcol))
+            return NULL;
+        use_copywin = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError,
+                        "overlay requires one or seven arguments");
+        return NULL;
     }
 
     if (use_copywin == TRUE) {
-	    rtn = copywin(self->win, temp->win, sminrow, smincol,
-			  dminrow, dmincol, dmaxrow, dmaxcol, TRUE);
-	    return PyCursesCheckERR(rtn, "copywin");
+        rtn = copywin(self->win, temp->win, sminrow, smincol,
+                      dminrow, dmincol, dmaxrow, dmaxcol, TRUE);
+        return PyCursesCheckERR(rtn, "copywin");
     }
     else {
-	    rtn = overlay(self->win, temp->win);
-	    return PyCursesCheckERR(rtn, "overlay");
+        rtn = overlay(self->win, temp->win);
+        return PyCursesCheckERR(rtn, "overlay");
     }
 }
 
@@ -1324,377 +1324,377 @@
     int use_copywin = FALSE;
     int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
     int rtn;
-    
+
     switch (PyTuple_Size(args)) {
     case 1:
-	if (!PyArg_ParseTuple(args, "O!;window object",
-			      &PyCursesWindow_Type, &temp))
-	    return NULL;
-	break;
+        if (!PyArg_ParseTuple(args, "O!;window object",
+                              &PyCursesWindow_Type, &temp))
+            return NULL;
+        break;
     case 7:
-	if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int",
-			      &PyCursesWindow_Type, &temp, &sminrow, &smincol,
-			      &dminrow, &dmincol, &dmaxrow, &dmaxcol))
-	    return NULL;
-	use_copywin = TRUE;
-	break;
-    default:
-	PyErr_SetString(PyExc_TypeError,
-			"overwrite requires one or seven arguments");
-	return NULL;
+        if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int",
+                              &PyCursesWindow_Type, &temp, &sminrow, &smincol,
+                              &dminrow, &dmincol, &dmaxrow, &dmaxcol))
+            return NULL;
+        use_copywin = TRUE;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError,
+                        "overwrite requires one or seven arguments");
+        return NULL;
     }
 
     if (use_copywin == TRUE) {
-	rtn = copywin(self->win, temp->win, sminrow, smincol,
-		      dminrow, dmincol, dmaxrow, dmaxcol, FALSE);
+        rtn = copywin(self->win, temp->win, sminrow, smincol,
+                      dminrow, dmincol, dmaxrow, dmaxcol, FALSE);
         return PyCursesCheckERR(rtn, "copywin");
     }
     else {
-	    rtn = overwrite(self->win, temp->win);
-	    return PyCursesCheckERR(rtn, "overwrite");
+        rtn = overwrite(self->win, temp->win);
+        return PyCursesCheckERR(rtn, "overwrite");
     }
 }
 
 static PyObject *
 PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
 {
-  /* We have to simulate this by writing to a temporary FILE*,
-     then reading back, then writing to the argument stream. */
-  char fn[100];
-  int fd;
-  FILE *fp;
-  PyObject *res;
-
-  strcpy(fn, "/tmp/py.curses.putwin.XXXXXX");
-  fd = mkstemp(fn);
-  if (fd < 0)
-    return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
-  fp = fdopen(fd, "wb+");
-  if (fp == NULL) {
-    close(fd);
-    remove(fn);
-    return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
-  }
-  res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
-  if (res == NULL) {
+    /* We have to simulate this by writing to a temporary FILE*,
+       then reading back, then writing to the argument stream. */
+    char fn[100];
+    int fd;
+    FILE *fp;
+    PyObject *res;
+
+    strcpy(fn, "/tmp/py.curses.putwin.XXXXXX");
+    fd = mkstemp(fn);
+    if (fd < 0)
+        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+    fp = fdopen(fd, "wb+");
+    if (fp == NULL) {
+        close(fd);
+        remove(fn);
+        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+    }
+    res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
+    if (res == NULL) {
+        fclose(fp);
+        remove(fn);
+        return res;
+    }
+    fseek(fp, 0, 0);
+    while (1) {
+        char buf[BUFSIZ];
+        Py_ssize_t n = fread(buf, 1, BUFSIZ, fp);
+        if (n <= 0)
+            break;
+        Py_DECREF(res);
+        res = PyObject_CallMethod(stream, "write", "y#", buf, n);
+        if (res == NULL)
+            break;
+    }
     fclose(fp);
     remove(fn);
     return res;
-  }
-  fseek(fp, 0, 0);
-  while (1) {
-    char buf[BUFSIZ];
-    Py_ssize_t n = fread(buf, 1, BUFSIZ, fp);
-    if (n <= 0)
-      break;
-    Py_DECREF(res);
-    res = PyObject_CallMethod(stream, "write", "y#", buf, n);
-    if (res == NULL)
-      break;
-  }
-  fclose(fp);
-  remove(fn);
-  return res;
 }
 
 static PyObject *
 PyCursesWindow_RedrawLine(PyCursesWindowObject *self, PyObject *args)
 {
-  int beg, num;
-  if (!PyArg_ParseTuple(args, "ii;beg,num", &beg, &num))
-    return NULL;
-  return PyCursesCheckERR(wredrawln(self->win,beg,num), "redrawln");
+    int beg, num;
+    if (!PyArg_ParseTuple(args, "ii;beg,num", &beg, &num))
+        return NULL;
+    return PyCursesCheckERR(wredrawln(self->win,beg,num), "redrawln");
 }
 
 static PyObject *
 PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args)
 {
-  int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
-  int rtn;
-  
+    int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
+    int rtn;
+
 #ifndef WINDOW_HAS_FLAGS
-  if (0)
+    if (0)
 #else
-  if (self->win->_flags & _ISPAD)
+        if (self->win->_flags & _ISPAD)
 #endif
-    {
-    switch(PyTuple_Size(args)) {
-    case 6:
-      if (!PyArg_ParseTuple(args, 
-		       "iiiiii;" \
-		       "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", 
-		       &pminrow, &pmincol, &sminrow, 
-		       &smincol, &smaxrow, &smaxcol))
-	return NULL;
-
-      Py_BEGIN_ALLOW_THREADS
-      rtn = prefresh(self->win,
-		     pminrow, pmincol, sminrow, 
-		     smincol, smaxrow, smaxcol);
-      Py_END_ALLOW_THREADS
-      return PyCursesCheckERR(rtn, "prefresh");
-    default:
-      PyErr_SetString(PyCursesError, 
-		      "refresh() for a pad requires 6 arguments");
-      return NULL;
-    }
-  } else {
-    if (!PyArg_ParseTuple(args, ":refresh"))
-      return NULL;    
-    Py_BEGIN_ALLOW_THREADS
-    rtn = wrefresh(self->win);
-    Py_END_ALLOW_THREADS
-    return PyCursesCheckERR(rtn, "prefresh");    
-  }
+        {
+            switch(PyTuple_Size(args)) {
+            case 6:
+                if (!PyArg_ParseTuple(args,
+                                      "iiiiii;" \
+                                      "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol",
+                                      &pminrow, &pmincol, &sminrow,
+                                      &smincol, &smaxrow, &smaxcol))
+                    return NULL;
+
+                Py_BEGIN_ALLOW_THREADS
+                rtn = prefresh(self->win,
+                               pminrow, pmincol, sminrow,
+                               smincol, smaxrow, smaxcol);
+                Py_END_ALLOW_THREADS
+                return PyCursesCheckERR(rtn, "prefresh");
+            default:
+                PyErr_SetString(PyCursesError,
+                                "refresh() for a pad requires 6 arguments");
+                return NULL;
+            }
+        } else {
+            if (!PyArg_ParseTuple(args, ":refresh"))
+                return NULL;
+            Py_BEGIN_ALLOW_THREADS
+            rtn = wrefresh(self->win);
+            Py_END_ALLOW_THREADS
+            return PyCursesCheckERR(rtn, "prefresh");
+        }
 }
 
 static PyObject *
 PyCursesWindow_SetScrollRegion(PyCursesWindowObject *self, PyObject *args)
 {
-  int x, y;
-  if (!PyArg_ParseTuple(args,"ii;top, bottom",&y,&x))
-    return NULL;
-  return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg");
+    int x, y;
+    if (!PyArg_ParseTuple(args,"ii;top, bottom",&y,&x))
+        return NULL;
+    return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg");
 }
 
 static PyObject *
 PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args)
 {
-  WINDOW *win;
-  int nlines, ncols, begin_y, begin_x;
+    WINDOW *win;
+    int nlines, ncols, begin_y, begin_x;
 
-  nlines = 0;
-  ncols  = 0;
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
-      return NULL;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
-		   &nlines,&ncols,&begin_y,&begin_x))
-      return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments");
-    return NULL;
-  }
+    nlines = 0;
+    ncols  = 0;
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
+            return NULL;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
+                              &nlines,&ncols,&begin_y,&begin_x))
+            return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments");
+        return NULL;
+    }
 
-  /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
+    /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
 #ifdef WINDOW_HAS_FLAGS
-  if (self->win->_flags & _ISPAD)
-    win = subpad(self->win, nlines, ncols, begin_y, begin_x);
-  else
-#endif
-    win = subwin(self->win, nlines, ncols, begin_y, begin_x);
-
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
-  
-  return (PyObject *)PyCursesWindow_New(win);
+    if (self->win->_flags & _ISPAD)
+        win = subpad(self->win, nlines, ncols, begin_y, begin_x);
+    else
+#endif
+        win = subwin(self->win, nlines, ncols, begin_y, begin_x);
+
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
+
+    return (PyObject *)PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCursesWindow_Scroll(PyCursesWindowObject *self, PyObject *args)
 {
-  int nlines;
-  switch(PyTuple_Size(args)) {
-  case 0:
-    return PyCursesCheckERR(scroll(self->win), "scroll");
-  case 1:
-    if (!PyArg_ParseTuple(args, "i;nlines", &nlines))
-      return NULL;
-    return PyCursesCheckERR(wscrl(self->win, nlines), "scroll");
-  default:
-    PyErr_SetString(PyExc_TypeError, "scroll requires 0 or 1 arguments");
-    return NULL;
-  }
+    int nlines;
+    switch(PyTuple_Size(args)) {
+    case 0:
+        return PyCursesCheckERR(scroll(self->win), "scroll");
+    case 1:
+        if (!PyArg_ParseTuple(args, "i;nlines", &nlines))
+            return NULL;
+        return PyCursesCheckERR(wscrl(self->win, nlines), "scroll");
+    default:
+        PyErr_SetString(PyExc_TypeError, "scroll requires 0 or 1 arguments");
+        return NULL;
+    }
 }
 
 static PyObject *
 PyCursesWindow_TouchLine(PyCursesWindowObject *self, PyObject *args)
 {
-  int st, cnt, val;
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;start,count",&st,&cnt))
-      return NULL;
-    return PyCursesCheckERR(touchline(self->win,st,cnt), "touchline");
-  case 3:
-    if (!PyArg_ParseTuple(args, "iii;start,count,val", &st, &cnt, &val))
-      return NULL;
-    return PyCursesCheckERR(wtouchln(self->win, st, cnt, val), "touchline");
-  default:
-    PyErr_SetString(PyExc_TypeError, "touchline requires 2 or 3 arguments");
-    return NULL;
-  }
+    int st, cnt, val;
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;start,count",&st,&cnt))
+            return NULL;
+        return PyCursesCheckERR(touchline(self->win,st,cnt), "touchline");
+    case 3:
+        if (!PyArg_ParseTuple(args, "iii;start,count,val", &st, &cnt, &val))
+            return NULL;
+        return PyCursesCheckERR(wtouchln(self->win, st, cnt, val), "touchline");
+    default:
+        PyErr_SetString(PyExc_TypeError, "touchline requires 2 or 3 arguments");
+        return NULL;
+    }
 }
 
 static PyObject *
 PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype ch;
-  int n, x, y, code = OK;
-  attr_t attr = A_NORMAL;
-  long lattr;
-
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n))
-      return NULL;
-    break;
-  case 3:
-    if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
-      return NULL;
-    code = wmove(self->win, y, x);
-    break;
-  case 5:
-    if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", 
-		     &y, &x, &temp, &n, &lattr))
-      return NULL;
-    attr = lattr;
-    code = wmove(self->win, y, x);
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments");
-    return NULL;
-  }
+    PyObject *temp;
+    chtype ch;
+    int n, x, y, code = OK;
+    attr_t attr = A_NORMAL;
+    long lattr;
 
-  if (code != ERR) {
-    if (!PyCurses_ConvertToChtype(temp, &ch)) {
-      PyErr_SetString(PyExc_TypeError, 
-		      "argument 1 or 3 must be a ch or an int");
-      return NULL;
-    }
-    return PyCursesCheckERR(wvline(self->win, ch | attr, n), "vline");
-  } else
-    return PyCursesCheckERR(code, "wmove");
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n))
+            return NULL;
+        break;
+    case 3:
+        if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
+            return NULL;
+        code = wmove(self->win, y, x);
+        break;
+    case 5:
+        if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
+                              &y, &x, &temp, &n, &lattr))
+            return NULL;
+        attr = lattr;
+        code = wmove(self->win, y, x);
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments");
+        return NULL;
+    }
+
+    if (code != ERR) {
+        if (!PyCurses_ConvertToChtype(temp, &ch)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "argument 1 or 3 must be a ch or an int");
+            return NULL;
+        }
+        return PyCursesCheckERR(wvline(self->win, ch | attr, n), "vline");
+    } else
+        return PyCursesCheckERR(code, "wmove");
 }
 
 static PyMethodDef PyCursesWindow_Methods[] = {
-	{"addch",           (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS},
-	{"addnstr",         (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS},
-	{"addstr",          (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS},
-	{"attroff",         (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS},
-	{"attron",          (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
-	{"attrset",         (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
-	{"bkgd",            (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
-	{"chgat",           (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
-	{"bkgdset",         (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
-	{"border",          (PyCFunction)PyCursesWindow_Border, METH_VARARGS},
-	{"box",             (PyCFunction)PyCursesWindow_Box, METH_VARARGS},
-	{"clear",           (PyCFunction)PyCursesWindow_wclear, METH_NOARGS},
-	{"clearok",         (PyCFunction)PyCursesWindow_clearok, METH_VARARGS},
-	{"clrtobot",        (PyCFunction)PyCursesWindow_wclrtobot, METH_NOARGS},
-	{"clrtoeol",        (PyCFunction)PyCursesWindow_wclrtoeol, METH_NOARGS},
-	{"cursyncup",       (PyCFunction)PyCursesWindow_wcursyncup, METH_NOARGS},
-	{"delch",           (PyCFunction)PyCursesWindow_DelCh, METH_VARARGS},
-	{"deleteln",        (PyCFunction)PyCursesWindow_wdeleteln, METH_NOARGS},
-	{"derwin",          (PyCFunction)PyCursesWindow_DerWin, METH_VARARGS},
-	{"echochar",        (PyCFunction)PyCursesWindow_EchoChar, METH_VARARGS},
+    {"addch",           (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS},
+    {"addnstr",         (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS},
+    {"addstr",          (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS},
+    {"attroff",         (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS},
+    {"attron",          (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
+    {"attrset",         (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
+    {"bkgd",            (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
+    {"chgat",           (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
+    {"bkgdset",         (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
+    {"border",          (PyCFunction)PyCursesWindow_Border, METH_VARARGS},
+    {"box",             (PyCFunction)PyCursesWindow_Box, METH_VARARGS},
+    {"clear",           (PyCFunction)PyCursesWindow_wclear, METH_NOARGS},
+    {"clearok",         (PyCFunction)PyCursesWindow_clearok, METH_VARARGS},
+    {"clrtobot",        (PyCFunction)PyCursesWindow_wclrtobot, METH_NOARGS},
+    {"clrtoeol",        (PyCFunction)PyCursesWindow_wclrtoeol, METH_NOARGS},
+    {"cursyncup",       (PyCFunction)PyCursesWindow_wcursyncup, METH_NOARGS},
+    {"delch",           (PyCFunction)PyCursesWindow_DelCh, METH_VARARGS},
+    {"deleteln",        (PyCFunction)PyCursesWindow_wdeleteln, METH_NOARGS},
+    {"derwin",          (PyCFunction)PyCursesWindow_DerWin, METH_VARARGS},
+    {"echochar",        (PyCFunction)PyCursesWindow_EchoChar, METH_VARARGS},
 #ifdef NCURSES_MOUSE_VERSION
-	{"enclose",         (PyCFunction)PyCursesWindow_Enclose, METH_VARARGS},
+    {"enclose",         (PyCFunction)PyCursesWindow_Enclose, METH_VARARGS},
 #endif
-	{"erase",           (PyCFunction)PyCursesWindow_werase, METH_NOARGS},
-	{"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
-	{"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
-	{"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
-	{"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
-	{"getmaxyx",        (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
-	{"getparyx",        (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},
-	{"getstr",          (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS},
-	{"getyx",           (PyCFunction)PyCursesWindow_getyx, METH_NOARGS},
-	{"hline",           (PyCFunction)PyCursesWindow_Hline, METH_VARARGS},
-	{"idcok",           (PyCFunction)PyCursesWindow_idcok, METH_VARARGS},
-	{"idlok",           (PyCFunction)PyCursesWindow_idlok, METH_VARARGS},
-	{"immedok",         (PyCFunction)PyCursesWindow_immedok, METH_VARARGS},
-	{"inch",            (PyCFunction)PyCursesWindow_InCh, METH_VARARGS},
-	{"insch",           (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS},
-	{"insdelln",        (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS},
-	{"insertln",        (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS},
-	{"insnstr",         (PyCFunction)PyCursesWindow_InsNStr, METH_VARARGS},
-	{"insstr",          (PyCFunction)PyCursesWindow_InsStr, METH_VARARGS},
-	{"instr",           (PyCFunction)PyCursesWindow_InStr, METH_VARARGS},
-	{"is_linetouched",  (PyCFunction)PyCursesWindow_Is_LineTouched, METH_VARARGS},
-	{"is_wintouched",   (PyCFunction)PyCursesWindow_is_wintouched, METH_NOARGS},
-	{"keypad",          (PyCFunction)PyCursesWindow_keypad, METH_VARARGS},
-	{"leaveok",         (PyCFunction)PyCursesWindow_leaveok, METH_VARARGS},
-	{"move",            (PyCFunction)PyCursesWindow_wmove, METH_VARARGS},
-	{"mvderwin",        (PyCFunction)PyCursesWindow_mvderwin, METH_VARARGS},
-	{"mvwin",           (PyCFunction)PyCursesWindow_mvwin, METH_VARARGS},
-	{"nodelay",         (PyCFunction)PyCursesWindow_nodelay, METH_VARARGS},
-	{"notimeout",       (PyCFunction)PyCursesWindow_notimeout, METH_VARARGS},
-	{"noutrefresh",     (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS},
-        /* Backward compatibility alias -- remove in Python 2.3 */
-	{"nooutrefresh",    (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS},
-	{"overlay",         (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS},
-	{"overwrite",       (PyCFunction)PyCursesWindow_Overwrite,
-         METH_VARARGS},
-	{"putwin",          (PyCFunction)PyCursesWindow_PutWin, METH_O},
-	{"redrawln",        (PyCFunction)PyCursesWindow_RedrawLine, METH_VARARGS},
-	{"redrawwin",       (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS},
-	{"refresh",         (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS},
+    {"erase",           (PyCFunction)PyCursesWindow_werase, METH_NOARGS},
+    {"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
+    {"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
+    {"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
+    {"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
+    {"getmaxyx",        (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
+    {"getparyx",        (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},
+    {"getstr",          (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS},
+    {"getyx",           (PyCFunction)PyCursesWindow_getyx, METH_NOARGS},
+    {"hline",           (PyCFunction)PyCursesWindow_Hline, METH_VARARGS},
+    {"idcok",           (PyCFunction)PyCursesWindow_idcok, METH_VARARGS},
+    {"idlok",           (PyCFunction)PyCursesWindow_idlok, METH_VARARGS},
+    {"immedok",         (PyCFunction)PyCursesWindow_immedok, METH_VARARGS},
+    {"inch",            (PyCFunction)PyCursesWindow_InCh, METH_VARARGS},
+    {"insch",           (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS},
+    {"insdelln",        (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS},
+    {"insertln",        (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS},
+    {"insnstr",         (PyCFunction)PyCursesWindow_InsNStr, METH_VARARGS},
+    {"insstr",          (PyCFunction)PyCursesWindow_InsStr, METH_VARARGS},
+    {"instr",           (PyCFunction)PyCursesWindow_InStr, METH_VARARGS},
+    {"is_linetouched",  (PyCFunction)PyCursesWindow_Is_LineTouched, METH_VARARGS},
+    {"is_wintouched",   (PyCFunction)PyCursesWindow_is_wintouched, METH_NOARGS},
+    {"keypad",          (PyCFunction)PyCursesWindow_keypad, METH_VARARGS},
+    {"leaveok",         (PyCFunction)PyCursesWindow_leaveok, METH_VARARGS},
+    {"move",            (PyCFunction)PyCursesWindow_wmove, METH_VARARGS},
+    {"mvderwin",        (PyCFunction)PyCursesWindow_mvderwin, METH_VARARGS},
+    {"mvwin",           (PyCFunction)PyCursesWindow_mvwin, METH_VARARGS},
+    {"nodelay",         (PyCFunction)PyCursesWindow_nodelay, METH_VARARGS},
+    {"notimeout",       (PyCFunction)PyCursesWindow_notimeout, METH_VARARGS},
+    {"noutrefresh",     (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS},
+    /* Backward compatibility alias -- remove in Python 2.3 */
+    {"nooutrefresh",    (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS},
+    {"overlay",         (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS},
+    {"overwrite",       (PyCFunction)PyCursesWindow_Overwrite,
+     METH_VARARGS},
+    {"putwin",          (PyCFunction)PyCursesWindow_PutWin, METH_O},
+    {"redrawln",        (PyCFunction)PyCursesWindow_RedrawLine, METH_VARARGS},
+    {"redrawwin",       (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS},
+    {"refresh",         (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS},
 #ifndef STRICT_SYSV_CURSES
-	{"resize",          (PyCFunction)PyCursesWindow_wresize, METH_VARARGS},
+    {"resize",          (PyCFunction)PyCursesWindow_wresize, METH_VARARGS},
 #endif
-	{"scroll",          (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS},
-	{"scrollok",        (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS},
-	{"setscrreg",       (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS},
-	{"standend",        (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS},
-	{"standout",        (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS},
-	{"subpad",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
-	{"subwin",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
-	{"syncdown",        (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS},
-	{"syncok",          (PyCFunction)PyCursesWindow_syncok, METH_VARARGS},
-	{"syncup",          (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS},
-	{"timeout",         (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS},
-	{"touchline",       (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS},
-	{"touchwin",        (PyCFunction)PyCursesWindow_touchwin, METH_NOARGS},
-	{"untouchwin",      (PyCFunction)PyCursesWindow_untouchwin, METH_NOARGS},
-	{"vline",           (PyCFunction)PyCursesWindow_Vline, METH_VARARGS},
-	{NULL,		    NULL}   /* sentinel */
+    {"scroll",          (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS},
+    {"scrollok",        (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS},
+    {"setscrreg",       (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS},
+    {"standend",        (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS},
+    {"standout",        (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS},
+    {"subpad",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
+    {"subwin",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
+    {"syncdown",        (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS},
+    {"syncok",          (PyCFunction)PyCursesWindow_syncok, METH_VARARGS},
+    {"syncup",          (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS},
+    {"timeout",         (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS},
+    {"touchline",       (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS},
+    {"touchwin",        (PyCFunction)PyCursesWindow_touchwin, METH_NOARGS},
+    {"untouchwin",      (PyCFunction)PyCursesWindow_untouchwin, METH_NOARGS},
+    {"vline",           (PyCFunction)PyCursesWindow_Vline, METH_VARARGS},
+    {NULL,                  NULL}   /* sentinel */
 };
 
 /* -------------------------------------------------------*/
 
 PyTypeObject PyCursesWindow_Type = {
-	PyVarObject_HEAD_INIT(NULL, 0)
-	"_curses.curses window",	/*tp_name*/
-	sizeof(PyCursesWindowObject),	/*tp_basicsize*/
-	0,			/*tp_itemsize*/
-	/* methods */
-	(destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/
-	0,			/*tp_print*/
-	(getattrfunc)0,		/*tp_getattr*/
-	(setattrfunc)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*/
-	PyCursesWindow_Methods,	/*tp_methods*/
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "_curses.curses window",            /*tp_name*/
+    sizeof(PyCursesWindowObject),       /*tp_basicsize*/
+    0,                          /*tp_itemsize*/
+    /* methods */
+    (destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/
+    0,                          /*tp_print*/
+    (getattrfunc)0,             /*tp_getattr*/
+    (setattrfunc)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*/
+    PyCursesWindow_Methods,     /*tp_methods*/
 };
 
 /*********************************************************************
@@ -1738,452 +1738,452 @@
 static PyObject *
 PyCurses_filter(PyObject *self)
 {
-  /* not checking for PyCursesInitialised here since filter() must
-     be called before initscr() */
-  filter();
-  Py_INCREF(Py_None);
-  return Py_None;
+    /* not checking for PyCursesInitialised here since filter() must
+       be called before initscr() */
+    filter();
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 PyCurses_Color_Content(PyObject *self, PyObject *args)
 {
-  short color,r,g,b;
+    short color,r,g,b;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  if (!PyArg_ParseTuple(args, "h:color_content", &color)) return NULL;
+    if (!PyArg_ParseTuple(args, "h:color_content", &color)) return NULL;
 
-  if (color_content(color, &r, &g, &b) != ERR)
-    return Py_BuildValue("(iii)", r, g, b);
-  else {
-    PyErr_SetString(PyCursesError, 
-		    "Argument 1 was out of range. Check value of COLORS.");
-    return NULL;
-  }
+    if (color_content(color, &r, &g, &b) != ERR)
+        return Py_BuildValue("(iii)", r, g, b);
+    else {
+        PyErr_SetString(PyCursesError,
+                        "Argument 1 was out of range. Check value of COLORS.");
+        return NULL;
+    }
 }
 
 static PyObject *
 PyCurses_color_pair(PyObject *self, PyObject *args)
 {
-  int n;
+    int n;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  if (!PyArg_ParseTuple(args, "i:color_pair", &n)) return NULL;
-  return PyLong_FromLong((long) (n << 8));
+    if (!PyArg_ParseTuple(args, "i:color_pair", &n)) return NULL;
+    return PyLong_FromLong((long) (n << 8));
 }
 
 static PyObject *
 PyCurses_Curs_Set(PyObject *self, PyObject *args)
 {
-  int vis,erg;
+    int vis,erg;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args, "i:curs_set", &vis)) return NULL;
+    if (!PyArg_ParseTuple(args, "i:curs_set", &vis)) return NULL;
 
-  erg = curs_set(vis);
-  if (erg == ERR) return PyCursesCheckERR(erg, "curs_set");
+    erg = curs_set(vis);
+    if (erg == ERR) return PyCursesCheckERR(erg, "curs_set");
 
-  return PyLong_FromLong((long) erg);
+    return PyLong_FromLong((long) erg);
 }
 
 static PyObject *
 PyCurses_Delay_Output(PyObject *self, PyObject *args)
 {
-  int ms;
+    int ms;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args, "i:delay_output", &ms)) return NULL;
+    if (!PyArg_ParseTuple(args, "i:delay_output", &ms)) return NULL;
 
-  return PyCursesCheckERR(delay_output(ms), "delay_output");
+    return PyCursesCheckERR(delay_output(ms), "delay_output");
 }
 
 static PyObject *
 PyCurses_EraseChar(PyObject *self)
 {
-  char ch;
+    char ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  ch = erasechar();
+    ch = erasechar();
 
-  return PyBytes_FromStringAndSize(&ch, 1);
+    return PyBytes_FromStringAndSize(&ch, 1);
 }
 
 static PyObject *
 PyCurses_getsyx(PyObject *self)
 {
-  int x = 0;
-  int y = 0;
+    int x = 0;
+    int y = 0;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  getsyx(y, x);
+    getsyx(y, x);
 
-  return Py_BuildValue("(ii)", y, x);
+    return Py_BuildValue("(ii)", y, x);
 }
 
 #ifdef NCURSES_MOUSE_VERSION
 static PyObject *
 PyCurses_GetMouse(PyObject *self)
 {
-	int rtn;
-	MEVENT event;
+    int rtn;
+    MEVENT event;
 
-	PyCursesInitialised;
+    PyCursesInitialised;
 
-	rtn = getmouse( &event );
-	if (rtn == ERR) {
-		PyErr_SetString(PyCursesError, "getmouse() returned ERR");
-		return NULL;
-	}
-	return Py_BuildValue("(hiiil)", 
-			     (short)event.id, 
-			     event.x, event.y, event.z,
-			     (long) event.bstate);
+    rtn = getmouse( &event );
+    if (rtn == ERR) {
+        PyErr_SetString(PyCursesError, "getmouse() returned ERR");
+        return NULL;
+    }
+    return Py_BuildValue("(hiiil)",
+                         (short)event.id,
+                         event.x, event.y, event.z,
+                         (long) event.bstate);
 }
 
 static PyObject *
 PyCurses_UngetMouse(PyObject *self, PyObject *args)
 {
-	MEVENT event;
+    MEVENT event;
 
-	PyCursesInitialised;
-	if (!PyArg_ParseTuple(args, "hiiil",
-			     &event.id, 
-			     &event.x, &event.y, &event.z,
-			     (int *) &event.bstate))
-	  return NULL;
+    PyCursesInitialised;
+    if (!PyArg_ParseTuple(args, "hiiil",
+                          &event.id,
+                          &event.x, &event.y, &event.z,
+                          (int *) &event.bstate))
+        return NULL;
 
-	return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
+    return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
 }
 #endif
 
 static PyObject *
 PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
 {
-  char fn[100];
-  int fd;
-  FILE *fp;
-  PyObject *data;
-  size_t datalen;
-  WINDOW *win;
-
-  PyCursesInitialised;
-
-  strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
-  fd = mkstemp(fn);
-  if (fd < 0)
-    return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
-  fp = fdopen(fd, "wb+");
-  if (fp == NULL) {
-    close(fd);
-    remove(fn);
-    return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
-  }
-  data = PyObject_CallMethod(stream, "read", "");
-  if (data == NULL) {
-    fclose(fp);
-    remove(fn);
-    return NULL;
-  }
-  if (!PyBytes_Check(data)) {
-    PyErr_Format(PyExc_TypeError,
-                 "f.read() returned %.100s instead of bytes",
-                 data->ob_type->tp_name);
-    Py_DECREF(data);
-    fclose(fp);
-    remove(fn);
-    return NULL;
-  }
-  datalen = PyBytes_GET_SIZE(data);
-  if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
+    char fn[100];
+    int fd;
+    FILE *fp;
+    PyObject *data;
+    size_t datalen;
+    WINDOW *win;
+
+    PyCursesInitialised;
+
+    strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
+    fd = mkstemp(fn);
+    if (fd < 0)
+        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+    fp = fdopen(fd, "wb+");
+    if (fp == NULL) {
+        close(fd);
+        remove(fn);
+        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+    }
+    data = PyObject_CallMethod(stream, "read", "");
+    if (data == NULL) {
+        fclose(fp);
+        remove(fn);
+        return NULL;
+    }
+    if (!PyBytes_Check(data)) {
+        PyErr_Format(PyExc_TypeError,
+                     "f.read() returned %.100s instead of bytes",
+                     data->ob_type->tp_name);
+        Py_DECREF(data);
+        fclose(fp);
+        remove(fn);
+        return NULL;
+    }
+    datalen = PyBytes_GET_SIZE(data);
+    if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
+        Py_DECREF(data);
+        fclose(fp);
+        remove(fn);
+        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+    }
     Py_DECREF(data);
+    fseek(fp, 0, 0);
+    win = getwin(fp);
     fclose(fp);
     remove(fn);
-    return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
-  }
-  Py_DECREF(data);
-  fseek(fp, 0, 0);
-  win = getwin(fp);
-  fclose(fp);
-  remove(fn);
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
-  return PyCursesWindow_New(win);
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
+    return PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCurses_HalfDelay(PyObject *self, PyObject *args)
 {
-  unsigned char tenths;
+    unsigned char tenths;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args, "b:halfdelay", &tenths)) return NULL;
+    if (!PyArg_ParseTuple(args, "b:halfdelay", &tenths)) return NULL;
 
-  return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
+    return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
 }
 
 #ifndef STRICT_SYSV_CURSES
- /* No has_key! */
+/* No has_key! */
 static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
 {
-  int ch;
+    int ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"i",&ch)) return NULL;
+    if (!PyArg_ParseTuple(args,"i",&ch)) return NULL;
 
-  if (has_key(ch) == FALSE) {
-    Py_INCREF(Py_False);
-    return Py_False;
-  }
-  Py_INCREF(Py_True);
-  return Py_True; 
+    if (has_key(ch) == FALSE) {
+        Py_INCREF(Py_False);
+        return Py_False;
+    }
+    Py_INCREF(Py_True);
+    return Py_True;
 }
 #endif /* STRICT_SYSV_CURSES */
 
 static PyObject *
 PyCurses_Init_Color(PyObject *self, PyObject *args)
 {
-  short color, r, g, b;
+    short color, r, g, b;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  switch(PyTuple_Size(args)) {
-  case 4:
-    if (!PyArg_ParseTuple(args, "hhhh;color,r,g,b", &color, &r, &g, &b)) return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments");
-    return NULL;
-  }
+    switch(PyTuple_Size(args)) {
+    case 4:
+        if (!PyArg_ParseTuple(args, "hhhh;color,r,g,b", &color, &r, &g, &b)) return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments");
+        return NULL;
+    }
 
-  return PyCursesCheckERR(init_color(color, r, g, b), "init_color");
+    return PyCursesCheckERR(init_color(color, r, g, b), "init_color");
 }
 
 static PyObject *
 PyCurses_Init_Pair(PyObject *self, PyObject *args)
 {
-  short pair, f, b;
+    short pair, f, b;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  if (PyTuple_Size(args) != 3) {
-    PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments");
-    return NULL;
-  }
+    if (PyTuple_Size(args) != 3) {
+        PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments");
+        return NULL;
+    }
 
-  if (!PyArg_ParseTuple(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL;
+    if (!PyArg_ParseTuple(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL;
 
-  return PyCursesCheckERR(init_pair(pair, f, b), "init_pair");
+    return PyCursesCheckERR(init_pair(pair, f, b), "init_pair");
 }
 
 static PyObject *ModDict;
 
-static PyObject * 
+static PyObject *
 PyCurses_InitScr(PyObject *self)
 {
-  WINDOW *win;
+    WINDOW *win;
 
-  if (initialised == TRUE) {
-    wrefresh(stdscr);
-    return (PyObject *)PyCursesWindow_New(stdscr);
-  }
+    if (initialised == TRUE) {
+        wrefresh(stdscr);
+        return (PyObject *)PyCursesWindow_New(stdscr);
+    }
 
-  win = initscr();
+    win = initscr();
 
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
 
-  initialised = initialised_setupterm = TRUE;
+    initialised = initialised_setupterm = TRUE;
 
 /* This was moved from initcurses() because it core dumped on SGI,
    where they're not defined until you've called initscr() */
-#define SetDictInt(string,ch) \
-    do {							\
-	PyObject *o = PyLong_FromLong((long) (ch));		\
-	if (o && PyDict_SetItemString(ModDict, string, o) == 0)	{ \
-	    Py_DECREF(o);					\
-	}							\
+#define SetDictInt(string,ch)                                           \
+    do {                                                                \
+        PyObject *o = PyLong_FromLong((long) (ch));                     \
+        if (o && PyDict_SetItemString(ModDict, string, o) == 0)     {   \
+            Py_DECREF(o);                                               \
+        }                                                               \
     } while (0)
 
-	/* Here are some graphic symbols you can use */
-        SetDictInt("ACS_ULCORNER",      (ACS_ULCORNER));
-	SetDictInt("ACS_LLCORNER",      (ACS_LLCORNER));
-	SetDictInt("ACS_URCORNER",      (ACS_URCORNER));
-	SetDictInt("ACS_LRCORNER",      (ACS_LRCORNER));
-	SetDictInt("ACS_LTEE",          (ACS_LTEE));
-	SetDictInt("ACS_RTEE",          (ACS_RTEE));
-	SetDictInt("ACS_BTEE",          (ACS_BTEE));
-	SetDictInt("ACS_TTEE",          (ACS_TTEE));
-	SetDictInt("ACS_HLINE",         (ACS_HLINE));
-	SetDictInt("ACS_VLINE",         (ACS_VLINE));
-	SetDictInt("ACS_PLUS",          (ACS_PLUS));
+    /* Here are some graphic symbols you can use */
+    SetDictInt("ACS_ULCORNER",      (ACS_ULCORNER));
+    SetDictInt("ACS_LLCORNER",      (ACS_LLCORNER));
+    SetDictInt("ACS_URCORNER",      (ACS_URCORNER));
+    SetDictInt("ACS_LRCORNER",      (ACS_LRCORNER));
+    SetDictInt("ACS_LTEE",          (ACS_LTEE));
+    SetDictInt("ACS_RTEE",          (ACS_RTEE));
+    SetDictInt("ACS_BTEE",          (ACS_BTEE));
+    SetDictInt("ACS_TTEE",          (ACS_TTEE));
+    SetDictInt("ACS_HLINE",         (ACS_HLINE));
+    SetDictInt("ACS_VLINE",         (ACS_VLINE));
+    SetDictInt("ACS_PLUS",          (ACS_PLUS));
 #if !defined(__hpux) || defined(HAVE_NCURSES_H)
-        /* On HP/UX 11, these are of type cchar_t, which is not an
-           integral type. If this is a problem on more platforms, a
-           configure test should be added to determine whether ACS_S1
-           is of integral type. */
-	SetDictInt("ACS_S1",            (ACS_S1));
-	SetDictInt("ACS_S9",            (ACS_S9));
-	SetDictInt("ACS_DIAMOND",       (ACS_DIAMOND));
-	SetDictInt("ACS_CKBOARD",       (ACS_CKBOARD));
-	SetDictInt("ACS_DEGREE",        (ACS_DEGREE));
-	SetDictInt("ACS_PLMINUS",       (ACS_PLMINUS));
-	SetDictInt("ACS_BULLET",        (ACS_BULLET));
-	SetDictInt("ACS_LARROW",        (ACS_LARROW));
-	SetDictInt("ACS_RARROW",        (ACS_RARROW));
-	SetDictInt("ACS_DARROW",        (ACS_DARROW));
-	SetDictInt("ACS_UARROW",        (ACS_UARROW));
-	SetDictInt("ACS_BOARD",         (ACS_BOARD));
-	SetDictInt("ACS_LANTERN",       (ACS_LANTERN));
-	SetDictInt("ACS_BLOCK",         (ACS_BLOCK));
-#endif
-	SetDictInt("ACS_BSSB",          (ACS_ULCORNER));
-	SetDictInt("ACS_SSBB",          (ACS_LLCORNER));
-	SetDictInt("ACS_BBSS",          (ACS_URCORNER));
-	SetDictInt("ACS_SBBS",          (ACS_LRCORNER));
-	SetDictInt("ACS_SBSS",          (ACS_RTEE));
-	SetDictInt("ACS_SSSB",          (ACS_LTEE));
-	SetDictInt("ACS_SSBS",          (ACS_BTEE));
-	SetDictInt("ACS_BSSS",          (ACS_TTEE));
-	SetDictInt("ACS_BSBS",          (ACS_HLINE));
-	SetDictInt("ACS_SBSB",          (ACS_VLINE));
-	SetDictInt("ACS_SSSS",          (ACS_PLUS));
+    /* On HP/UX 11, these are of type cchar_t, which is not an
+       integral type. If this is a problem on more platforms, a
+       configure test should be added to determine whether ACS_S1
+       is of integral type. */
+    SetDictInt("ACS_S1",            (ACS_S1));
+    SetDictInt("ACS_S9",            (ACS_S9));
+    SetDictInt("ACS_DIAMOND",       (ACS_DIAMOND));
+    SetDictInt("ACS_CKBOARD",       (ACS_CKBOARD));
+    SetDictInt("ACS_DEGREE",        (ACS_DEGREE));
+    SetDictInt("ACS_PLMINUS",       (ACS_PLMINUS));
+    SetDictInt("ACS_BULLET",        (ACS_BULLET));
+    SetDictInt("ACS_LARROW",        (ACS_LARROW));
+    SetDictInt("ACS_RARROW",        (ACS_RARROW));
+    SetDictInt("ACS_DARROW",        (ACS_DARROW));
+    SetDictInt("ACS_UARROW",        (ACS_UARROW));
+    SetDictInt("ACS_BOARD",         (ACS_BOARD));
+    SetDictInt("ACS_LANTERN",       (ACS_LANTERN));
+    SetDictInt("ACS_BLOCK",         (ACS_BLOCK));
+#endif
+    SetDictInt("ACS_BSSB",          (ACS_ULCORNER));
+    SetDictInt("ACS_SSBB",          (ACS_LLCORNER));
+    SetDictInt("ACS_BBSS",          (ACS_URCORNER));
+    SetDictInt("ACS_SBBS",          (ACS_LRCORNER));
+    SetDictInt("ACS_SBSS",          (ACS_RTEE));
+    SetDictInt("ACS_SSSB",          (ACS_LTEE));
+    SetDictInt("ACS_SSBS",          (ACS_BTEE));
+    SetDictInt("ACS_BSSS",          (ACS_TTEE));
+    SetDictInt("ACS_BSBS",          (ACS_HLINE));
+    SetDictInt("ACS_SBSB",          (ACS_VLINE));
+    SetDictInt("ACS_SSSS",          (ACS_PLUS));
 
-	/* The following are never available with strict SYSV curses */
+    /* The following are never available with strict SYSV curses */
 #ifdef ACS_S3
-	SetDictInt("ACS_S3",            (ACS_S3));
+    SetDictInt("ACS_S3",            (ACS_S3));
 #endif
 #ifdef ACS_S7
-	SetDictInt("ACS_S7",            (ACS_S7));
+    SetDictInt("ACS_S7",            (ACS_S7));
 #endif
 #ifdef ACS_LEQUAL
-	SetDictInt("ACS_LEQUAL",        (ACS_LEQUAL));
+    SetDictInt("ACS_LEQUAL",        (ACS_LEQUAL));
 #endif
 #ifdef ACS_GEQUAL
-	SetDictInt("ACS_GEQUAL",        (ACS_GEQUAL));
+    SetDictInt("ACS_GEQUAL",        (ACS_GEQUAL));
 #endif
 #ifdef ACS_PI
-	SetDictInt("ACS_PI",            (ACS_PI));
+    SetDictInt("ACS_PI",            (ACS_PI));
 #endif
 #ifdef ACS_NEQUAL
-	SetDictInt("ACS_NEQUAL",        (ACS_NEQUAL));
+    SetDictInt("ACS_NEQUAL",        (ACS_NEQUAL));
 #endif
 #ifdef ACS_STERLING
-	SetDictInt("ACS_STERLING",      (ACS_STERLING));
+    SetDictInt("ACS_STERLING",      (ACS_STERLING));
 #endif
 
-  SetDictInt("LINES", LINES);
-  SetDictInt("COLS", COLS);
+    SetDictInt("LINES", LINES);
+    SetDictInt("COLS", COLS);
 
-  return (PyObject *)PyCursesWindow_New(win);
+    return (PyObject *)PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds)
 {
-	int fd = -1;
-	int err;
-	char* termstr = NULL;
-
-	static char *kwlist[] = {"term", "fd", NULL};
-
-	if (!PyArg_ParseTupleAndKeywords(
-		args, keywds, "|zi:setupterm", kwlist, &termstr, &fd)) {
-		return NULL;
-	}
-	
-	if (fd == -1) {
-		PyObject* sys_stdout;
-
-		sys_stdout = PySys_GetObject("stdout");
-
-		if (sys_stdout == NULL || sys_stdout == Py_None) {
-			PyErr_SetString(
-				PyCursesError,
-				"lost sys.stdout");
-			return NULL;
-		}
-
-		fd = PyObject_AsFileDescriptor(sys_stdout);
-
-		if (fd == -1) {
-			return NULL;
-		}
-	}
-
-	if (setupterm(termstr,fd,&err) == ERR) {
-		char* s = "setupterm: unknown error";
-		
-		if (err == 0) {
-			s = "setupterm: could not find terminal";
-		} else if (err == -1) {
-			s = "setupterm: could not find terminfo database";
-		}
-
-		PyErr_SetString(PyCursesError,s);
-		return NULL;
-	}
+    int fd = -1;
+    int err;
+    char* termstr = NULL;
 
-	initialised_setupterm = TRUE;
+    static char *kwlist[] = {"term", "fd", NULL};
 
-	Py_INCREF(Py_None);
-	return Py_None;	
+    if (!PyArg_ParseTupleAndKeywords(
+            args, keywds, "|zi:setupterm", kwlist, &termstr, &fd)) {
+        return NULL;
+    }
+
+    if (fd == -1) {
+        PyObject* sys_stdout;
+
+        sys_stdout = PySys_GetObject("stdout");
+
+        if (sys_stdout == NULL || sys_stdout == Py_None) {
+            PyErr_SetString(
+                PyCursesError,
+                "lost sys.stdout");
+            return NULL;
+        }
+
+        fd = PyObject_AsFileDescriptor(sys_stdout);
+
+        if (fd == -1) {
+            return NULL;
+        }
+    }
+
+    if (setupterm(termstr,fd,&err) == ERR) {
+        char* s = "setupterm: unknown error";
+
+        if (err == 0) {
+            s = "setupterm: could not find terminal";
+        } else if (err == -1) {
+            s = "setupterm: could not find terminfo database";
+        }
+
+        PyErr_SetString(PyCursesError,s);
+        return NULL;
+    }
+
+    initialised_setupterm = TRUE;
+
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 PyCurses_IntrFlush(PyObject *self, PyObject *args)
 {
-  int ch;
+    int ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  switch(PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "intrflush requires 1 argument");
-    return NULL;
-  }
+    switch(PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "intrflush requires 1 argument");
+        return NULL;
+    }
 
-  return PyCursesCheckERR(intrflush(NULL,ch), "intrflush");
+    return PyCursesCheckERR(intrflush(NULL,ch), "intrflush");
 }
 
 #ifdef HAVE_CURSES_IS_TERM_RESIZED
 static PyObject *
 PyCurses_Is_Term_Resized(PyObject *self, PyObject *args)
 {
-  int lines;
-  int columns;
-  int result;
-
-  PyCursesInitialised;
-
-  if (!PyArg_ParseTuple(args,"ii:is_term_resized", &lines, &columns))
-    return NULL;
-  result = is_term_resized(lines, columns);
-  if (result == TRUE) {
-    Py_INCREF(Py_True);
-    return Py_True;
-  } else {
-    Py_INCREF(Py_False);
-    return Py_False;
-  }
+    int lines;
+    int columns;
+    int result;
+
+    PyCursesInitialised;
+
+    if (!PyArg_ParseTuple(args,"ii:is_term_resized", &lines, &columns))
+        return NULL;
+    result = is_term_resized(lines, columns);
+    if (result == TRUE) {
+        Py_INCREF(Py_True);
+        return Py_True;
+    } else {
+        Py_INCREF(Py_False);
+        return Py_False;
+    }
 }
 #endif /* HAVE_CURSES_IS_TERM_RESIZED */
 
@@ -2191,75 +2191,75 @@
 static PyObject *
 PyCurses_KeyName(PyObject *self, PyObject *args)
 {
-  const char *knp;
-  int ch;
+    const char *knp;
+    int ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"i",&ch)) return NULL;
+    if (!PyArg_ParseTuple(args,"i",&ch)) return NULL;
 
-  if (ch < 0) {
-    PyErr_SetString(PyExc_ValueError, "invalid key number");
-    return NULL;
-  }
-  knp = keyname(ch);
+    if (ch < 0) {
+        PyErr_SetString(PyExc_ValueError, "invalid key number");
+        return NULL;
+    }
+    knp = keyname(ch);
 
-  return PyBytes_FromString((knp == NULL) ? "" : (char *)knp);
+    return PyBytes_FromString((knp == NULL) ? "" : (char *)knp);
 }
 #endif
 
-static PyObject *  
-PyCurses_KillChar(PyObject *self)  
-{  
-  char ch;  
+static PyObject *
+PyCurses_KillChar(PyObject *self)
+{
+    char ch;
 
-  ch = killchar();  
+    ch = killchar();
 
-  return PyBytes_FromStringAndSize(&ch, 1);  
-}  
+    return PyBytes_FromStringAndSize(&ch, 1);
+}
 
 static PyObject *
 PyCurses_Meta(PyObject *self, PyObject *args)
 {
-  int ch;
+    int ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  switch(PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "meta requires 1 argument");
-    return NULL;
-  }
+    switch(PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "meta requires 1 argument");
+        return NULL;
+    }
 
-  return PyCursesCheckERR(meta(stdscr, ch), "meta");
+    return PyCursesCheckERR(meta(stdscr, ch), "meta");
 }
 
 #ifdef NCURSES_MOUSE_VERSION
 static PyObject *
 PyCurses_MouseInterval(PyObject *self, PyObject *args)
 {
-	int interval;
-	PyCursesInitialised;
+    int interval;
+    PyCursesInitialised;
 
-	if (!PyArg_ParseTuple(args,"i;interval",&interval)) 
-		return NULL;
-	return PyCursesCheckERR(mouseinterval(interval), "mouseinterval");
+    if (!PyArg_ParseTuple(args,"i;interval",&interval))
+        return NULL;
+    return PyCursesCheckERR(mouseinterval(interval), "mouseinterval");
 }
 
 static PyObject *
 PyCurses_MouseMask(PyObject *self, PyObject *args)
 {
-	int newmask;
-	mmask_t oldmask, availmask;
+    int newmask;
+    mmask_t oldmask, availmask;
 
-	PyCursesInitialised;
-	if (!PyArg_ParseTuple(args,"i;mousemask",&newmask)) 
-		return NULL;
-	availmask = mousemask(newmask, &oldmask);
-	return Py_BuildValue("(ll)", (long)availmask, (long)oldmask);
+    PyCursesInitialised;
+    if (!PyArg_ParseTuple(args,"i;mousemask",&newmask))
+        return NULL;
+    availmask = mousemask(newmask, &oldmask);
+    return Py_BuildValue("(ll)", (long)availmask, (long)oldmask);
 }
 #endif
 
@@ -2278,133 +2278,133 @@
 static PyObject *
 PyCurses_NewPad(PyObject *self, PyObject *args)
 {
-  WINDOW *win;
-  int nlines, ncols;
+    WINDOW *win;
+    int nlines, ncols;
+
+    PyCursesInitialised;
 
-  PyCursesInitialised;
+    if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) return NULL;
 
-  if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) return NULL;
+    win = newpad(nlines, ncols);
 
-  win = newpad(nlines, ncols);
-  
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
 
-  return (PyObject *)PyCursesWindow_New(win);
+    return (PyObject *)PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCurses_NewWindow(PyObject *self, PyObject *args)
 {
-  WINDOW *win;
-  int nlines, ncols, begin_y=0, begin_x=0;
+    WINDOW *win;
+    int nlines, ncols, begin_y=0, begin_x=0;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  switch (PyTuple_Size(args)) {
-  case 2:
-    if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols))
-      return NULL;
-    break;
-  case 4:
-    if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
-		   &nlines,&ncols,&begin_y,&begin_x))
-      return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments");
-    return NULL;
-  }
-
-  win = newwin(nlines,ncols,begin_y,begin_x);
-  if (win == NULL) {
-    PyErr_SetString(PyCursesError, catchall_NULL);
-    return NULL;
-  }
+    switch (PyTuple_Size(args)) {
+    case 2:
+        if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols))
+            return NULL;
+        break;
+    case 4:
+        if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x",
+                              &nlines,&ncols,&begin_y,&begin_x))
+            return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments");
+        return NULL;
+    }
+
+    win = newwin(nlines,ncols,begin_y,begin_x);
+    if (win == NULL) {
+        PyErr_SetString(PyCursesError, catchall_NULL);
+        return NULL;
+    }
 
-  return (PyObject *)PyCursesWindow_New(win);
+    return (PyObject *)PyCursesWindow_New(win);
 }
 
 static PyObject *
 PyCurses_Pair_Content(PyObject *self, PyObject *args)
 {
-  short pair,f,b;
+    short pair,f,b;
+
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    switch(PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args, "h;pair", &pair)) return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "pair_content requires 1 argument");
+        return NULL;
+    }
 
-  switch(PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args, "h;pair", &pair)) return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "pair_content requires 1 argument");
-    return NULL;
-  }
-
-  if (pair_content(pair, &f, &b)==ERR) {
-    PyErr_SetString(PyCursesError,
-		    "Argument 1 was out of range. (1..COLOR_PAIRS-1)");
-    return NULL;
-  }
+    if (pair_content(pair, &f, &b)==ERR) {
+        PyErr_SetString(PyCursesError,
+                        "Argument 1 was out of range. (1..COLOR_PAIRS-1)");
+        return NULL;
+    }
 
-  return Py_BuildValue("(ii)", f, b);
+    return Py_BuildValue("(ii)", f, b);
 }
 
 static PyObject *
 PyCurses_pair_number(PyObject *self, PyObject *args)
 {
-  int n;
+    int n;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  switch(PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args, "i;pairvalue", &n)) return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError,
-                    "pair_number requires 1 argument");
-    return NULL;
-  }
+    switch(PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args, "i;pairvalue", &n)) return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError,
+                        "pair_number requires 1 argument");
+        return NULL;
+    }
 
-  return PyLong_FromLong((long) ((n & A_COLOR) >> 8));
+    return PyLong_FromLong((long) ((n & A_COLOR) >> 8));
 }
 
 static PyObject *
 PyCurses_Putp(PyObject *self, PyObject *args)
 {
-  char *str;
+    char *str;
 
-  if (!PyArg_ParseTuple(args,"s;str", &str)) return NULL;
-  return PyCursesCheckERR(putp(str), "putp");
+    if (!PyArg_ParseTuple(args,"s;str", &str)) return NULL;
+    return PyCursesCheckERR(putp(str), "putp");
 }
 
 static PyObject *
 PyCurses_QiFlush(PyObject *self, PyObject *args)
 {
-  int flag = 0;
+    int flag = 0;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  switch(PyTuple_Size(args)) {
-  case 0:
-    qiflush();
-    Py_INCREF(Py_None);
-    return Py_None;
-  case 1:
-    if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL;
-    if (flag) qiflush();
-    else noqiflush();
-    Py_INCREF(Py_None);
-    return Py_None;
-  default:
-    PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments");
-    return NULL;
-  }
+    switch(PyTuple_Size(args)) {
+    case 0:
+        qiflush();
+        Py_INCREF(Py_None);
+        return Py_None;
+    case 1:
+        if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL;
+        if (flag) qiflush();
+        else noqiflush();
+        Py_INCREF(Py_None);
+        return Py_None;
+    default:
+        PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments");
+        return NULL;
+    }
 }
 
 /* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
@@ -2413,46 +2413,46 @@
 static int
 update_lines_cols(void)
 {
-  PyObject *o;
-  PyObject *m = PyImport_ImportModuleNoBlock("curses");
+    PyObject *o;
+    PyObject *m = PyImport_ImportModuleNoBlock("curses");
 
-  if (!m)
-    return 0;
+    if (!m)
+        return 0;
 
-  o = PyLong_FromLong(LINES);
-  if (!o) {
-    Py_DECREF(m);
-    return 0;
-  }
-  if (PyObject_SetAttrString(m, "LINES", o)) {
-    Py_DECREF(m);
-    Py_DECREF(o);
-    return 0;
-  }
-  if (PyDict_SetItemString(ModDict, "LINES", o)) {
-    Py_DECREF(m);
+    o = PyLong_FromLong(LINES);
+    if (!o) {
+        Py_DECREF(m);
+        return 0;
+    }
+    if (PyObject_SetAttrString(m, "LINES", o)) {
+        Py_DECREF(m);
+        Py_DECREF(o);
+        return 0;
+    }
+    if (PyDict_SetItemString(ModDict, "LINES", o)) {
+        Py_DECREF(m);
+        Py_DECREF(o);
+        return 0;
+    }
     Py_DECREF(o);
-    return 0;
-  }
-  Py_DECREF(o);
-  o = PyLong_FromLong(COLS);
-  if (!o) {
-    Py_DECREF(m);
-    return 0;
-  }
-  if (PyObject_SetAttrString(m, "COLS", o)) {
-    Py_DECREF(m);
+    o = PyLong_FromLong(COLS);
+    if (!o) {
+        Py_DECREF(m);
+        return 0;
+    }
+    if (PyObject_SetAttrString(m, "COLS", o)) {
+        Py_DECREF(m);
+        Py_DECREF(o);
+        return 0;
+    }
+    if (PyDict_SetItemString(ModDict, "COLS", o)) {
+        Py_DECREF(m);
+        Py_DECREF(o);
+        return 0;
+    }
     Py_DECREF(o);
-    return 0;
-  }
-  if (PyDict_SetItemString(ModDict, "COLS", o)) {
     Py_DECREF(m);
-    Py_DECREF(o);
-    return 0;
-  }
-  Py_DECREF(o);
-  Py_DECREF(m);
-  return 1;
+    return 1;
 }
 #endif
 
@@ -2460,21 +2460,21 @@
 static PyObject *
 PyCurses_ResizeTerm(PyObject *self, PyObject *args)
 {
-  int lines;
-  int columns;
-  PyObject *result;
-
-  PyCursesInitialised;
-
-  if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns))
-    return NULL;
-
-  result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
-  if (!result)
-    return NULL;
-  if (!update_lines_cols())
-    return NULL;
-  return result;
+    int lines;
+    int columns;
+    PyObject *result;
+
+    PyCursesInitialised;
+
+    if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns))
+        return NULL;
+
+    result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
+    if (!result)
+        return NULL;
+    if (!update_lines_cols())
+        return NULL;
+    return result;
 }
 
 #endif
@@ -2483,496 +2483,496 @@
 static PyObject *
 PyCurses_Resize_Term(PyObject *self, PyObject *args)
 {
-  int lines;
-  int columns;
+    int lines;
+    int columns;
 
-  PyObject *result;
+    PyObject *result;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns))
-    return NULL;
-
-  result = PyCursesCheckERR(resize_term(lines, columns), "resize_term");
-  if (!result)
-    return NULL;
-  if (!update_lines_cols())
-    return NULL;
-  return result;
+    if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns))
+        return NULL;
+
+    result = PyCursesCheckERR(resize_term(lines, columns), "resize_term");
+    if (!result)
+        return NULL;
+    if (!update_lines_cols())
+        return NULL;
+    return result;
 }
 #endif /* HAVE_CURSES_RESIZE_TERM */
 
 static PyObject *
 PyCurses_setsyx(PyObject *self, PyObject *args)
 {
-  int y,x;
+    int y,x;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (PyTuple_Size(args)!=2) {
-    PyErr_SetString(PyExc_TypeError, "setsyx requires 2 arguments");
-    return NULL;
-  }
+    if (PyTuple_Size(args)!=2) {
+        PyErr_SetString(PyExc_TypeError, "setsyx requires 2 arguments");
+        return NULL;
+    }
 
-  if (!PyArg_ParseTuple(args, "ii;y, x", &y, &x)) return NULL;
+    if (!PyArg_ParseTuple(args, "ii;y, x", &y, &x)) return NULL;
 
-  setsyx(y,x);
+    setsyx(y,x);
 
-  Py_INCREF(Py_None);
-  return Py_None;
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 static PyObject *
 PyCurses_Start_Color(PyObject *self)
 {
-  int code;
-  PyObject *c, *cp;
+    int code;
+    PyObject *c, *cp;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  code = start_color();
-  if (code != ERR) {
-    initialisedcolors = TRUE;
-    c = PyLong_FromLong((long) COLORS);
-    PyDict_SetItemString(ModDict, "COLORS", c);
-    Py_DECREF(c);
-    cp = PyLong_FromLong((long) COLOR_PAIRS);
-    PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp);
-    Py_DECREF(cp);
-    Py_INCREF(Py_None);
-    return Py_None;
-  } else {
-    PyErr_SetString(PyCursesError, "start_color() returned ERR");
-    return NULL;
-  }
+    code = start_color();
+    if (code != ERR) {
+        initialisedcolors = TRUE;
+        c = PyLong_FromLong((long) COLORS);
+        PyDict_SetItemString(ModDict, "COLORS", c);
+        Py_DECREF(c);
+        cp = PyLong_FromLong((long) COLOR_PAIRS);
+        PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp);
+        Py_DECREF(cp);
+        Py_INCREF(Py_None);
+        return Py_None;
+    } else {
+        PyErr_SetString(PyCursesError, "start_color() returned ERR");
+        return NULL;
+    }
 }
 
 static PyObject *
 PyCurses_tigetflag(PyObject *self, PyObject *args)
 {
-	char *capname;
+    char *capname;
 
-	PyCursesSetupTermCalled;
-		
-	if (!PyArg_ParseTuple(args, "s", &capname))
-		return NULL;
+    PyCursesSetupTermCalled;
 
-	return PyLong_FromLong( (long) tigetflag( capname ) );
+    if (!PyArg_ParseTuple(args, "s", &capname))
+        return NULL;
+
+    return PyLong_FromLong( (long) tigetflag( capname ) );
 }
 
 static PyObject *
 PyCurses_tigetnum(PyObject *self, PyObject *args)
 {
-	char *capname;
+    char *capname;
 
-	PyCursesSetupTermCalled;
-		
-	if (!PyArg_ParseTuple(args, "s", &capname))
-		return NULL;
+    PyCursesSetupTermCalled;
 
-	return PyLong_FromLong( (long) tigetnum( capname ) );
+    if (!PyArg_ParseTuple(args, "s", &capname))
+        return NULL;
+
+    return PyLong_FromLong( (long) tigetnum( capname ) );
 }
 
 static PyObject *
 PyCurses_tigetstr(PyObject *self, PyObject *args)
 {
-	char *capname;
+    char *capname;
+
+    PyCursesSetupTermCalled;
 
-	PyCursesSetupTermCalled;
-		
-	if (!PyArg_ParseTuple(args, "s", &capname))
-		return NULL;
-
-	capname = tigetstr( capname );
-	if (capname == 0 || capname == (char*) -1) {
-		Py_INCREF(Py_None);
-		return Py_None;
-	}
-	return PyBytes_FromString( capname );
+    if (!PyArg_ParseTuple(args, "s", &capname))
+        return NULL;
+
+    capname = tigetstr( capname );
+    if (capname == 0 || capname == (char*) -1) {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    return PyBytes_FromString( capname );
 }
 
 static PyObject *
 PyCurses_tparm(PyObject *self, PyObject *args)
 {
-	char* fmt;
-	char* result = NULL;
-	int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0;
-
-	PyCursesSetupTermCalled;
-
-	if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm", 
-			      &fmt, &i1, &i2, &i3, &i4, 
-			      &i5, &i6, &i7, &i8, &i9)) {
-		return NULL;
-	}
-
-	result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
-	if (!result) {
-		PyErr_SetString(PyCursesError, "tparm() returned NULL");
-  		return NULL;
-	}
+    char* fmt;
+    char* result = NULL;
+    int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0;
+
+    PyCursesSetupTermCalled;
+
+    if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm",
+                          &fmt, &i1, &i2, &i3, &i4,
+                          &i5, &i6, &i7, &i8, &i9)) {
+        return NULL;
+    }
 
-	return PyBytes_FromString(result);
+    result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
+    if (!result) {
+        PyErr_SetString(PyCursesError, "tparm() returned NULL");
+        return NULL;
+    }
+
+    return PyBytes_FromString(result);
 }
 
 static PyObject *
 PyCurses_TypeAhead(PyObject *self, PyObject *args)
 {
-  int fd;
+    int fd;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL;
+    if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL;
 
-  return PyCursesCheckERR(typeahead( fd ), "typeahead");
+    return PyCursesCheckERR(typeahead( fd ), "typeahead");
 }
 
 static PyObject *
 PyCurses_UnCtrl(PyObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype ch;
+    PyObject *temp;
+    chtype ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
+    if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
 
-  if (!PyCurses_ConvertToChtype(temp, &ch)) {
-    PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
-    return NULL;
-  }
+    if (!PyCurses_ConvertToChtype(temp, &ch)) {
+        PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
+        return NULL;
+    }
 
-  return PyBytes_FromString(unctrl(ch));
+    return PyBytes_FromString(unctrl(ch));
 }
 
 static PyObject *
 PyCurses_UngetCh(PyObject *self, PyObject *args)
 {
-  PyObject *temp;
-  chtype ch;
+    PyObject *temp;
+    chtype ch;
 
-  PyCursesInitialised;
+    PyCursesInitialised;
 
-  if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
+    if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
 
-  if (!PyCurses_ConvertToChtype(temp, &ch)) {
-    PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
-    return NULL;
-  }
+    if (!PyCurses_ConvertToChtype(temp, &ch)) {
+        PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
+        return NULL;
+    }
 
-  return PyCursesCheckERR(ungetch(ch), "ungetch");
+    return PyCursesCheckERR(ungetch(ch), "ungetch");
 }
 
 static PyObject *
 PyCurses_Use_Env(PyObject *self, PyObject *args)
 {
-  int flag;
+    int flag;
 
-  switch(PyTuple_Size(args)) {
-  case 1:
-    if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&flag))
-      return NULL;
-    break;
-  default:
-    PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument");
-    return NULL;
-  }
-  use_env(flag);
-  Py_INCREF(Py_None);
-  return Py_None;
+    switch(PyTuple_Size(args)) {
+    case 1:
+        if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&flag))
+            return NULL;
+        break;
+    default:
+        PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument");
+        return NULL;
+    }
+    use_env(flag);
+    Py_INCREF(Py_None);
+    return Py_None;
 }
 
 #ifndef STRICT_SYSV_CURSES
 static PyObject *
 PyCurses_Use_Default_Colors(PyObject *self)
 {
-  int code;
+    int code;
 
-  PyCursesInitialised;
-  PyCursesInitialisedColor;
+    PyCursesInitialised;
+    PyCursesInitialisedColor;
 
-  code = use_default_colors();
-  if (code != ERR) {
-    Py_INCREF(Py_None);
-    return Py_None;
-  } else {
-    PyErr_SetString(PyCursesError, "use_default_colors() returned ERR");
-    return NULL;
-  }
+    code = use_default_colors();
+    if (code != ERR) {
+        Py_INCREF(Py_None);
+        return Py_None;
+    } else {
+        PyErr_SetString(PyCursesError, "use_default_colors() returned ERR");
+        return NULL;
+    }
 }
 #endif /* STRICT_SYSV_CURSES */
 
 /* List of functions defined in the module */
 
 static PyMethodDef PyCurses_methods[] = {
-  {"baudrate",            (PyCFunction)PyCurses_baudrate, METH_NOARGS},
-  {"beep",                (PyCFunction)PyCurses_beep, METH_NOARGS},
-  {"can_change_color",    (PyCFunction)PyCurses_can_change_color, METH_NOARGS},
-  {"cbreak",              (PyCFunction)PyCurses_cbreak, METH_VARARGS},
-  {"color_content",       (PyCFunction)PyCurses_Color_Content, METH_VARARGS},
-  {"color_pair",          (PyCFunction)PyCurses_color_pair, METH_VARARGS},
-  {"curs_set",            (PyCFunction)PyCurses_Curs_Set, METH_VARARGS},
-  {"def_prog_mode",       (PyCFunction)PyCurses_def_prog_mode, METH_NOARGS},
-  {"def_shell_mode",      (PyCFunction)PyCurses_def_shell_mode, METH_NOARGS},
-  {"delay_output",        (PyCFunction)PyCurses_Delay_Output, METH_VARARGS},
-  {"doupdate",            (PyCFunction)PyCurses_doupdate, METH_NOARGS},
-  {"echo",                (PyCFunction)PyCurses_echo, METH_VARARGS},
-  {"endwin",              (PyCFunction)PyCurses_endwin, METH_NOARGS},
-  {"erasechar",           (PyCFunction)PyCurses_EraseChar, METH_NOARGS},
-  {"filter",              (PyCFunction)PyCurses_filter, METH_NOARGS},
-  {"flash",               (PyCFunction)PyCurses_flash, METH_NOARGS},
-  {"flushinp",            (PyCFunction)PyCurses_flushinp, METH_NOARGS},
+    {"baudrate",            (PyCFunction)PyCurses_baudrate, METH_NOARGS},
+    {"beep",                (PyCFunction)PyCurses_beep, METH_NOARGS},
+    {"can_change_color",    (PyCFunction)PyCurses_can_change_color, METH_NOARGS},
+    {"cbreak",              (PyCFunction)PyCurses_cbreak, METH_VARARGS},
+    {"color_content",       (PyCFunction)PyCurses_Color_Content, METH_VARARGS},
+    {"color_pair",          (PyCFunction)PyCurses_color_pair, METH_VARARGS},
+    {"curs_set",            (PyCFunction)PyCurses_Curs_Set, METH_VARARGS},
+    {"def_prog_mode",       (PyCFunction)PyCurses_def_prog_mode, METH_NOARGS},
+    {"def_shell_mode",      (PyCFunction)PyCurses_def_shell_mode, METH_NOARGS},
+    {"delay_output",        (PyCFunction)PyCurses_Delay_Output, METH_VARARGS},
+    {"doupdate",            (PyCFunction)PyCurses_doupdate, METH_NOARGS},
+    {"echo",                (PyCFunction)PyCurses_echo, METH_VARARGS},
+    {"endwin",              (PyCFunction)PyCurses_endwin, METH_NOARGS},
+    {"erasechar",           (PyCFunction)PyCurses_EraseChar, METH_NOARGS},
+    {"filter",              (PyCFunction)PyCurses_filter, METH_NOARGS},
+    {"flash",               (PyCFunction)PyCurses_flash, METH_NOARGS},
+    {"flushinp",            (PyCFunction)PyCurses_flushinp, METH_NOARGS},
 #ifdef NCURSES_MOUSE_VERSION
-  {"getmouse",            (PyCFunction)PyCurses_GetMouse, METH_NOARGS},
-  {"ungetmouse",          (PyCFunction)PyCurses_UngetMouse, METH_VARARGS},
+    {"getmouse",            (PyCFunction)PyCurses_GetMouse, METH_NOARGS},
+    {"ungetmouse",          (PyCFunction)PyCurses_UngetMouse, METH_VARARGS},
 #endif
-  {"getsyx",              (PyCFunction)PyCurses_getsyx, METH_NOARGS},
-  {"getwin",              (PyCFunction)PyCurses_GetWin, METH_O},
-  {"has_colors",          (PyCFunction)PyCurses_has_colors, METH_NOARGS},
-  {"has_ic",              (PyCFunction)PyCurses_has_ic, METH_NOARGS},
-  {"has_il",              (PyCFunction)PyCurses_has_il, METH_NOARGS},
+    {"getsyx",              (PyCFunction)PyCurses_getsyx, METH_NOARGS},
+    {"getwin",              (PyCFunction)PyCurses_GetWin, METH_O},
+    {"has_colors",          (PyCFunction)PyCurses_has_colors, METH_NOARGS},
+    {"has_ic",              (PyCFunction)PyCurses_has_ic, METH_NOARGS},
+    {"has_il",              (PyCFunction)PyCurses_has_il, METH_NOARGS},
 #ifndef STRICT_SYSV_CURSES
-  {"has_key",             (PyCFunction)PyCurses_has_key, METH_VARARGS},
+    {"has_key",             (PyCFunction)PyCurses_has_key, METH_VARARGS},
 #endif
-  {"halfdelay",           (PyCFunction)PyCurses_HalfDelay, METH_VARARGS},
-  {"init_color",          (PyCFunction)PyCurses_Init_Color, METH_VARARGS},
-  {"init_pair",           (PyCFunction)PyCurses_Init_Pair, METH_VARARGS},
-  {"initscr",             (PyCFunction)PyCurses_InitScr, METH_NOARGS},
-  {"intrflush",           (PyCFunction)PyCurses_IntrFlush, METH_VARARGS},
-  {"isendwin",            (PyCFunction)PyCurses_isendwin, METH_NOARGS},
+    {"halfdelay",           (PyCFunction)PyCurses_HalfDelay, METH_VARARGS},
+    {"init_color",          (PyCFunction)PyCurses_Init_Color, METH_VARARGS},
+    {"init_pair",           (PyCFunction)PyCurses_Init_Pair, METH_VARARGS},
+    {"initscr",             (PyCFunction)PyCurses_InitScr, METH_NOARGS},
+    {"intrflush",           (PyCFunction)PyCurses_IntrFlush, METH_VARARGS},
+    {"isendwin",            (PyCFunction)PyCurses_isendwin, METH_NOARGS},
 #ifdef HAVE_CURSES_IS_TERM_RESIZED
-  {"is_term_resized",     (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS},
+    {"is_term_resized",     (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS},
 #endif
 #if !defined(__NetBSD__)
-  {"keyname",             (PyCFunction)PyCurses_KeyName, METH_VARARGS},
+    {"keyname",             (PyCFunction)PyCurses_KeyName, METH_VARARGS},
 #endif
-  {"killchar",            (PyCFunction)PyCurses_KillChar, METH_NOARGS}, 
-  {"longname",            (PyCFunction)PyCurses_longname, METH_NOARGS}, 
-  {"meta",                (PyCFunction)PyCurses_Meta, METH_VARARGS},
+    {"killchar",            (PyCFunction)PyCurses_KillChar, METH_NOARGS},
+    {"longname",            (PyCFunction)PyCurses_longname, METH_NOARGS},
+    {"meta",                (PyCFunction)PyCurses_Meta, METH_VARARGS},
 #ifdef NCURSES_MOUSE_VERSION
-  {"mouseinterval",       (PyCFunction)PyCurses_MouseInterval, METH_VARARGS},
-  {"mousemask",           (PyCFunction)PyCurses_MouseMask, METH_VARARGS},
+    {"mouseinterval",       (PyCFunction)PyCurses_MouseInterval, METH_VARARGS},
+    {"mousemask",           (PyCFunction)PyCurses_MouseMask, METH_VARARGS},
 #endif
-  {"napms",               (PyCFunction)PyCurses_Napms, METH_VARARGS},
-  {"newpad",              (PyCFunction)PyCurses_NewPad, METH_VARARGS},
-  {"newwin",              (PyCFunction)PyCurses_NewWindow, METH_VARARGS},
-  {"nl",                  (PyCFunction)PyCurses_nl, METH_VARARGS},
-  {"nocbreak",            (PyCFunction)PyCurses_nocbreak, METH_NOARGS},
-  {"noecho",              (PyCFunction)PyCurses_noecho, METH_NOARGS},
-  {"nonl",                (PyCFunction)PyCurses_nonl, METH_NOARGS},
-  {"noqiflush",           (PyCFunction)PyCurses_noqiflush, METH_NOARGS},
-  {"noraw",               (PyCFunction)PyCurses_noraw, METH_NOARGS},
-  {"pair_content",        (PyCFunction)PyCurses_Pair_Content, METH_VARARGS},
-  {"pair_number",         (PyCFunction)PyCurses_pair_number, METH_VARARGS},
-  {"putp",                (PyCFunction)PyCurses_Putp, METH_VARARGS},
-  {"qiflush",             (PyCFunction)PyCurses_QiFlush, METH_VARARGS},
-  {"raw",                 (PyCFunction)PyCurses_raw, METH_VARARGS},
-  {"reset_prog_mode",     (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS},
-  {"reset_shell_mode",    (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS},
-  {"resetty",             (PyCFunction)PyCurses_resetty, METH_NOARGS},
+    {"napms",               (PyCFunction)PyCurses_Napms, METH_VARARGS},
+    {"newpad",              (PyCFunction)PyCurses_NewPad, METH_VARARGS},
+    {"newwin",              (PyCFunction)PyCurses_NewWindow, METH_VARARGS},
+    {"nl",                  (PyCFunction)PyCurses_nl, METH_VARARGS},
+    {"nocbreak",            (PyCFunction)PyCurses_nocbreak, METH_NOARGS},
+    {"noecho",              (PyCFunction)PyCurses_noecho, METH_NOARGS},
+    {"nonl",                (PyCFunction)PyCurses_nonl, METH_NOARGS},
+    {"noqiflush",           (PyCFunction)PyCurses_noqiflush, METH_NOARGS},
+    {"noraw",               (PyCFunction)PyCurses_noraw, METH_NOARGS},
+    {"pair_content",        (PyCFunction)PyCurses_Pair_Content, METH_VARARGS},
+    {"pair_number",         (PyCFunction)PyCurses_pair_number, METH_VARARGS},
+    {"putp",                (PyCFunction)PyCurses_Putp, METH_VARARGS},
+    {"qiflush",             (PyCFunction)PyCurses_QiFlush, METH_VARARGS},
+    {"raw",                 (PyCFunction)PyCurses_raw, METH_VARARGS},
+    {"reset_prog_mode",     (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS},
+    {"reset_shell_mode",    (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS},
+    {"resetty",             (PyCFunction)PyCurses_resetty, METH_NOARGS},
 #ifdef HAVE_CURSES_RESIZETERM
-  {"resizeterm",          (PyCFunction)PyCurses_ResizeTerm, METH_VARARGS},
+    {"resizeterm",          (PyCFunction)PyCurses_ResizeTerm, METH_VARARGS},
 #endif
 #ifdef HAVE_CURSES_RESIZE_TERM
-  {"resize_term",         (PyCFunction)PyCurses_Resize_Term, METH_VARARGS},
+    {"resize_term",         (PyCFunction)PyCurses_Resize_Term, METH_VARARGS},
 #endif
-  {"savetty",             (PyCFunction)PyCurses_savetty, METH_NOARGS},
-  {"setsyx",              (PyCFunction)PyCurses_setsyx, METH_VARARGS},
-  {"setupterm",           (PyCFunction)PyCurses_setupterm,
-   METH_VARARGS|METH_KEYWORDS},
-  {"start_color",         (PyCFunction)PyCurses_Start_Color, METH_NOARGS},
-  {"termattrs",           (PyCFunction)PyCurses_termattrs, METH_NOARGS},
-  {"termname",            (PyCFunction)PyCurses_termname, METH_NOARGS},
-  {"tigetflag",		  (PyCFunction)PyCurses_tigetflag, METH_VARARGS},
-  {"tigetnum",		  (PyCFunction)PyCurses_tigetnum, METH_VARARGS},
-  {"tigetstr",		  (PyCFunction)PyCurses_tigetstr, METH_VARARGS},
-  {"tparm",               (PyCFunction)PyCurses_tparm, METH_VARARGS},
-  {"typeahead",           (PyCFunction)PyCurses_TypeAhead, METH_VARARGS},
-  {"unctrl",              (PyCFunction)PyCurses_UnCtrl, METH_VARARGS},
-  {"ungetch",             (PyCFunction)PyCurses_UngetCh, METH_VARARGS},
-  {"use_env",             (PyCFunction)PyCurses_Use_Env, METH_VARARGS},
+    {"savetty",             (PyCFunction)PyCurses_savetty, METH_NOARGS},
+    {"setsyx",              (PyCFunction)PyCurses_setsyx, METH_VARARGS},
+    {"setupterm",           (PyCFunction)PyCurses_setupterm,
+     METH_VARARGS|METH_KEYWORDS},
+    {"start_color",         (PyCFunction)PyCurses_Start_Color, METH_NOARGS},
+    {"termattrs",           (PyCFunction)PyCurses_termattrs, METH_NOARGS},
+    {"termname",            (PyCFunction)PyCurses_termname, METH_NOARGS},
+    {"tigetflag",           (PyCFunction)PyCurses_tigetflag, METH_VARARGS},
+    {"tigetnum",            (PyCFunction)PyCurses_tigetnum, METH_VARARGS},
+    {"tigetstr",            (PyCFunction)PyCurses_tigetstr, METH_VARARGS},
+    {"tparm",               (PyCFunction)PyCurses_tparm, METH_VARARGS},
+    {"typeahead",           (PyCFunction)PyCurses_TypeAhead, METH_VARARGS},
+    {"unctrl",              (PyCFunction)PyCurses_UnCtrl, METH_VARARGS},
+    {"ungetch",             (PyCFunction)PyCurses_UngetCh, METH_VARARGS},
+    {"use_env",             (PyCFunction)PyCurses_Use_Env, METH_VARARGS},
 #ifndef STRICT_SYSV_CURSES
-  {"use_default_colors",  (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS},
+    {"use_default_colors",  (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS},
 #endif
-  {NULL,		  NULL}		/* sentinel */
+    {NULL,                  NULL}         /* sentinel */
 };
 
 /* Initialization function for the module */
 
 
 static struct PyModuleDef _cursesmodule = {
-	PyModuleDef_HEAD_INIT,
-	"_curses",
-	NULL,
-	-1,
-	PyCurses_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
+    PyModuleDef_HEAD_INIT,
+    "_curses",
+    NULL,
+    -1,
+    PyCurses_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
 };
 
 PyMODINIT_FUNC
 PyInit__curses(void)
 {
-	PyObject *m, *d, *v, *c_api_object;
-	static void *PyCurses_API[PyCurses_API_pointers];
+    PyObject *m, *d, *v, *c_api_object;
+    static void *PyCurses_API[PyCurses_API_pointers];
+
+    /* Initialize object type */
+    if (PyType_Ready(&PyCursesWindow_Type) < 0)
+        return NULL;
+
+    /* Initialize the C API pointer array */
+    PyCurses_API[0] = (void *)&PyCursesWindow_Type;
+    PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled;
+    PyCurses_API[2] = (void *)func_PyCursesInitialised;
+    PyCurses_API[3] = (void *)func_PyCursesInitialisedColor;
+
+    /* Create the module and add the functions */
+    m = PyModule_Create(&_cursesmodule);
+    if (m == NULL)
+        return NULL;
 
-	/* Initialize object type */
-	if (PyType_Ready(&PyCursesWindow_Type) < 0)
-		return NULL;
-
-	/* Initialize the C API pointer array */
-	PyCurses_API[0] = (void *)&PyCursesWindow_Type;
-	PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled;
-	PyCurses_API[2] = (void *)func_PyCursesInitialised;
-	PyCurses_API[3] = (void *)func_PyCursesInitialisedColor;
-
-	/* Create the module and add the functions */
-	m = PyModule_Create(&_cursesmodule);
-	if (m == NULL)
-    		return NULL;
-
-	/* Add some symbolic constants to the module */
-	d = PyModule_GetDict(m);
-	if (d == NULL)
-		return NULL;
-	ModDict = d; /* For PyCurses_InitScr to use later */
-
-	/* Add a capsule for the C API */
-	c_api_object = PyCapsule_New(PyCurses_API, PyCurses_CAPSULE_NAME, NULL);
-	PyDict_SetItemString(d, "_C_API", c_api_object);
-	Py_DECREF(c_api_object);
-
-	/* For exception curses.error */
-	PyCursesError = PyErr_NewException("_curses.error", NULL, NULL);
-	PyDict_SetItemString(d, "error", PyCursesError);
-
-	/* Make the version available */
-	v = PyBytes_FromString(PyCursesVersion);
-	PyDict_SetItemString(d, "version", v);
-	PyDict_SetItemString(d, "__version__", v);
-	Py_DECREF(v);
-
-        SetDictInt("ERR", ERR);
-        SetDictInt("OK", OK);
-
-	/* Here are some attributes you can add to chars to print */
-	
-	SetDictInt("A_ATTRIBUTES",      A_ATTRIBUTES);
-	SetDictInt("A_NORMAL",		A_NORMAL);
-	SetDictInt("A_STANDOUT",	A_STANDOUT);
-	SetDictInt("A_UNDERLINE",	A_UNDERLINE);
-	SetDictInt("A_REVERSE",		A_REVERSE);
-	SetDictInt("A_BLINK",		A_BLINK);
-	SetDictInt("A_DIM",		A_DIM);
-	SetDictInt("A_BOLD",		A_BOLD);
-	SetDictInt("A_ALTCHARSET",	A_ALTCHARSET);
+    /* Add some symbolic constants to the module */
+    d = PyModule_GetDict(m);
+    if (d == NULL)
+        return NULL;
+    ModDict = d; /* For PyCurses_InitScr to use later */
+
+    /* Add a capsule for the C API */
+    c_api_object = PyCapsule_New(PyCurses_API, PyCurses_CAPSULE_NAME, NULL);
+    PyDict_SetItemString(d, "_C_API", c_api_object);
+    Py_DECREF(c_api_object);
+
+    /* For exception curses.error */
+    PyCursesError = PyErr_NewException("_curses.error", NULL, NULL);
+    PyDict_SetItemString(d, "error", PyCursesError);
+
+    /* Make the version available */
+    v = PyBytes_FromString(PyCursesVersion);
+    PyDict_SetItemString(d, "version", v);
+    PyDict_SetItemString(d, "__version__", v);
+    Py_DECREF(v);
+
+    SetDictInt("ERR", ERR);
+    SetDictInt("OK", OK);
+
+    /* Here are some attributes you can add to chars to print */
+
+    SetDictInt("A_ATTRIBUTES",      A_ATTRIBUTES);
+    SetDictInt("A_NORMAL",              A_NORMAL);
+    SetDictInt("A_STANDOUT",            A_STANDOUT);
+    SetDictInt("A_UNDERLINE",           A_UNDERLINE);
+    SetDictInt("A_REVERSE",             A_REVERSE);
+    SetDictInt("A_BLINK",               A_BLINK);
+    SetDictInt("A_DIM",                 A_DIM);
+    SetDictInt("A_BOLD",                A_BOLD);
+    SetDictInt("A_ALTCHARSET",          A_ALTCHARSET);
 #if !defined(__NetBSD__)
-	SetDictInt("A_INVIS",           A_INVIS);
+    SetDictInt("A_INVIS",           A_INVIS);
 #endif
-	SetDictInt("A_PROTECT",         A_PROTECT);
-	SetDictInt("A_CHARTEXT",        A_CHARTEXT);
-	SetDictInt("A_COLOR",           A_COLOR);
+    SetDictInt("A_PROTECT",         A_PROTECT);
+    SetDictInt("A_CHARTEXT",        A_CHARTEXT);
+    SetDictInt("A_COLOR",           A_COLOR);
 
-	/* The following are never available with strict SYSV curses */
+    /* The following are never available with strict SYSV curses */
 #ifdef A_HORIZONTAL
-	SetDictInt("A_HORIZONTAL",      A_HORIZONTAL);
+    SetDictInt("A_HORIZONTAL",      A_HORIZONTAL);
 #endif
 #ifdef A_LEFT
-	SetDictInt("A_LEFT",            A_LEFT);
+    SetDictInt("A_LEFT",            A_LEFT);
 #endif
 #ifdef A_LOW
-	SetDictInt("A_LOW",             A_LOW);
+    SetDictInt("A_LOW",             A_LOW);
 #endif
 #ifdef A_RIGHT
-	SetDictInt("A_RIGHT",           A_RIGHT);
+    SetDictInt("A_RIGHT",           A_RIGHT);
 #endif
 #ifdef A_TOP
-	SetDictInt("A_TOP",             A_TOP);
+    SetDictInt("A_TOP",             A_TOP);
 #endif
 #ifdef A_VERTICAL
-	SetDictInt("A_VERTICAL",        A_VERTICAL);
+    SetDictInt("A_VERTICAL",        A_VERTICAL);
 #endif
 
-	SetDictInt("COLOR_BLACK",       COLOR_BLACK);
-	SetDictInt("COLOR_RED",         COLOR_RED);
-	SetDictInt("COLOR_GREEN",       COLOR_GREEN);
-	SetDictInt("COLOR_YELLOW",      COLOR_YELLOW);
-	SetDictInt("COLOR_BLUE",        COLOR_BLUE);
-	SetDictInt("COLOR_MAGENTA",     COLOR_MAGENTA);
-	SetDictInt("COLOR_CYAN",        COLOR_CYAN);
-	SetDictInt("COLOR_WHITE",       COLOR_WHITE);
+    SetDictInt("COLOR_BLACK",       COLOR_BLACK);
+    SetDictInt("COLOR_RED",         COLOR_RED);
+    SetDictInt("COLOR_GREEN",       COLOR_GREEN);
+    SetDictInt("COLOR_YELLOW",      COLOR_YELLOW);
+    SetDictInt("COLOR_BLUE",        COLOR_BLUE);
+    SetDictInt("COLOR_MAGENTA",     COLOR_MAGENTA);
+    SetDictInt("COLOR_CYAN",        COLOR_CYAN);
+    SetDictInt("COLOR_WHITE",       COLOR_WHITE);
 
 #ifdef NCURSES_MOUSE_VERSION
-	/* Mouse-related constants */
-	SetDictInt("BUTTON1_PRESSED",          BUTTON1_PRESSED);
-	SetDictInt("BUTTON1_RELEASED",         BUTTON1_RELEASED);
-	SetDictInt("BUTTON1_CLICKED",          BUTTON1_CLICKED);
-	SetDictInt("BUTTON1_DOUBLE_CLICKED",   BUTTON1_DOUBLE_CLICKED);
-	SetDictInt("BUTTON1_TRIPLE_CLICKED",   BUTTON1_TRIPLE_CLICKED);
-
-	SetDictInt("BUTTON2_PRESSED",          BUTTON2_PRESSED);
-	SetDictInt("BUTTON2_RELEASED",         BUTTON2_RELEASED);
-	SetDictInt("BUTTON2_CLICKED",          BUTTON2_CLICKED);
-	SetDictInt("BUTTON2_DOUBLE_CLICKED",   BUTTON2_DOUBLE_CLICKED);
-	SetDictInt("BUTTON2_TRIPLE_CLICKED",   BUTTON2_TRIPLE_CLICKED);
-
-	SetDictInt("BUTTON3_PRESSED",          BUTTON3_PRESSED);
-	SetDictInt("BUTTON3_RELEASED",         BUTTON3_RELEASED);
-	SetDictInt("BUTTON3_CLICKED",          BUTTON3_CLICKED);
-	SetDictInt("BUTTON3_DOUBLE_CLICKED",   BUTTON3_DOUBLE_CLICKED);
-	SetDictInt("BUTTON3_TRIPLE_CLICKED",   BUTTON3_TRIPLE_CLICKED);
-
-	SetDictInt("BUTTON4_PRESSED",          BUTTON4_PRESSED);
-	SetDictInt("BUTTON4_RELEASED",         BUTTON4_RELEASED);
-	SetDictInt("BUTTON4_CLICKED",          BUTTON4_CLICKED);
-	SetDictInt("BUTTON4_DOUBLE_CLICKED",   BUTTON4_DOUBLE_CLICKED);
-	SetDictInt("BUTTON4_TRIPLE_CLICKED",   BUTTON4_TRIPLE_CLICKED);
-
-	SetDictInt("BUTTON_SHIFT",             BUTTON_SHIFT);
-	SetDictInt("BUTTON_CTRL",              BUTTON_CTRL);
-	SetDictInt("BUTTON_ALT",               BUTTON_ALT);
-
-	SetDictInt("ALL_MOUSE_EVENTS",         ALL_MOUSE_EVENTS);
-	SetDictInt("REPORT_MOUSE_POSITION",    REPORT_MOUSE_POSITION);
-#endif
-	/* Now set everything up for KEY_ variables */
-	{
-	  int key;
-	  char *key_n;
-	  char *key_n2;
+    /* Mouse-related constants */
+    SetDictInt("BUTTON1_PRESSED",          BUTTON1_PRESSED);
+    SetDictInt("BUTTON1_RELEASED",         BUTTON1_RELEASED);
+    SetDictInt("BUTTON1_CLICKED",          BUTTON1_CLICKED);
+    SetDictInt("BUTTON1_DOUBLE_CLICKED",   BUTTON1_DOUBLE_CLICKED);
+    SetDictInt("BUTTON1_TRIPLE_CLICKED",   BUTTON1_TRIPLE_CLICKED);
+
+    SetDictInt("BUTTON2_PRESSED",          BUTTON2_PRESSED);
+    SetDictInt("BUTTON2_RELEASED",         BUTTON2_RELEASED);
+    SetDictInt("BUTTON2_CLICKED",          BUTTON2_CLICKED);
+    SetDictInt("BUTTON2_DOUBLE_CLICKED",   BUTTON2_DOUBLE_CLICKED);
+    SetDictInt("BUTTON2_TRIPLE_CLICKED",   BUTTON2_TRIPLE_CLICKED);
+
+    SetDictInt("BUTTON3_PRESSED",          BUTTON3_PRESSED);
+    SetDictInt("BUTTON3_RELEASED",         BUTTON3_RELEASED);
+    SetDictInt("BUTTON3_CLICKED",          BUTTON3_CLICKED);
+    SetDictInt("BUTTON3_DOUBLE_CLICKED",   BUTTON3_DOUBLE_CLICKED);
+    SetDictInt("BUTTON3_TRIPLE_CLICKED",   BUTTON3_TRIPLE_CLICKED);
+
+    SetDictInt("BUTTON4_PRESSED",          BUTTON4_PRESSED);
+    SetDictInt("BUTTON4_RELEASED",         BUTTON4_RELEASED);
+    SetDictInt("BUTTON4_CLICKED",          BUTTON4_CLICKED);
+    SetDictInt("BUTTON4_DOUBLE_CLICKED",   BUTTON4_DOUBLE_CLICKED);
+    SetDictInt("BUTTON4_TRIPLE_CLICKED",   BUTTON4_TRIPLE_CLICKED);
+
+    SetDictInt("BUTTON_SHIFT",             BUTTON_SHIFT);
+    SetDictInt("BUTTON_CTRL",              BUTTON_CTRL);
+    SetDictInt("BUTTON_ALT",               BUTTON_ALT);
+
+    SetDictInt("ALL_MOUSE_EVENTS",         ALL_MOUSE_EVENTS);
+    SetDictInt("REPORT_MOUSE_POSITION",    REPORT_MOUSE_POSITION);
+#endif
+    /* Now set everything up for KEY_ variables */
+    {
+        int key;
+        char *key_n;
+        char *key_n2;
 #if !defined(__NetBSD__)
-	  for (key=KEY_MIN;key < KEY_MAX; key++) {
-	    key_n = (char *)keyname(key);
-	    if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0)
-	      continue;
-	    if (strncmp(key_n,"KEY_F(",6)==0) {
-	      char *p1, *p2;
-	      key_n2 = malloc(strlen(key_n)+1);
-	      if (!key_n2) {
-		PyErr_NoMemory();
-		break;
-              }
-	      p1 = key_n;
-	      p2 = key_n2;
-	      while (*p1) {
-		if (*p1 != '(' && *p1 != ')') {
-		  *p2 = *p1;
-		  p2++;
-		}
-		p1++;
-	      }
-	      *p2 = (char)0;
-	    } else
-	      key_n2 = key_n;
-	    SetDictInt(key_n2,key);
-	    if (key_n2 != key_n)
-	      free(key_n2);
-	  }
-#endif
-	  SetDictInt("KEY_MIN", KEY_MIN);
-	  SetDictInt("KEY_MAX", KEY_MAX);
-	}
-	return m;
+        for (key=KEY_MIN;key < KEY_MAX; key++) {
+            key_n = (char *)keyname(key);
+            if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0)
+                continue;
+            if (strncmp(key_n,"KEY_F(",6)==0) {
+                char *p1, *p2;
+                key_n2 = malloc(strlen(key_n)+1);
+                if (!key_n2) {
+                    PyErr_NoMemory();
+                    break;
+                }
+                p1 = key_n;
+                p2 = key_n2;
+                while (*p1) {
+                    if (*p1 != '(' && *p1 != ')') {
+                        *p2 = *p1;
+                        p2++;
+                    }
+                    p1++;
+                }
+                *p2 = (char)0;
+            } else
+                key_n2 = key_n;
+            SetDictInt(key_n2,key);
+            if (key_n2 != key_n)
+                free(key_n2);
+        }
+#endif
+        SetDictInt("KEY_MIN", KEY_MIN);
+        SetDictInt("KEY_MAX", KEY_MAX);
+    }
+    return m;
 }

Modified: python/branches/py3k-cdecimal/Modules/_io/textio.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_io/textio.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_io/textio.c	Wed May 19 17:30:16 2010
@@ -905,8 +905,11 @@
                 Py_CLEAR(self->encoding);
         }
     }
-    if (self->encoding != NULL)
+    if (self->encoding != NULL) {
         encoding = _PyUnicode_AsString(self->encoding);
+        if (encoding == NULL)
+            goto error;
+    }
     else if (encoding != NULL) {
         self->encoding = PyUnicode_FromString(encoding);
         if (self->encoding == NULL)
@@ -935,6 +938,8 @@
     self->writetranslate = (newline == NULL || newline[0] != '\0');
     if (!self->readuniversal && self->readnl) {
         self->writenl = _PyUnicode_AsString(self->readnl);
+        if (self->writenl == NULL)
+            goto error;
         if (!strcmp(self->writenl, "\n"))
             self->writenl = NULL;
     }
@@ -2408,7 +2413,7 @@
     Py_DECREF(res);
     if (r < 0)
         return NULL;
-    
+
     if (r > 0) {
         Py_RETURN_NONE; /* stream already closed */
     }

Modified: python/branches/py3k-cdecimal/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_sqlite/connection.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_sqlite/connection.c	Wed May 19 17:30:16 2010
@@ -3,7 +3,7 @@
  * Copyright (C) 2004-2010 Gerhard Häring <gh at ghaering.de>
  *
  * This file is part of pysqlite.
- * 
+ *
  * This software is provided 'as-is', without any express or implied
  * warranty.  In no event will the authors be held liable for any damages
  * arising from the use of this software.
@@ -495,7 +495,9 @@
     } else if (PyFloat_Check(py_val)) {
         sqlite3_result_double(context, PyFloat_AsDouble(py_val));
     } else if (PyUnicode_Check(py_val)) {
-        sqlite3_result_text(context, _PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);
+        char *str = _PyUnicode_AsString(py_val);
+        if (str != NULL)
+            sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT);
     } else if (PyObject_CheckBuffer(py_val)) {
         if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
             PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
@@ -892,7 +894,7 @@
         }
 
         /* abort query if error occurred */
-        rc = 1; 
+        rc = 1;
     } else {
         rc = (int)PyObject_IsTrue(ret);
         Py_DECREF(ret);

Modified: python/branches/py3k-cdecimal/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_sqlite/cursor.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_sqlite/cursor.c	Wed May 19 17:30:16 2010
@@ -368,7 +368,7 @@
                         }
                         PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'",
                                      colname , val_str);
-                        buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf)); 
+                        buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf));
                         if (!buf_bytes) {
                             PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8");
                         } else {
@@ -533,7 +533,7 @@
     }
 
     operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
-    if (operation == NULL)
+    if (operation_cstr == NULL)
         goto error;
 
     /* reset description and rowcount */

Modified: python/branches/py3k-cdecimal/Modules/_sqlite/row.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_sqlite/row.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_sqlite/row.c	Wed May 19 17:30:16 2010
@@ -83,6 +83,8 @@
         return item;
     } else if (PyUnicode_Check(idx)) {
         key = _PyUnicode_AsString(idx);
+        if (key == NULL)
+            return NULL;
 
         nitems = PyTuple_Size(self->description);
 

Modified: python/branches/py3k-cdecimal/Modules/_sqlite/statement.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_sqlite/statement.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_sqlite/statement.c	Wed May 19 17:30:16 2010
@@ -130,7 +130,10 @@
             break;
         case TYPE_UNICODE:
             string = _PyUnicode_AsString(parameter);
-            rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            if (string != NULL)
+                rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            else
+                rc = -1;
             break;
         case TYPE_BUFFER:
             if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {

Modified: python/branches/py3k-cdecimal/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_ssl.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_ssl.c	Wed May 19 17:30:16 2010
@@ -115,23 +115,29 @@
 
 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;
-
-} PySSLObject;
-
-static PyTypeObject PySSL_Type;
-static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args);
-static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args);
+    SSL_CTX *ctx;
+} PySSLContext;
+
+typedef struct {
+    PyObject_HEAD
+    PyObject *Socket; /* weakref to socket on which we're layered */
+    SSL *ssl;
+    X509 *peer_cert;
+    int shutdown_seen_zero;
+} PySSLSocket;
+
+static PyTypeObject PySSLContext_Type;
+static PyTypeObject PySSLSocket_Type;
+
+static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args);
+static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args);
 static int check_socket_and_wait_for_timeout(PySocketSockObject *s,
                                              int writing);
-static PyObject *PySSL_peercert(PySSLObject *self, PyObject *args);
-static PyObject *PySSL_cipher(PySSLObject *self);
+static PyObject *PySSL_peercert(PySSLSocket *self, PyObject *args);
+static PyObject *PySSL_cipher(PySSLSocket *self);
 
-#define PySSLObject_Check(v)    (Py_TYPE(v) == &PySSL_Type)
+#define PySSLContext_Check(v)   (Py_TYPE(v) == &PySSLContext_Type)
+#define PySSLSocket_Check(v)    (Py_TYPE(v) == &PySSLSocket_Type)
 
 typedef enum {
     SOCKET_IS_NONBLOCKING,
@@ -154,7 +160,7 @@
 */
 
 static PyObject *
-PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
+PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
 {
     PyObject *v;
     char buf[2048];
@@ -199,6 +205,7 @@
                     errstr = "EOF occurred in violation of protocol";
                 } else if (ret == -1) {
                     /* underlying BIO reported an I/O error */
+                    ERR_clear_error();
                     return s->errorhandler();
                 } else { /* possible? */
                     p = PY_SSL_ERROR_SYSCALL;
@@ -231,6 +238,7 @@
         errstr = ERR_error_string(ERR_peek_last_error(), NULL);
     }
     PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
+    ERR_clear_error();
     v = Py_BuildValue("(is)", p, buf);
     if (v != NULL) {
         PyErr_SetObject(PySSLErrorObject, v);
@@ -250,6 +258,7 @@
         errstr = ERR_error_string(errcode, NULL);
     }
     PyOS_snprintf(buf, sizeof(buf), "_ssl.c:%d: %s", lineno, errstr);
+    ERR_clear_error();
     v = Py_BuildValue("(is)", errcode, buf);
     if (v != NULL) {
         PyErr_SetObject(PySSLErrorObject, v);
@@ -258,126 +267,28 @@
     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)
+static PySSLSocket *
+newPySSLSocket(SSL_CTX *ctx, PySocketSockObject *sock,
+               enum py_ssl_server_or_client socket_type)
 {
-    PySSLObject *self;
-    char *errstr = NULL;
-    int ret;
-    int verification_mode;
+    PySSLSocket *self;
 
-    self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */
+    self = PyObject_New(PySSLSocket, &PySSLSocket_Type);
     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 */
+    self->ssl = SSL_new(ctx);
     PySSL_END_ALLOW_THREADS
-    SSL_set_fd(self->ssl, Sock->sock_fd);       /* Set the socket for SSL */
+    SSL_set_fd(self->ssl, sock->sock_fd);
 #ifdef SSL_MODE_AUTO_RETRY
     SSL_set_mode(self->ssl, SSL_MODE_AUTO_RETRY);
 #endif
@@ -385,8 +296,7 @@
     /* 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 */
+    if (sock->sock_timeout >= 0.0) {
         BIO_set_nbio(SSL_get_rbio(self->ssl), 1);
         BIO_set_nbio(SSL_get_wbio(self->ssl), 1);
     }
@@ -398,57 +308,13 @@
         SSL_set_accept_state(self->ssl);
     PySSL_END_ALLOW_THREADS
 
-    self->Socket = PyWeakref_NewRef((PyObject *) Sock, Py_None);
+    self->Socket = PyWeakref_NewRef((PyObject *) sock, NULL);
     return self;
- fail:
-    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);
-}
-
-PyDoc_STRVAR(ssl_doc,
-"sslwrap(socket, server_side, [keyfile, certfile, certs_mode, protocol,\n"
-"                              cacertsfile, ciphers]) -> sslobject");
-
 /* SSL object methods */
 
-static PyObject *PySSL_SSLdo_handshake(PySSLObject *self)
+static PyObject *PySSL_SSLdo_handshake(PySSLSocket *self)
 {
     int ret;
     int err;
@@ -948,13 +814,13 @@
 PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
 
     PyObject *retval = NULL;
-    char *filename = NULL;
+    PyObject *filename;
     X509 *x=NULL;
     BIO *cert;
     int verbose = 1;
 
-    if (!PyArg_ParseTuple(args, "s|i:test_decode_certificate",
-                          &filename, &verbose))
+    if (!PyArg_ParseTuple(args, "O&|i:test_decode_certificate",
+                          PyUnicode_FSConverter, &filename, &verbose))
         return NULL;
 
     if ((cert=BIO_new(BIO_s_file())) == NULL) {
@@ -963,7 +829,7 @@
         goto fail0;
     }
 
-    if (BIO_read_filename(cert,filename) <= 0) {
+    if (BIO_read_filename(cert, PyBytes_AsString(filename)) <= 0) {
         PyErr_SetString(PySSLErrorObject,
                         "Can't open file");
         goto fail0;
@@ -979,14 +845,14 @@
     retval = _decode_certificate(x, verbose);
 
   fail0:
-
+    Py_DECREF(filename);
     if (cert != NULL) BIO_free(cert);
     return retval;
 }
 
 
 static PyObject *
-PySSL_peercert(PySSLObject *self, PyObject *args)
+PySSL_peercert(PySSLSocket *self, PyObject *args)
 {
     PyObject *retval = NULL;
     int len;
@@ -1017,8 +883,7 @@
         return retval;
 
     } else {
-
-        verification = SSL_CTX_get_verify_mode(self->ctx);
+        verification = SSL_CTX_get_verify_mode(SSL_get_SSL_CTX(self->ssl));
         if ((verification & SSL_VERIFY_PEER) == 0)
             return PyDict_New();
         else
@@ -1038,7 +903,7 @@
 peer certificate, or None if no certificate was provided.  This will\n\
 return the certificate even if it wasn't validated.");
 
-static PyObject *PySSL_cipher (PySSLObject *self) {
+static PyObject *PySSL_cipher (PySSLSocket *self) {
 
     PyObject *retval, *v;
     SSL_CIPHER *current;
@@ -1084,14 +949,12 @@
     return NULL;
 }
 
-static void PySSL_dealloc(PySSLObject *self)
+static void PySSL_dealloc(PySSLSocket *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);
 }
@@ -1166,7 +1029,7 @@
     return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK;
 }
 
-static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args)
+static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args)
 {
     Py_buffer buf;
     int len;
@@ -1250,7 +1113,7 @@
 Writes the string s into the SSL object.  Returns the number\n\
 of bytes written.");
 
-static PyObject *PySSL_SSLpending(PySSLObject *self)
+static PyObject *PySSL_SSLpending(PySSLSocket *self)
 {
     int count = 0;
 
@@ -1269,7 +1132,7 @@
 Returns the number of already decrypted bytes available for read,\n\
 pending on the connection.\n");
 
-static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
+static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
 {
     PyObject *dest = NULL;
     Py_buffer buf;
@@ -1392,7 +1255,7 @@
 \n\
 Read up to len bytes from the SSL socket.");
 
-static PyObject *PySSL_SSLshutdown(PySSLObject *self)
+static PyObject *PySSL_SSLshutdown(PySSLSocket *self)
 {
     int err, ssl_err, sockstate, nonblocking;
     int zeros = 0;
@@ -1497,10 +1360,10 @@
     {NULL, NULL}
 };
 
-static PyTypeObject PySSL_Type = {
+static PyTypeObject PySSLSocket_Type = {
     PyVarObject_HEAD_INIT(NULL, 0)
-    "ssl.SSLContext",                   /*tp_name*/
-    sizeof(PySSLObject),                /*tp_basicsize*/
+    "_ssl._SSLSocket",                  /*tp_name*/
+    sizeof(PySSLSocket),                /*tp_basicsize*/
     0,                                  /*tp_itemsize*/
     /* methods */
     (destructor)PySSL_dealloc,          /*tp_dealloc*/
@@ -1529,6 +1392,310 @@
     PySSLMethods,                       /*tp_methods*/
 };
 
+
+/*
+ * _SSLContext objects
+ */
+
+static PyObject *
+context_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    char *kwlist[] = {"protocol", NULL};
+    PySSLContext *self;
+    int proto_version = PY_SSL_VERSION_SSL23;
+    SSL_CTX *ctx = NULL;
+
+    if (!PyArg_ParseTupleAndKeywords(
+        args, kwds, "i:_SSLContext", kwlist,
+        &proto_version))
+        return NULL;
+
+    PySSL_BEGIN_ALLOW_THREADS
+    if (proto_version == PY_SSL_VERSION_TLS1)
+        ctx = SSL_CTX_new(TLSv1_method());
+    else if (proto_version == PY_SSL_VERSION_SSL3)
+        ctx = SSL_CTX_new(SSLv3_method());
+    else if (proto_version == PY_SSL_VERSION_SSL2)
+        ctx = SSL_CTX_new(SSLv2_method());
+    else if (proto_version == PY_SSL_VERSION_SSL23)
+        ctx = SSL_CTX_new(SSLv23_method());
+    else
+        proto_version = -1;
+    PySSL_END_ALLOW_THREADS
+
+    if (proto_version == -1) {
+        PyErr_SetString(PyExc_ValueError,
+                        "invalid protocol version");
+        return NULL;
+    }
+    if (ctx == NULL) {
+        PyErr_SetString(PySSLErrorObject,
+                        "failed to allocate SSL context");
+        return NULL;
+    }
+
+    assert(type != NULL && type->tp_alloc != NULL);
+    self = (PySSLContext *) type->tp_alloc(type, 0);
+    if (self == NULL) {
+        SSL_CTX_free(ctx);
+        return NULL;
+    }
+    self->ctx = ctx;
+    /* Defaults */
+    SSL_CTX_set_verify(self->ctx, SSL_VERIFY_NONE, NULL);
+    SSL_CTX_set_options(self->ctx, SSL_OP_ALL);
+
+    return (PyObject *)self;
+}
+
+static void
+context_dealloc(PySSLContext *self)
+{
+    SSL_CTX_free(self->ctx);
+    Py_TYPE(self)->tp_free(self);
+}
+
+static PyObject *
+set_ciphers(PySSLContext *self, PyObject *args)
+{
+    int ret;
+    const char *cipherlist;
+
+    if (!PyArg_ParseTuple(args, "s:set_ciphers", &cipherlist))
+        return NULL;
+    ret = SSL_CTX_set_cipher_list(self->ctx, cipherlist);
+    if (ret == 0) {
+        /* Clearing the error queue is necessary on some OpenSSL versions,
+           otherwise the error will be reported again when another SSL call
+           is done. */
+        ERR_clear_error();
+        PyErr_SetString(PySSLErrorObject,
+                        "No cipher can be selected.");
+        return NULL;
+    }
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+get_verify_mode(PySSLContext *self, void *c)
+{
+    switch (SSL_CTX_get_verify_mode(self->ctx)) {
+    case SSL_VERIFY_NONE:
+        return PyLong_FromLong(PY_SSL_CERT_NONE);
+    case SSL_VERIFY_PEER:
+        return PyLong_FromLong(PY_SSL_CERT_OPTIONAL);
+    case SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT:
+        return PyLong_FromLong(PY_SSL_CERT_REQUIRED);
+    }
+    PyErr_SetString(PySSLErrorObject,
+                    "invalid return value from SSL_CTX_get_verify_mode");
+    return NULL;
+}
+
+static int
+set_verify_mode(PySSLContext *self, PyObject *arg, void *c)
+{
+    int n, mode;
+    if (!PyArg_Parse(arg, "i", &n))
+        return -1;
+    if (n == PY_SSL_CERT_NONE)
+        mode = SSL_VERIFY_NONE;
+    else if (n == PY_SSL_CERT_OPTIONAL)
+        mode = SSL_VERIFY_PEER;
+    else if (n == PY_SSL_CERT_REQUIRED)
+        mode = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
+    else {
+        PyErr_SetString(PyExc_ValueError,
+                        "invalid value for verify_mode");
+        return -1;
+    }
+    SSL_CTX_set_verify(self->ctx, mode, NULL);
+    return 0;
+}
+
+static PyObject *
+load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwds)
+{
+    char *kwlist[] = {"certfile", "keyfile", NULL};
+    PyObject *certfile, *keyfile = NULL;
+    PyObject *certfile_bytes = NULL, *keyfile_bytes = NULL;
+    int r;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds,
+        "O|O:load_cert_chain", kwlist,
+        &certfile, &keyfile))
+        return NULL;
+    if (keyfile == Py_None)
+        keyfile = NULL;
+    if (!PyUnicode_FSConverter(certfile, &certfile_bytes)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "certfile should be a valid filesystem path");
+        return NULL;
+    }
+    if (keyfile && !PyUnicode_FSConverter(keyfile, &keyfile_bytes)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "keyfile should be a valid filesystem path");
+        goto error;
+    }
+    PySSL_BEGIN_ALLOW_THREADS
+    r = SSL_CTX_use_certificate_chain_file(self->ctx,
+        PyBytes_AS_STRING(certfile_bytes));
+    PySSL_END_ALLOW_THREADS
+    if (r != 1) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        goto error;
+    }
+    PySSL_BEGIN_ALLOW_THREADS
+    r = SSL_CTX_use_RSAPrivateKey_file(self->ctx,
+        PyBytes_AS_STRING(keyfile ? keyfile_bytes : certfile_bytes),
+        SSL_FILETYPE_PEM);
+    PySSL_END_ALLOW_THREADS
+    Py_XDECREF(keyfile_bytes);
+    Py_XDECREF(certfile_bytes);
+    if (r != 1) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        return NULL;
+    }
+    PySSL_BEGIN_ALLOW_THREADS
+    r = SSL_CTX_check_private_key(self->ctx);
+    PySSL_END_ALLOW_THREADS
+    if (r != 1) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        return NULL;
+    }
+    Py_RETURN_NONE;
+
+error:
+    Py_XDECREF(keyfile_bytes);
+    Py_XDECREF(certfile_bytes);
+    return NULL;
+}
+
+static PyObject *
+load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwds)
+{
+    char *kwlist[] = {"cafile", "capath", NULL};
+    PyObject *cafile = NULL, *capath = NULL;
+    PyObject *cafile_bytes = NULL, *capath_bytes = NULL;
+    const char *cafile_buf = NULL, *capath_buf = NULL;
+    int r;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds,
+        "|OO:load_verify_locations", kwlist,
+        &cafile, &capath))
+        return NULL;
+    if (cafile == Py_None)
+        cafile = NULL;
+    if (capath == Py_None)
+        capath = NULL;
+    if (cafile == NULL && capath == NULL) {
+        PyErr_SetString(PyExc_TypeError,
+                        "cafile and capath cannot be both omitted");
+        return NULL;
+    }
+    if (cafile && !PyUnicode_FSConverter(cafile, &cafile_bytes)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "cafile should be a valid filesystem path");
+        return NULL;
+    }
+    if (capath && !PyUnicode_FSConverter(capath, &capath_bytes)) {
+        Py_DECREF(cafile_bytes);
+        PyErr_SetString(PyExc_TypeError,
+                        "capath should be a valid filesystem path");
+        return NULL;
+    }
+    if (cafile)
+        cafile_buf = PyBytes_AS_STRING(cafile_bytes);
+    if (capath)
+        capath_buf = PyBytes_AS_STRING(capath_bytes);
+    PySSL_BEGIN_ALLOW_THREADS
+    r = SSL_CTX_load_verify_locations(self->ctx, cafile_buf, capath_buf);
+    PySSL_END_ALLOW_THREADS
+    Py_XDECREF(cafile_bytes);
+    Py_XDECREF(capath_bytes);
+    if (r != 1) {
+        _setSSLError(NULL, 0, __FILE__, __LINE__);
+        return NULL;
+    }
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+context_wrap_socket(PySSLContext *self, PyObject *args, PyObject *kwds)
+{
+    char *kwlist[] = {"sock", "server_side", NULL};
+    PySocketSockObject *sock;
+    int server_side = 0;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i:_wrap_socket", kwlist,
+                                     PySocketModule.Sock_Type,
+                                     &sock, &server_side))
+        return NULL;
+
+    return (PyObject *) newPySSLSocket(self->ctx, sock, server_side);
+}
+
+static PyGetSetDef context_getsetlist[] = {
+    {"verify_mode", (getter) get_verify_mode,
+                    (setter) set_verify_mode, NULL},
+    {NULL},            /* sentinel */
+};
+
+static struct PyMethodDef context_methods[] = {
+    {"_wrap_socket", (PyCFunction) context_wrap_socket,
+                       METH_VARARGS | METH_KEYWORDS, NULL},
+    {"set_ciphers", (PyCFunction) set_ciphers,
+                    METH_VARARGS, NULL},
+    {"load_cert_chain", (PyCFunction) load_cert_chain,
+                        METH_VARARGS | METH_KEYWORDS, NULL},
+    {"load_verify_locations", (PyCFunction) load_verify_locations,
+                              METH_VARARGS | METH_KEYWORDS, NULL},
+    {NULL, NULL}        /* sentinel */
+};
+
+static PyTypeObject PySSLContext_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "_ssl._SSLContext",                        /*tp_name*/
+    sizeof(PySSLContext),                      /*tp_basicsize*/
+    0,                                         /*tp_itemsize*/
+    (destructor)context_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 | Py_TPFLAGS_BASETYPE,  /*tp_flags*/
+    0,                                         /*tp_doc*/
+    0,                                         /*tp_traverse*/
+    0,                                         /*tp_clear*/
+    0,                                         /*tp_richcompare*/
+    0,                                         /*tp_weaklistoffset*/
+    0,                                         /*tp_iter*/
+    0,                                         /*tp_iternext*/
+    context_methods,                           /*tp_methods*/
+    0,                                         /*tp_members*/
+    context_getsetlist,                        /*tp_getset*/
+    0,                                         /*tp_base*/
+    0,                                         /*tp_dict*/
+    0,                                         /*tp_descr_get*/
+    0,                                         /*tp_descr_set*/
+    0,                                         /*tp_dictoffset*/
+    0,                                         /*tp_init*/
+    0,                                         /*tp_alloc*/
+    context_new,                               /*tp_new*/
+};
+
+
+
 #ifdef HAVE_OPENSSL_RAND
 
 /* helper routines for seeding the SSL PRNG */
@@ -1566,15 +1733,17 @@
 using the ssl() function.");
 
 static PyObject *
-PySSL_RAND_egd(PyObject *self, PyObject *arg)
+PySSL_RAND_egd(PyObject *self, PyObject *args)
 {
+    PyObject *path;
     int bytes;
 
-    if (!PyUnicode_Check(arg))
-        return PyErr_Format(PyExc_TypeError,
-                            "RAND_egd() expected string, found %s",
-                            Py_TYPE(arg)->tp_name);
-    bytes = RAND_egd(_PyUnicode_AsString(arg));
+    if (!PyArg_ParseTuple(args, "O&|i:RAND_egd",
+                          PyUnicode_FSConverter, &path))
+        return NULL;
+
+    bytes = RAND_egd(PyBytes_AsString(path));
+    Py_DECREF(path);
     if (bytes == -1) {
         PyErr_SetString(PySSLErrorObject,
                         "EGD connection failed or EGD did not return "
@@ -1598,14 +1767,12 @@
 /* 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},
 #ifdef HAVE_OPENSSL_RAND
     {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
      PySSL_RAND_add_doc},
-    {"RAND_egd",            PySSL_RAND_egd, METH_O,
+    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
      PySSL_RAND_egd_doc},
     {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
      PySSL_RAND_status_doc},
@@ -1708,7 +1875,9 @@
     unsigned int major, minor, fix, patch, status;
     PySocketModule_APIObject *socket_api;
 
-    if (PyType_Ready(&PySSL_Type) < 0)
+    if (PyType_Ready(&PySSLContext_Type) < 0)
+        return NULL;
+    if (PyType_Ready(&PySSLSocket_Type) < 0)
         return NULL;
 
     m = PyModule_Create(&_sslmodule);
@@ -1741,8 +1910,11 @@
         return NULL;
     if (PyDict_SetItemString(d, "SSLError", PySSLErrorObject) != 0)
         return NULL;
-    if (PyDict_SetItemString(d, "SSLType",
-                             (PyObject *)&PySSL_Type) != 0)
+    if (PyDict_SetItemString(d, "_SSLContext",
+                             (PyObject *)&PySSLContext_Type) != 0)
+        return NULL;
+    if (PyDict_SetItemString(d, "_SSLSocket",
+                             (PyObject *)&PySSLSocket_Type) != 0)
         return NULL;
     PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN",
                             PY_SSL_ERROR_ZERO_RETURN);

Modified: python/branches/py3k-cdecimal/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_testcapimodule.c	Wed May 19 17:30:16 2010
@@ -2011,7 +2011,11 @@
 crash_no_current_thread(PyObject *self)
 {
     Py_BEGIN_ALLOW_THREADS
-    PyErr_SetString(PyExc_SystemError, "bork bork bork");
+    /* Using PyThreadState_Get() directly allows the test to pass in
+       !pydebug mode. However, the test only actually tests anything
+       in pydebug mode, since that's where the infinite loop was in
+       the first place. */
+    PyThreadState_Get();
     Py_END_ALLOW_THREADS
     return NULL;
 }

Modified: python/branches/py3k-cdecimal/Modules/main.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/main.c	(original)
+++ python/branches/py3k-cdecimal/Modules/main.c	Wed May 19 17:30:16 2010
@@ -563,18 +563,22 @@
     }
 
     if (command) {
+        char *commandStr;
         PyObject *commandObj = PyUnicode_FromWideChar(
             command, wcslen(command));
         free(command);
-        if (commandObj != NULL) {
-            sts = PyRun_SimpleStringFlags(
-                _PyUnicode_AsString(commandObj), &cf) != 0;
+        if (commandObj != NULL)
+            commandStr = _PyUnicode_AsString(commandObj);
+        else
+            commandStr = NULL;
+        if (commandStr != NULL) {
+            sts = PyRun_SimpleStringFlags(commandStr, &cf) != 0;
+            Py_DECREF(commandObj);
         }
         else {
             PyErr_Print();
             sts = 1;
         }
-        Py_DECREF(commandObj);
     } else if (module) {
         sts = RunModule(module, 1);
     }

Modified: python/branches/py3k-cdecimal/Objects/moduleobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/moduleobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/moduleobject.c	Wed May 19 17:30:16 2010
@@ -263,10 +263,15 @@
     pos = 0;
     while (PyDict_Next(d, &pos, &key, &value)) {
         if (value != Py_None && PyUnicode_Check(key)) {
-            const char *s = _PyUnicode_AsString(key);
-            if (s[0] == '_' && s[1] != '_') {
-                if (Py_VerboseFlag > 1)
-                    PySys_WriteStderr("#   clear[1] %s\n", s);
+            Py_UNICODE *u = PyUnicode_AS_UNICODE(key);
+            if (u[0] == '_' && u[1] != '_') {
+                if (Py_VerboseFlag > 1) {
+                    const char *s = _PyUnicode_AsString(key);
+                    if (s != NULL)
+                        PySys_WriteStderr("#   clear[1] %s\n", s);
+                    else
+                        PyErr_Clear();
+                }
                 PyDict_SetItem(d, key, Py_None);
             }
         }
@@ -276,10 +281,17 @@
     pos = 0;
     while (PyDict_Next(d, &pos, &key, &value)) {
         if (value != Py_None && PyUnicode_Check(key)) {
-            const char *s = _PyUnicode_AsString(key);
-            if (s[0] != '_' || strcmp(s, "__builtins__") != 0) {
-                if (Py_VerboseFlag > 1)
-                    PySys_WriteStderr("#   clear[2] %s\n", s);
+            Py_UNICODE *u = PyUnicode_AS_UNICODE(key);
+            if (u[0] != '_'
+                || PyUnicode_CompareWithASCIIString(key, "__builtins__") != 0)
+            {
+                if (Py_VerboseFlag > 1) {
+                    const char *s = _PyUnicode_AsString(key);
+                    if (s != NULL)
+                        PySys_WriteStderr("#   clear[2] %s\n", s);
+                    else
+                        PyErr_Clear();
+                }
                 PyDict_SetItem(d, key, Py_None);
             }
         }

Modified: python/branches/py3k-cdecimal/Objects/object.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/object.c	(original)
+++ python/branches/py3k-cdecimal/Objects/object.c	Wed May 19 17:30:16 2010
@@ -303,12 +303,15 @@
             }
             else if (PyUnicode_Check(s)) {
                 PyObject *t;
-                t = _PyUnicode_AsDefaultEncodedString(s, NULL);
+                t = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(s),
+                                         PyUnicode_GET_SIZE(s),
+                                         "backslashreplace");
                 if (t == NULL)
                     ret = 0;
                 else {
                     fwrite(PyBytes_AS_STRING(t), 1,
                            PyBytes_GET_SIZE(t), fp);
+                    Py_DECREF(t);
                 }
             }
             else {

Modified: python/branches/py3k-cdecimal/Objects/typeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/typeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/typeobject.c	Wed May 19 17:30:16 2010
@@ -1347,8 +1347,14 @@
     i = 0;
     while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
         PyObject *name = class_name(k);
-        off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s",
-                             name ? _PyUnicode_AsString(name) : "?");
+        char *name_str;
+        if (name != NULL) {
+            name_str = _PyUnicode_AsString(name);
+            if (name_str == NULL)
+                name_str = "?";
+        } else
+            name_str = "?";
+        off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s", name_str);
         Py_XDECREF(name);
         if (--n && (size_t)(off+1) < sizeof(buf)) {
             buf[off++] = ',';
@@ -2220,6 +2226,10 @@
         for (i = 0; i < nslots; i++, mp++) {
             mp->name = _PyUnicode_AsString(
                 PyTuple_GET_ITEM(slots, i));
+            if (mp->name == NULL) {
+                Py_DECREF(type);
+                return NULL;
+            }
             mp->type = T_OBJECT_EX;
             mp->offset = slotoffset;
 

Modified: python/branches/py3k-cdecimal/Parser/asdl.py
==============================================================================
--- python/branches/py3k-cdecimal/Parser/asdl.py	(original)
+++ python/branches/py3k-cdecimal/Parser/asdl.py	Wed May 19 17:30:16 2010
@@ -1,7 +1,7 @@
 """An implementation of the Zephyr Abstract Syntax Definition Language.
 
 See http://asdl.sourceforge.net/ and
-http://www.cs.princeton.edu/~danwang/Papers/dsl97/dsl97-abstract.html.
+http://www.cs.princeton.edu/research/techreps/TR-554-97
 
 Only supports top level module decl, not view.  I'm guessing that view
 is intended to support the browser and I'm not interested in the

Modified: python/branches/py3k-cdecimal/Parser/printgrammar.c
==============================================================================
--- python/branches/py3k-cdecimal/Parser/printgrammar.c	(original)
+++ python/branches/py3k-cdecimal/Parser/printgrammar.c	Wed May 19 17:30:16 2010
@@ -20,10 +20,10 @@
     printdfas(g, fp);
     printlabels(g, fp);
     fprintf(fp, "grammar _PyParser_Grammar = {\n");
-    fprintf(fp, "\t%d,\n", g->g_ndfas);
-    fprintf(fp, "\tdfas,\n");
-    fprintf(fp, "\t{%d, labels},\n", g->g_ll.ll_nlabels);
-    fprintf(fp, "\t%d\n", g->g_start);
+    fprintf(fp, "    %d,\n", g->g_ndfas);
+    fprintf(fp, "    dfas,\n");
+    fprintf(fp, "    {%d, labels},\n", g->g_ll.ll_nlabels);
+    fprintf(fp, "    %d\n", g->g_start);
     fprintf(fp, "};\n");
 }
 
@@ -53,7 +53,7 @@
             i, j, s->s_narcs);
         a = s->s_arc;
         for (k = 0; k < s->s_narcs; k++, a++)
-            fprintf(fp, "\t{%d, %d},\n", a->a_lbl, a->a_arrow);
+            fprintf(fp, "    {%d, %d},\n", a->a_lbl, a->a_arrow);
         fprintf(fp, "};\n");
     }
 }
@@ -72,7 +72,7 @@
             i, d->d_nstates);
         s = d->d_state;
         for (j = 0; j < d->d_nstates; j++, s++)
-            fprintf(fp, "\t{%d, arcs_%d_%d},\n",
+            fprintf(fp, "    {%d, arcs_%d_%d},\n",
                 s->s_narcs, i, j);
         fprintf(fp, "};\n");
     }
@@ -88,9 +88,9 @@
     fprintf(fp, "static dfa dfas[%d] = {\n", g->g_ndfas);
     d = g->g_dfa;
     for (i = 0; i < g->g_ndfas; i++, d++) {
-        fprintf(fp, "\t{%d, \"%s\", %d, %d, states_%d,\n",
+        fprintf(fp, "    {%d, \"%s\", %d, %d, states_%d,\n",
             d->d_type, d->d_name, d->d_initial, d->d_nstates, i);
-        fprintf(fp, "\t \"");
+        fprintf(fp, "     \"");
         for (j = 0; j < NBYTES(g->g_ll.ll_nlabels); j++)
             fprintf(fp, "\\%03o", d->d_first[j] & 0xff);
         fprintf(fp, "\"},\n");
@@ -108,9 +108,9 @@
     l = g->g_ll.ll_label;
     for (i = g->g_ll.ll_nlabels; --i >= 0; l++) {
         if (l->lb_str == NULL)
-            fprintf(fp, "\t{%d, 0},\n", l->lb_type);
+            fprintf(fp, "    {%d, 0},\n", l->lb_type);
         else
-            fprintf(fp, "\t{%d, \"%s\"},\n",
+            fprintf(fp, "    {%d, \"%s\"},\n",
                 l->lb_type, l->lb_str);
     }
     fprintf(fp, "};\n");

Modified: python/branches/py3k-cdecimal/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/bltinmodule.c	(original)
+++ python/branches/py3k-cdecimal/Python/bltinmodule.c	Wed May 19 17:30:16 2010
@@ -1610,6 +1610,7 @@
         char *prompt;
         char *s;
         PyObject *stdin_encoding;
+        char *stdin_encoding_str;
         PyObject *result;
 
         stdin_encoding = PyObject_GetAttrString(fin, "encoding");
@@ -1617,6 +1618,11 @@
             /* stdin is a text stream, so it must have an
                encoding. */
             return NULL;
+        stdin_encoding_str = _PyUnicode_AsString(stdin_encoding);
+        if (stdin_encoding_str  == NULL) {
+            Py_DECREF(stdin_encoding);
+            return NULL;
+        }
         tmp = PyObject_CallMethod(fout, "flush", "");
         if (tmp == NULL)
             PyErr_Clear();
@@ -1625,12 +1631,18 @@
         if (promptarg != NULL) {
             PyObject *stringpo;
             PyObject *stdout_encoding;
-            stdout_encoding = PyObject_GetAttrString(fout,
-                                                     "encoding");
+            char *stdout_encoding_str;
+            stdout_encoding = PyObject_GetAttrString(fout, "encoding");
             if (stdout_encoding == NULL) {
                 Py_DECREF(stdin_encoding);
                 return NULL;
             }
+            stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
+            if (stdout_encoding_str == NULL) {
+                Py_DECREF(stdin_encoding);
+                Py_DECREF(stdout_encoding);
+                return NULL;
+            }
             stringpo = PyObject_Str(promptarg);
             if (stringpo == NULL) {
                 Py_DECREF(stdin_encoding);
@@ -1638,7 +1650,7 @@
                 return NULL;
             }
             po = PyUnicode_AsEncodedString(stringpo,
-                _PyUnicode_AsString(stdout_encoding), NULL);
+                stdout_encoding_str, NULL);
             Py_DECREF(stdout_encoding);
             Py_DECREF(stringpo);
             if (po == NULL) {
@@ -1676,10 +1688,7 @@
                 result = NULL;
             }
             else {
-                result = PyUnicode_Decode
-                    (s, len-1,
-                     _PyUnicode_AsString(stdin_encoding),
-                     NULL);
+                result = PyUnicode_Decode(s, len-1, stdin_encoding_str, NULL);
             }
         }
         Py_DECREF(stdin_encoding);

Modified: python/branches/py3k-cdecimal/Python/getargs.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/getargs.c	(original)
+++ python/branches/py3k-cdecimal/Python/getargs.c	Wed May 19 17:30:16 2010
@@ -1755,18 +1755,21 @@
                                 "keywords must be strings");
                 return cleanreturn(0, freelist);
             }
+            /* check that _PyUnicode_AsString() result is not NULL */
             ks = _PyUnicode_AsString(key);
-            for (i = 0; i < len; i++) {
-                if (!strcmp(ks, kwlist[i])) {
-                    match = 1;
-                    break;
+            if (ks != NULL) {
+                for (i = 0; i < len; i++) {
+                    if (!strcmp(ks, kwlist[i])) {
+                        match = 1;
+                        break;
+                    }
                 }
             }
             if (!match) {
                 PyErr_Format(PyExc_TypeError,
-                             "'%s' is an invalid keyword "
+                             "'%U' is an invalid keyword "
                              "argument for this function",
-                             ks);
+                             key);
                 return cleanreturn(0, freelist);
             }
         }

Modified: python/branches/py3k-cdecimal/Python/graminit.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/graminit.c	(original)
+++ python/branches/py3k-cdecimal/Python/graminit.c	Wed May 19 17:30:16 2010
@@ -4,2077 +4,2077 @@
 #include "grammar.h"
 PyAPI_DATA(grammar) _PyParser_Grammar;
 static arc arcs_0_0[3] = {
-	{2, 1},
-	{3, 1},
-	{4, 2},
+    {2, 1},
+    {3, 1},
+    {4, 2},
 };
 static arc arcs_0_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static arc arcs_0_2[1] = {
-	{2, 1},
+    {2, 1},
 };
 static state states_0[3] = {
-	{3, arcs_0_0},
-	{1, arcs_0_1},
-	{1, arcs_0_2},
+    {3, arcs_0_0},
+    {1, arcs_0_1},
+    {1, arcs_0_2},
 };
 static arc arcs_1_0[3] = {
-	{2, 0},
-	{6, 0},
-	{7, 1},
+    {2, 0},
+    {6, 0},
+    {7, 1},
 };
 static arc arcs_1_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_1[2] = {
-	{3, arcs_1_0},
-	{1, arcs_1_1},
+    {3, arcs_1_0},
+    {1, arcs_1_1},
 };
 static arc arcs_2_0[1] = {
-	{9, 1},
+    {9, 1},
 };
 static arc arcs_2_1[2] = {
-	{2, 1},
-	{7, 2},
+    {2, 1},
+    {7, 2},
 };
 static arc arcs_2_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_2[3] = {
-	{1, arcs_2_0},
-	{2, arcs_2_1},
-	{1, arcs_2_2},
+    {1, arcs_2_0},
+    {2, arcs_2_1},
+    {1, arcs_2_2},
 };
 static arc arcs_3_0[1] = {
-	{11, 1},
+    {11, 1},
 };
 static arc arcs_3_1[1] = {
-	{12, 2},
+    {12, 2},
 };
 static arc arcs_3_2[2] = {
-	{13, 3},
-	{2, 4},
+    {13, 3},
+    {2, 4},
 };
 static arc arcs_3_3[2] = {
-	{14, 5},
-	{15, 6},
+    {14, 5},
+    {15, 6},
 };
 static arc arcs_3_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static arc arcs_3_5[1] = {
-	{15, 6},
+    {15, 6},
 };
 static arc arcs_3_6[1] = {
-	{2, 4},
+    {2, 4},
 };
 static state states_3[7] = {
-	{1, arcs_3_0},
-	{1, arcs_3_1},
-	{2, arcs_3_2},
-	{2, arcs_3_3},
-	{1, arcs_3_4},
-	{1, arcs_3_5},
-	{1, arcs_3_6},
+    {1, arcs_3_0},
+    {1, arcs_3_1},
+    {2, arcs_3_2},
+    {2, arcs_3_3},
+    {1, arcs_3_4},
+    {1, arcs_3_5},
+    {1, arcs_3_6},
 };
 static arc arcs_4_0[1] = {
-	{10, 1},
+    {10, 1},
 };
 static arc arcs_4_1[2] = {
-	{10, 1},
-	{0, 1},
+    {10, 1},
+    {0, 1},
 };
 static state states_4[2] = {
-	{1, arcs_4_0},
-	{2, arcs_4_1},
+    {1, arcs_4_0},
+    {2, arcs_4_1},
 };
 static arc arcs_5_0[1] = {
-	{16, 1},
+    {16, 1},
 };
 static arc arcs_5_1[2] = {
-	{18, 2},
-	{19, 2},
+    {18, 2},
+    {19, 2},
 };
 static arc arcs_5_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_5[3] = {
-	{1, arcs_5_0},
-	{2, arcs_5_1},
-	{1, arcs_5_2},
+    {1, arcs_5_0},
+    {2, arcs_5_1},
+    {1, arcs_5_2},
 };
 static arc arcs_6_0[1] = {
-	{20, 1},
+    {20, 1},
 };
 static arc arcs_6_1[1] = {
-	{21, 2},
+    {21, 2},
 };
 static arc arcs_6_2[1] = {
-	{22, 3},
+    {22, 3},
 };
 static arc arcs_6_3[2] = {
-	{23, 4},
-	{25, 5},
+    {23, 4},
+    {25, 5},
 };
 static arc arcs_6_4[1] = {
-	{24, 6},
+    {24, 6},
 };
 static arc arcs_6_5[1] = {
-	{26, 7},
+    {26, 7},
 };
 static arc arcs_6_6[1] = {
-	{25, 5},
+    {25, 5},
 };
 static arc arcs_6_7[1] = {
-	{0, 7},
+    {0, 7},
 };
 static state states_6[8] = {
-	{1, arcs_6_0},
-	{1, arcs_6_1},
-	{1, arcs_6_2},
-	{2, arcs_6_3},
-	{1, arcs_6_4},
-	{1, arcs_6_5},
-	{1, arcs_6_6},
-	{1, arcs_6_7},
+    {1, arcs_6_0},
+    {1, arcs_6_1},
+    {1, arcs_6_2},
+    {2, arcs_6_3},
+    {1, arcs_6_4},
+    {1, arcs_6_5},
+    {1, arcs_6_6},
+    {1, arcs_6_7},
 };
 static arc arcs_7_0[1] = {
-	{13, 1},
+    {13, 1},
 };
 static arc arcs_7_1[2] = {
-	{27, 2},
-	{15, 3},
+    {27, 2},
+    {15, 3},
 };
 static arc arcs_7_2[1] = {
-	{15, 3},
+    {15, 3},
 };
 static arc arcs_7_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_7[4] = {
-	{1, arcs_7_0},
-	{2, arcs_7_1},
-	{1, arcs_7_2},
-	{1, arcs_7_3},
+    {1, arcs_7_0},
+    {2, arcs_7_1},
+    {1, arcs_7_2},
+    {1, arcs_7_3},
 };
 static arc arcs_8_0[3] = {
-	{28, 1},
-	{31, 2},
-	{32, 3},
+    {28, 1},
+    {31, 2},
+    {32, 3},
 };
 static arc arcs_8_1[3] = {
-	{29, 4},
-	{30, 5},
-	{0, 1},
+    {29, 4},
+    {30, 5},
+    {0, 1},
 };
 static arc arcs_8_2[3] = {
-	{28, 6},
-	{30, 7},
-	{0, 2},
+    {28, 6},
+    {30, 7},
+    {0, 2},
 };
 static arc arcs_8_3[1] = {
-	{28, 8},
+    {28, 8},
 };
 static arc arcs_8_4[1] = {
-	{24, 9},
+    {24, 9},
 };
 static arc arcs_8_5[4] = {
-	{28, 1},
-	{31, 2},
-	{32, 3},
-	{0, 5},
+    {28, 1},
+    {31, 2},
+    {32, 3},
+    {0, 5},
 };
 static arc arcs_8_6[2] = {
-	{30, 7},
-	{0, 6},
+    {30, 7},
+    {0, 6},
 };
 static arc arcs_8_7[2] = {
-	{28, 10},
-	{32, 3},
+    {28, 10},
+    {32, 3},
 };
 static arc arcs_8_8[1] = {
-	{0, 8},
+    {0, 8},
 };
 static arc arcs_8_9[2] = {
-	{30, 5},
-	{0, 9},
+    {30, 5},
+    {0, 9},
 };
 static arc arcs_8_10[3] = {
-	{30, 7},
-	{29, 11},
-	{0, 10},
+    {30, 7},
+    {29, 11},
+    {0, 10},
 };
 static arc arcs_8_11[1] = {
-	{24, 6},
+    {24, 6},
 };
 static state states_8[12] = {
-	{3, arcs_8_0},
-	{3, arcs_8_1},
-	{3, arcs_8_2},
-	{1, arcs_8_3},
-	{1, arcs_8_4},
-	{4, arcs_8_5},
-	{2, arcs_8_6},
-	{2, arcs_8_7},
-	{1, arcs_8_8},
-	{2, arcs_8_9},
-	{3, arcs_8_10},
-	{1, arcs_8_11},
+    {3, arcs_8_0},
+    {3, arcs_8_1},
+    {3, arcs_8_2},
+    {1, arcs_8_3},
+    {1, arcs_8_4},
+    {4, arcs_8_5},
+    {2, arcs_8_6},
+    {2, arcs_8_7},
+    {1, arcs_8_8},
+    {2, arcs_8_9},
+    {3, arcs_8_10},
+    {1, arcs_8_11},
 };
 static arc arcs_9_0[1] = {
-	{21, 1},
+    {21, 1},
 };
 static arc arcs_9_1[2] = {
-	{25, 2},
-	{0, 1},
+    {25, 2},
+    {0, 1},
 };
 static arc arcs_9_2[1] = {
-	{24, 3},
+    {24, 3},
 };
 static arc arcs_9_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_9[4] = {
-	{1, arcs_9_0},
-	{2, arcs_9_1},
-	{1, arcs_9_2},
-	{1, arcs_9_3},
+    {1, arcs_9_0},
+    {2, arcs_9_1},
+    {1, arcs_9_2},
+    {1, arcs_9_3},
 };
 static arc arcs_10_0[3] = {
-	{34, 1},
-	{31, 2},
-	{32, 3},
+    {34, 1},
+    {31, 2},
+    {32, 3},
 };
 static arc arcs_10_1[3] = {
-	{29, 4},
-	{30, 5},
-	{0, 1},
+    {29, 4},
+    {30, 5},
+    {0, 1},
 };
 static arc arcs_10_2[3] = {
-	{34, 6},
-	{30, 7},
-	{0, 2},
+    {34, 6},
+    {30, 7},
+    {0, 2},
 };
 static arc arcs_10_3[1] = {
-	{34, 8},
+    {34, 8},
 };
 static arc arcs_10_4[1] = {
-	{24, 9},
+    {24, 9},
 };
 static arc arcs_10_5[4] = {
-	{34, 1},
-	{31, 2},
-	{32, 3},
-	{0, 5},
+    {34, 1},
+    {31, 2},
+    {32, 3},
+    {0, 5},
 };
 static arc arcs_10_6[2] = {
-	{30, 7},
-	{0, 6},
+    {30, 7},
+    {0, 6},
 };
 static arc arcs_10_7[2] = {
-	{34, 10},
-	{32, 3},
+    {34, 10},
+    {32, 3},
 };
 static arc arcs_10_8[1] = {
-	{0, 8},
+    {0, 8},
 };
 static arc arcs_10_9[2] = {
-	{30, 5},
-	{0, 9},
+    {30, 5},
+    {0, 9},
 };
 static arc arcs_10_10[3] = {
-	{30, 7},
-	{29, 11},
-	{0, 10},
+    {30, 7},
+    {29, 11},
+    {0, 10},
 };
 static arc arcs_10_11[1] = {
-	{24, 6},
+    {24, 6},
 };
 static state states_10[12] = {
-	{3, arcs_10_0},
-	{3, arcs_10_1},
-	{3, arcs_10_2},
-	{1, arcs_10_3},
-	{1, arcs_10_4},
-	{4, arcs_10_5},
-	{2, arcs_10_6},
-	{2, arcs_10_7},
-	{1, arcs_10_8},
-	{2, arcs_10_9},
-	{3, arcs_10_10},
-	{1, arcs_10_11},
+    {3, arcs_10_0},
+    {3, arcs_10_1},
+    {3, arcs_10_2},
+    {1, arcs_10_3},
+    {1, arcs_10_4},
+    {4, arcs_10_5},
+    {2, arcs_10_6},
+    {2, arcs_10_7},
+    {1, arcs_10_8},
+    {2, arcs_10_9},
+    {3, arcs_10_10},
+    {1, arcs_10_11},
 };
 static arc arcs_11_0[1] = {
-	{21, 1},
+    {21, 1},
 };
 static arc arcs_11_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_11[2] = {
-	{1, arcs_11_0},
-	{1, arcs_11_1},
+    {1, arcs_11_0},
+    {1, arcs_11_1},
 };
 static arc arcs_12_0[2] = {
-	{3, 1},
-	{4, 1},
+    {3, 1},
+    {4, 1},
 };
 static arc arcs_12_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_12[2] = {
-	{2, arcs_12_0},
-	{1, arcs_12_1},
+    {2, arcs_12_0},
+    {1, arcs_12_1},
 };
 static arc arcs_13_0[1] = {
-	{35, 1},
+    {35, 1},
 };
 static arc arcs_13_1[2] = {
-	{36, 2},
-	{2, 3},
+    {36, 2},
+    {2, 3},
 };
 static arc arcs_13_2[2] = {
-	{35, 1},
-	{2, 3},
+    {35, 1},
+    {2, 3},
 };
 static arc arcs_13_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_13[4] = {
-	{1, arcs_13_0},
-	{2, arcs_13_1},
-	{2, arcs_13_2},
-	{1, arcs_13_3},
+    {1, arcs_13_0},
+    {2, arcs_13_1},
+    {2, arcs_13_2},
+    {1, arcs_13_3},
 };
 static arc arcs_14_0[8] = {
-	{37, 1},
-	{38, 1},
-	{39, 1},
-	{40, 1},
-	{41, 1},
-	{42, 1},
-	{43, 1},
-	{44, 1},
+    {37, 1},
+    {38, 1},
+    {39, 1},
+    {40, 1},
+    {41, 1},
+    {42, 1},
+    {43, 1},
+    {44, 1},
 };
 static arc arcs_14_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_14[2] = {
-	{8, arcs_14_0},
-	{1, arcs_14_1},
+    {8, arcs_14_0},
+    {1, arcs_14_1},
 };
 static arc arcs_15_0[1] = {
-	{45, 1},
+    {45, 1},
 };
 static arc arcs_15_1[3] = {
-	{46, 2},
-	{29, 3},
-	{0, 1},
+    {46, 2},
+    {29, 3},
+    {0, 1},
 };
 static arc arcs_15_2[2] = {
-	{47, 4},
-	{9, 4},
+    {47, 4},
+    {9, 4},
 };
 static arc arcs_15_3[2] = {
-	{47, 5},
-	{45, 5},
+    {47, 5},
+    {45, 5},
 };
 static arc arcs_15_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static arc arcs_15_5[2] = {
-	{29, 3},
-	{0, 5},
+    {29, 3},
+    {0, 5},
 };
 static state states_15[6] = {
-	{1, arcs_15_0},
-	{3, arcs_15_1},
-	{2, arcs_15_2},
-	{2, arcs_15_3},
-	{1, arcs_15_4},
-	{2, arcs_15_5},
+    {1, arcs_15_0},
+    {3, arcs_15_1},
+    {2, arcs_15_2},
+    {2, arcs_15_3},
+    {1, arcs_15_4},
+    {2, arcs_15_5},
 };
 static arc arcs_16_0[2] = {
-	{24, 1},
-	{48, 1},
+    {24, 1},
+    {48, 1},
 };
 static arc arcs_16_1[2] = {
-	{30, 2},
-	{0, 1},
+    {30, 2},
+    {0, 1},
 };
 static arc arcs_16_2[3] = {
-	{24, 1},
-	{48, 1},
-	{0, 2},
+    {24, 1},
+    {48, 1},
+    {0, 2},
 };
 static state states_16[3] = {
-	{2, arcs_16_0},
-	{2, arcs_16_1},
-	{3, arcs_16_2},
+    {2, arcs_16_0},
+    {2, arcs_16_1},
+    {3, arcs_16_2},
 };
 static arc arcs_17_0[12] = {
-	{49, 1},
-	{50, 1},
-	{51, 1},
-	{52, 1},
-	{53, 1},
-	{54, 1},
-	{55, 1},
-	{56, 1},
-	{57, 1},
-	{58, 1},
-	{59, 1},
-	{60, 1},
+    {49, 1},
+    {50, 1},
+    {51, 1},
+    {52, 1},
+    {53, 1},
+    {54, 1},
+    {55, 1},
+    {56, 1},
+    {57, 1},
+    {58, 1},
+    {59, 1},
+    {60, 1},
 };
 static arc arcs_17_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_17[2] = {
-	{12, arcs_17_0},
-	{1, arcs_17_1},
+    {12, arcs_17_0},
+    {1, arcs_17_1},
 };
 static arc arcs_18_0[1] = {
-	{61, 1},
+    {61, 1},
 };
 static arc arcs_18_1[1] = {
-	{62, 2},
+    {62, 2},
 };
 static arc arcs_18_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_18[3] = {
-	{1, arcs_18_0},
-	{1, arcs_18_1},
-	{1, arcs_18_2},
+    {1, arcs_18_0},
+    {1, arcs_18_1},
+    {1, arcs_18_2},
 };
 static arc arcs_19_0[1] = {
-	{63, 1},
+    {63, 1},
 };
 static arc arcs_19_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_19[2] = {
-	{1, arcs_19_0},
-	{1, arcs_19_1},
+    {1, arcs_19_0},
+    {1, arcs_19_1},
 };
 static arc arcs_20_0[5] = {
-	{64, 1},
-	{65, 1},
-	{66, 1},
-	{67, 1},
-	{68, 1},
+    {64, 1},
+    {65, 1},
+    {66, 1},
+    {67, 1},
+    {68, 1},
 };
 static arc arcs_20_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_20[2] = {
-	{5, arcs_20_0},
-	{1, arcs_20_1},
+    {5, arcs_20_0},
+    {1, arcs_20_1},
 };
 static arc arcs_21_0[1] = {
-	{69, 1},
+    {69, 1},
 };
 static arc arcs_21_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_21[2] = {
-	{1, arcs_21_0},
-	{1, arcs_21_1},
+    {1, arcs_21_0},
+    {1, arcs_21_1},
 };
 static arc arcs_22_0[1] = {
-	{70, 1},
+    {70, 1},
 };
 static arc arcs_22_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_22[2] = {
-	{1, arcs_22_0},
-	{1, arcs_22_1},
+    {1, arcs_22_0},
+    {1, arcs_22_1},
 };
 static arc arcs_23_0[1] = {
-	{71, 1},
+    {71, 1},
 };
 static arc arcs_23_1[2] = {
-	{9, 2},
-	{0, 1},
+    {9, 2},
+    {0, 1},
 };
 static arc arcs_23_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_23[3] = {
-	{1, arcs_23_0},
-	{2, arcs_23_1},
-	{1, arcs_23_2},
+    {1, arcs_23_0},
+    {2, arcs_23_1},
+    {1, arcs_23_2},
 };
 static arc arcs_24_0[1] = {
-	{47, 1},
+    {47, 1},
 };
 static arc arcs_24_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_24[2] = {
-	{1, arcs_24_0},
-	{1, arcs_24_1},
+    {1, arcs_24_0},
+    {1, arcs_24_1},
 };
 static arc arcs_25_0[1] = {
-	{72, 1},
+    {72, 1},
 };
 static arc arcs_25_1[2] = {
-	{24, 2},
-	{0, 1},
+    {24, 2},
+    {0, 1},
 };
 static arc arcs_25_2[2] = {
-	{73, 3},
-	{0, 2},
+    {73, 3},
+    {0, 2},
 };
 static arc arcs_25_3[1] = {
-	{24, 4},
+    {24, 4},
 };
 static arc arcs_25_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_25[5] = {
-	{1, arcs_25_0},
-	{2, arcs_25_1},
-	{2, arcs_25_2},
-	{1, arcs_25_3},
-	{1, arcs_25_4},
+    {1, arcs_25_0},
+    {2, arcs_25_1},
+    {2, arcs_25_2},
+    {1, arcs_25_3},
+    {1, arcs_25_4},
 };
 static arc arcs_26_0[2] = {
-	{74, 1},
-	{75, 1},
+    {74, 1},
+    {75, 1},
 };
 static arc arcs_26_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_26[2] = {
-	{2, arcs_26_0},
-	{1, arcs_26_1},
+    {2, arcs_26_0},
+    {1, arcs_26_1},
 };
 static arc arcs_27_0[1] = {
-	{76, 1},
+    {76, 1},
 };
 static arc arcs_27_1[1] = {
-	{77, 2},
+    {77, 2},
 };
 static arc arcs_27_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_27[3] = {
-	{1, arcs_27_0},
-	{1, arcs_27_1},
-	{1, arcs_27_2},
+    {1, arcs_27_0},
+    {1, arcs_27_1},
+    {1, arcs_27_2},
 };
 static arc arcs_28_0[1] = {
-	{73, 1},
+    {73, 1},
 };
 static arc arcs_28_1[3] = {
-	{78, 2},
-	{79, 2},
-	{12, 3},
+    {78, 2},
+    {79, 2},
+    {12, 3},
 };
 static arc arcs_28_2[4] = {
-	{78, 2},
-	{79, 2},
-	{12, 3},
-	{76, 4},
+    {78, 2},
+    {79, 2},
+    {12, 3},
+    {76, 4},
 };
 static arc arcs_28_3[1] = {
-	{76, 4},
+    {76, 4},
 };
 static arc arcs_28_4[3] = {
-	{31, 5},
-	{13, 6},
-	{80, 5},
+    {31, 5},
+    {13, 6},
+    {80, 5},
 };
 static arc arcs_28_5[1] = {
-	{0, 5},
+    {0, 5},
 };
 static arc arcs_28_6[1] = {
-	{80, 7},
+    {80, 7},
 };
 static arc arcs_28_7[1] = {
-	{15, 5},
+    {15, 5},
 };
 static state states_28[8] = {
-	{1, arcs_28_0},
-	{3, arcs_28_1},
-	{4, arcs_28_2},
-	{1, arcs_28_3},
-	{3, arcs_28_4},
-	{1, arcs_28_5},
-	{1, arcs_28_6},
-	{1, arcs_28_7},
+    {1, arcs_28_0},
+    {3, arcs_28_1},
+    {4, arcs_28_2},
+    {1, arcs_28_3},
+    {3, arcs_28_4},
+    {1, arcs_28_5},
+    {1, arcs_28_6},
+    {1, arcs_28_7},
 };
 static arc arcs_29_0[1] = {
-	{21, 1},
+    {21, 1},
 };
 static arc arcs_29_1[2] = {
-	{82, 2},
-	{0, 1},
+    {82, 2},
+    {0, 1},
 };
 static arc arcs_29_2[1] = {
-	{21, 3},
+    {21, 3},
 };
 static arc arcs_29_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_29[4] = {
-	{1, arcs_29_0},
-	{2, arcs_29_1},
-	{1, arcs_29_2},
-	{1, arcs_29_3},
+    {1, arcs_29_0},
+    {2, arcs_29_1},
+    {1, arcs_29_2},
+    {1, arcs_29_3},
 };
 static arc arcs_30_0[1] = {
-	{12, 1},
+    {12, 1},
 };
 static arc arcs_30_1[2] = {
-	{82, 2},
-	{0, 1},
+    {82, 2},
+    {0, 1},
 };
 static arc arcs_30_2[1] = {
-	{21, 3},
+    {21, 3},
 };
 static arc arcs_30_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_30[4] = {
-	{1, arcs_30_0},
-	{2, arcs_30_1},
-	{1, arcs_30_2},
-	{1, arcs_30_3},
+    {1, arcs_30_0},
+    {2, arcs_30_1},
+    {1, arcs_30_2},
+    {1, arcs_30_3},
 };
 static arc arcs_31_0[1] = {
-	{81, 1},
+    {81, 1},
 };
 static arc arcs_31_1[2] = {
-	{30, 2},
-	{0, 1},
+    {30, 2},
+    {0, 1},
 };
 static arc arcs_31_2[2] = {
-	{81, 1},
-	{0, 2},
+    {81, 1},
+    {0, 2},
 };
 static state states_31[3] = {
-	{1, arcs_31_0},
-	{2, arcs_31_1},
-	{2, arcs_31_2},
+    {1, arcs_31_0},
+    {2, arcs_31_1},
+    {2, arcs_31_2},
 };
 static arc arcs_32_0[1] = {
-	{83, 1},
+    {83, 1},
 };
 static arc arcs_32_1[2] = {
-	{30, 0},
-	{0, 1},
+    {30, 0},
+    {0, 1},
 };
 static state states_32[2] = {
-	{1, arcs_32_0},
-	{2, arcs_32_1},
+    {1, arcs_32_0},
+    {2, arcs_32_1},
 };
 static arc arcs_33_0[1] = {
-	{21, 1},
+    {21, 1},
 };
 static arc arcs_33_1[2] = {
-	{78, 0},
-	{0, 1},
+    {78, 0},
+    {0, 1},
 };
 static state states_33[2] = {
-	{1, arcs_33_0},
-	{2, arcs_33_1},
+    {1, arcs_33_0},
+    {2, arcs_33_1},
 };
 static arc arcs_34_0[1] = {
-	{84, 1},
+    {84, 1},
 };
 static arc arcs_34_1[1] = {
-	{21, 2},
+    {21, 2},
 };
 static arc arcs_34_2[2] = {
-	{30, 1},
-	{0, 2},
+    {30, 1},
+    {0, 2},
 };
 static state states_34[3] = {
-	{1, arcs_34_0},
-	{1, arcs_34_1},
-	{2, arcs_34_2},
+    {1, arcs_34_0},
+    {1, arcs_34_1},
+    {2, arcs_34_2},
 };
 static arc arcs_35_0[1] = {
-	{85, 1},
+    {85, 1},
 };
 static arc arcs_35_1[1] = {
-	{21, 2},
+    {21, 2},
 };
 static arc arcs_35_2[2] = {
-	{30, 1},
-	{0, 2},
+    {30, 1},
+    {0, 2},
 };
 static state states_35[3] = {
-	{1, arcs_35_0},
-	{1, arcs_35_1},
-	{2, arcs_35_2},
+    {1, arcs_35_0},
+    {1, arcs_35_1},
+    {2, arcs_35_2},
 };
 static arc arcs_36_0[1] = {
-	{86, 1},
+    {86, 1},
 };
 static arc arcs_36_1[1] = {
-	{24, 2},
+    {24, 2},
 };
 static arc arcs_36_2[2] = {
-	{30, 3},
-	{0, 2},
+    {30, 3},
+    {0, 2},
 };
 static arc arcs_36_3[1] = {
-	{24, 4},
+    {24, 4},
 };
 static arc arcs_36_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_36[5] = {
-	{1, arcs_36_0},
-	{1, arcs_36_1},
-	{2, arcs_36_2},
-	{1, arcs_36_3},
-	{1, arcs_36_4},
+    {1, arcs_36_0},
+    {1, arcs_36_1},
+    {2, arcs_36_2},
+    {1, arcs_36_3},
+    {1, arcs_36_4},
 };
 static arc arcs_37_0[8] = {
-	{87, 1},
-	{88, 1},
-	{89, 1},
-	{90, 1},
-	{91, 1},
-	{19, 1},
-	{18, 1},
-	{17, 1},
+    {87, 1},
+    {88, 1},
+    {89, 1},
+    {90, 1},
+    {91, 1},
+    {19, 1},
+    {18, 1},
+    {17, 1},
 };
 static arc arcs_37_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_37[2] = {
-	{8, arcs_37_0},
-	{1, arcs_37_1},
+    {8, arcs_37_0},
+    {1, arcs_37_1},
 };
 static arc arcs_38_0[1] = {
-	{92, 1},
+    {92, 1},
 };
 static arc arcs_38_1[1] = {
-	{24, 2},
+    {24, 2},
 };
 static arc arcs_38_2[1] = {
-	{25, 3},
+    {25, 3},
 };
 static arc arcs_38_3[1] = {
-	{26, 4},
+    {26, 4},
 };
 static arc arcs_38_4[3] = {
-	{93, 1},
-	{94, 5},
-	{0, 4},
+    {93, 1},
+    {94, 5},
+    {0, 4},
 };
 static arc arcs_38_5[1] = {
-	{25, 6},
+    {25, 6},
 };
 static arc arcs_38_6[1] = {
-	{26, 7},
+    {26, 7},
 };
 static arc arcs_38_7[1] = {
-	{0, 7},
+    {0, 7},
 };
 static state states_38[8] = {
-	{1, arcs_38_0},
-	{1, arcs_38_1},
-	{1, arcs_38_2},
-	{1, arcs_38_3},
-	{3, arcs_38_4},
-	{1, arcs_38_5},
-	{1, arcs_38_6},
-	{1, arcs_38_7},
+    {1, arcs_38_0},
+    {1, arcs_38_1},
+    {1, arcs_38_2},
+    {1, arcs_38_3},
+    {3, arcs_38_4},
+    {1, arcs_38_5},
+    {1, arcs_38_6},
+    {1, arcs_38_7},
 };
 static arc arcs_39_0[1] = {
-	{95, 1},
+    {95, 1},
 };
 static arc arcs_39_1[1] = {
-	{24, 2},
+    {24, 2},
 };
 static arc arcs_39_2[1] = {
-	{25, 3},
+    {25, 3},
 };
 static arc arcs_39_3[1] = {
-	{26, 4},
+    {26, 4},
 };
 static arc arcs_39_4[2] = {
-	{94, 5},
-	{0, 4},
+    {94, 5},
+    {0, 4},
 };
 static arc arcs_39_5[1] = {
-	{25, 6},
+    {25, 6},
 };
 static arc arcs_39_6[1] = {
-	{26, 7},
+    {26, 7},
 };
 static arc arcs_39_7[1] = {
-	{0, 7},
+    {0, 7},
 };
 static state states_39[8] = {
-	{1, arcs_39_0},
-	{1, arcs_39_1},
-	{1, arcs_39_2},
-	{1, arcs_39_3},
-	{2, arcs_39_4},
-	{1, arcs_39_5},
-	{1, arcs_39_6},
-	{1, arcs_39_7},
+    {1, arcs_39_0},
+    {1, arcs_39_1},
+    {1, arcs_39_2},
+    {1, arcs_39_3},
+    {2, arcs_39_4},
+    {1, arcs_39_5},
+    {1, arcs_39_6},
+    {1, arcs_39_7},
 };
 static arc arcs_40_0[1] = {
-	{96, 1},
+    {96, 1},
 };
 static arc arcs_40_1[1] = {
-	{62, 2},
+    {62, 2},
 };
 static arc arcs_40_2[1] = {
-	{97, 3},
+    {97, 3},
 };
 static arc arcs_40_3[1] = {
-	{9, 4},
+    {9, 4},
 };
 static arc arcs_40_4[1] = {
-	{25, 5},
+    {25, 5},
 };
 static arc arcs_40_5[1] = {
-	{26, 6},
+    {26, 6},
 };
 static arc arcs_40_6[2] = {
-	{94, 7},
-	{0, 6},
+    {94, 7},
+    {0, 6},
 };
 static arc arcs_40_7[1] = {
-	{25, 8},
+    {25, 8},
 };
 static arc arcs_40_8[1] = {
-	{26, 9},
+    {26, 9},
 };
 static arc arcs_40_9[1] = {
-	{0, 9},
+    {0, 9},
 };
 static state states_40[10] = {
-	{1, arcs_40_0},
-	{1, arcs_40_1},
-	{1, arcs_40_2},
-	{1, arcs_40_3},
-	{1, arcs_40_4},
-	{1, arcs_40_5},
-	{2, arcs_40_6},
-	{1, arcs_40_7},
-	{1, arcs_40_8},
-	{1, arcs_40_9},
+    {1, arcs_40_0},
+    {1, arcs_40_1},
+    {1, arcs_40_2},
+    {1, arcs_40_3},
+    {1, arcs_40_4},
+    {1, arcs_40_5},
+    {2, arcs_40_6},
+    {1, arcs_40_7},
+    {1, arcs_40_8},
+    {1, arcs_40_9},
 };
 static arc arcs_41_0[1] = {
-	{98, 1},
+    {98, 1},
 };
 static arc arcs_41_1[1] = {
-	{25, 2},
+    {25, 2},
 };
 static arc arcs_41_2[1] = {
-	{26, 3},
+    {26, 3},
 };
 static arc arcs_41_3[2] = {
-	{99, 4},
-	{100, 5},
+    {99, 4},
+    {100, 5},
 };
 static arc arcs_41_4[1] = {
-	{25, 6},
+    {25, 6},
 };
 static arc arcs_41_5[1] = {
-	{25, 7},
+    {25, 7},
 };
 static arc arcs_41_6[1] = {
-	{26, 8},
+    {26, 8},
 };
 static arc arcs_41_7[1] = {
-	{26, 9},
+    {26, 9},
 };
 static arc arcs_41_8[4] = {
-	{99, 4},
-	{94, 10},
-	{100, 5},
-	{0, 8},
+    {99, 4},
+    {94, 10},
+    {100, 5},
+    {0, 8},
 };
 static arc arcs_41_9[1] = {
-	{0, 9},
+    {0, 9},
 };
 static arc arcs_41_10[1] = {
-	{25, 11},
+    {25, 11},
 };
 static arc arcs_41_11[1] = {
-	{26, 12},
+    {26, 12},
 };
 static arc arcs_41_12[2] = {
-	{100, 5},
-	{0, 12},
+    {100, 5},
+    {0, 12},
 };
 static state states_41[13] = {
-	{1, arcs_41_0},
-	{1, arcs_41_1},
-	{1, arcs_41_2},
-	{2, arcs_41_3},
-	{1, arcs_41_4},
-	{1, arcs_41_5},
-	{1, arcs_41_6},
-	{1, arcs_41_7},
-	{4, arcs_41_8},
-	{1, arcs_41_9},
-	{1, arcs_41_10},
-	{1, arcs_41_11},
-	{2, arcs_41_12},
+    {1, arcs_41_0},
+    {1, arcs_41_1},
+    {1, arcs_41_2},
+    {2, arcs_41_3},
+    {1, arcs_41_4},
+    {1, arcs_41_5},
+    {1, arcs_41_6},
+    {1, arcs_41_7},
+    {4, arcs_41_8},
+    {1, arcs_41_9},
+    {1, arcs_41_10},
+    {1, arcs_41_11},
+    {2, arcs_41_12},
 };
 static arc arcs_42_0[1] = {
-	{101, 1},
+    {101, 1},
 };
 static arc arcs_42_1[1] = {
-	{102, 2},
+    {102, 2},
 };
 static arc arcs_42_2[2] = {
-	{30, 1},
-	{25, 3},
+    {30, 1},
+    {25, 3},
 };
 static arc arcs_42_3[1] = {
-	{26, 4},
+    {26, 4},
 };
 static arc arcs_42_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_42[5] = {
-	{1, arcs_42_0},
-	{1, arcs_42_1},
-	{2, arcs_42_2},
-	{1, arcs_42_3},
-	{1, arcs_42_4},
+    {1, arcs_42_0},
+    {1, arcs_42_1},
+    {2, arcs_42_2},
+    {1, arcs_42_3},
+    {1, arcs_42_4},
 };
 static arc arcs_43_0[1] = {
-	{24, 1},
+    {24, 1},
 };
 static arc arcs_43_1[2] = {
-	{82, 2},
-	{0, 1},
+    {82, 2},
+    {0, 1},
 };
 static arc arcs_43_2[1] = {
-	{103, 3},
+    {103, 3},
 };
 static arc arcs_43_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_43[4] = {
-	{1, arcs_43_0},
-	{2, arcs_43_1},
-	{1, arcs_43_2},
-	{1, arcs_43_3},
+    {1, arcs_43_0},
+    {2, arcs_43_1},
+    {1, arcs_43_2},
+    {1, arcs_43_3},
 };
 static arc arcs_44_0[1] = {
-	{104, 1},
+    {104, 1},
 };
 static arc arcs_44_1[2] = {
-	{24, 2},
-	{0, 1},
+    {24, 2},
+    {0, 1},
 };
 static arc arcs_44_2[2] = {
-	{82, 3},
-	{0, 2},
+    {82, 3},
+    {0, 2},
 };
 static arc arcs_44_3[1] = {
-	{21, 4},
+    {21, 4},
 };
 static arc arcs_44_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_44[5] = {
-	{1, arcs_44_0},
-	{2, arcs_44_1},
-	{2, arcs_44_2},
-	{1, arcs_44_3},
-	{1, arcs_44_4},
+    {1, arcs_44_0},
+    {2, arcs_44_1},
+    {2, arcs_44_2},
+    {1, arcs_44_3},
+    {1, arcs_44_4},
 };
 static arc arcs_45_0[2] = {
-	{3, 1},
-	{2, 2},
+    {3, 1},
+    {2, 2},
 };
 static arc arcs_45_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static arc arcs_45_2[1] = {
-	{105, 3},
+    {105, 3},
 };
 static arc arcs_45_3[1] = {
-	{6, 4},
+    {6, 4},
 };
 static arc arcs_45_4[2] = {
-	{6, 4},
-	{106, 1},
+    {6, 4},
+    {106, 1},
 };
 static state states_45[5] = {
-	{2, arcs_45_0},
-	{1, arcs_45_1},
-	{1, arcs_45_2},
-	{1, arcs_45_3},
-	{2, arcs_45_4},
+    {2, arcs_45_0},
+    {1, arcs_45_1},
+    {1, arcs_45_2},
+    {1, arcs_45_3},
+    {2, arcs_45_4},
 };
 static arc arcs_46_0[2] = {
-	{107, 1},
-	{108, 2},
+    {107, 1},
+    {108, 2},
 };
 static arc arcs_46_1[2] = {
-	{92, 3},
-	{0, 1},
+    {92, 3},
+    {0, 1},
 };
 static arc arcs_46_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static arc arcs_46_3[1] = {
-	{107, 4},
+    {107, 4},
 };
 static arc arcs_46_4[1] = {
-	{94, 5},
+    {94, 5},
 };
 static arc arcs_46_5[1] = {
-	{24, 2},
+    {24, 2},
 };
 static state states_46[6] = {
-	{2, arcs_46_0},
-	{2, arcs_46_1},
-	{1, arcs_46_2},
-	{1, arcs_46_3},
-	{1, arcs_46_4},
-	{1, arcs_46_5},
+    {2, arcs_46_0},
+    {2, arcs_46_1},
+    {1, arcs_46_2},
+    {1, arcs_46_3},
+    {1, arcs_46_4},
+    {1, arcs_46_5},
 };
 static arc arcs_47_0[2] = {
-	{107, 1},
-	{110, 1},
+    {107, 1},
+    {110, 1},
 };
 static arc arcs_47_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_47[2] = {
-	{2, arcs_47_0},
-	{1, arcs_47_1},
+    {2, arcs_47_0},
+    {1, arcs_47_1},
 };
 static arc arcs_48_0[1] = {
-	{111, 1},
+    {111, 1},
 };
 static arc arcs_48_1[2] = {
-	{33, 2},
-	{25, 3},
+    {33, 2},
+    {25, 3},
 };
 static arc arcs_48_2[1] = {
-	{25, 3},
+    {25, 3},
 };
 static arc arcs_48_3[1] = {
-	{24, 4},
+    {24, 4},
 };
 static arc arcs_48_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_48[5] = {
-	{1, arcs_48_0},
-	{2, arcs_48_1},
-	{1, arcs_48_2},
-	{1, arcs_48_3},
-	{1, arcs_48_4},
+    {1, arcs_48_0},
+    {2, arcs_48_1},
+    {1, arcs_48_2},
+    {1, arcs_48_3},
+    {1, arcs_48_4},
 };
 static arc arcs_49_0[1] = {
-	{111, 1},
+    {111, 1},
 };
 static arc arcs_49_1[2] = {
-	{33, 2},
-	{25, 3},
+    {33, 2},
+    {25, 3},
 };
 static arc arcs_49_2[1] = {
-	{25, 3},
+    {25, 3},
 };
 static arc arcs_49_3[1] = {
-	{109, 4},
+    {109, 4},
 };
 static arc arcs_49_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_49[5] = {
-	{1, arcs_49_0},
-	{2, arcs_49_1},
-	{1, arcs_49_2},
-	{1, arcs_49_3},
-	{1, arcs_49_4},
+    {1, arcs_49_0},
+    {2, arcs_49_1},
+    {1, arcs_49_2},
+    {1, arcs_49_3},
+    {1, arcs_49_4},
 };
 static arc arcs_50_0[1] = {
-	{112, 1},
+    {112, 1},
 };
 static arc arcs_50_1[2] = {
-	{113, 0},
-	{0, 1},
+    {113, 0},
+    {0, 1},
 };
 static state states_50[2] = {
-	{1, arcs_50_0},
-	{2, arcs_50_1},
+    {1, arcs_50_0},
+    {2, arcs_50_1},
 };
 static arc arcs_51_0[1] = {
-	{114, 1},
+    {114, 1},
 };
 static arc arcs_51_1[2] = {
-	{115, 0},
-	{0, 1},
+    {115, 0},
+    {0, 1},
 };
 static state states_51[2] = {
-	{1, arcs_51_0},
-	{2, arcs_51_1},
+    {1, arcs_51_0},
+    {2, arcs_51_1},
 };
 static arc arcs_52_0[2] = {
-	{116, 1},
-	{117, 2},
+    {116, 1},
+    {117, 2},
 };
 static arc arcs_52_1[1] = {
-	{114, 2},
+    {114, 2},
 };
 static arc arcs_52_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_52[3] = {
-	{2, arcs_52_0},
-	{1, arcs_52_1},
-	{1, arcs_52_2},
+    {2, arcs_52_0},
+    {1, arcs_52_1},
+    {1, arcs_52_2},
 };
 static arc arcs_53_0[1] = {
-	{103, 1},
+    {103, 1},
 };
 static arc arcs_53_1[2] = {
-	{118, 0},
-	{0, 1},
+    {118, 0},
+    {0, 1},
 };
 static state states_53[2] = {
-	{1, arcs_53_0},
-	{2, arcs_53_1},
+    {1, arcs_53_0},
+    {2, arcs_53_1},
 };
 static arc arcs_54_0[10] = {
-	{119, 1},
-	{120, 1},
-	{121, 1},
-	{122, 1},
-	{123, 1},
-	{124, 1},
-	{125, 1},
-	{97, 1},
-	{116, 2},
-	{126, 3},
+    {119, 1},
+    {120, 1},
+    {121, 1},
+    {122, 1},
+    {123, 1},
+    {124, 1},
+    {125, 1},
+    {97, 1},
+    {116, 2},
+    {126, 3},
 };
 static arc arcs_54_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static arc arcs_54_2[1] = {
-	{97, 1},
+    {97, 1},
 };
 static arc arcs_54_3[2] = {
-	{116, 1},
-	{0, 3},
+    {116, 1},
+    {0, 3},
 };
 static state states_54[4] = {
-	{10, arcs_54_0},
-	{1, arcs_54_1},
-	{1, arcs_54_2},
-	{2, arcs_54_3},
+    {10, arcs_54_0},
+    {1, arcs_54_1},
+    {1, arcs_54_2},
+    {2, arcs_54_3},
 };
 static arc arcs_55_0[1] = {
-	{31, 1},
+    {31, 1},
 };
 static arc arcs_55_1[1] = {
-	{103, 2},
+    {103, 2},
 };
 static arc arcs_55_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_55[3] = {
-	{1, arcs_55_0},
-	{1, arcs_55_1},
-	{1, arcs_55_2},
+    {1, arcs_55_0},
+    {1, arcs_55_1},
+    {1, arcs_55_2},
 };
 static arc arcs_56_0[1] = {
-	{127, 1},
+    {127, 1},
 };
 static arc arcs_56_1[2] = {
-	{128, 0},
-	{0, 1},
+    {128, 0},
+    {0, 1},
 };
 static state states_56[2] = {
-	{1, arcs_56_0},
-	{2, arcs_56_1},
+    {1, arcs_56_0},
+    {2, arcs_56_1},
 };
 static arc arcs_57_0[1] = {
-	{129, 1},
+    {129, 1},
 };
 static arc arcs_57_1[2] = {
-	{130, 0},
-	{0, 1},
+    {130, 0},
+    {0, 1},
 };
 static state states_57[2] = {
-	{1, arcs_57_0},
-	{2, arcs_57_1},
+    {1, arcs_57_0},
+    {2, arcs_57_1},
 };
 static arc arcs_58_0[1] = {
-	{131, 1},
+    {131, 1},
 };
 static arc arcs_58_1[2] = {
-	{132, 0},
-	{0, 1},
+    {132, 0},
+    {0, 1},
 };
 static state states_58[2] = {
-	{1, arcs_58_0},
-	{2, arcs_58_1},
+    {1, arcs_58_0},
+    {2, arcs_58_1},
 };
 static arc arcs_59_0[1] = {
-	{133, 1},
+    {133, 1},
 };
 static arc arcs_59_1[3] = {
-	{134, 0},
-	{135, 0},
-	{0, 1},
+    {134, 0},
+    {135, 0},
+    {0, 1},
 };
 static state states_59[2] = {
-	{1, arcs_59_0},
-	{3, arcs_59_1},
+    {1, arcs_59_0},
+    {3, arcs_59_1},
 };
 static arc arcs_60_0[1] = {
-	{136, 1},
+    {136, 1},
 };
 static arc arcs_60_1[3] = {
-	{137, 0},
-	{138, 0},
-	{0, 1},
+    {137, 0},
+    {138, 0},
+    {0, 1},
 };
 static state states_60[2] = {
-	{1, arcs_60_0},
-	{3, arcs_60_1},
+    {1, arcs_60_0},
+    {3, arcs_60_1},
 };
 static arc arcs_61_0[1] = {
-	{139, 1},
+    {139, 1},
 };
 static arc arcs_61_1[5] = {
-	{31, 0},
-	{140, 0},
-	{141, 0},
-	{142, 0},
-	{0, 1},
+    {31, 0},
+    {140, 0},
+    {141, 0},
+    {142, 0},
+    {0, 1},
 };
 static state states_61[2] = {
-	{1, arcs_61_0},
-	{5, arcs_61_1},
+    {1, arcs_61_0},
+    {5, arcs_61_1},
 };
 static arc arcs_62_0[4] = {
-	{137, 1},
-	{138, 1},
-	{143, 1},
-	{144, 2},
+    {137, 1},
+    {138, 1},
+    {143, 1},
+    {144, 2},
 };
 static arc arcs_62_1[1] = {
-	{139, 2},
+    {139, 2},
 };
 static arc arcs_62_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_62[3] = {
-	{4, arcs_62_0},
-	{1, arcs_62_1},
-	{1, arcs_62_2},
+    {4, arcs_62_0},
+    {1, arcs_62_1},
+    {1, arcs_62_2},
 };
 static arc arcs_63_0[1] = {
-	{145, 1},
+    {145, 1},
 };
 static arc arcs_63_1[3] = {
-	{146, 1},
-	{32, 2},
-	{0, 1},
+    {146, 1},
+    {32, 2},
+    {0, 1},
 };
 static arc arcs_63_2[1] = {
-	{139, 3},
+    {139, 3},
 };
 static arc arcs_63_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_63[4] = {
-	{1, arcs_63_0},
-	{3, arcs_63_1},
-	{1, arcs_63_2},
-	{1, arcs_63_3},
+    {1, arcs_63_0},
+    {3, arcs_63_1},
+    {1, arcs_63_2},
+    {1, arcs_63_3},
 };
 static arc arcs_64_0[10] = {
-	{13, 1},
-	{148, 2},
-	{150, 3},
-	{21, 4},
-	{153, 4},
-	{154, 5},
-	{79, 4},
-	{155, 4},
-	{156, 4},
-	{157, 4},
+    {13, 1},
+    {148, 2},
+    {150, 3},
+    {21, 4},
+    {153, 4},
+    {154, 5},
+    {79, 4},
+    {155, 4},
+    {156, 4},
+    {157, 4},
 };
 static arc arcs_64_1[3] = {
-	{47, 6},
-	{147, 6},
-	{15, 4},
+    {47, 6},
+    {147, 6},
+    {15, 4},
 };
 static arc arcs_64_2[2] = {
-	{147, 7},
-	{149, 4},
+    {147, 7},
+    {149, 4},
 };
 static arc arcs_64_3[2] = {
-	{151, 8},
-	{152, 4},
+    {151, 8},
+    {152, 4},
 };
 static arc arcs_64_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static arc arcs_64_5[2] = {
-	{154, 5},
-	{0, 5},
+    {154, 5},
+    {0, 5},
 };
 static arc arcs_64_6[1] = {
-	{15, 4},
+    {15, 4},
 };
 static arc arcs_64_7[1] = {
-	{149, 4},
+    {149, 4},
 };
 static arc arcs_64_8[1] = {
-	{152, 4},
+    {152, 4},
 };
 static state states_64[9] = {
-	{10, arcs_64_0},
-	{3, arcs_64_1},
-	{2, arcs_64_2},
-	{2, arcs_64_3},
-	{1, arcs_64_4},
-	{2, arcs_64_5},
-	{1, arcs_64_6},
-	{1, arcs_64_7},
-	{1, arcs_64_8},
+    {10, arcs_64_0},
+    {3, arcs_64_1},
+    {2, arcs_64_2},
+    {2, arcs_64_3},
+    {1, arcs_64_4},
+    {2, arcs_64_5},
+    {1, arcs_64_6},
+    {1, arcs_64_7},
+    {1, arcs_64_8},
 };
 static arc arcs_65_0[2] = {
-	{24, 1},
-	{48, 1},
+    {24, 1},
+    {48, 1},
 };
 static arc arcs_65_1[3] = {
-	{158, 2},
-	{30, 3},
-	{0, 1},
+    {158, 2},
+    {30, 3},
+    {0, 1},
 };
 static arc arcs_65_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static arc arcs_65_3[3] = {
-	{24, 4},
-	{48, 4},
-	{0, 3},
+    {24, 4},
+    {48, 4},
+    {0, 3},
 };
 static arc arcs_65_4[2] = {
-	{30, 3},
-	{0, 4},
+    {30, 3},
+    {0, 4},
 };
 static state states_65[5] = {
-	{2, arcs_65_0},
-	{3, arcs_65_1},
-	{1, arcs_65_2},
-	{3, arcs_65_3},
-	{2, arcs_65_4},
+    {2, arcs_65_0},
+    {3, arcs_65_1},
+    {1, arcs_65_2},
+    {3, arcs_65_3},
+    {2, arcs_65_4},
 };
 static arc arcs_66_0[3] = {
-	{13, 1},
-	{148, 2},
-	{78, 3},
+    {13, 1},
+    {148, 2},
+    {78, 3},
 };
 static arc arcs_66_1[2] = {
-	{14, 4},
-	{15, 5},
+    {14, 4},
+    {15, 5},
 };
 static arc arcs_66_2[1] = {
-	{159, 6},
+    {159, 6},
 };
 static arc arcs_66_3[1] = {
-	{21, 5},
+    {21, 5},
 };
 static arc arcs_66_4[1] = {
-	{15, 5},
+    {15, 5},
 };
 static arc arcs_66_5[1] = {
-	{0, 5},
+    {0, 5},
 };
 static arc arcs_66_6[1] = {
-	{149, 5},
+    {149, 5},
 };
 static state states_66[7] = {
-	{3, arcs_66_0},
-	{2, arcs_66_1},
-	{1, arcs_66_2},
-	{1, arcs_66_3},
-	{1, arcs_66_4},
-	{1, arcs_66_5},
-	{1, arcs_66_6},
+    {3, arcs_66_0},
+    {2, arcs_66_1},
+    {1, arcs_66_2},
+    {1, arcs_66_3},
+    {1, arcs_66_4},
+    {1, arcs_66_5},
+    {1, arcs_66_6},
 };
 static arc arcs_67_0[1] = {
-	{160, 1},
+    {160, 1},
 };
 static arc arcs_67_1[2] = {
-	{30, 2},
-	{0, 1},
+    {30, 2},
+    {0, 1},
 };
 static arc arcs_67_2[2] = {
-	{160, 1},
-	{0, 2},
+    {160, 1},
+    {0, 2},
 };
 static state states_67[3] = {
-	{1, arcs_67_0},
-	{2, arcs_67_1},
-	{2, arcs_67_2},
+    {1, arcs_67_0},
+    {2, arcs_67_1},
+    {2, arcs_67_2},
 };
 static arc arcs_68_0[2] = {
-	{24, 1},
-	{25, 2},
+    {24, 1},
+    {25, 2},
 };
 static arc arcs_68_1[2] = {
-	{25, 2},
-	{0, 1},
+    {25, 2},
+    {0, 1},
 };
 static arc arcs_68_2[3] = {
-	{24, 3},
-	{161, 4},
-	{0, 2},
+    {24, 3},
+    {161, 4},
+    {0, 2},
 };
 static arc arcs_68_3[2] = {
-	{161, 4},
-	{0, 3},
+    {161, 4},
+    {0, 3},
 };
 static arc arcs_68_4[1] = {
-	{0, 4},
+    {0, 4},
 };
 static state states_68[5] = {
-	{2, arcs_68_0},
-	{2, arcs_68_1},
-	{3, arcs_68_2},
-	{2, arcs_68_3},
-	{1, arcs_68_4},
+    {2, arcs_68_0},
+    {2, arcs_68_1},
+    {3, arcs_68_2},
+    {2, arcs_68_3},
+    {1, arcs_68_4},
 };
 static arc arcs_69_0[1] = {
-	{25, 1},
+    {25, 1},
 };
 static arc arcs_69_1[2] = {
-	{24, 2},
-	{0, 1},
+    {24, 2},
+    {0, 1},
 };
 static arc arcs_69_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_69[3] = {
-	{1, arcs_69_0},
-	{2, arcs_69_1},
-	{1, arcs_69_2},
+    {1, arcs_69_0},
+    {2, arcs_69_1},
+    {1, arcs_69_2},
 };
 static arc arcs_70_0[2] = {
-	{103, 1},
-	{48, 1},
+    {103, 1},
+    {48, 1},
 };
 static arc arcs_70_1[2] = {
-	{30, 2},
-	{0, 1},
+    {30, 2},
+    {0, 1},
 };
 static arc arcs_70_2[3] = {
-	{103, 1},
-	{48, 1},
-	{0, 2},
+    {103, 1},
+    {48, 1},
+    {0, 2},
 };
 static state states_70[3] = {
-	{2, arcs_70_0},
-	{2, arcs_70_1},
-	{3, arcs_70_2},
+    {2, arcs_70_0},
+    {2, arcs_70_1},
+    {3, arcs_70_2},
 };
 static arc arcs_71_0[1] = {
-	{24, 1},
+    {24, 1},
 };
 static arc arcs_71_1[2] = {
-	{30, 2},
-	{0, 1},
+    {30, 2},
+    {0, 1},
 };
 static arc arcs_71_2[2] = {
-	{24, 1},
-	{0, 2},
+    {24, 1},
+    {0, 2},
 };
 static state states_71[3] = {
-	{1, arcs_71_0},
-	{2, arcs_71_1},
-	{2, arcs_71_2},
+    {1, arcs_71_0},
+    {2, arcs_71_1},
+    {2, arcs_71_2},
 };
 static arc arcs_72_0[1] = {
-	{24, 1},
+    {24, 1},
 };
 static arc arcs_72_1[4] = {
-	{25, 2},
-	{158, 3},
-	{30, 4},
-	{0, 1},
+    {25, 2},
+    {158, 3},
+    {30, 4},
+    {0, 1},
 };
 static arc arcs_72_2[1] = {
-	{24, 5},
+    {24, 5},
 };
 static arc arcs_72_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static arc arcs_72_4[2] = {
-	{24, 6},
-	{0, 4},
+    {24, 6},
+    {0, 4},
 };
 static arc arcs_72_5[3] = {
-	{158, 3},
-	{30, 7},
-	{0, 5},
+    {158, 3},
+    {30, 7},
+    {0, 5},
 };
 static arc arcs_72_6[2] = {
-	{30, 4},
-	{0, 6},
+    {30, 4},
+    {0, 6},
 };
 static arc arcs_72_7[2] = {
-	{24, 8},
-	{0, 7},
+    {24, 8},
+    {0, 7},
 };
 static arc arcs_72_8[1] = {
-	{25, 9},
+    {25, 9},
 };
 static arc arcs_72_9[1] = {
-	{24, 10},
+    {24, 10},
 };
 static arc arcs_72_10[2] = {
-	{30, 7},
-	{0, 10},
+    {30, 7},
+    {0, 10},
 };
 static state states_72[11] = {
-	{1, arcs_72_0},
-	{4, arcs_72_1},
-	{1, arcs_72_2},
-	{1, arcs_72_3},
-	{2, arcs_72_4},
-	{3, arcs_72_5},
-	{2, arcs_72_6},
-	{2, arcs_72_7},
-	{1, arcs_72_8},
-	{1, arcs_72_9},
-	{2, arcs_72_10},
+    {1, arcs_72_0},
+    {4, arcs_72_1},
+    {1, arcs_72_2},
+    {1, arcs_72_3},
+    {2, arcs_72_4},
+    {3, arcs_72_5},
+    {2, arcs_72_6},
+    {2, arcs_72_7},
+    {1, arcs_72_8},
+    {1, arcs_72_9},
+    {2, arcs_72_10},
 };
 static arc arcs_73_0[1] = {
-	{162, 1},
+    {162, 1},
 };
 static arc arcs_73_1[1] = {
-	{21, 2},
+    {21, 2},
 };
 static arc arcs_73_2[2] = {
-	{13, 3},
-	{25, 4},
+    {13, 3},
+    {25, 4},
 };
 static arc arcs_73_3[2] = {
-	{14, 5},
-	{15, 6},
+    {14, 5},
+    {15, 6},
 };
 static arc arcs_73_4[1] = {
-	{26, 7},
+    {26, 7},
 };
 static arc arcs_73_5[1] = {
-	{15, 6},
+    {15, 6},
 };
 static arc arcs_73_6[1] = {
-	{25, 4},
+    {25, 4},
 };
 static arc arcs_73_7[1] = {
-	{0, 7},
+    {0, 7},
 };
 static state states_73[8] = {
-	{1, arcs_73_0},
-	{1, arcs_73_1},
-	{2, arcs_73_2},
-	{2, arcs_73_3},
-	{1, arcs_73_4},
-	{1, arcs_73_5},
-	{1, arcs_73_6},
-	{1, arcs_73_7},
+    {1, arcs_73_0},
+    {1, arcs_73_1},
+    {2, arcs_73_2},
+    {2, arcs_73_3},
+    {1, arcs_73_4},
+    {1, arcs_73_5},
+    {1, arcs_73_6},
+    {1, arcs_73_7},
 };
 static arc arcs_74_0[3] = {
-	{163, 1},
-	{31, 2},
-	{32, 3},
+    {163, 1},
+    {31, 2},
+    {32, 3},
 };
 static arc arcs_74_1[2] = {
-	{30, 4},
-	{0, 1},
+    {30, 4},
+    {0, 1},
 };
 static arc arcs_74_2[1] = {
-	{24, 5},
+    {24, 5},
 };
 static arc arcs_74_3[1] = {
-	{24, 6},
+    {24, 6},
 };
 static arc arcs_74_4[4] = {
-	{163, 1},
-	{31, 2},
-	{32, 3},
-	{0, 4},
+    {163, 1},
+    {31, 2},
+    {32, 3},
+    {0, 4},
 };
 static arc arcs_74_5[2] = {
-	{30, 7},
-	{0, 5},
+    {30, 7},
+    {0, 5},
 };
 static arc arcs_74_6[1] = {
-	{0, 6},
+    {0, 6},
 };
 static arc arcs_74_7[2] = {
-	{163, 5},
-	{32, 3},
+    {163, 5},
+    {32, 3},
 };
 static state states_74[8] = {
-	{3, arcs_74_0},
-	{2, arcs_74_1},
-	{1, arcs_74_2},
-	{1, arcs_74_3},
-	{4, arcs_74_4},
-	{2, arcs_74_5},
-	{1, arcs_74_6},
-	{2, arcs_74_7},
+    {3, arcs_74_0},
+    {2, arcs_74_1},
+    {1, arcs_74_2},
+    {1, arcs_74_3},
+    {4, arcs_74_4},
+    {2, arcs_74_5},
+    {1, arcs_74_6},
+    {2, arcs_74_7},
 };
 static arc arcs_75_0[1] = {
-	{24, 1},
+    {24, 1},
 };
 static arc arcs_75_1[3] = {
-	{158, 2},
-	{29, 3},
-	{0, 1},
+    {158, 2},
+    {29, 3},
+    {0, 1},
 };
 static arc arcs_75_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static arc arcs_75_3[1] = {
-	{24, 2},
+    {24, 2},
 };
 static state states_75[4] = {
-	{1, arcs_75_0},
-	{3, arcs_75_1},
-	{1, arcs_75_2},
-	{1, arcs_75_3},
+    {1, arcs_75_0},
+    {3, arcs_75_1},
+    {1, arcs_75_2},
+    {1, arcs_75_3},
 };
 static arc arcs_76_0[2] = {
-	{158, 1},
-	{165, 1},
+    {158, 1},
+    {165, 1},
 };
 static arc arcs_76_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_76[2] = {
-	{2, arcs_76_0},
-	{1, arcs_76_1},
+    {2, arcs_76_0},
+    {1, arcs_76_1},
 };
 static arc arcs_77_0[1] = {
-	{96, 1},
+    {96, 1},
 };
 static arc arcs_77_1[1] = {
-	{62, 2},
+    {62, 2},
 };
 static arc arcs_77_2[1] = {
-	{97, 3},
+    {97, 3},
 };
 static arc arcs_77_3[1] = {
-	{107, 4},
+    {107, 4},
 };
 static arc arcs_77_4[2] = {
-	{164, 5},
-	{0, 4},
+    {164, 5},
+    {0, 4},
 };
 static arc arcs_77_5[1] = {
-	{0, 5},
+    {0, 5},
 };
 static state states_77[6] = {
-	{1, arcs_77_0},
-	{1, arcs_77_1},
-	{1, arcs_77_2},
-	{1, arcs_77_3},
-	{2, arcs_77_4},
-	{1, arcs_77_5},
+    {1, arcs_77_0},
+    {1, arcs_77_1},
+    {1, arcs_77_2},
+    {1, arcs_77_3},
+    {2, arcs_77_4},
+    {1, arcs_77_5},
 };
 static arc arcs_78_0[1] = {
-	{92, 1},
+    {92, 1},
 };
 static arc arcs_78_1[1] = {
-	{109, 2},
+    {109, 2},
 };
 static arc arcs_78_2[2] = {
-	{164, 3},
-	{0, 2},
+    {164, 3},
+    {0, 2},
 };
 static arc arcs_78_3[1] = {
-	{0, 3},
+    {0, 3},
 };
 static state states_78[4] = {
-	{1, arcs_78_0},
-	{1, arcs_78_1},
-	{2, arcs_78_2},
-	{1, arcs_78_3},
+    {1, arcs_78_0},
+    {1, arcs_78_1},
+    {2, arcs_78_2},
+    {1, arcs_78_3},
 };
 static arc arcs_79_0[1] = {
-	{21, 1},
+    {21, 1},
 };
 static arc arcs_79_1[1] = {
-	{0, 1},
+    {0, 1},
 };
 static state states_79[2] = {
-	{1, arcs_79_0},
-	{1, arcs_79_1},
+    {1, arcs_79_0},
+    {1, arcs_79_1},
 };
 static arc arcs_80_0[1] = {
-	{167, 1},
+    {167, 1},
 };
 static arc arcs_80_1[2] = {
-	{9, 2},
-	{0, 1},
+    {9, 2},
+    {0, 1},
 };
 static arc arcs_80_2[1] = {
-	{0, 2},
+    {0, 2},
 };
 static state states_80[3] = {
-	{1, arcs_80_0},
-	{2, arcs_80_1},
-	{1, arcs_80_2},
+    {1, arcs_80_0},
+    {2, arcs_80_1},
+    {1, arcs_80_2},
 };
 static dfa dfas[81] = {
-	{256, "single_input", 0, 3, states_0,
-	 "\004\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
-	{257, "file_input", 0, 2, states_1,
-	 "\204\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
-	{258, "eval_input", 0, 3, states_2,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{259, "decorator", 0, 7, states_3,
-	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{260, "decorators", 0, 2, states_4,
-	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{261, "decorated", 0, 3, states_5,
-	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{262, "funcdef", 0, 8, states_6,
-	 "\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{263, "parameters", 0, 4, states_7,
-	 "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{264, "typedargslist", 0, 12, states_8,
-	 "\000\000\040\200\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{265, "tfpdef", 0, 4, states_9,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{266, "varargslist", 0, 12, states_10,
-	 "\000\000\040\200\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{267, "vfpdef", 0, 2, states_11,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{268, "stmt", 0, 2, states_12,
-	 "\000\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
-	{269, "simple_stmt", 0, 4, states_13,
-	 "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
-	{270, "small_stmt", 0, 2, states_14,
-	 "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
-	{271, "expr_stmt", 0, 6, states_15,
-	 "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{272, "testlist_star_expr", 0, 3, states_16,
-	 "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{273, "augassign", 0, 2, states_17,
-	 "\000\000\000\000\000\000\376\037\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{274, "del_stmt", 0, 3, states_18,
-	 "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{275, "pass_stmt", 0, 2, states_19,
-	 "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{276, "flow_stmt", 0, 2, states_20,
-	 "\000\000\000\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000\000\000\200"},
-	{277, "break_stmt", 0, 2, states_21,
-	 "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{278, "continue_stmt", 0, 2, states_22,
-	 "\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{279, "return_stmt", 0, 3, states_23,
-	 "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{280, "yield_stmt", 0, 2, states_24,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"},
-	{281, "raise_stmt", 0, 5, states_25,
-	 "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
-	{282, "import_stmt", 0, 2, states_26,
-	 "\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000"},
-	{283, "import_name", 0, 3, states_27,
-	 "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"},
-	{284, "import_from", 0, 8, states_28,
-	 "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
-	{285, "import_as_name", 0, 4, states_29,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{286, "dotted_as_name", 0, 4, states_30,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{287, "import_as_names", 0, 3, states_31,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{288, "dotted_as_names", 0, 2, states_32,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{289, "dotted_name", 0, 2, states_33,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{290, "global_stmt", 0, 3, states_34,
-	 "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
-	{291, "nonlocal_stmt", 0, 3, states_35,
-	 "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"},
-	{292, "assert_stmt", 0, 5, states_36,
-	 "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000"},
-	{293, "compound_stmt", 0, 2, states_37,
-	 "\000\010\020\000\000\000\000\000\000\000\000\220\045\000\000\000\000\000\000\000\004"},
-	{294, "if_stmt", 0, 8, states_38,
-	 "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
-	{295, "while_stmt", 0, 8, states_39,
-	 "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
-	{296, "for_stmt", 0, 10, states_40,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
-	{297, "try_stmt", 0, 13, states_41,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"},
-	{298, "with_stmt", 0, 5, states_42,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
-	{299, "with_item", 0, 4, states_43,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{300, "except_clause", 0, 5, states_44,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"},
-	{301, "suite", 0, 5, states_45,
-	 "\004\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
-	{302, "test", 0, 6, states_46,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{303, "test_nocond", 0, 2, states_47,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{304, "lambdef", 0, 5, states_48,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000"},
-	{305, "lambdef_nocond", 0, 5, states_49,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000"},
-	{306, "or_test", 0, 2, states_50,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
-	{307, "and_test", 0, 2, states_51,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
-	{308, "not_test", 0, 3, states_52,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
-	{309, "comparison", 0, 2, states_53,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{310, "comp_op", 0, 4, states_54,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\220\177\000\000\000\000\000"},
-	{311, "star_expr", 0, 3, states_55,
-	 "\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{312, "expr", 0, 2, states_56,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{313, "xor_expr", 0, 2, states_57,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{314, "and_expr", 0, 2, states_58,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{315, "shift_expr", 0, 2, states_59,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{316, "arith_expr", 0, 2, states_60,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{317, "term", 0, 2, states_61,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{318, "factor", 0, 3, states_62,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{319, "power", 0, 4, states_63,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000"},
-	{320, "atom", 0, 9, states_64,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000"},
-	{321, "testlist_comp", 0, 5, states_65,
-	 "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{322, "trailer", 0, 7, states_66,
-	 "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\020\000\000"},
-	{323, "subscriptlist", 0, 3, states_67,
-	 "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{324, "subscript", 0, 5, states_68,
-	 "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{325, "sliceop", 0, 3, states_69,
-	 "\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{326, "exprlist", 0, 3, states_70,
-	 "\000\040\040\200\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
-	{327, "testlist", 0, 3, states_71,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{328, "dictorsetmaker", 0, 11, states_72,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{329, "classdef", 0, 8, states_73,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004"},
-	{330, "arglist", 0, 8, states_74,
-	 "\000\040\040\200\001\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{331, "argument", 0, 4, states_75,
-	 "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
-	{332, "comp_iter", 0, 2, states_76,
-	 "\000\000\000\000\000\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000"},
-	{333, "comp_for", 0, 6, states_77,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
-	{334, "comp_if", 0, 4, states_78,
-	 "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
-	{335, "encoding_decl", 0, 2, states_79,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{336, "yield_expr", 0, 3, states_80,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"},
+    {256, "single_input", 0, 3, states_0,
+     "\004\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
+    {257, "file_input", 0, 2, states_1,
+     "\204\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
+    {258, "eval_input", 0, 3, states_2,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {259, "decorator", 0, 7, states_3,
+     "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {260, "decorators", 0, 2, states_4,
+     "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {261, "decorated", 0, 3, states_5,
+     "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {262, "funcdef", 0, 8, states_6,
+     "\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {263, "parameters", 0, 4, states_7,
+     "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {264, "typedargslist", 0, 12, states_8,
+     "\000\000\040\200\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {265, "tfpdef", 0, 4, states_9,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {266, "varargslist", 0, 12, states_10,
+     "\000\000\040\200\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {267, "vfpdef", 0, 2, states_11,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {268, "stmt", 0, 2, states_12,
+     "\000\050\060\200\000\000\000\240\340\223\160\220\045\200\020\000\000\206\120\076\204"},
+    {269, "simple_stmt", 0, 4, states_13,
+     "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
+    {270, "small_stmt", 0, 2, states_14,
+     "\000\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
+    {271, "expr_stmt", 0, 6, states_15,
+     "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {272, "testlist_star_expr", 0, 3, states_16,
+     "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {273, "augassign", 0, 2, states_17,
+     "\000\000\000\000\000\000\376\037\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {274, "del_stmt", 0, 3, states_18,
+     "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {275, "pass_stmt", 0, 2, states_19,
+     "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {276, "flow_stmt", 0, 2, states_20,
+     "\000\000\000\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000\000\000\200"},
+    {277, "break_stmt", 0, 2, states_21,
+     "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {278, "continue_stmt", 0, 2, states_22,
+     "\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {279, "return_stmt", 0, 3, states_23,
+     "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {280, "yield_stmt", 0, 2, states_24,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"},
+    {281, "raise_stmt", 0, 5, states_25,
+     "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
+    {282, "import_stmt", 0, 2, states_26,
+     "\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000"},
+    {283, "import_name", 0, 3, states_27,
+     "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"},
+    {284, "import_from", 0, 8, states_28,
+     "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
+    {285, "import_as_name", 0, 4, states_29,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {286, "dotted_as_name", 0, 4, states_30,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {287, "import_as_names", 0, 3, states_31,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {288, "dotted_as_names", 0, 2, states_32,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {289, "dotted_name", 0, 2, states_33,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {290, "global_stmt", 0, 3, states_34,
+     "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
+    {291, "nonlocal_stmt", 0, 3, states_35,
+     "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"},
+    {292, "assert_stmt", 0, 5, states_36,
+     "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000"},
+    {293, "compound_stmt", 0, 2, states_37,
+     "\000\010\020\000\000\000\000\000\000\000\000\220\045\000\000\000\000\000\000\000\004"},
+    {294, "if_stmt", 0, 8, states_38,
+     "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
+    {295, "while_stmt", 0, 8, states_39,
+     "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
+    {296, "for_stmt", 0, 10, states_40,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
+    {297, "try_stmt", 0, 13, states_41,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"},
+    {298, "with_stmt", 0, 5, states_42,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+    {299, "with_item", 0, 4, states_43,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {300, "except_clause", 0, 5, states_44,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"},
+    {301, "suite", 0, 5, states_45,
+     "\004\040\040\200\000\000\000\240\340\223\160\000\000\200\020\000\000\206\120\076\200"},
+    {302, "test", 0, 6, states_46,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {303, "test_nocond", 0, 2, states_47,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {304, "lambdef", 0, 5, states_48,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000"},
+    {305, "lambdef_nocond", 0, 5, states_49,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000"},
+    {306, "or_test", 0, 2, states_50,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
+    {307, "and_test", 0, 2, states_51,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
+    {308, "not_test", 0, 3, states_52,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\020\000\000\206\120\076\000"},
+    {309, "comparison", 0, 2, states_53,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {310, "comp_op", 0, 4, states_54,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\220\177\000\000\000\000\000"},
+    {311, "star_expr", 0, 3, states_55,
+     "\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {312, "expr", 0, 2, states_56,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {313, "xor_expr", 0, 2, states_57,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {314, "and_expr", 0, 2, states_58,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {315, "shift_expr", 0, 2, states_59,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {316, "arith_expr", 0, 2, states_60,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {317, "term", 0, 2, states_61,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {318, "factor", 0, 3, states_62,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {319, "power", 0, 4, states_63,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000"},
+    {320, "atom", 0, 9, states_64,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\076\000"},
+    {321, "testlist_comp", 0, 5, states_65,
+     "\000\040\040\200\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {322, "trailer", 0, 7, states_66,
+     "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\020\000\000"},
+    {323, "subscriptlist", 0, 3, states_67,
+     "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {324, "subscript", 0, 5, states_68,
+     "\000\040\040\002\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {325, "sliceop", 0, 3, states_69,
+     "\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {326, "exprlist", 0, 3, states_70,
+     "\000\040\040\200\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\076\000"},
+    {327, "testlist", 0, 3, states_71,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {328, "dictorsetmaker", 0, 11, states_72,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {329, "classdef", 0, 8, states_73,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004"},
+    {330, "arglist", 0, 8, states_74,
+     "\000\040\040\200\001\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {331, "argument", 0, 4, states_75,
+     "\000\040\040\000\000\000\000\000\000\200\000\000\000\200\020\000\000\206\120\076\000"},
+    {332, "comp_iter", 0, 2, states_76,
+     "\000\000\000\000\000\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000"},
+    {333, "comp_for", 0, 6, states_77,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
+    {334, "comp_if", 0, 4, states_78,
+     "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
+    {335, "encoding_decl", 0, 2, states_79,
+     "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+    {336, "yield_expr", 0, 3, states_80,
+     "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"},
 };
 static label labels[168] = {
-	{0, "EMPTY"},
-	{256, 0},
-	{4, 0},
-	{269, 0},
-	{293, 0},
-	{257, 0},
-	{268, 0},
-	{0, 0},
-	{258, 0},
-	{327, 0},
-	{259, 0},
-	{50, 0},
-	{289, 0},
-	{7, 0},
-	{330, 0},
-	{8, 0},
-	{260, 0},
-	{261, 0},
-	{329, 0},
-	{262, 0},
-	{1, "def"},
-	{1, 0},
-	{263, 0},
-	{51, 0},
-	{302, 0},
-	{11, 0},
-	{301, 0},
-	{264, 0},
-	{265, 0},
-	{22, 0},
-	{12, 0},
-	{16, 0},
-	{36, 0},
-	{266, 0},
-	{267, 0},
-	{270, 0},
-	{13, 0},
-	{271, 0},
-	{274, 0},
-	{275, 0},
-	{276, 0},
-	{282, 0},
-	{290, 0},
-	{291, 0},
-	{292, 0},
-	{272, 0},
-	{273, 0},
-	{336, 0},
-	{311, 0},
-	{37, 0},
-	{38, 0},
-	{39, 0},
-	{40, 0},
-	{41, 0},
-	{42, 0},
-	{43, 0},
-	{44, 0},
-	{45, 0},
-	{46, 0},
-	{47, 0},
-	{49, 0},
-	{1, "del"},
-	{326, 0},
-	{1, "pass"},
-	{277, 0},
-	{278, 0},
-	{279, 0},
-	{281, 0},
-	{280, 0},
-	{1, "break"},
-	{1, "continue"},
-	{1, "return"},
-	{1, "raise"},
-	{1, "from"},
-	{283, 0},
-	{284, 0},
-	{1, "import"},
-	{288, 0},
-	{23, 0},
-	{52, 0},
-	{287, 0},
-	{285, 0},
-	{1, "as"},
-	{286, 0},
-	{1, "global"},
-	{1, "nonlocal"},
-	{1, "assert"},
-	{294, 0},
-	{295, 0},
-	{296, 0},
-	{297, 0},
-	{298, 0},
-	{1, "if"},
-	{1, "elif"},
-	{1, "else"},
-	{1, "while"},
-	{1, "for"},
-	{1, "in"},
-	{1, "try"},
-	{300, 0},
-	{1, "finally"},
-	{1, "with"},
-	{299, 0},
-	{312, 0},
-	{1, "except"},
-	{5, 0},
-	{6, 0},
-	{306, 0},
-	{304, 0},
-	{303, 0},
-	{305, 0},
-	{1, "lambda"},
-	{307, 0},
-	{1, "or"},
-	{308, 0},
-	{1, "and"},
-	{1, "not"},
-	{309, 0},
-	{310, 0},
-	{20, 0},
-	{21, 0},
-	{28, 0},
-	{31, 0},
-	{30, 0},
-	{29, 0},
-	{29, 0},
-	{1, "is"},
-	{313, 0},
-	{18, 0},
-	{314, 0},
-	{33, 0},
-	{315, 0},
-	{19, 0},
-	{316, 0},
-	{34, 0},
-	{35, 0},
-	{317, 0},
-	{14, 0},
-	{15, 0},
-	{318, 0},
-	{17, 0},
-	{24, 0},
-	{48, 0},
-	{32, 0},
-	{319, 0},
-	{320, 0},
-	{322, 0},
-	{321, 0},
-	{9, 0},
-	{10, 0},
-	{26, 0},
-	{328, 0},
-	{27, 0},
-	{2, 0},
-	{3, 0},
-	{1, "None"},
-	{1, "True"},
-	{1, "False"},
-	{333, 0},
-	{323, 0},
-	{324, 0},
-	{325, 0},
-	{1, "class"},
-	{331, 0},
-	{332, 0},
-	{334, 0},
-	{335, 0},
-	{1, "yield"},
+    {0, "EMPTY"},
+    {256, 0},
+    {4, 0},
+    {269, 0},
+    {293, 0},
+    {257, 0},
+    {268, 0},
+    {0, 0},
+    {258, 0},
+    {327, 0},
+    {259, 0},
+    {50, 0},
+    {289, 0},
+    {7, 0},
+    {330, 0},
+    {8, 0},
+    {260, 0},
+    {261, 0},
+    {329, 0},
+    {262, 0},
+    {1, "def"},
+    {1, 0},
+    {263, 0},
+    {51, 0},
+    {302, 0},
+    {11, 0},
+    {301, 0},
+    {264, 0},
+    {265, 0},
+    {22, 0},
+    {12, 0},
+    {16, 0},
+    {36, 0},
+    {266, 0},
+    {267, 0},
+    {270, 0},
+    {13, 0},
+    {271, 0},
+    {274, 0},
+    {275, 0},
+    {276, 0},
+    {282, 0},
+    {290, 0},
+    {291, 0},
+    {292, 0},
+    {272, 0},
+    {273, 0},
+    {336, 0},
+    {311, 0},
+    {37, 0},
+    {38, 0},
+    {39, 0},
+    {40, 0},
+    {41, 0},
+    {42, 0},
+    {43, 0},
+    {44, 0},
+    {45, 0},
+    {46, 0},
+    {47, 0},
+    {49, 0},
+    {1, "del"},
+    {326, 0},
+    {1, "pass"},
+    {277, 0},
+    {278, 0},
+    {279, 0},
+    {281, 0},
+    {280, 0},
+    {1, "break"},
+    {1, "continue"},
+    {1, "return"},
+    {1, "raise"},
+    {1, "from"},
+    {283, 0},
+    {284, 0},
+    {1, "import"},
+    {288, 0},
+    {23, 0},
+    {52, 0},
+    {287, 0},
+    {285, 0},
+    {1, "as"},
+    {286, 0},
+    {1, "global"},
+    {1, "nonlocal"},
+    {1, "assert"},
+    {294, 0},
+    {295, 0},
+    {296, 0},
+    {297, 0},
+    {298, 0},
+    {1, "if"},
+    {1, "elif"},
+    {1, "else"},
+    {1, "while"},
+    {1, "for"},
+    {1, "in"},
+    {1, "try"},
+    {300, 0},
+    {1, "finally"},
+    {1, "with"},
+    {299, 0},
+    {312, 0},
+    {1, "except"},
+    {5, 0},
+    {6, 0},
+    {306, 0},
+    {304, 0},
+    {303, 0},
+    {305, 0},
+    {1, "lambda"},
+    {307, 0},
+    {1, "or"},
+    {308, 0},
+    {1, "and"},
+    {1, "not"},
+    {309, 0},
+    {310, 0},
+    {20, 0},
+    {21, 0},
+    {28, 0},
+    {31, 0},
+    {30, 0},
+    {29, 0},
+    {29, 0},
+    {1, "is"},
+    {313, 0},
+    {18, 0},
+    {314, 0},
+    {33, 0},
+    {315, 0},
+    {19, 0},
+    {316, 0},
+    {34, 0},
+    {35, 0},
+    {317, 0},
+    {14, 0},
+    {15, 0},
+    {318, 0},
+    {17, 0},
+    {24, 0},
+    {48, 0},
+    {32, 0},
+    {319, 0},
+    {320, 0},
+    {322, 0},
+    {321, 0},
+    {9, 0},
+    {10, 0},
+    {26, 0},
+    {328, 0},
+    {27, 0},
+    {2, 0},
+    {3, 0},
+    {1, "None"},
+    {1, "True"},
+    {1, "False"},
+    {333, 0},
+    {323, 0},
+    {324, 0},
+    {325, 0},
+    {1, "class"},
+    {331, 0},
+    {332, 0},
+    {334, 0},
+    {335, 0},
+    {1, "yield"},
 };
 grammar _PyParser_Grammar = {
-	81,
-	dfas,
-	{168, labels},
-	256
+    81,
+    dfas,
+    {168, labels},
+    256
 };

Modified: python/branches/py3k-cdecimal/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/pythonrun.c	(original)
+++ python/branches/py3k-cdecimal/Python/pythonrun.c	Wed May 19 17:30:16 2010
@@ -138,8 +138,8 @@
 static char*
 get_codeset(void)
 {
-    char* codeset;
-    PyObject *codec, *name;
+    char* codeset, *name_str;
+    PyObject *codec, *name = NULL;
 
     codeset = nl_langinfo(CODESET);
     if (!codeset || codeset[0] == '\0')
@@ -154,12 +154,16 @@
     if (!name)
         goto error;
 
-    codeset = strdup(_PyUnicode_AsString(name));
+    name_str = _PyUnicode_AsString(name);
+    if (name == NULL)
+        goto error;
+    codeset = strdup(name_str);
     Py_DECREF(name);
     return codeset;
 
 error:
     Py_XDECREF(codec);
+    Py_XDECREF(name);
     return NULL;
 }
 #endif
@@ -1060,22 +1064,34 @@
         if (!oenc)
             return -1;
         enc = _PyUnicode_AsString(oenc);
+        if (enc == NULL)
+            return -1;
     }
     v = PySys_GetObject("ps1");
     if (v != NULL) {
         v = PyObject_Str(v);
         if (v == NULL)
             PyErr_Clear();
-        else if (PyUnicode_Check(v))
+        else if (PyUnicode_Check(v)) {
             ps1 = _PyUnicode_AsString(v);
+            if (ps1 == NULL) {
+                PyErr_Clear();
+                ps1 = "";
+            }
+        }
     }
     w = PySys_GetObject("ps2");
     if (w != NULL) {
         w = PyObject_Str(w);
         if (w == NULL)
             PyErr_Clear();
-        else if (PyUnicode_Check(w))
+        else if (PyUnicode_Check(w)) {
             ps2 = _PyUnicode_AsString(w);
+            if (ps2 == NULL) {
+                PyErr_Clear();
+                ps2 = "";
+            }
+        }
     }
     arena = PyArena_New();
     if (arena == NULL) {
@@ -1367,7 +1383,11 @@
     if (PyLong_Check(value))
         exitcode = (int)PyLong_AsLong(value);
     else {
+        PyObject *sys_stderr = PySys_GetObject("stderr");
+        if (sys_stderr != NULL)
+            PyObject_CallMethod(sys_stderr, "flush", NULL);
         PyObject_Print(value, stderr, Py_PRINT_RAW);
+        fflush(stderr);
         PySys_WriteStderr("\n");
         exitcode = 1;
     }


More information about the Python-checkins mailing list