[Python-checkins] r51748 - in python/branches/bcannon-objcap: Doc/lib/libdecimal.tex Doc/lib/libhashlib.tex Doc/lib/libstdtypes.tex Doc/lib/libunittest.tex Doc/ref/ref3.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew25.tex Lib/SimpleXMLRPCServer.py Lib/bsddb/test/test_basics.py Lib/decimal.py Lib/doctest.py Lib/genericpath.py Lib/pdb.py Lib/test/string_tests.py Lib/test/test_codecencodings_cn.py Lib/test/test_contextlib.py Lib/test/test_decimal.py Lib/test/test_fcntl.py Lib/test/test_genericpath.py Lib/test/test_grammar.py Lib/test/test_itertools.py Lib/test/test_multibytecodec.py Lib/test/test_mutants.py Lib/test/test_tempfile.py Lib/test/test_tokenize.py Misc/NEWS Misc/Vim/vimrc Modules/_cursesmodule.c Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Modules/itertoolsmodule.c Objects/dictobject.c Objects/intobject.c Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c Python/ast.c Python/bltinmodule.c Python/import.c Tools/pybench/pybench.py configure configure.in

brett.cannon python-checkins at python.org
Tue Sep 5 19:47:09 CEST 2006


Author: brett.cannon
Date: Tue Sep  5 19:47:00 2006
New Revision: 51748

Modified:
   python/branches/bcannon-objcap/   (props changed)
   python/branches/bcannon-objcap/Doc/lib/libdecimal.tex
   python/branches/bcannon-objcap/Doc/lib/libhashlib.tex
   python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex
   python/branches/bcannon-objcap/Doc/lib/libunittest.tex
   python/branches/bcannon-objcap/Doc/ref/ref3.tex
   python/branches/bcannon-objcap/Doc/tut/tut.tex
   python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex
   python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py
   python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py
   python/branches/bcannon-objcap/Lib/decimal.py
   python/branches/bcannon-objcap/Lib/doctest.py
   python/branches/bcannon-objcap/Lib/genericpath.py   (contents, props changed)
   python/branches/bcannon-objcap/Lib/pdb.py
   python/branches/bcannon-objcap/Lib/test/string_tests.py
   python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py
   python/branches/bcannon-objcap/Lib/test/test_contextlib.py
   python/branches/bcannon-objcap/Lib/test/test_decimal.py
   python/branches/bcannon-objcap/Lib/test/test_fcntl.py
   python/branches/bcannon-objcap/Lib/test/test_genericpath.py   (props changed)
   python/branches/bcannon-objcap/Lib/test/test_grammar.py
   python/branches/bcannon-objcap/Lib/test/test_itertools.py
   python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py
   python/branches/bcannon-objcap/Lib/test/test_mutants.py
   python/branches/bcannon-objcap/Lib/test/test_tempfile.py
   python/branches/bcannon-objcap/Lib/test/test_tokenize.py
   python/branches/bcannon-objcap/Misc/NEWS
   python/branches/bcannon-objcap/Misc/Vim/vimrc
   python/branches/bcannon-objcap/Modules/_cursesmodule.c
   python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c
   python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c
   python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h
   python/branches/bcannon-objcap/Modules/itertoolsmodule.c
   python/branches/bcannon-objcap/Objects/dictobject.c
   python/branches/bcannon-objcap/Objects/intobject.c
   python/branches/bcannon-objcap/Objects/stringlib/partition.h
   python/branches/bcannon-objcap/Objects/stringobject.c
   python/branches/bcannon-objcap/Objects/unicodeobject.c
   python/branches/bcannon-objcap/Python/ast.c
   python/branches/bcannon-objcap/Python/bltinmodule.c
   python/branches/bcannon-objcap/Python/import.c
   python/branches/bcannon-objcap/Tools/pybench/pybench.py
   python/branches/bcannon-objcap/configure
   python/branches/bcannon-objcap/configure.in
Log:
Merged revisions 51634-51747 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk



Modified: python/branches/bcannon-objcap/Doc/lib/libdecimal.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/lib/libdecimal.tex	(original)
+++ python/branches/bcannon-objcap/Doc/lib/libdecimal.tex	Tue Sep  5 19:47:00 2006
@@ -435,36 +435,37 @@
 the \function{getcontext()} and \function{setcontext()} functions:
 
 \begin{funcdesc}{getcontext}{}
-  Return the current context for the active thread.                                          
+  Return the current context for the active thread.
 \end{funcdesc}            
 
 \begin{funcdesc}{setcontext}{c}
-  Set the current context for the active thread to \var{c}.                                          
+  Set the current context for the active thread to \var{c}.
 \end{funcdesc}  
 
 Beginning with Python 2.5, you can also use the \keyword{with} statement
-to temporarily change the active context. For example the following code
-increases the current decimal precision by 2 places, performs a
-calculation, and then automatically restores the previous context:
+and the \function{localcontext()} function to temporarily change the
+active context.
 
-\begin{verbatim}
-from __future__ import with_statement
-import decimal
-
-with decimal.getcontext() as ctx:
-    ctx.prec += 2   # add 2 more digits of precision
-    calculate_something()
+\begin{funcdesc}{localcontext}{\optional{c}}
+  Return a context manager that will set the current context for
+  the active thread to a copy of \var{c} on entry to the with-statement
+  and restore the previous context when exiting the with-statement. If
+  no context is specified, a copy of the current context is used.
+  \versionadded{2.5}
+
+  For example, the following code sets the current decimal precision
+  to 42 places, performs a calculation, and then automatically restores
+  the previous context:
+\begin{verbatim}
+    from __future__ import with_statement
+    from decimal import localcontext
+
+    with localcontext() as ctx:
+        ctx.prec = 42   # Perform a high precision calculation
+        s = calculate_something()
+    s = +s  # Round the final result back to the default precision
 \end{verbatim}
-
-The context that's active in the body of the \keyword{with} statement is
-a \emph{copy} of the context you provided to the \keyword{with}
-statement, so modifying its attributes doesn't affect anything except
-that temporary copy.
-
-You can use any decimal context in a \keyword{with} statement, but if
-you just want to make a temporary change to some aspect of the current
-context, it's easiest to just use \function{getcontext()} as shown
-above.
+\end{funcdesc}
 
 New contexts can also be created using the \class{Context} constructor
 described below. In addition, the module provides three pre-made

Modified: python/branches/bcannon-objcap/Doc/lib/libhashlib.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/lib/libhashlib.tex	(original)
+++ python/branches/bcannon-objcap/Doc/lib/libhashlib.tex	Tue Sep  5 19:47:00 2006
@@ -86,8 +86,8 @@
 
 \begin{methoddesc}[hash]{digest}{}
 Return the digest of the strings passed to the \method{update()}
-method so far.  This is a 16-byte string which may contain
-non-\ASCII{} characters, including null bytes.
+method so far.  This is a string of \member{digest_size} bytes which may
+contain non-\ASCII{} characters, including null bytes.
 \end{methoddesc}
 
 \begin{methoddesc}[hash]{hexdigest}{}

Modified: python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex	(original)
+++ python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex	Tue Sep  5 19:47:00 2006
@@ -771,8 +771,8 @@
 Split the string at the last occurrence of \var{sep}, and return
 a 3-tuple containing the part before the separator, the separator
 itself, and the part after the separator.  If the separator is not
-found, return a 3-tuple containing the string itself, followed by
-two empty strings.
+found, return a 3-tuple containing two empty strings, followed by
+the string itself.
 \versionadded{2.5}
 \end{methoddesc}
 
@@ -1410,15 +1410,15 @@
           {(1)}
   \lineiii{\var{a}.clear()}{remove all items from \code{a}}{}
   \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{}
-  \lineiii{\var{a}.has_key(\var{k})}
+  \lineiii{\var{k} in \var{a}}
           {\code{True} if \var{a} has a key \var{k}, else \code{False}}
-          {}
-  \lineiii{\var{k} \code{in} \var{a}}
-          {Equivalent to \var{a}.has_key(\var{k})}
           {(2)}
   \lineiii{\var{k} not in \var{a}}
-          {Equivalent to \code{not} \var{a}.has_key(\var{k})}
+          {Equivalent to \code{not} \var{k} in \var{a}}
           {(2)}
+  \lineiii{\var{a}.has_key(\var{k})}
+          {Equivalent to \var{k} \code{in} \var{a}, use that form in new code}
+          {}
   \lineiii{\var{a}.items()}
           {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs}
           {(3)}

Modified: python/branches/bcannon-objcap/Doc/lib/libunittest.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/lib/libunittest.tex	(original)
+++ python/branches/bcannon-objcap/Doc/lib/libunittest.tex	Tue Sep  5 19:47:00 2006
@@ -212,8 +212,8 @@
 
 class DefaultWidgetSizeTestCase(unittest.TestCase):
     def runTest(self):
-        widget = Widget("The widget")
-        self.failUnless(widget.size() == (50,50), 'incorrect default size')
+        widget = Widget('The widget')
+        self.assertEqual(widget.size(), (50, 50), 'incorrect default size')
 \end{verbatim}
 
 Note that in order to test something, we use the one of the
@@ -247,7 +247,7 @@
 
 class SimpleWidgetTestCase(unittest.TestCase):
     def setUp(self):
-        self.widget = Widget("The widget")
+        self.widget = Widget('The widget')
 
 class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
     def runTest(self):
@@ -273,7 +273,7 @@
 
 class SimpleWidgetTestCase(unittest.TestCase):
     def setUp(self):
-        self.widget = Widget("The widget")
+        self.widget = Widget('The widget')
 
     def tearDown(self):
         self.widget.dispose()
@@ -298,7 +298,7 @@
 
 class WidgetTestCase(unittest.TestCase):
     def setUp(self):
-        self.widget = Widget("The widget")
+        self.widget = Widget('The widget')
 
     def tearDown(self):
         self.widget.dispose()
@@ -322,8 +322,8 @@
 passing the method name in the constructor:
 
 \begin{verbatim}
-defaultSizeTestCase = WidgetTestCase("testDefaultSize")
-resizeTestCase = WidgetTestCase("testResize")
+defaultSizeTestCase = WidgetTestCase('testDefaultSize')
+resizeTestCase = WidgetTestCase('testResize')
 \end{verbatim}
 
 Test case instances are grouped together according to the features
@@ -333,8 +333,8 @@
 
 \begin{verbatim}
 widgetTestSuite = unittest.TestSuite()
-widgetTestSuite.addTest(WidgetTestCase("testDefaultSize"))
-widgetTestSuite.addTest(WidgetTestCase("testResize"))
+widgetTestSuite.addTest(WidgetTestCase('testDefaultSize'))
+widgetTestSuite.addTest(WidgetTestCase('testResize'))
 \end{verbatim}
 
 For the ease of running tests, as we will see later, it is a good
@@ -344,8 +344,8 @@
 \begin{verbatim}
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(WidgetTestCase("testDefaultSize"))
-    suite.addTest(WidgetTestCase("testResize"))
+    suite.addTest(WidgetTestCase('testDefaultSize'))
+    suite.addTest(WidgetTestCase('testResize'))
     return suite
 \end{verbatim}
 
@@ -353,7 +353,7 @@
 
 \begin{verbatim}
 def suite():
-    tests = ["testDefaultSize", "testResize"]
+    tests = ['testDefaultSize', 'testResize']
 
     return unittest.TestSuite(map(WidgetTestCase, tests))
 \end{verbatim}
@@ -462,7 +462,7 @@
 \subsection{Classes and functions
             \label{unittest-contents}}
 
-\begin{classdesc}{TestCase}{}
+\begin{classdesc}{TestCase}{\optional{methodName}}
   Instances of the \class{TestCase} class represent the smallest
   testable units in the \module{unittest} universe.  This class is
   intended to be used as a base class, with specific tests being
@@ -470,6 +470,23 @@
   interface needed by the test runner to allow it to drive the
   test, and methods that the test code can use to check for and
   report various kinds of failure.
+  
+  Each instance of \class{TestCase} will run a single test method:
+  the method named \var{methodName}.  If you remember, we had an
+  earlier example that went something like this:
+  
+  \begin{verbatim}
+  def suite():
+      suite = unittest.TestSuite()
+      suite.addTest(WidgetTestCase('testDefaultSize'))
+      suite.addTest(WidgetTestCase('testResize'))
+      return suite
+  \end{verbatim}
+  
+  Here, we create two instances of \class{WidgetTestCase}, each of
+  which runs a single test.
+  
+  \var{methodName} defaults to \code{'runTest'}.
 \end{classdesc}
 
 \begin{classdesc}{FunctionTestCase}{testFunc\optional{,
@@ -502,6 +519,11 @@
   subclass.
 \end{classdesc}
 
+\begin{classdesc}{TestResult}{}
+  This class is used to compile information about which tests have succeeded
+  and which have failed.
+\end{classdesc}
+
 \begin{datadesc}{defaultTestLoader}
   Instance of the \class{TestLoader} class intended to be shared.  If no
   customization of the \class{TestLoader} is needed, this instance can
@@ -574,8 +596,9 @@
 \begin{methoddesc}[TestCase]{run}{\optional{result}}
   Run the test, collecting the result into the test result object
   passed as \var{result}.  If \var{result} is omitted or \constant{None},
-  a temporary result object is created and used, but is not made
-  available to the caller.
+  a temporary result object is created (by calling the
+  \method{defaultTestCase()} method) and used; this result object is not
+  returned to \method{run()}'s caller.
   
   The same effect may be had by simply calling the \class{TestCase}
   instance.
@@ -684,8 +707,13 @@
 \end{methoddesc}
 
 \begin{methoddesc}[TestCase]{defaultTestResult}{}
-  Return the default type of test result object to be used to run this
-  test.
+  Return an instance of the test result class that should be used
+  for this test case class (if no other result instance is provided
+  to the \method{run()} method).
+  
+  For \class{TestCase} instances, this will always be an instance of
+  \class{TestResult};  subclasses of \class{TestCase} should
+  override this as necessary.
 \end{methoddesc}
 
 \begin{methoddesc}[TestCase]{id}{}
@@ -761,26 +789,20 @@
 tests for reporting purposes; a \class{TestResult} instance is
 returned by the \method{TestRunner.run()} method for this purpose.
 
-Each instance holds the total number of tests run, and collections of
-failures and errors that occurred among those test runs.  The
-collections contain tuples of \code{(\var{testcase},
-\var{traceback})}, where \var{traceback} is a string containing a
-formatted version of the traceback for the exception.
-
 \class{TestResult} instances have the following attributes that will
 be of interest when inspecting the results of running a set of tests:
 
 \begin{memberdesc}[TestResult]{errors}
   A list containing 2-tuples of \class{TestCase} instances and
-  formatted tracebacks. Each tuple represents a test which raised an
-  unexpected exception.
+  strings holding formatted tracebacks. Each tuple represents a test which
+  raised an unexpected exception.
   \versionchanged[Contains formatted tracebacks instead of
                   \function{sys.exc_info()} results]{2.2}
 \end{memberdesc}
 
 \begin{memberdesc}[TestResult]{failures}
-  A list containing 2-tuples of \class{TestCase} instances and
-  formatted tracebacks. Each tuple represents a test where a failure
+  A list containing 2-tuples of \class{TestCase} instances and strings
+  holding formatted tracebacks. Each tuple represents a test where a failure
   was explicitly signalled using the \method{TestCase.fail*()} or
   \method{TestCase.assert*()} methods.
   \versionchanged[Contains formatted tracebacks instead of
@@ -817,17 +839,25 @@
 
 \begin{methoddesc}[TestResult]{startTest}{test}
   Called when the test case \var{test} is about to be run.
+  
+  The default implementation simply increments the instance's
+  \code{testsRun} counter.
 \end{methoddesc}
 
 \begin{methoddesc}[TestResult]{stopTest}{test}
-  Called when the test case \var{test} has been executed, regardless
+  Called after the test case \var{test} has been executed, regardless
   of the outcome.
+  
+  The default implementation does nothing.
 \end{methoddesc}
 
 \begin{methoddesc}[TestResult]{addError}{test, err}
   Called when the test case \var{test} raises an unexpected exception
   \var{err} is a tuple of the form returned by \function{sys.exc_info()}:
   \code{(\var{type}, \var{value}, \var{traceback})}.
+  
+  The default implementation appends \code{(\var{test}, \var{err})} to
+  the instance's \code{errors} attribute.
 \end{methoddesc}
 
 \begin{methoddesc}[TestResult]{addFailure}{test, err}
@@ -835,10 +865,15 @@
   \var{err} is a tuple of the form returned by
   \function{sys.exc_info()}:  \code{(\var{type}, \var{value},
   \var{traceback})}.
+  
+  The default implementation appends \code{(\var{test}, \var{err})} to
+  the instance's \code{failures} attribute.
 \end{methoddesc}
 
 \begin{methoddesc}[TestResult]{addSuccess}{test}
   Called when the test case \var{test} succeeds.
+  
+  The default implementation does nothing.
 \end{methoddesc}
 
 
@@ -878,9 +913,12 @@
   Return a suite of all tests cases given a string specifier.
 
   The specifier \var{name} is a ``dotted name'' that may resolve
-  either to a module, a test case class, a \class{TestSuite} instance,
-  a test method within a test case class, or a callable object which
-  returns a \class{TestCase} or \class{TestSuite} instance.
+  either to a module, a test case class, a test method within a test
+  case class, a \class{TestSuite} instance, or a callable object which
+  returns a \class{TestCase} or \class{TestSuite} instance.  These checks
+  are applied in the order listed here; that is, a method on a possible
+  test case class will be picked up as ``a test method within a test
+  case class'', rather than ``a callable object''.
 
   For example, if you have a module \module{SampleTests} containing a
   \class{TestCase}-derived class \class{SampleTestCase} with three test
@@ -905,7 +943,7 @@
 
 \begin{methoddesc}[TestLoader]{getTestCaseNames}{testCaseClass}
   Return a sorted sequence of method names found within
-  \var{testCaseClass}.
+  \var{testCaseClass}; this should be a subclass of \class{TestCase}.
 \end{methoddesc}
 
 

Modified: python/branches/bcannon-objcap/Doc/ref/ref3.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/ref/ref3.tex	(original)
+++ python/branches/bcannon-objcap/Doc/ref/ref3.tex	Tue Sep  5 19:47:00 2006
@@ -762,7 +762,7 @@
 (call it~\class{C}) of the instance for which the attribute reference
 was initiated or one of its bases,
 it is transformed into a bound user-defined method object whose
-\member{im_class} attribute is~\class{C} whose \member{im_self} attribute
+\member{im_class} attribute is~\class{C} and whose \member{im_self} attribute
 is the instance. Static method and class method objects are also
 transformed, as if they had been retrieved from class~\class{C};
 see above under ``Classes''. See section~\ref{descriptors} for

Modified: python/branches/bcannon-objcap/Doc/tut/tut.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/tut/tut.tex	(original)
+++ python/branches/bcannon-objcap/Doc/tut/tut.tex	Tue Sep  5 19:47:00 2006
@@ -4381,7 +4381,7 @@
 makes use of private variables of the base class possible.)
 
 Notice that code passed to \code{exec}, \code{eval()} or
-\code{evalfile()} does not consider the classname of the invoking 
+\code{execfile()} does not consider the classname of the invoking 
 class to be the current class; this is similar to the effect of the 
 \code{global} statement, the effect of which is likewise restricted to 
 code that is byte-compiled together.  The same restriction applies to

Modified: python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex
==============================================================================
--- python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex	(original)
+++ python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex	Tue Sep  5 19:47:00 2006
@@ -683,22 +683,22 @@
 The lock is acquired before the block is executed and always released once 
 the block is complete.
 
-The \module{decimal} module's contexts, which encapsulate the desired
-precision and rounding characteristics for computations, provide a 
-\method{context_manager()} method for getting a context manager:
+The new \function{localcontext()} function in the \module{decimal} module
+makes it easy to save and restore the current decimal context, which
+encapsulates the desired precision and rounding characteristics for
+computations:
 
 \begin{verbatim}
-import decimal
+from decimal import Decimal, Context, localcontext
 
 # Displays with default precision of 28 digits
-v1 = decimal.Decimal('578')
-print v1.sqrt()
+v = Decimal('578')
+print v.sqrt()
 
-ctx = decimal.Context(prec=16) 
-with ctx.context_manager():
+with localcontext(Context(prec=16)):
     # All code in this block uses a precision of 16 digits.
     # The original context is restored on exiting the block.
-    print v1.sqrt()
+    print v.sqrt()
 \end{verbatim}
 
 \subsection{Writing Context Managers\label{context-managers}}
@@ -1115,12 +1115,14 @@
 \begin{verbatim}
 >>> ('http://www.python.org').partition('://')
 ('http', '://', 'www.python.org')
->>> (u'Subject: a quick question').partition(':')
-(u'Subject', u':', u' a quick question')
 >>> ('file:/usr/share/doc/index.html').partition('://')
 ('file:/usr/share/doc/index.html', '', '')
+>>> (u'Subject: a quick question').partition(':')
+(u'Subject', u':', u' a quick question')
 >>> 'www.python.org'.rpartition('.')
 ('www.python', '.', 'org')
+>>> 'www.python.org'.rpartition(':')
+('', '', 'www.python.org')
 \end{verbatim}
 
 (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.)

Modified: python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py	(original)
+++ python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py	Tue Sep  5 19:47:00 2006
@@ -264,8 +264,9 @@
                                        encoding=self.encoding)
         except:
             # report exception back to server
+            exc_type, exc_value, exc_tb = sys.exc_info()
             response = xmlrpclib.dumps(
-                xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)),
+                xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
                 encoding=self.encoding, allow_none=self.allow_none,
                 )
 
@@ -364,9 +365,10 @@
                      'faultString' : fault.faultString}
                     )
             except:
+                exc_type, exc_value, exc_tb = sys.exc_info()
                 results.append(
                     {'faultCode' : 1,
-                     'faultString' : "%s:%s" % (sys.exc_type, sys.exc_value)}
+                     'faultString' : "%s:%s" % (exc_type, exc_value)}
                     )
         return results
 

Modified: python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py	(original)
+++ python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py	Tue Sep  5 19:47:00 2006
@@ -697,7 +697,7 @@
         for log in logs:
             if verbose:
                 print 'log file: ' + log
-        if db.version >= (4,2):
+        if db.version() >= (4,2):
             logs = self.env.log_archive(db.DB_ARCH_REMOVE)
             assert not logs
 

Modified: python/branches/bcannon-objcap/Lib/decimal.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/decimal.py	(original)
+++ python/branches/bcannon-objcap/Lib/decimal.py	Tue Sep  5 19:47:00 2006
@@ -131,7 +131,7 @@
     'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN',
 
     # Functions for manipulating contexts
-    'setcontext', 'getcontext'
+    'setcontext', 'getcontext', 'localcontext'
 ]
 
 import copy as _copy
@@ -458,6 +458,49 @@
 
     del threading, local        # Don't contaminate the namespace
 
+def localcontext(ctx=None):
+    """Return a context manager for a copy of the supplied context
+
+    Uses a copy of the current context if no context is specified
+    The returned context manager creates a local decimal context
+    in a with statement:
+        def sin(x):
+             with localcontext() as ctx:
+                 ctx.prec += 2
+                 # Rest of sin calculation algorithm
+                 # uses a precision 2 greater than normal
+             return +s # Convert result to normal precision
+
+         def sin(x):
+             with localcontext(ExtendedContext):
+                 # Rest of sin calculation algorithm
+                 # uses the Extended Context from the
+                 # General Decimal Arithmetic Specification
+             return +s # Convert result to normal context
+
+    """
+    # The string below can't be included in the docstring until Python 2.6
+    # as the doctest module doesn't understand __future__ statements
+    """
+    >>> from __future__ import with_statement
+    >>> print getcontext().prec
+    28
+    >>> with localcontext():
+    ...     ctx = getcontext()
+    ...     ctx.prec() += 2
+    ...     print ctx.prec
+    ...
+    30
+    >>> with localcontext(ExtendedContext):
+    ...     print getcontext().prec
+    ...
+    9
+    >>> print getcontext().prec
+    28
+    """
+    if ctx is None: ctx = getcontext()
+    return _ContextManager(ctx)
+
 
 ##### Decimal class ###########################################
 
@@ -2173,23 +2216,14 @@
 
 del name, val, globalname, rounding_functions
 
-class ContextManager(object):
-    """Helper class to simplify Context management.
-
-    Sample usage:
-
-    with decimal.ExtendedContext:
-        s = ...
-    return +s # Convert result to normal precision
-
-    with decimal.getcontext() as ctx:
-        ctx.prec += 2
-        s = ...
-    return +s
+class _ContextManager(object):
+    """Context manager class to support localcontext().
 
+      Sets a copy of the supplied context in __enter__() and restores
+      the previous decimal context in __exit__()
     """
     def __init__(self, new_context):
-        self.new_context = new_context
+        self.new_context = new_context.copy()
     def __enter__(self):
         self.saved_context = getcontext()
         setcontext(self.new_context)
@@ -2248,9 +2282,6 @@
         s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']')
         return ', '.join(s) + ')'
 
-    def get_manager(self):
-        return ContextManager(self.copy())
-
     def clear_flags(self):
         """Reset all flags to zero"""
         for flag in self.flags:

Modified: python/branches/bcannon-objcap/Lib/doctest.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/doctest.py	(original)
+++ python/branches/bcannon-objcap/Lib/doctest.py	Tue Sep  5 19:47:00 2006
@@ -1561,7 +1561,7 @@
 
     - test: the DocTest object being run
 
-    - excample: the Example object that failed
+    - example: the Example object that failed
 
     - got: the actual output
     """
@@ -1580,7 +1580,7 @@
 
     - test: the DocTest object being run
 
-    - excample: the Example object that failed
+    - example: the Example object that failed
 
     - exc_info: the exception info
     """

Modified: python/branches/bcannon-objcap/Lib/genericpath.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/genericpath.py	(original)
+++ python/branches/bcannon-objcap/Lib/genericpath.py	Tue Sep  5 19:47:00 2006
@@ -75,4 +75,3 @@
         if s1[i] != s2[i]:
             return s1[:i]
     return s1[:n]
-

Modified: python/branches/bcannon-objcap/Lib/pdb.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/pdb.py	(original)
+++ python/branches/bcannon-objcap/Lib/pdb.py	Tue Sep  5 19:47:00 2006
@@ -23,7 +23,7 @@
            "post_mortem", "help"]
 
 def find_function(funcname, filename):
-    cre = re.compile(r'def\s+%s\s*[(]' % funcname)
+    cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
     try:
         fp = open(filename)
     except IOError:

Modified: python/branches/bcannon-objcap/Lib/test/string_tests.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/string_tests.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/string_tests.py	Tue Sep  5 19:47:00 2006
@@ -1069,7 +1069,7 @@
         # from raymond's original specification
         S = 'http://www.python.org'
         self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://')
-        self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?')
+        self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?')
         self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://')
         self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org')
 

Modified: python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py	Tue Sep  5 19:47:00 2006
@@ -32,6 +32,7 @@
         ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
         ("abc\x80\x80\xc1\xc4", "ignore",  u"abc\u804a"),
         ("\x83\x34\x83\x31", "strict", None),
+        (u"\u30fb", "strict", None),
     )
 
 class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -45,6 +46,7 @@
         ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
         ("abc\x80\x80\xc1\xc4", "ignore",  u"abc\u804a"),
         ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"),
+        (u"\u30fb", "strict", "\x819\xa79"),
     )
     has_iso10646 = True
 

Modified: python/branches/bcannon-objcap/Lib/test/test_contextlib.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_contextlib.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_contextlib.py	Tue Sep  5 19:47:00 2006
@@ -330,32 +330,6 @@
                 return True
         self.boilerPlate(lock, locked)
 
-class DecimalContextTestCase(unittest.TestCase):
-
-    # XXX Somebody should write more thorough tests for this
-
-    def testBasic(self):
-        ctx = decimal.getcontext()
-        orig_context = ctx.copy()
-        try:
-            ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
-            with decimal.ExtendedContext.get_manager():
-                self.assertEqual(decimal.getcontext().prec,
-                                 decimal.ExtendedContext.prec)
-            self.assertEqual(decimal.getcontext().prec, save_prec)
-            try:
-                with decimal.ExtendedContext.get_manager():
-                    self.assertEqual(decimal.getcontext().prec,
-                                     decimal.ExtendedContext.prec)
-                    1/0
-            except ZeroDivisionError:
-                self.assertEqual(decimal.getcontext().prec, save_prec)
-            else:
-                self.fail("Didn't raise ZeroDivisionError")
-        finally:
-            decimal.setcontext(orig_context)
-
-
 # This is needed to make the test actually run under regrtest.py!
 def test_main():
     run_suite(

Modified: python/branches/bcannon-objcap/Lib/test/test_decimal.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_decimal.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_decimal.py	Tue Sep  5 19:47:00 2006
@@ -23,6 +23,7 @@
 you're working through IDLE, you can import this test module and call test_main()
 with the corresponding argument.
 """
+from __future__ import with_statement
 
 import unittest
 import glob
@@ -1064,6 +1065,32 @@
         self.assertNotEqual(id(c.flags), id(d.flags))
         self.assertNotEqual(id(c.traps), id(d.traps))
 
+class WithStatementTest(unittest.TestCase):
+    # Can't do these as docstrings until Python 2.6
+    # as doctest can't handle __future__ statements
+
+    def test_localcontext(self):
+        # Use a copy of the current context in the block
+        orig_ctx = getcontext()
+        with localcontext() as enter_ctx:
+            set_ctx = getcontext()
+        final_ctx = getcontext()
+        self.assert_(orig_ctx is final_ctx, 'did not restore context correctly')
+        self.assert_(orig_ctx is not set_ctx, 'did not copy the context')
+        self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context')
+
+    def test_localcontextarg(self):
+        # Use a copy of the supplied context in the block
+        orig_ctx = getcontext()
+        new_ctx = Context(prec=42)
+        with localcontext(new_ctx) as enter_ctx:
+            set_ctx = getcontext()
+        final_ctx = getcontext()
+        self.assert_(orig_ctx is final_ctx, 'did not restore context correctly')
+        self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context')
+        self.assert_(new_ctx is not set_ctx, 'did not copy the context')
+        self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context')
+
 def test_main(arith=False, verbose=None):
     """ Execute the tests.
 
@@ -1084,6 +1111,7 @@
         DecimalPythonAPItests,
         ContextAPItests,
         DecimalTest,
+        WithStatementTest,
     ]
 
     try:

Modified: python/branches/bcannon-objcap/Lib/test/test_fcntl.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_fcntl.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_fcntl.py	Tue Sep  5 19:47:00 2006
@@ -25,7 +25,7 @@
                     'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
                     'freebsd6', 'freebsd7',
                     'bsdos2', 'bsdos3', 'bsdos4',
-                    'openbsd', 'openbsd2', 'openbsd3'):
+                    'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
     if struct.calcsize('l') == 8:
         off_t = 'l'
         pid_t = 'i'

Modified: python/branches/bcannon-objcap/Lib/test/test_grammar.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_grammar.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_grammar.py	Tue Sep  5 19:47:00 2006
@@ -825,6 +825,10 @@
 verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7])
 verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7])
 
+# Verify unpacking single element tuples in listcomp/genexp.
+vereq([x for x, in [(4,), (5,), (6,)]], [4, 5, 6])
+vereq(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9])
+
 # Test ifelse expressions in various cases
 def _checkeval(msg, ret):
     "helper to check that evaluation of expressions is done correctly"

Modified: python/branches/bcannon-objcap/Lib/test/test_itertools.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_itertools.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_itertools.py	Tue Sep  5 19:47:00 2006
@@ -371,6 +371,7 @@
 
         # test values of n
         self.assertRaises(TypeError, tee, 'abc', 'invalid')
+        self.assertRaises(ValueError, tee, [], -1)
         for n in xrange(5):
             result = tee('abc', n)
             self.assertEqual(type(result), tuple)

Modified: python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py	Tue Sep  5 19:47:00 2006
@@ -202,6 +202,12 @@
         uni = u':hu4:unit\xe9 de famille'
         self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
 
+    def test_iso2022_jp_g0(self):
+        self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+        for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
+            e = u'\u3406'.encode(encoding)
+            self.failIf(filter(lambda x: x >= '\x80', e))
+
 def test_main():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(Test_MultibyteCodec))

Modified: python/branches/bcannon-objcap/Lib/test/test_mutants.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_mutants.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_mutants.py	Tue Sep  5 19:47:00 2006
@@ -91,12 +91,17 @@
         self.hashcode = random.randrange(1000000000)
 
     def __hash__(self):
+        return 42
         return self.hashcode
 
     def __cmp__(self, other):
         maybe_mutate()   # The point of the test.
         return cmp(self.i, other.i)
 
+    def __eq__(self, other):
+        maybe_mutate()   # The point of the test.
+        return self.i == other.i
+
     def __repr__(self):
         return "Horrid(%d)" % self.i
 
@@ -132,7 +137,10 @@
     while dict1 and len(dict1) == len(dict2):
         if verbose:
             print ".",
-        c = cmp(dict1, dict2)
+        if random.random() < 0.5:
+            c = cmp(dict1, dict2)
+        else:
+            c = dict1 == dict2
     if verbose:
         print
 

Modified: python/branches/bcannon-objcap/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_tempfile.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_tempfile.py	Tue Sep  5 19:47:00 2006
@@ -27,7 +27,7 @@
 # number of files that can be opened at one time (see ulimit -n)
 if sys.platform == 'mac':
     TEST_FILES = 32
-elif sys.platform == 'openbsd3':
+elif sys.platform in ('openbsd3', 'openbsd4'):
     TEST_FILES = 48
 else:
     TEST_FILES = 100

Modified: python/branches/bcannon-objcap/Lib/test/test_tokenize.py
==============================================================================
--- python/branches/bcannon-objcap/Lib/test/test_tokenize.py	(original)
+++ python/branches/bcannon-objcap/Lib/test/test_tokenize.py	Tue Sep  5 19:47:00 2006
@@ -79,13 +79,16 @@
 
 """
 
-import os, glob, random
+import os, glob, random, time, sys
 from cStringIO import StringIO
 from test.test_support import (verbose, findfile, is_resource_enabled,
                                TestFailed)
 from tokenize import (tokenize, generate_tokens, untokenize, tok_name,
                       ENDMARKER, NUMBER, NAME, OP, STRING, COMMENT)
 
+# How much time in seconds can pass before we print a 'Still working' message.
+_PRINT_WORKING_MSG_INTERVAL = 5 * 60
+
 # Test roundtrip for `untokenize`.  `f` is a file path.  The source code in f
 # is tokenized, converted back to source code via tokenize.untokenize(),
 # and tokenized again from the latter.  The test fails if the second
@@ -164,6 +167,8 @@
     if verbose:
         print 'starting...'
 
+    next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
+
     # This displays the tokenization of tokenize_tests.py to stdout, and
     # regrtest.py checks that this equals the expected output (in the
     # test/output/ directory).
@@ -183,6 +188,12 @@
         testfiles = random.sample(testfiles, 10)
 
     for f in testfiles:
+        # Print still working message since this test can be really slow
+        if next_time <= time.time():
+            next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
+            print >>sys.__stdout__, '  test_main still working, be patient...'
+            sys.__stdout__.flush()
+
         test_roundtrip(f)
 
     # Test detecton of IndentationError.

Modified: python/branches/bcannon-objcap/Misc/NEWS
==============================================================================
--- python/branches/bcannon-objcap/Misc/NEWS	(original)
+++ python/branches/bcannon-objcap/Misc/NEWS	Tue Sep  5 19:47:00 2006
@@ -4,20 +4,36 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
-What's New in Python 2.6?
-=========================
+What's New in Python 2.6 alpha 1?
+=================================
 
 *Release date: XX-XXX-200X*
 
 Core and builtins
 -----------------
 
+- Overflow checking code in integer division ran afoul of new gcc
+  optimizations.  Changed to be more standard-conforming.
+
 - Patch #1542451: disallow continue anywhere under a finally.
 
+- Patch #1546288: fix seg fault in dict_equal due to ref counting bug.
+
+- The return tuple from str.rpartition(sep) is (tail, sep, head) where
+  head is the original string if sep was not found.
+
+- Bug #1520864: unpacking singleton tuples in list comprehensions and
+  generator expressions (x for x, in ... ) works again.  Fixing this problem
+  required changing the .pyc magic number.  This means that .pyc files
+  generated before 2.5c2 will be regenerated.
+
 
 Library
 -------
 
+- Patch #1550886: Fix decimal module context management implementation
+  to match the localcontext() example from PEP 343.
+
 - Bug #1541863: uuid.uuid1 failed to generate unique identifiers
   on systems with low clock resolution.
 
@@ -25,10 +41,23 @@
 Extension Modules
 -----------------
 
+- Bug #1548092: fix curses.tparm seg fault on invalid input.
+
+- Bug #1550714: fix SystemError from itertools.tee on negative value for n.
+
+- Fixed a few bugs on cjkcodecs:
+  - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly.
+  - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312
+    codepoints to conform the standard.
+  - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2
+    codepoints now.
 
 Tests
 -----
 
+- Fix bsddb test_basics.test06_Transactions to check the version
+  number properly.
+
 
 Documentation
 -------------
@@ -41,6 +70,8 @@
 Build
 -----
 
+- Patch #1540470, for OpenBSD 4.0.
+
 
 C API
 -----
@@ -129,7 +160,7 @@
 - The __repr__ method of a NULL ctypes.py_object() no longer raises
   an exception.
 
-- uuid.UUID now has a bytes_le attribute. This returns the UUID in 
+- uuid.UUID now has a bytes_le attribute. This returns the UUID in
   little-endian byte order for Windows. In addition, uuid.py gained some
   workarounds for clocks with low resolution, to stop the code yielding
   duplicate UUIDs.
@@ -288,7 +319,7 @@
 - Bug #1002398: The documentation for os.path.sameopenfile now correctly
   refers to file descriptors, not file objects.
 
-- The renaming of the xml package to xmlcore, and the import hackery done 
+- The renaming of the xml package to xmlcore, and the import hackery done
   to make it appear at both names, has been removed.  Bug #1511497,
   #1513611, and probably others.
 

Modified: python/branches/bcannon-objcap/Misc/Vim/vimrc
==============================================================================
--- python/branches/bcannon-objcap/Misc/Vim/vimrc	(original)
+++ python/branches/bcannon-objcap/Misc/Vim/vimrc	Tue Sep  5 19:47:00 2006
@@ -19,9 +19,10 @@
 " Number of spaces to use for an indent.
 " This will affect Ctrl-T and 'autoindent'.
 " Python: 4 spaces
-" C: tab (8 spaces)
+" C: 8 spaces (pre-existing files) or 4 spaces (new files)
 au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
-au BufRead,BufNewFile *.c,*.h set shiftwidth=4
+au BufRead *.c,*.h set shiftwidth=8
+au BufNewFile *.c,*.h set shiftwidth=4
 
 " Number of spaces that a pre-existing tab is equal to.
 " For the amount of space used for a new tab use shiftwidth.

Modified: python/branches/bcannon-objcap/Modules/_cursesmodule.c
==============================================================================
--- python/branches/bcannon-objcap/Modules/_cursesmodule.c	(original)
+++ python/branches/bcannon-objcap/Modules/_cursesmodule.c	Tue Sep  5 19:47:00 2006
@@ -2334,6 +2334,10 @@
 	}
 
 	result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
+	if (!result) {
+		PyErr_SetString(PyCursesError, "tparm() returned NULL");
+  		return NULL;
+	}
 
 	return PyString_FromString(result);
 }

Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c
==============================================================================
--- python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c	(original)
+++ python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c	Tue Sep  5 19:47:00 2006
@@ -15,14 +15,26 @@
 #undef hz
 #endif
 
-#define GBK_PREDECODE(dc1, dc2, assi) \
+/* GBK and GB2312 map differently in few codepoints that are listed below:
+ *
+ *		gb2312				gbk
+ * A1A4		U+30FB KATAKANA MIDDLE DOT	U+00B7 MIDDLE DOT
+ * A1AA		U+2015 HORIZONTAL BAR		U+2014 EM DASH
+ * A844		undefined			U+2015 HORIZONTAL BAR
+ */
+
+#define GBK_DECODE(dc1, dc2, assi) \
 	if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \
 	else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \
-	else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7;
-#define GBK_PREENCODE(code, assi) \
+	else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \
+	else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \
+	else TRYMAP_DEC(gbkext, assi, dc1, dc2);
+
+#define GBK_ENCODE(code, assi) \
 	if ((code) == 0x2014) (assi) = 0xa1aa; \
 	else if ((code) == 0x2015) (assi) = 0xa844; \
-	else if ((code) == 0x00b7) (assi) = 0xa1a4;
+	else if ((code) == 0x00b7) (assi) = 0xa1a4; \
+	else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code));
 
 /*
  * GB2312 codec
@@ -99,8 +111,7 @@
 
 		REQUIRE_OUTBUF(2)
 
-		GBK_PREENCODE(c, code)
-		else TRYMAP_ENC(gbcommon, code, c);
+		GBK_ENCODE(c, code)
 		else return 1;
 
 		OUT1((code >> 8) | 0x80)
@@ -129,9 +140,7 @@
 
 		REQUIRE_INBUF(2)
 
-		GBK_PREDECODE(c, IN2, **outbuf)
-		else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80);
-		else TRYMAP_DEC(gbkext, **outbuf, c, IN2);
+		GBK_DECODE(c, IN2, **outbuf)
 		else return 2;
 
 		NEXT(2, 1)
@@ -187,9 +196,7 @@
 
 		REQUIRE_OUTBUF(2)
 
-		GBK_PREENCODE(c, code)
-		else TRYMAP_ENC(gbcommon, code, c);
-		else TRYMAP_ENC(gb18030ext, code, c);
+		GBK_ENCODE(c, code)
 		else {
 			const struct _gb18030_to_unibmp_ranges *utrrange;
 
@@ -287,9 +294,7 @@
 			return 4;
 		}
 
-		GBK_PREDECODE(c, c2, **outbuf)
-		else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80);
-		else TRYMAP_DEC(gbkext, **outbuf, c, c2);
+		GBK_DECODE(c, c2, **outbuf)
 		else TRYMAP_DEC(gb18030ext, **outbuf, c, c2);
 		else return 2;
 

Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c
==============================================================================
--- python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c	(original)
+++ python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c	Tue Sep  5 19:47:00 2006
@@ -854,7 +854,7 @@
 	if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL)
 		return coded;
 	else if (coded & 0x8000)
-		return coded;
+		return coded & 0x7fff;
 	else
 		return MAP_UNMAPPABLE;
 }
@@ -901,7 +901,7 @@
 	if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL)
 		return coded;
 	else if (coded & 0x8000)
-		return coded;
+		return coded & 0x7fff;
 	else
 		return MAP_UNMAPPABLE;
 }
@@ -992,7 +992,10 @@
 
 /*-*- registry tables -*-*/
 
-#define REGISTRY_KSX1001	{ CHARSET_KSX1001, 1, 2,		\
+#define REGISTRY_KSX1001_G0	{ CHARSET_KSX1001, 0, 2,		\
+				  ksx1001_init,				\
+				  ksx1001_decoder, ksx1001_encoder }
+#define REGISTRY_KSX1001_G1	{ CHARSET_KSX1001, 1, 2,		\
 				  ksx1001_init,				\
 				  ksx1001_decoder, ksx1001_encoder }
 #define REGISTRY_JISX0201_R	{ CHARSET_JISX0201_R, 0, 1,		\
@@ -1034,7 +1037,7 @@
 				  jisx0213_init,			\
 				  jisx0213_2004_2_decoder,		\
 				  jisx0213_2004_2_encoder }
-#define REGISTRY_GB2312		{ CHARSET_GB2312, 1, 2,			\
+#define REGISTRY_GB2312		{ CHARSET_GB2312, 0, 2,			\
 				  gb2312_init,				\
 				  gb2312_decoder, gb2312_encoder }
 #define REGISTRY_CNS11643_1	{ CHARSET_CNS11643_1, 1, 2,		\
@@ -1054,7 +1057,7 @@
 	};
 
 static const struct iso2022_designation iso2022_kr_designations[] = {
-	REGISTRY_KSX1001, REGISTRY_SENTINEL
+	REGISTRY_KSX1001_G1, REGISTRY_SENTINEL
 };
 CONFIGDEF(kr, 0)
 
@@ -1071,7 +1074,7 @@
 CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT)
 
 static const struct iso2022_designation iso2022_jp_2_designations[] = {
-	REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001,
+	REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0,
 	REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
 	REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL
 };

Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h
==============================================================================
--- python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h	(original)
+++ python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h	Tue Sep  5 19:47:00 2006
@@ -159,29 +159,32 @@
 #endif
 
 #define _TRYMAP_ENC(m, assi, val)				\
-	if ((m)->map != NULL && (val) >= (m)->bottom &&		\
+	((m)->map != NULL && (val) >= (m)->bottom &&		\
 	    (val)<= (m)->top && ((assi) = (m)->map[(val) -	\
 	    (m)->bottom]) != NOCHAR)
-#define TRYMAP_ENC(charset, assi, uni)				\
+#define TRYMAP_ENC_COND(charset, assi, uni)			\
 	_TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff)
+#define TRYMAP_ENC(charset, assi, uni)				\
+	if TRYMAP_ENC_COND(charset, assi, uni)
+
 #define _TRYMAP_DEC(m, assi, val)				\
-	if ((m)->map != NULL && (val) >= (m)->bottom &&		\
+	((m)->map != NULL && (val) >= (m)->bottom &&		\
 	    (val)<= (m)->top && ((assi) = (m)->map[(val) -	\
 	    (m)->bottom]) != UNIINV)
 #define TRYMAP_DEC(charset, assi, c1, c2)			\
-	_TRYMAP_DEC(&charset##_decmap[c1], assi, c2)
+	if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2)
 
 #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val)	\
-	if ((m)->map != NULL && (val) >= (m)->bottom &&		\
+	((m)->map != NULL && (val) >= (m)->bottom &&		\
 	    (val)<= (m)->top &&					\
 	    ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \
 	    (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \
 	    (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1))
 #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni)	\
-	_TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \
+	if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \
 			   assplane, asshi, asslo, (uni) & 0xff)
 #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2)		\
-	_TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2)
+	if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2)
 
 #if Py_UNICODE_SIZE == 2
 #define DECODE_SURROGATE(c)					\

Modified: python/branches/bcannon-objcap/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/bcannon-objcap/Modules/itertoolsmodule.c	(original)
+++ python/branches/bcannon-objcap/Modules/itertoolsmodule.c	Tue Sep  5 19:47:00 2006
@@ -618,11 +618,15 @@
 static PyObject *
 tee(PyObject *self, PyObject *args)
 {
-	int i, n=2;
+	Py_ssize_t i, n=2;
 	PyObject *it, *iterable, *copyable, *result;
 
-	if (!PyArg_ParseTuple(args, "O|i", &iterable, &n))
+	if (!PyArg_ParseTuple(args, "O|n", &iterable, &n))
 		return NULL;
+	if (n < 0) {
+		PyErr_SetString(PyExc_ValueError, "n must be >= 0");
+		return NULL;
+	}
 	result = PyTuple_New(n);
 	if (result == NULL)
 		return NULL;

Modified: python/branches/bcannon-objcap/Objects/dictobject.c
==============================================================================
--- python/branches/bcannon-objcap/Objects/dictobject.c	(original)
+++ python/branches/bcannon-objcap/Objects/dictobject.c	Tue Sep  5 19:47:00 2006
@@ -1585,7 +1585,10 @@
 			/* temporarily bump aval's refcount to ensure it stays
 			   alive until we're done with it */
 			Py_INCREF(aval);
+			/* ditto for key */
+			Py_INCREF(key);
 			bval = PyDict_GetItem((PyObject *)b, key);
+			Py_DECREF(key);
 			if (bval == NULL) {
 				Py_DECREF(aval);
 				return 0;

Modified: python/branches/bcannon-objcap/Objects/intobject.c
==============================================================================
--- python/branches/bcannon-objcap/Objects/intobject.c	(original)
+++ python/branches/bcannon-objcap/Objects/intobject.c	Tue Sep  5 19:47:00 2006
@@ -565,7 +565,7 @@
 		return DIVMOD_ERROR;
 	}
 	/* (-sys.maxint-1)/-1 is the only overflow case. */
-	if (y == -1 && x < 0 && x == -x)
+	if (y == -1 && x == LONG_MIN)
 		return DIVMOD_OVERFLOW;
 	xdivy = x / y;
 	xmody = x - xdivy * y;

Modified: python/branches/bcannon-objcap/Objects/stringlib/partition.h
==============================================================================
--- python/branches/bcannon-objcap/Objects/stringlib/partition.h	(original)
+++ python/branches/bcannon-objcap/Objects/stringlib/partition.h	Tue Sep  5 19:47:00 2006
@@ -78,12 +78,12 @@
             }
 
     if (pos < 0) {
-	Py_INCREF(str_obj);
-	PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
 	Py_INCREF(STRINGLIB_EMPTY);
-	PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+	PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
 	Py_INCREF(STRINGLIB_EMPTY);
-	PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY);
+	PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+	Py_INCREF(str_obj);        
+	PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
 	return out;
     }
 

Modified: python/branches/bcannon-objcap/Objects/stringobject.c
==============================================================================
--- python/branches/bcannon-objcap/Objects/stringobject.c	(original)
+++ python/branches/bcannon-objcap/Objects/stringobject.c	Tue Sep  5 19:47:00 2006
@@ -1543,11 +1543,11 @@
 }
 
 PyDoc_STRVAR(rpartition__doc__,
-"S.rpartition(sep) -> (head, sep, tail)\n\
+"S.rpartition(sep) -> (tail, sep, head)\n\
 \n\
 Searches for the separator sep in S, starting at the end of S, and returns\n\
 the part before it, the separator itself, and the part after it.  If the\n\
-separator is not found, returns S and two empty strings.");
+separator is not found, returns two empty strings and S.");
 
 static PyObject *
 string_rpartition(PyStringObject *self, PyObject *sep_obj)

Modified: python/branches/bcannon-objcap/Objects/unicodeobject.c
==============================================================================
--- python/branches/bcannon-objcap/Objects/unicodeobject.c	(original)
+++ python/branches/bcannon-objcap/Objects/unicodeobject.c	Tue Sep  5 19:47:00 2006
@@ -6712,11 +6712,11 @@
 }
 
 PyDoc_STRVAR(rpartition__doc__,
-"S.rpartition(sep) -> (head, sep, tail)\n\
+"S.rpartition(sep) -> (tail, sep, head)\n\
 \n\
 Searches for the separator sep in S, starting at the end of S, and returns\n\
 the part before it, the separator itself, and the part after it.  If the\n\
-separator is not found, returns S and two empty strings.");
+separator is not found, returns two empty strings and S.");
 
 static PyObject*
 unicode_rpartition(PyUnicodeObject *self, PyObject *separator)

Modified: python/branches/bcannon-objcap/Python/ast.c
==============================================================================
--- python/branches/bcannon-objcap/Python/ast.c	(original)
+++ python/branches/bcannon-objcap/Python/ast.c	Tue Sep  5 19:47:00 2006
@@ -15,12 +15,6 @@
 
 #include <assert.h>
 
-/* XXX TO DO
-   - re-indent this file (should be done)
-   - internal error checking (freeing memory, etc.)
-   - syntax errors
-*/
-
 /* Data structure used internally */
 struct compiling {
     char *c_encoding; /* source encoding */
@@ -43,7 +37,7 @@
 static PyObject *parsestrplus(struct compiling *, const node *n);
 
 #ifndef LINENO
-#define LINENO(n)	((n)->n_lineno)
+#define LINENO(n)       ((n)->n_lineno)
 #endif
 
 static identifier
@@ -68,7 +62,7 @@
 {
     PyObject *u = Py_BuildValue("zi", errstr, LINENO(n));
     if (!u)
-	return 0;
+        return 0;
     PyErr_SetObject(PyExc_SyntaxError, u);
     Py_DECREF(u);
     return 0;
@@ -82,36 +76,36 @@
 
     assert(PyErr_Occurred());
     if (!PyErr_ExceptionMatches(PyExc_SyntaxError))
-	return;
+        return;
 
     PyErr_Fetch(&type, &value, &tback);
     errstr = PyTuple_GetItem(value, 0);
     if (!errstr)
-	return;
+        return;
     Py_INCREF(errstr);
     lineno = PyInt_AsLong(PyTuple_GetItem(value, 1));
     if (lineno == -1) {
-	Py_DECREF(errstr);
-	return;
+        Py_DECREF(errstr);
+        return;
     }
     Py_DECREF(value);
 
     loc = PyErr_ProgramText(filename, lineno);
     if (!loc) {
-	Py_INCREF(Py_None);
-	loc = Py_None;
+        Py_INCREF(Py_None);
+        loc = Py_None;
     }
     tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc);
     Py_DECREF(loc);
     if (!tmp) {
-	Py_DECREF(errstr);
-	return;
+        Py_DECREF(errstr);
+        return;
     }
     value = PyTuple_Pack(2, errstr, tmp);
     Py_DECREF(errstr);
     Py_DECREF(tmp);
     if (!value)
-	return;
+        return;
     PyErr_Restore(type, value, tback);
 }
 
@@ -246,7 +240,7 @@
             if (TYPE(CHILD(n, 0)) == NEWLINE) {
                 stmts = asdl_seq_new(1, arena);
                 if (!stmts)
-		    goto error;
+                    goto error;
                 asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
                                             arena));
                 return Interactive(stmts, arena);
@@ -256,11 +250,11 @@
                 num = num_stmts(n);
                 stmts = asdl_seq_new(num, arena);
                 if (!stmts)
-		    goto error;
+                    goto error;
                 if (num == 1) {
-		    s = ast_for_stmt(&c, n);
-		    if (!s)
-			goto error;
+                    s = ast_for_stmt(&c, n);
+                    if (!s)
+                        goto error;
                     asdl_seq_SET(stmts, 0, s);
                 }
                 else {
@@ -347,38 +341,38 @@
 
     switch (e->kind) {
         case Attribute_kind:
-	    if (ctx == Store &&
-		    !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) {
-		    return ast_error(n, "assignment to None");
-	    }
-	    e->v.Attribute.ctx = ctx;
-	    break;
+            if (ctx == Store &&
+                    !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) {
+                    return ast_error(n, "assignment to None");
+            }
+            e->v.Attribute.ctx = ctx;
+            break;
         case Subscript_kind:
-	    e->v.Subscript.ctx = ctx;
-	    break;
+            e->v.Subscript.ctx = ctx;
+            break;
         case Name_kind:
-	    if (ctx == Store &&
-		!strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
-		    return ast_error(n, "assignment to None");
-	    }
-	    e->v.Name.ctx = ctx;
-	    break;
+            if (ctx == Store &&
+                !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
+                    return ast_error(n, "assignment to None");
+            }
+            e->v.Name.ctx = ctx;
+            break;
         case List_kind:
-	    e->v.List.ctx = ctx;
-	    s = e->v.List.elts;
-	    break;
+            e->v.List.ctx = ctx;
+            s = e->v.List.elts;
+            break;
         case Tuple_kind:
             if (asdl_seq_LEN(e->v.Tuple.elts) == 0) 
                 return ast_error(n, "can't assign to ()");
-	    e->v.Tuple.ctx = ctx;
-	    s = e->v.Tuple.elts;
-	    break;
+            e->v.Tuple.ctx = ctx;
+            s = e->v.Tuple.elts;
+            break;
         case Lambda_kind:
             expr_name = "lambda";
             break;
         case Call_kind:
             expr_name = "function call";
-	    break;
+            break;
         case BoolOp_kind:
         case BinOp_kind:
         case UnaryOp_kind:
@@ -427,12 +421,12 @@
        context for all the contained elements.  
     */
     if (s) {
-	int i;
+        int i;
 
-	for (i = 0; i < asdl_seq_LEN(s); i++) {
-	    if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n))
-		return 0;
-	}
+        for (i = 0; i < asdl_seq_LEN(s); i++) {
+            if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n))
+                return 0;
+        }
     }
     return 1;
 }
@@ -483,13 +477,13 @@
     */
     REQ(n, comp_op);
     if (NCH(n) == 1) {
-	n = CHILD(n, 0);
-	switch (TYPE(n)) {
+        n = CHILD(n, 0);
+        switch (TYPE(n)) {
             case LESS:
                 return Lt;
             case GREATER:
                 return Gt;
-            case EQEQUAL:			/* == */
+            case EQEQUAL:                       /* == */
                 return Eq;
             case LESSEQUAL:
                 return LtE;
@@ -506,11 +500,11 @@
                 PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
                              STR(n));
                 return (cmpop_ty)0;
-	}
+        }
     }
     else if (NCH(n) == 2) {
-	/* handle "not in" and "is not" */
-	switch (TYPE(CHILD(n, 0))) {
+        /* handle "not in" and "is not" */
+        switch (TYPE(CHILD(n, 0))) {
             case NAME:
                 if (strcmp(STR(CHILD(n, 1)), "in") == 0)
                     return NotIn;
@@ -520,7 +514,7 @@
                 PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
                              STR(CHILD(n, 0)), STR(CHILD(n, 1)));
                 return (cmpop_ty)0;
-	}
+        }
     }
     PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children",
                  NCH(n));
@@ -535,10 +529,10 @@
     expr_ty expression;
     int i;
     assert(TYPE(n) == testlist
-	   || TYPE(n) == listmaker
-	   || TYPE(n) == testlist_gexp
-	   || TYPE(n) == testlist_safe
-	   );
+           || TYPE(n) == listmaker
+           || TYPE(n) == testlist_gexp
+           || TYPE(n) == testlist_safe
+           );
 
     seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
     if (!seq)
@@ -571,13 +565,13 @@
         const node *child = CHILD(CHILD(n, 2*i), 0);
         expr_ty arg;
         if (TYPE(child) == NAME) {
-    		if (!strcmp(STR(child), "None")) {
-	    		ast_error(child, "assignment to None");
-		    	return NULL;
-		    }   
+                if (!strcmp(STR(child), "None")) {
+                        ast_error(child, "assignment to None");
+                        return NULL;
+                    }   
             arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child),
                        child->n_col_offset, c->c_arena);
-	    }
+            }
         else {
             arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1));
         }
@@ -606,26 +600,26 @@
     node *ch;
 
     if (TYPE(n) == parameters) {
-	if (NCH(n) == 2) /* () as argument list */
-	    return arguments(NULL, NULL, NULL, NULL, c->c_arena);
-	n = CHILD(n, 1);
+        if (NCH(n) == 2) /* () as argument list */
+            return arguments(NULL, NULL, NULL, NULL, c->c_arena);
+        n = CHILD(n, 1);
     }
     REQ(n, varargslist);
 
     /* first count the number of normal args & defaults */
     for (i = 0; i < NCH(n); i++) {
-	ch = CHILD(n, i);
-	if (TYPE(ch) == fpdef)
-	    n_args++;
-	if (TYPE(ch) == EQUAL)
-	    n_defaults++;
+        ch = CHILD(n, i);
+        if (TYPE(ch) == fpdef)
+            n_args++;
+        if (TYPE(ch) == EQUAL)
+            n_defaults++;
     }
     args = (n_args ? asdl_seq_new(n_args, c->c_arena) : NULL);
     if (!args && n_args)
-    	return NULL; /* Don't need to goto error; no objects allocated */
+        return NULL; /* Don't need to goto error; no objects allocated */
     defaults = (n_defaults ? asdl_seq_new(n_defaults, c->c_arena) : NULL);
     if (!defaults && n_defaults)
-    	return NULL; /* Don't need to goto error; no objects allocated */
+        return NULL; /* Don't need to goto error; no objects allocated */
 
     /* fpdef: NAME | '(' fplist ')'
        fplist: fpdef (',' fpdef)* [',']
@@ -634,8 +628,8 @@
     j = 0;  /* index for defaults */
     k = 0;  /* index for args */
     while (i < NCH(n)) {
-	ch = CHILD(n, i);
-	switch (TYPE(ch)) {
+        ch = CHILD(n, i);
+        switch (TYPE(ch)) {
             case fpdef:
                 /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is
                    anything other than EQUAL or a comma? */
@@ -647,53 +641,53 @@
                     assert(defaults != NULL);
                     asdl_seq_SET(defaults, j++, expression);
                     i += 2;
-		    found_default = 1;
+                    found_default = 1;
+                }
+                else if (found_default) {
+                    ast_error(n, 
+                             "non-default argument follows default argument");
+                    goto error;
                 }
-		else if (found_default) {
-		    ast_error(n, 
-			     "non-default argument follows default argument");
-		    goto error;
-		}
                 if (NCH(ch) == 3) {
-		    ch = CHILD(ch, 1);
-		    /* def foo((x)): is not complex, special case. */
-		    if (NCH(ch) != 1) {
-			/* We have complex arguments, setup for unpacking. */
-			asdl_seq_SET(args, k++, compiler_complex_args(c, ch));
-		    } else {
-			/* def foo((x)): setup for checking NAME below. */
-			ch = CHILD(ch, 0);
-		    }
+                    ch = CHILD(ch, 1);
+                    /* def foo((x)): is not complex, special case. */
+                    if (NCH(ch) != 1) {
+                        /* We have complex arguments, setup for unpacking. */
+                        asdl_seq_SET(args, k++, compiler_complex_args(c, ch));
+                    } else {
+                        /* def foo((x)): setup for checking NAME below. */
+                        ch = CHILD(ch, 0);
+                    }
                 }
                 if (TYPE(CHILD(ch, 0)) == NAME) {
-		    expr_ty name;
-		    if (!strcmp(STR(CHILD(ch, 0)), "None")) {
-			    ast_error(CHILD(ch, 0), "assignment to None");
-			    goto error;
-		    }
+                    expr_ty name;
+                    if (!strcmp(STR(CHILD(ch, 0)), "None")) {
+                            ast_error(CHILD(ch, 0), "assignment to None");
+                            goto error;
+                    }
                     name = Name(NEW_IDENTIFIER(CHILD(ch, 0)),
                                 Param, LINENO(ch), ch->n_col_offset,
                                 c->c_arena);
                     if (!name)
                         goto error;
                     asdl_seq_SET(args, k++, name);
-					 
-		}
+                                         
+                }
                 i += 2; /* the name and the comma */
                 break;
             case STAR:
-		if (!strcmp(STR(CHILD(n, i+1)), "None")) {
-			ast_error(CHILD(n, i+1), "assignment to None");
-			goto error;
-		}
+                if (!strcmp(STR(CHILD(n, i+1)), "None")) {
+                        ast_error(CHILD(n, i+1), "assignment to None");
+                        goto error;
+                }
                 vararg = NEW_IDENTIFIER(CHILD(n, i+1));
                 i += 3;
                 break;
             case DOUBLESTAR:
-		if (!strcmp(STR(CHILD(n, i+1)), "None")) {
-			ast_error(CHILD(n, i+1), "assignment to None");
-			goto error;
-		}
+                if (!strcmp(STR(CHILD(n, i+1)), "None")) {
+                        ast_error(CHILD(n, i+1), "assignment to None");
+                        goto error;
+                }
                 kwarg = NEW_IDENTIFIER(CHILD(n, i+1));
                 i += 3;
                 break;
@@ -702,7 +696,7 @@
                              "unexpected node in varargslist: %d @ %d",
                              TYPE(ch), i);
                 goto error;
-	}
+        }
     }
 
     return arguments(args, vararg, kwarg, defaults, c->c_arena);
@@ -731,15 +725,15 @@
         return NULL;
     e = Name(id, Load, lineno, col_offset, c->c_arena);
     if (!e)
-	return NULL;
+        return NULL;
 
     for (i = 2; i < NCH(n); i+=2) {
         id = NEW_IDENTIFIER(CHILD(n, i));
-	if (!id)
-	    return NULL;
-	e = Attribute(e, id, Load, lineno, col_offset, c->c_arena);
-	if (!e)
-	    return NULL;
+        if (!id)
+            return NULL;
+        e = Attribute(e, id, Load, lineno, col_offset, c->c_arena);
+        if (!e)
+            return NULL;
     }
 
     return e;
@@ -758,24 +752,24 @@
     
     name_expr = ast_for_dotted_name(c, CHILD(n, 1));
     if (!name_expr)
-	return NULL;
-	
+        return NULL;
+        
     if (NCH(n) == 3) { /* No arguments */
-	d = name_expr;
-	name_expr = NULL;
+        d = name_expr;
+        name_expr = NULL;
     }
     else if (NCH(n) == 5) { /* Call with no arguments */
-	d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n),
+        d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n),
                  n->n_col_offset, c->c_arena);
-	if (!d)
-	    return NULL;
-	name_expr = NULL;
+        if (!d)
+            return NULL;
+        name_expr = NULL;
     }
     else {
-	d = ast_for_call(c, CHILD(n, 3), name_expr);
-	if (!d)
-	    return NULL;
-	name_expr = NULL;
+        d = ast_for_call(c, CHILD(n, 3), name_expr);
+        if (!d)
+            return NULL;
+        name_expr = NULL;
     }
 
     return d;
@@ -792,12 +786,12 @@
     decorator_seq = asdl_seq_new(NCH(n), c->c_arena);
     if (!decorator_seq)
         return NULL;
-	
+        
     for (i = 0; i < NCH(n); i++) {
         d = ast_for_decorator(c, CHILD(n, i));
-	    if (!d)
-	        return NULL;
-	    asdl_seq_SET(decorator_seq, i, d);
+            if (!d)
+                return NULL;
+            asdl_seq_SET(decorator_seq, i, d);
     }
     return decorator_seq;
 }
@@ -815,28 +809,28 @@
     REQ(n, funcdef);
 
     if (NCH(n) == 6) { /* decorators are present */
-	decorator_seq = ast_for_decorators(c, CHILD(n, 0));
-	if (!decorator_seq)
-	    return NULL;
-	name_i = 2;
+        decorator_seq = ast_for_decorators(c, CHILD(n, 0));
+        if (!decorator_seq)
+            return NULL;
+        name_i = 2;
     }
     else {
-	name_i = 1;
+        name_i = 1;
     }
 
     name = NEW_IDENTIFIER(CHILD(n, name_i));
     if (!name)
-	return NULL;
+        return NULL;
     else if (!strcmp(STR(CHILD(n, name_i)), "None")) {
-	ast_error(CHILD(n, name_i), "assignment to None");
-	return NULL;
+        ast_error(CHILD(n, name_i), "assignment to None");
+        return NULL;
     }
     args = ast_for_arguments(c, CHILD(n, name_i + 1));
     if (!args)
-	return NULL;
+        return NULL;
     body = ast_for_suite(c, CHILD(n, name_i + 3));
     if (!body)
-	return NULL;
+        return NULL;
 
     return FunctionDef(name, args, body, decorator_seq, LINENO(n),
                        n->n_col_offset, c->c_arena);
@@ -878,17 +872,22 @@
     assert(NCH(n) == 5);
     body = ast_for_expr(c, CHILD(n, 0));
     if (!body)
-    	return NULL;
+        return NULL;
     expression = ast_for_expr(c, CHILD(n, 2));
     if (!expression)
-    	return NULL;
+        return NULL;
     orelse = ast_for_expr(c, CHILD(n, 4));
     if (!orelse)
-	return NULL;
+        return NULL;
     return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset,
                  c->c_arena);
 }
 
+/* XXX(nnorwitz): the listcomp and genexpr code should be refactored
+   so there is only a single version.  Possibly for loops can also re-use
+   the code.
+*/
+
 /* Count the number of 'for' loop in a list comprehension.
 
    Helper for ast_for_listcomp().
@@ -904,14 +903,14 @@
     n_fors++;
     REQ(ch, list_for);
     if (NCH(ch) == 5)
-	ch = CHILD(ch, 4);
+        ch = CHILD(ch, 4);
     else
-	return n_fors;
+        return n_fors;
  count_list_iter:
     REQ(ch, list_iter);
     ch = CHILD(ch, 0);
     if (TYPE(ch) == list_for)
-	goto count_list_for;
+        goto count_list_for;
     else if (TYPE(ch) == list_if) {
         if (NCH(ch) == 3) {
             ch = CHILD(ch, 2);
@@ -939,12 +938,12 @@
  count_list_iter:
     REQ(n, list_iter);
     if (TYPE(CHILD(n, 0)) == list_for)
-	return n_ifs;
+        return n_ifs;
     n = CHILD(n, 0);
     REQ(n, list_if);
     n_ifs++;
     if (NCH(n) == 2)
-	return n_ifs;
+        return n_ifs;
     n = CHILD(n, 2);
     goto count_list_iter;
 }
@@ -976,61 +975,65 @@
 
     listcomps = asdl_seq_new(n_fors, c->c_arena);
     if (!listcomps)
-    	return NULL;
+        return NULL;
 
     ch = CHILD(n, 1);
     for (i = 0; i < n_fors; i++) {
-	comprehension_ty lc;
-	asdl_seq *t;
+        comprehension_ty lc;
+        asdl_seq *t;
         expr_ty expression;
+        node *for_ch;
 
-	REQ(ch, list_for);
+        REQ(ch, list_for);
 
-	t = ast_for_exprlist(c, CHILD(ch, 1), Store);
+        for_ch = CHILD(ch, 1);
+        t = ast_for_exprlist(c, for_ch, Store);
         if (!t)
             return NULL;
         expression = ast_for_testlist(c, CHILD(ch, 3));
         if (!expression)
             return NULL;
 
-	if (asdl_seq_LEN(t) == 1)
-	    lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL,
+        /* Check the # of children rather than the length of t, since
+           [x for x, in ... ] has 1 element in t, but still requires a Tuple. */
+        if (NCH(for_ch) == 1)
+            lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL,
                                c->c_arena);
-	else
-	    lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset,
+        else
+            lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset,
                                      c->c_arena),
                                expression, NULL, c->c_arena);
         if (!lc)
             return NULL;
 
-	if (NCH(ch) == 5) {
-	    int j, n_ifs;
-	    asdl_seq *ifs;
+        if (NCH(ch) == 5) {
+            int j, n_ifs;
+            asdl_seq *ifs;
 
-	    ch = CHILD(ch, 4);
-	    n_ifs = count_list_ifs(ch);
+            ch = CHILD(ch, 4);
+            n_ifs = count_list_ifs(ch);
             if (n_ifs == -1)
                 return NULL;
 
-	    ifs = asdl_seq_new(n_ifs, c->c_arena);
-	    if (!ifs)
-		return NULL;
+            ifs = asdl_seq_new(n_ifs, c->c_arena);
+            if (!ifs)
+                return NULL;
 
-	    for (j = 0; j < n_ifs; j++) {
+            for (j = 0; j < n_ifs; j++) {
             REQ(ch, list_iter);
-		    ch = CHILD(ch, 0);
-		    REQ(ch, list_if);
+                    ch = CHILD(ch, 0);
+                    REQ(ch, list_if);
 
-    		asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1)));
-    		if (NCH(ch) == 3)
-	    	    ch = CHILD(ch, 2);
-	        }
-	        /* on exit, must guarantee that ch is a list_for */
-	        if (TYPE(ch) == list_iter)
-		        ch = CHILD(ch, 0);
+                asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1)));
+                if (NCH(ch) == 3)
+                    ch = CHILD(ch, 2);
+                }
+                /* on exit, must guarantee that ch is a list_for */
+                if (TYPE(ch) == list_iter)
+                        ch = CHILD(ch, 0);
             lc->ifs = ifs;
-	    }
-	    asdl_seq_SET(listcomps, i, lc);
+            }
+            asdl_seq_SET(listcomps, i, lc);
     }
 
     return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena);
@@ -1045,34 +1048,34 @@
 static int
 count_gen_fors(const node *n)
 {
-	int n_fors = 0;
-	node *ch = CHILD(n, 1);
+        int n_fors = 0;
+        node *ch = CHILD(n, 1);
 
  count_gen_for:
-	n_fors++;
-	REQ(ch, gen_for);
-	if (NCH(ch) == 5)
-		ch = CHILD(ch, 4);
-	else
-		return n_fors;
+        n_fors++;
+        REQ(ch, gen_for);
+        if (NCH(ch) == 5)
+                ch = CHILD(ch, 4);
+        else
+                return n_fors;
  count_gen_iter:
-	REQ(ch, gen_iter);
-	ch = CHILD(ch, 0);
-	if (TYPE(ch) == gen_for)
-		goto count_gen_for;
-	else if (TYPE(ch) == gen_if) {
-		if (NCH(ch) == 3) {
-			ch = CHILD(ch, 2);
-			goto count_gen_iter;
-		}
-		else
-		    return n_fors;
-	}
-
-	/* Should never be reached */
-	PyErr_SetString(PyExc_SystemError,
-			"logic error in count_gen_fors");
-	return -1;
+        REQ(ch, gen_iter);
+        ch = CHILD(ch, 0);
+        if (TYPE(ch) == gen_for)
+                goto count_gen_for;
+        else if (TYPE(ch) == gen_if) {
+                if (NCH(ch) == 3) {
+                        ch = CHILD(ch, 2);
+                        goto count_gen_iter;
+                }
+                else
+                    return n_fors;
+        }
+
+        /* Should never be reached */
+        PyErr_SetString(PyExc_SystemError,
+                        "logic error in count_gen_fors");
+        return -1;
 }
 
 /* Count the number of 'if' statements in a generator expression.
@@ -1083,19 +1086,19 @@
 static int
 count_gen_ifs(const node *n)
 {
-	int n_ifs = 0;
+        int n_ifs = 0;
 
-	while (1) {
-		REQ(n, gen_iter);
-		if (TYPE(CHILD(n, 0)) == gen_for)
-			return n_ifs;
-		n = CHILD(n, 0);
-		REQ(n, gen_if);
-		n_ifs++;
-		if (NCH(n) == 2)
-			return n_ifs;
-		n = CHILD(n, 2);
-	}
+        while (1) {
+                REQ(n, gen_iter);
+                if (TYPE(CHILD(n, 0)) == gen_for)
+                        return n_ifs;
+                n = CHILD(n, 0);
+                REQ(n, gen_if);
+                n_ifs++;
+                if (NCH(n) == 2)
+                        return n_ifs;
+                n = CHILD(n, 2);
+        }
 }
 
 /* TODO(jhylton): Combine with list comprehension code? */
@@ -1103,7 +1106,7 @@
 ast_for_genexp(struct compiling *c, const node *n)
 {
     /* testlist_gexp: test ( gen_for | (',' test)* [','] )
-       argument: [test '='] test [gen_for]	 # Really [keyword '='] test */
+       argument: [test '='] test [gen_for]       # Really [keyword '='] test */
     expr_ty elt;
     asdl_seq *genexps;
     int i, n_fors;
@@ -1129,17 +1132,21 @@
         comprehension_ty ge;
         asdl_seq *t;
         expr_ty expression;
+        node *for_ch;
         
         REQ(ch, gen_for);
         
-        t = ast_for_exprlist(c, CHILD(ch, 1), Store);
+        for_ch = CHILD(ch, 1);
+        t = ast_for_exprlist(c, for_ch, Store);
         if (!t)
             return NULL;
         expression = ast_for_expr(c, CHILD(ch, 3));
         if (!expression)
             return NULL;
 
-        if (asdl_seq_LEN(t) == 1)
+        /* Check the # of children rather than the length of t, since
+           (x for x, in ...) has 1 element in t, but still requires a Tuple. */
+        if (NCH(for_ch) == 1)
             ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression,
                                NULL, c->c_arena);
         else
@@ -1196,96 +1203,96 @@
     
     switch (TYPE(ch)) {
     case NAME:
-	/* All names start in Load context, but may later be
-	   changed. */
-	return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena);
+        /* All names start in Load context, but may later be
+           changed. */
+        return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena);
     case STRING: {
-	PyObject *str = parsestrplus(c, n);
-	if (!str)
-	    return NULL;
+        PyObject *str = parsestrplus(c, n);
+        if (!str)
+            return NULL;
 
-	PyArena_AddPyObject(c->c_arena, str);
-	return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
+        PyArena_AddPyObject(c->c_arena, str);
+        return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
     }
     case NUMBER: {
-	PyObject *pynum = parsenumber(STR(ch));
-	if (!pynum)
-	    return NULL;
+        PyObject *pynum = parsenumber(STR(ch));
+        if (!pynum)
+            return NULL;
 
-	PyArena_AddPyObject(c->c_arena, pynum);
-	return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);
+        PyArena_AddPyObject(c->c_arena, pynum);
+        return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);
     }
     case LPAR: /* some parenthesized expressions */
-	ch = CHILD(n, 1);
-	
-	if (TYPE(ch) == RPAR)
-	    return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
-	
-	if (TYPE(ch) == yield_expr)
-	    return ast_for_expr(c, ch);
-	
-	if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for))
-	    return ast_for_genexp(c, ch);
-	
-	return ast_for_testlist_gexp(c, ch);
+        ch = CHILD(n, 1);
+        
+        if (TYPE(ch) == RPAR)
+            return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
+        
+        if (TYPE(ch) == yield_expr)
+            return ast_for_expr(c, ch);
+        
+        if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for))
+            return ast_for_genexp(c, ch);
+        
+        return ast_for_testlist_gexp(c, ch);
     case LSQB: /* list (or list comprehension) */
-	ch = CHILD(n, 1);
-	
-	if (TYPE(ch) == RSQB)
-	    return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
-	
-	REQ(ch, listmaker);
-	if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
-	    asdl_seq *elts = seq_for_testlist(c, ch);
-	    if (!elts)
-		return NULL;
-
-	    return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);
-	}
-	else
-	    return ast_for_listcomp(c, ch);
+        ch = CHILD(n, 1);
+        
+        if (TYPE(ch) == RSQB)
+            return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
+        
+        REQ(ch, listmaker);
+        if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
+            asdl_seq *elts = seq_for_testlist(c, ch);
+            if (!elts)
+                return NULL;
+
+            return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);
+        }
+        else
+            return ast_for_listcomp(c, ch);
     case LBRACE: {
-	/* dictmaker: test ':' test (',' test ':' test)* [','] */
-	int i, size;
-	asdl_seq *keys, *values;
-	
-	ch = CHILD(n, 1);
-	size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */
-	keys = asdl_seq_new(size, c->c_arena);
-	if (!keys)
-	    return NULL;
-	
-	values = asdl_seq_new(size, c->c_arena);
-	if (!values)
-	    return NULL;
-	
-	for (i = 0; i < NCH(ch); i += 4) {
-	    expr_ty expression;
-	    
-	    expression = ast_for_expr(c, CHILD(ch, i));
-	    if (!expression)
-		return NULL;
-
-	    asdl_seq_SET(keys, i / 4, expression);
-
-	    expression = ast_for_expr(c, CHILD(ch, i + 2));
-	    if (!expression)
-		return NULL;
-
-	    asdl_seq_SET(values, i / 4, expression);
-	}
-	return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
+        /* dictmaker: test ':' test (',' test ':' test)* [','] */
+        int i, size;
+        asdl_seq *keys, *values;
+        
+        ch = CHILD(n, 1);
+        size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */
+        keys = asdl_seq_new(size, c->c_arena);
+        if (!keys)
+            return NULL;
+        
+        values = asdl_seq_new(size, c->c_arena);
+        if (!values)
+            return NULL;
+        
+        for (i = 0; i < NCH(ch); i += 4) {
+            expr_ty expression;
+            
+            expression = ast_for_expr(c, CHILD(ch, i));
+            if (!expression)
+                return NULL;
+
+            asdl_seq_SET(keys, i / 4, expression);
+
+            expression = ast_for_expr(c, CHILD(ch, i + 2));
+            if (!expression)
+                return NULL;
+
+            asdl_seq_SET(values, i / 4, expression);
+        }
+        return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
     }
     case BACKQUOTE: { /* repr */
-	expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
-	if (!expression)
-	    return NULL;
+        expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
+        if (!expression)
+            return NULL;
 
-	return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);
+        return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);
     }
     default:
-	PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
-	return NULL;
+        PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
+        return NULL;
     }
 }
 
@@ -1303,7 +1310,7 @@
     */
     ch = CHILD(n, 0);
     if (TYPE(ch) == DOT)
-	return Ellipsis(c->c_arena);
+        return Ellipsis(c->c_arena);
 
     if (NCH(n) == 1 && TYPE(ch) == test) {
         /* 'step' variable hold no significance in terms of being used over
@@ -1312,31 +1319,31 @@
         if (!step)
             return NULL;
             
-	return Index(step, c->c_arena);
+        return Index(step, c->c_arena);
     }
 
     if (TYPE(ch) == test) {
-	lower = ast_for_expr(c, ch);
+        lower = ast_for_expr(c, ch);
         if (!lower)
             return NULL;
     }
 
     /* If there's an upper bound it's in the second or third position. */
     if (TYPE(ch) == COLON) {
-	if (NCH(n) > 1) {
-	    node *n2 = CHILD(n, 1);
+        if (NCH(n) > 1) {
+            node *n2 = CHILD(n, 1);
 
-	    if (TYPE(n2) == test) {
-		upper = ast_for_expr(c, n2);
+            if (TYPE(n2) == test) {
+                upper = ast_for_expr(c, n2);
                 if (!upper)
                     return NULL;
             }
-	}
+        }
     } else if (NCH(n) > 2) {
-	node *n2 = CHILD(n, 2);
+        node *n2 = CHILD(n, 2);
 
-	if (TYPE(n2) == test) {
-	    upper = ast_for_expr(c, n2);
+        if (TYPE(n2) == test) {
+            upper = ast_for_expr(c, n2);
             if (!upper)
                 return NULL;
         }
@@ -1367,13 +1374,13 @@
 static expr_ty
 ast_for_binop(struct compiling *c, const node *n)
 {
-	/* Must account for a sequence of expressions.
-	   How should A op B op C by represented?  
-	   BinOp(BinOp(A, op, B), op, C).
-	*/
+        /* Must account for a sequence of expressions.
+           How should A op B op C by represented?  
+           BinOp(BinOp(A, op, B), op, C).
+        */
 
-	int i, nops;
-	expr_ty expr1, expr2, result;
+        int i, nops;
+        expr_ty expr1, expr2, result;
         operator_ty newoperator;
 
         expr1 = ast_for_expr(c, CHILD(n, 0));
@@ -1388,17 +1395,17 @@
         if (!newoperator)
             return NULL;
 
-	result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
+        result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
                        c->c_arena);
-	if (!result)
+        if (!result)
             return NULL;
 
-	nops = (NCH(n) - 1) / 2;
-	for (i = 1; i < nops; i++) {
-		expr_ty tmp_result, tmp;
-		const node* next_oper = CHILD(n, i * 2 + 1);
+        nops = (NCH(n) - 1) / 2;
+        for (i = 1; i < nops; i++) {
+                expr_ty tmp_result, tmp;
+                const node* next_oper = CHILD(n, i * 2 + 1);
 
-		newoperator = get_operator(next_oper);
+                newoperator = get_operator(next_oper);
                 if (!newoperator)
                     return NULL;
 
@@ -1407,13 +1414,13 @@
                     return NULL;
 
                 tmp_result = BinOp(result, newoperator, tmp, 
-				   LINENO(next_oper), next_oper->n_col_offset,
+                                   LINENO(next_oper), next_oper->n_col_offset,
                                    c->c_arena);
-		if (!tmp) 
-			return NULL;
-		result = tmp_result;
-	}
-	return result;
+                if (!tmp) 
+                        return NULL;
+                result = tmp_result;
+        }
+        return result;
 }
 
 static expr_ty
@@ -1560,8 +1567,8 @@
         tmp = ast_for_trailer(c, ch, e);
         if (!tmp)
             return NULL;
-	tmp->lineno = e->lineno;
-	tmp->col_offset = e->col_offset;
+        tmp->lineno = e->lineno;
+        tmp->col_offset = e->col_offset;
         e = tmp;
     }
     if (TYPE(CHILD(n, NCH(n) - 1)) == factor) {
@@ -1619,8 +1626,8 @@
                 return ast_for_lambdef(c, CHILD(n, 0));
             else if (NCH(n) > 1)
                 return ast_for_ifexpr(c, n);
-	    /* Fallthrough */
-	case or_test:
+            /* Fallthrough */
+        case or_test:
         case and_test:
             if (NCH(n) == 1) {
                 n = CHILD(n, 0);
@@ -1661,7 +1668,7 @@
             else {
                 expr_ty expression;
                 asdl_int_seq *ops;
-		asdl_seq *cmps;
+                asdl_seq *cmps;
                 ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena);
                 if (!ops)
                     return NULL;
@@ -1675,12 +1682,12 @@
                     newoperator = ast_for_comp_op(CHILD(n, i));
                     if (!newoperator) {
                         return NULL;
-		    }
+                    }
 
                     expression = ast_for_expr(c, CHILD(n, i + 1));
                     if (!expression) {
                         return NULL;
-		    }
+                    }
                         
                     asdl_seq_SET(ops, i / 2, newoperator);
                     asdl_seq_SET(cmps, i / 2, expression);
@@ -1688,7 +1695,7 @@
                 expression = ast_for_expr(c, CHILD(n, 0));
                 if (!expression) {
                     return NULL;
-		}
+                }
                     
                 return Compare(expression, ops, cmps, LINENO(n),
                                n->n_col_offset, c->c_arena);
@@ -1711,20 +1718,20 @@
             }
             return ast_for_binop(c, n);
         case yield_expr: {
-	    expr_ty exp = NULL;
-	    if (NCH(n) == 2) {
-		exp = ast_for_testlist(c, CHILD(n, 1));
-		if (!exp)
-		    return NULL;
-	    }
-	    return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena);
-	}
+            expr_ty exp = NULL;
+            if (NCH(n) == 2) {
+                exp = ast_for_testlist(c, CHILD(n, 1));
+                if (!exp)
+                    return NULL;
+            }
+            return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena);
+        }
         case factor:
             if (NCH(n) == 1) {
                 n = CHILD(n, 0);
                 goto loop;
             }
-	    return ast_for_factor(c, n);
+            return ast_for_factor(c, n);
         case power:
             return ast_for_power(c, n);
         default:
@@ -1741,7 +1748,7 @@
     /*
       arglist: (argument ',')* (argument [',']| '*' test [',' '**' test]
                | '**' test)
-      argument: [test '='] test [gen_for]	 # Really [keyword '='] test
+      argument: [test '='] test [gen_for]        # Really [keyword '='] test
     */
 
     int i, nargs, nkeywords, ngens;
@@ -1755,20 +1762,20 @@
     nkeywords = 0;
     ngens = 0;
     for (i = 0; i < NCH(n); i++) {
-	node *ch = CHILD(n, i);
-	if (TYPE(ch) == argument) {
-	    if (NCH(ch) == 1)
-		nargs++;
-	    else if (TYPE(CHILD(ch, 1)) == gen_for)
-		ngens++;
+        node *ch = CHILD(n, i);
+        if (TYPE(ch) == argument) {
+            if (NCH(ch) == 1)
+                nargs++;
+            else if (TYPE(CHILD(ch, 1)) == gen_for)
+                ngens++;
             else
-		nkeywords++;
-	}
+                nkeywords++;
+        }
     }
     if (ngens > 1 || (ngens && (nargs || nkeywords))) {
         ast_error(n, "Generator expression must be parenthesized "
-		  "if not sole argument");
-	return NULL;
+                  "if not sole argument");
+        return NULL;
     }
 
     if (nargs + nkeywords + ngens > 255) {
@@ -1785,32 +1792,32 @@
     nargs = 0;
     nkeywords = 0;
     for (i = 0; i < NCH(n); i++) {
-	node *ch = CHILD(n, i);
-	if (TYPE(ch) == argument) {
-	    expr_ty e;
-	    if (NCH(ch) == 1) {
-		if (nkeywords) {
-		    ast_error(CHILD(ch, 0),
-			      "non-keyword arg after keyword arg");
-		    return NULL;
-		}
-		e = ast_for_expr(c, CHILD(ch, 0));
+        node *ch = CHILD(n, i);
+        if (TYPE(ch) == argument) {
+            expr_ty e;
+            if (NCH(ch) == 1) {
+                if (nkeywords) {
+                    ast_error(CHILD(ch, 0),
+                              "non-keyword arg after keyword arg");
+                    return NULL;
+                }
+                e = ast_for_expr(c, CHILD(ch, 0));
                 if (!e)
                     return NULL;
-		asdl_seq_SET(args, nargs++, e);
-	    }  
-	    else if (TYPE(CHILD(ch, 1)) == gen_for) {
-        	e = ast_for_genexp(c, ch);
+                asdl_seq_SET(args, nargs++, e);
+            }  
+            else if (TYPE(CHILD(ch, 1)) == gen_for) {
+                e = ast_for_genexp(c, ch);
                 if (!e)
                     return NULL;
-		asdl_seq_SET(args, nargs++, e);
+                asdl_seq_SET(args, nargs++, e);
             }
-	    else {
-		keyword_ty kw;
-		identifier key;
+            else {
+                keyword_ty kw;
+                identifier key;
 
-		/* CHILD(ch, 0) is test, but must be an identifier? */ 
-		e = ast_for_expr(c, CHILD(ch, 0));
+                /* CHILD(ch, 0) is test, but must be an identifier? */ 
+                e = ast_for_expr(c, CHILD(ch, 0));
                 if (!e)
                     return NULL;
                 /* f(lambda x: x[0] = 3) ends up getting parsed with
@@ -1825,24 +1832,24 @@
                   ast_error(CHILD(ch, 0), "keyword can't be an expression");
                   return NULL;
                 }
-		key = e->v.Name.id;
-		e = ast_for_expr(c, CHILD(ch, 2));
+                key = e->v.Name.id;
+                e = ast_for_expr(c, CHILD(ch, 2));
                 if (!e)
                     return NULL;
-		kw = keyword(key, e, c->c_arena);
+                kw = keyword(key, e, c->c_arena);
                 if (!kw)
                     return NULL;
-		asdl_seq_SET(keywords, nkeywords++, kw);
-	    }
-	}
-	else if (TYPE(ch) == STAR) {
-	    vararg = ast_for_expr(c, CHILD(n, i+1));
-	    i++;
-	}
-	else if (TYPE(ch) == DOUBLESTAR) {
-	    kwarg = ast_for_expr(c, CHILD(n, i+1));
-	    i++;
-	}
+                asdl_seq_SET(keywords, nkeywords++, kw);
+            }
+        }
+        else if (TYPE(ch) == STAR) {
+            vararg = ast_for_expr(c, CHILD(n, i+1));
+            i++;
+        }
+        else if (TYPE(ch) == DOUBLESTAR) {
+            kwarg = ast_for_expr(c, CHILD(n, i+1));
+            i++;
+        }
     }
 
     return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena);
@@ -1866,12 +1873,12 @@
                TYPE(n) == testlist1);
     }
     if (NCH(n) == 1)
-	return ast_for_expr(c, CHILD(n, 0));
+        return ast_for_expr(c, CHILD(n, 0));
     else {
         asdl_seq *tmp = seq_for_testlist(c, n);
         if (!tmp)
             return NULL;
-	return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena);
+        return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena);
     }
 }
 
@@ -1882,7 +1889,7 @@
     /* argument: test [ gen_for ] */
     assert(TYPE(n) == testlist_gexp || TYPE(n) == argument);
     if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for)
-	return ast_for_genexp(c, n);
+        return ast_for_genexp(c, n);
     return ast_for_testlist(c, n);
 }
 
@@ -1916,23 +1923,23 @@
                 | ('=' (yield_expr|testlist))*)
        testlist: test (',' test)* [',']
        augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^='
-	        | '<<=' | '>>=' | '**=' | '//='
+                | '<<=' | '>>=' | '**=' | '//='
        test: ... here starts the operator precendence dance
      */
 
     if (NCH(n) == 1) {
-	expr_ty e = ast_for_testlist(c, CHILD(n, 0));
+        expr_ty e = ast_for_testlist(c, CHILD(n, 0));
         if (!e)
             return NULL;
 
-	return Expr(e, LINENO(n), n->n_col_offset, c->c_arena);
+        return Expr(e, LINENO(n), n->n_col_offset, c->c_arena);
     }
     else if (TYPE(CHILD(n, 1)) == augassign) {
         expr_ty expr1, expr2;
         operator_ty newoperator;
-	node *ch = CHILD(n, 0);
+        node *ch = CHILD(n, 0);
 
-	expr1 = ast_for_testlist(c, ch);
+        expr1 = ast_for_testlist(c, ch);
         if (!expr1)
             return NULL;
         /* TODO(nas): Remove duplicated error checks (set_context does it) */
@@ -1961,13 +1968,13 @@
                           "assignment");
                 return NULL;
         }
-	set_context(expr1, Store, ch);
+        set_context(expr1, Store, ch);
 
-	ch = CHILD(n, 2);
-	if (TYPE(ch) == testlist)
-	    expr2 = ast_for_testlist(c, ch);
-	else
-	    expr2 = ast_for_expr(c, ch);
+        ch = CHILD(n, 2);
+        if (TYPE(ch) == testlist)
+            expr2 = ast_for_testlist(c, ch);
+        else
+            expr2 = ast_for_expr(c, ch);
         if (!expr2)
             return NULL;
 
@@ -1975,45 +1982,45 @@
         if (!newoperator)
             return NULL;
 
-	return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
+        return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
     }
     else {
-	int i;
-	asdl_seq *targets;
-	node *value;
+        int i;
+        asdl_seq *targets;
+        node *value;
         expr_ty expression;
 
-	/* a normal assignment */
-	REQ(CHILD(n, 1), EQUAL);
-	targets = asdl_seq_new(NCH(n) / 2, c->c_arena);
-	if (!targets)
-	    return NULL;
-	for (i = 0; i < NCH(n) - 2; i += 2) {
-	    expr_ty e;
-	    node *ch = CHILD(n, i);
-	    if (TYPE(ch) == yield_expr) {
-		ast_error(ch, "assignment to yield expression not possible");
-		return NULL;
-	    }
-	    e = ast_for_testlist(c, ch);
-
-	    /* set context to assign */
-	    if (!e) 
-	      return NULL;
-
-	    if (!set_context(e, Store, CHILD(n, i)))
-	      return NULL;
-
-	    asdl_seq_SET(targets, i / 2, e);
-	}
-	value = CHILD(n, NCH(n) - 1);
-	if (TYPE(value) == testlist)
-	    expression = ast_for_testlist(c, value);
-	else
-	    expression = ast_for_expr(c, value);
-	if (!expression)
-	    return NULL;
-	return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena);
+        /* a normal assignment */
+        REQ(CHILD(n, 1), EQUAL);
+        targets = asdl_seq_new(NCH(n) / 2, c->c_arena);
+        if (!targets)
+            return NULL;
+        for (i = 0; i < NCH(n) - 2; i += 2) {
+            expr_ty e;
+            node *ch = CHILD(n, i);
+            if (TYPE(ch) == yield_expr) {
+                ast_error(ch, "assignment to yield expression not possible");
+                return NULL;
+            }
+            e = ast_for_testlist(c, ch);
+
+            /* set context to assign */
+            if (!e) 
+              return NULL;
+
+            if (!set_context(e, Store, CHILD(n, i)))
+              return NULL;
+
+            asdl_seq_SET(targets, i / 2, e);
+        }
+        value = CHILD(n, NCH(n) - 1);
+        if (TYPE(value) == testlist)
+            expression = ast_for_testlist(c, value);
+        else
+            expression = ast_for_expr(c, value);
+        if (!expression)
+            return NULL;
+        return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena);
     }
 }
 
@@ -2030,19 +2037,19 @@
 
     REQ(n, print_stmt);
     if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) {
-	dest = ast_for_expr(c, CHILD(n, 2));
+        dest = ast_for_expr(c, CHILD(n, 2));
         if (!dest)
             return NULL;
-	    start = 4;
+            start = 4;
     }
     seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena);
     if (!seq)
-    	return NULL;
+        return NULL;
     for (i = start, j = 0; i < NCH(n); i += 2, ++j) {
         expression = ast_for_expr(c, CHILD(n, i));
         if (!expression)
             return NULL;
-    	asdl_seq_SET(seq, j, expression);
+        asdl_seq_SET(seq, j, expression);
     }
     nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true;
     return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena);
@@ -2059,14 +2066,14 @@
 
     seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
     if (!seq)
-	return NULL;
+        return NULL;
     for (i = 0; i < NCH(n); i += 2) {
-	e = ast_for_expr(c, CHILD(n, i));
-	if (!e)
-	    return NULL;
-	asdl_seq_SET(seq, i / 2, e);
-	if (context && !set_context(e, context, CHILD(n, i)))
-	    return NULL;
+        e = ast_for_expr(c, CHILD(n, i));
+        if (!e)
+            return NULL;
+        asdl_seq_SET(seq, i / 2, e);
+        if (context && !set_context(e, context, CHILD(n, i)))
+            return NULL;
     }
     return seq;
 }
@@ -2108,9 +2115,9 @@
         case continue_stmt:
             return Continue(LINENO(n), n->n_col_offset, c->c_arena);
         case yield_stmt: { /* will reduce to yield_expr */
-	    expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
-	    if (!exp)
-		return NULL;
+            expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
+            if (!exp)
+                return NULL;
             return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena);
         }
         case return_stmt:
@@ -2237,13 +2244,13 @@
                 --s;
                 *s = '\0';
                 PyString_InternInPlace(&str);
-		PyArena_AddPyObject(c->c_arena, str);
+                PyArena_AddPyObject(c->c_arena, str);
                 return alias(str, NULL, c->c_arena);
             }
             break;
         case STAR:
-	    str = PyString_InternFromString("*");
-	    PyArena_AddPyObject(c->c_arena, str);
+            str = PyString_InternFromString("*");
+            PyArena_AddPyObject(c->c_arena, str);
             return alias(str, NULL, c->c_arena);
         default:
             PyErr_Format(PyExc_SystemError,
@@ -2275,69 +2282,69 @@
     n = CHILD(n, 0);
     if (TYPE(n) == import_name) {
         n = CHILD(n, 1);
-	REQ(n, dotted_as_names);
-	aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
-	if (!aliases)
-		return NULL;
-	for (i = 0; i < NCH(n); i += 2) {
+        REQ(n, dotted_as_names);
+        aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
+        if (!aliases)
+                return NULL;
+        for (i = 0; i < NCH(n); i += 2) {
             alias_ty import_alias = alias_for_import_name(c, CHILD(n, i));
             if (!import_alias)
                 return NULL;
-	    asdl_seq_SET(aliases, i / 2, import_alias);
+            asdl_seq_SET(aliases, i / 2, import_alias);
         }
-	return Import(aliases, lineno, col_offset, c->c_arena);
+        return Import(aliases, lineno, col_offset, c->c_arena);
     }
     else if (TYPE(n) == import_from) {
         int n_children;
-	int idx, ndots = 0;
-	alias_ty mod = NULL;
-	identifier modname;
-	
+        int idx, ndots = 0;
+        alias_ty mod = NULL;
+        identifier modname;
+        
        /* Count the number of dots (for relative imports) and check for the
           optional module name */
-	for (idx = 1; idx < NCH(n); idx++) {
-	    if (TYPE(CHILD(n, idx)) == dotted_name) {
-	    	mod = alias_for_import_name(c, CHILD(n, idx));
-	    	idx++;
-	    	break;
-	    } else if (TYPE(CHILD(n, idx)) != DOT) {
-	        break;
-	    }
-	    ndots++;
-	}
-	idx++; /* skip over the 'import' keyword */
+        for (idx = 1; idx < NCH(n); idx++) {
+            if (TYPE(CHILD(n, idx)) == dotted_name) {
+                mod = alias_for_import_name(c, CHILD(n, idx));
+                idx++;
+                break;
+            } else if (TYPE(CHILD(n, idx)) != DOT) {
+                break;
+            }
+            ndots++;
+        }
+        idx++; /* skip over the 'import' keyword */
         switch (TYPE(CHILD(n, idx))) {
         case STAR:
             /* from ... import * */
-	    n = CHILD(n, idx);
-	    n_children = 1;
-	    if (ndots) {
-	        ast_error(n, "'import *' not allowed with 'from .'");
-	        return NULL;
-	    }
-	    break;
-	case LPAR:
-	    /* from ... import (x, y, z) */
-	    n = CHILD(n, idx + 1);
-	    n_children = NCH(n);
-	    break;
-	case import_as_names:
-	    /* from ... import x, y, z */
-	    n = CHILD(n, idx);
-	    n_children = NCH(n);
+            n = CHILD(n, idx);
+            n_children = 1;
+            if (ndots) {
+                ast_error(n, "'import *' not allowed with 'from .'");
+                return NULL;
+            }
+            break;
+        case LPAR:
+            /* from ... import (x, y, z) */
+            n = CHILD(n, idx + 1);
+            n_children = NCH(n);
+            break;
+        case import_as_names:
+            /* from ... import x, y, z */
+            n = CHILD(n, idx);
+            n_children = NCH(n);
             if (n_children % 2 == 0) {
                 ast_error(n, "trailing comma not allowed without"
                              " surrounding parentheses");
                 return NULL;
             }
-	    break;
-	default:
-	    ast_error(n, "Unexpected node-type in from-import");
-	    return NULL;
-	}
+            break;
+        default:
+            ast_error(n, "Unexpected node-type in from-import");
+            return NULL;
+        }
 
-	aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena);
-	if (!aliases)
+        aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena);
+        if (!aliases)
             return NULL;
 
         /* handle "from ... import *" special b/c there's no children */
@@ -2345,14 +2352,14 @@
             alias_ty import_alias = alias_for_import_name(c, n);
             if (!import_alias)
                 return NULL;
-	        asdl_seq_SET(aliases, 0, import_alias);
+                asdl_seq_SET(aliases, 0, import_alias);
         }
         else {
-    	    for (i = 0; i < NCH(n); i += 2) {
+            for (i = 0; i < NCH(n); i += 2) {
                 alias_ty import_alias = alias_for_import_name(c, CHILD(n, i));
                 if (!import_alias)
                     return NULL;
-	            asdl_seq_SET(aliases, i / 2, import_alias);
+                    asdl_seq_SET(aliases, i / 2, import_alias);
             }
         }
         if (mod != NULL)
@@ -2379,12 +2386,12 @@
     REQ(n, global_stmt);
     s = asdl_seq_new(NCH(n) / 2, c->c_arena);
     if (!s)
-    	return NULL;
+        return NULL;
     for (i = 1; i < NCH(n); i += 2) {
-	name = NEW_IDENTIFIER(CHILD(n, i));
-	if (!name)
-	    return NULL;
-	asdl_seq_SET(s, i / 2, name);
+        name = NEW_IDENTIFIER(CHILD(n, i));
+        if (!name)
+            return NULL;
+        asdl_seq_SET(s, i / 2, name);
     }
     return Global(s, LINENO(n), n->n_col_offset, c->c_arena);
 }
@@ -2429,7 +2436,7 @@
         expr_ty expression = ast_for_expr(c, CHILD(n, 1));
         if (!expression)
             return NULL;
-	return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+        return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena);
     }
     else if (NCH(n) == 4) {
         expr_ty expr1, expr2;
@@ -2441,7 +2448,7 @@
         if (!expr2)
             return NULL;
             
-	return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena);
+        return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena);
     }
     PyErr_Format(PyExc_SystemError,
                  "improper number of parts to 'assert' statement: %d",
@@ -2463,53 +2470,53 @@
     total = num_stmts(n);
     seq = asdl_seq_new(total, c->c_arena);
     if (!seq)
-    	return NULL;
+        return NULL;
     if (TYPE(CHILD(n, 0)) == simple_stmt) {
-	n = CHILD(n, 0);
-	/* simple_stmt always ends with a NEWLINE,
-	   and may have a trailing SEMI 
-	*/
-	end = NCH(n) - 1;
-	if (TYPE(CHILD(n, end - 1)) == SEMI)
-	    end--;
+        n = CHILD(n, 0);
+        /* simple_stmt always ends with a NEWLINE,
+           and may have a trailing SEMI 
+        */
+        end = NCH(n) - 1;
+        if (TYPE(CHILD(n, end - 1)) == SEMI)
+            end--;
         /* loop by 2 to skip semi-colons */
-	for (i = 0; i < end; i += 2) {
-	    ch = CHILD(n, i);
-	    s = ast_for_stmt(c, ch);
-	    if (!s)
-		return NULL;
-	    asdl_seq_SET(seq, pos++, s);
-	}
+        for (i = 0; i < end; i += 2) {
+            ch = CHILD(n, i);
+            s = ast_for_stmt(c, ch);
+            if (!s)
+                return NULL;
+            asdl_seq_SET(seq, pos++, s);
+        }
     }
     else {
-	for (i = 2; i < (NCH(n) - 1); i++) {
-	    ch = CHILD(n, i);
-	    REQ(ch, stmt);
-	    num = num_stmts(ch);
-	    if (num == 1) {
-		/* small_stmt or compound_stmt with only one child */
-		s = ast_for_stmt(c, ch);
-		if (!s)
-		    return NULL;
-		asdl_seq_SET(seq, pos++, s);
-	    }
-	    else {
-		int j;
-		ch = CHILD(ch, 0);
-		REQ(ch, simple_stmt);
-		for (j = 0; j < NCH(ch); j += 2) {
-		    /* statement terminates with a semi-colon ';' */
-		    if (NCH(CHILD(ch, j)) == 0) {
-			assert((j + 1) == NCH(ch));
-			break;
-		    }
-		    s = ast_for_stmt(c, CHILD(ch, j));
-		    if (!s)
-			return NULL;
-		    asdl_seq_SET(seq, pos++, s);
-		}
-	    }
-	}
+        for (i = 2; i < (NCH(n) - 1); i++) {
+            ch = CHILD(n, i);
+            REQ(ch, stmt);
+            num = num_stmts(ch);
+            if (num == 1) {
+                /* small_stmt or compound_stmt with only one child */
+                s = ast_for_stmt(c, ch);
+                if (!s)
+                    return NULL;
+                asdl_seq_SET(seq, pos++, s);
+            }
+            else {
+                int j;
+                ch = CHILD(ch, 0);
+                REQ(ch, simple_stmt);
+                for (j = 0; j < NCH(ch); j += 2) {
+                    /* statement terminates with a semi-colon ';' */
+                    if (NCH(CHILD(ch, j)) == 0) {
+                        assert((j + 1) == NCH(ch));
+                        break;
+                    }
+                    s = ast_for_stmt(c, CHILD(ch, j));
+                    if (!s)
+                        return NULL;
+                    asdl_seq_SET(seq, pos++, s);
+                }
+            }
+        }
     }
     assert(pos == seq->size);
     return seq;
@@ -2536,7 +2543,7 @@
         if (!suite_seq)
             return NULL;
             
-	return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+        return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
     }
 
     s = STR(CHILD(n, 4));
@@ -2558,28 +2565,28 @@
         if (!seq2)
             return NULL;
 
-	return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
+        return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
     }
     else if (s[2] == 'i') {
-	int i, n_elif, has_else = 0;
-	asdl_seq *orelse = NULL;
-	n_elif = NCH(n) - 4;
+        int i, n_elif, has_else = 0;
+        asdl_seq *orelse = NULL;
+        n_elif = NCH(n) - 4;
         /* must reference the child n_elif+1 since 'else' token is third,
            not fourth, child from the end. */
-	if (TYPE(CHILD(n, (n_elif + 1))) == NAME
-	    && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
-	    has_else = 1;
-	    n_elif -= 3;
-	}
-	n_elif /= 4;
+        if (TYPE(CHILD(n, (n_elif + 1))) == NAME
+            && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
+            has_else = 1;
+            n_elif -= 3;
+        }
+        n_elif /= 4;
 
-	if (has_else) {
+        if (has_else) {
             expr_ty expression;
             asdl_seq *seq1, *seq2;
 
-	    orelse = asdl_seq_new(1, c->c_arena);
-	    if (!orelse)
-		return NULL;
+            orelse = asdl_seq_new(1, c->c_arena);
+            if (!orelse)
+                return NULL;
             expression = ast_for_expr(c, CHILD(n, NCH(n) - 6));
             if (!expression)
                 return NULL;
@@ -2590,20 +2597,20 @@
             if (!seq2)
                 return NULL;
 
-	    asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, 
-				       LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset,
+            asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, 
+                                       LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset,
                                        c->c_arena));
-	    /* the just-created orelse handled the last elif */
-	    n_elif--;
-	}
+            /* the just-created orelse handled the last elif */
+            n_elif--;
+        }
 
-	for (i = 0; i < n_elif; i++) {
-	    int off = 5 + (n_elif - i - 1) * 4;
+        for (i = 0; i < n_elif; i++) {
+            int off = 5 + (n_elif - i - 1) * 4;
             expr_ty expression;
             asdl_seq *suite_seq;
-	    asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
-	    if (!newobj)
-		return NULL;
+            asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
+            if (!newobj)
+                return NULL;
             expression = ast_for_expr(c, CHILD(n, off));
             if (!expression)
                 return NULL;
@@ -2611,14 +2618,14 @@
             if (!suite_seq)
                 return NULL;
 
-	    asdl_seq_SET(newobj, 0,
-			 If(expression, suite_seq, orelse, 
-			    LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
-	    orelse = newobj;
-	}
-	return If(ast_for_expr(c, CHILD(n, 1)),
-		  ast_for_suite(c, CHILD(n, 3)),
-		  orelse, LINENO(n), n->n_col_offset, c->c_arena);
+            asdl_seq_SET(newobj, 0,
+                         If(expression, suite_seq, orelse, 
+                            LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
+            orelse = newobj;
+        }
+        return If(ast_for_expr(c, CHILD(n, 1)),
+                  ast_for_suite(c, CHILD(n, 3)),
+                  orelse, LINENO(n), n->n_col_offset, c->c_arena);
     }
 
     PyErr_Format(PyExc_SystemError,
@@ -2642,7 +2649,7 @@
         suite_seq = ast_for_suite(c, CHILD(n, 3));
         if (!suite_seq)
             return NULL;
-	return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+        return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
     }
     else if (NCH(n) == 7) {
         expr_ty expression;
@@ -2658,7 +2665,7 @@
         if (!seq2)
             return NULL;
 
-	return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
+        return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
     }
 
     PyErr_Format(PyExc_SystemError,
@@ -2678,7 +2685,7 @@
     REQ(n, for_stmt);
 
     if (NCH(n) == 9) {
-	seq = ast_for_suite(c, CHILD(n, 8));
+        seq = ast_for_suite(c, CHILD(n, 8));
         if (!seq)
             return NULL;
     }
@@ -2690,9 +2697,9 @@
     /* Check the # of children rather than the length of _target, since
        for x, in ... has 1 element in _target, but still requires a Tuple. */
     if (NCH(node_target) == 1)
-	target = (expr_ty)asdl_seq_GET(_target, 0);
+        target = (expr_ty)asdl_seq_GET(_target, 0);
     else
-	target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);
+        target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);
 
     expression = ast_for_testlist(c, CHILD(n, 3));
     if (!expression)
@@ -2717,7 +2724,7 @@
         if (!suite_seq)
             return NULL;
 
-	return excepthandler(NULL, NULL, suite_seq, LINENO(exc),
+        return excepthandler(NULL, NULL, suite_seq, LINENO(exc),
                              exc->n_col_offset, c->c_arena);
     }
     else if (NCH(exc) == 2) {
@@ -2731,16 +2738,16 @@
         if (!suite_seq)
             return NULL;
 
-	return excepthandler(expression, NULL, suite_seq, LINENO(exc),
+        return excepthandler(expression, NULL, suite_seq, LINENO(exc),
                              exc->n_col_offset, c->c_arena);
     }
     else if (NCH(exc) == 4) {
         asdl_seq *suite_seq;
         expr_ty expression;
-	expr_ty e = ast_for_expr(c, CHILD(exc, 3));
-	if (!e)
+        expr_ty e = ast_for_expr(c, CHILD(exc, 3));
+        if (!e)
             return NULL;
-	if (!set_context(e, Store, CHILD(exc, 3)))
+        if (!set_context(e, Store, CHILD(exc, 3)))
             return NULL;
         expression = ast_for_expr(c, CHILD(exc, 1));
         if (!expression)
@@ -2749,7 +2756,7 @@
         if (!suite_seq)
             return NULL;
 
-	return excepthandler(expression, e, suite_seq, LINENO(exc),
+        return excepthandler(expression, e, suite_seq, LINENO(exc),
                              exc->n_col_offset, c->c_arena);
     }
 
@@ -2804,8 +2811,8 @@
     }
     
     if (n_except > 0) {
-	int i;
-	stmt_ty except_st;
+        int i;
+        stmt_ty except_st;
         /* process except statements to create a try ... except */
         asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena);
         if (handlers == NULL)
@@ -2819,17 +2826,17 @@
             asdl_seq_SET(handlers, i, e);
         }
 
-	except_st = TryExcept(body, handlers, orelse, LINENO(n),
+        except_st = TryExcept(body, handlers, orelse, LINENO(n),
                               n->n_col_offset, c->c_arena);
         if (!finally)
-	    return except_st;
+            return except_st;
 
         /* if a 'finally' is present too, we nest the TryExcept within a
            TryFinally to emulate try ... except ... finally */
-	body = asdl_seq_new(1, c->c_arena);
-	if (body == NULL)
-	    return NULL;
-	asdl_seq_SET(body, 0, except_st);
+        body = asdl_seq_new(1, c->c_arena);
+        if (body == NULL)
+            return NULL;
+        asdl_seq_SET(body, 0, except_st);
     }
 
     /* must be a try ... finally (except clauses are in body, if any exist) */
@@ -2864,9 +2871,9 @@
         if (!optional_vars) {
             return NULL;
         }
-	if (!set_context(optional_vars, Store, n)) {
-	    return NULL;
-	}
+        if (!set_context(optional_vars, Store, n)) {
+            return NULL;
+        }
         suite_index = 4;
     }
 
@@ -2875,7 +2882,7 @@
         return NULL;
     }
     return With(context_expr, optional_vars, suite_seq, LINENO(n), 
-		n->n_col_offset, c->c_arena);
+                n->n_col_offset, c->c_arena);
 }
 
 static stmt_ty
@@ -2887,23 +2894,23 @@
     REQ(n, classdef);
 
     if (!strcmp(STR(CHILD(n, 1)), "None")) {
-	    ast_error(n, "assignment to None");
-	    return NULL;
+            ast_error(n, "assignment to None");
+            return NULL;
     }
 
     if (NCH(n) == 4) {
         s = ast_for_suite(c, CHILD(n, 3));
         if (!s)
             return NULL;
-	return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
+        return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
                         n->n_col_offset, c->c_arena);
     }
     /* check for empty base list */
     if (TYPE(CHILD(n,3)) == RPAR) {
-	s = ast_for_suite(c, CHILD(n,5));
-	if (!s)
-		return NULL;
-	return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
+        s = ast_for_suite(c, CHILD(n,5));
+        if (!s)
+                return NULL;
+        return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
                         n->n_col_offset, c->c_arena);
     }
 
@@ -2923,21 +2930,21 @@
 ast_for_stmt(struct compiling *c, const node *n)
 {
     if (TYPE(n) == stmt) {
-	assert(NCH(n) == 1);
-	n = CHILD(n, 0);
+        assert(NCH(n) == 1);
+        n = CHILD(n, 0);
     }
     if (TYPE(n) == simple_stmt) {
-	assert(num_stmts(n) == 1);
-	n = CHILD(n, 0);
+        assert(num_stmts(n) == 1);
+        n = CHILD(n, 0);
     }
     if (TYPE(n) == small_stmt) {
-	REQ(n, small_stmt);
-	n = CHILD(n, 0);
-	/* small_stmt: expr_stmt | print_stmt  | del_stmt | pass_stmt
-	             | flow_stmt | import_stmt | global_stmt | exec_stmt
+        REQ(n, small_stmt);
+        n = CHILD(n, 0);
+        /* small_stmt: expr_stmt | print_stmt  | del_stmt | pass_stmt
+                     | flow_stmt | import_stmt | global_stmt | exec_stmt
                      | assert_stmt
-	*/
-	switch (TYPE(n)) {
+        */
+        switch (TYPE(n)) {
             case expr_stmt:
                 return ast_for_expr_stmt(c, n);
             case print_stmt:
@@ -2965,11 +2972,11 @@
     }
     else {
         /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt
-	                | funcdef | classdef
-	*/
-	node *ch = CHILD(n, 0);
-	REQ(n, compound_stmt);
-	switch (TYPE(ch)) {
+                        | funcdef | classdef
+        */
+        node *ch = CHILD(n, 0);
+        REQ(n, compound_stmt);
+        switch (TYPE(ch)) {
             case if_stmt:
                 return ast_for_if_stmt(c, ch);
             case while_stmt:
@@ -2989,144 +2996,144 @@
                              "unhandled small_stmt: TYPE=%d NCH=%d\n",
                              TYPE(n), NCH(n));
                 return NULL;
-	}
+        }
     }
 }
 
 static PyObject *
 parsenumber(const char *s)
 {
-	const char *end;
-	long x;
-	double dx;
+        const char *end;
+        long x;
+        double dx;
 #ifndef WITHOUT_COMPLEX
-	Py_complex c;
-	int imflag;
+        Py_complex c;
+        int imflag;
 #endif
 
-	errno = 0;
-	end = s + strlen(s) - 1;
+        errno = 0;
+        end = s + strlen(s) - 1;
 #ifndef WITHOUT_COMPLEX
-	imflag = *end == 'j' || *end == 'J';
+        imflag = *end == 'j' || *end == 'J';
 #endif
-	if (*end == 'l' || *end == 'L')
-		return PyLong_FromString((char *)s, (char **)0, 0);
-	if (s[0] == '0') {
-		x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
- 		if (x < 0 && errno == 0) {
-	 			return PyLong_FromString((char *)s,
-							 (char **)0,
-							 0);
-		}
-	}
-	else
-		x = PyOS_strtol((char *)s, (char **)&end, 0);
-	if (*end == '\0') {
-		if (errno != 0)
-			return PyLong_FromString((char *)s, (char **)0, 0);
-		return PyInt_FromLong(x);
-	}
-	/* XXX Huge floats may silently fail */
+        if (*end == 'l' || *end == 'L')
+                return PyLong_FromString((char *)s, (char **)0, 0);
+        if (s[0] == '0') {
+                x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
+                if (x < 0 && errno == 0) {
+                                return PyLong_FromString((char *)s,
+                                                         (char **)0,
+                                                         0);
+                }
+        }
+        else
+                x = PyOS_strtol((char *)s, (char **)&end, 0);
+        if (*end == '\0') {
+                if (errno != 0)
+                        return PyLong_FromString((char *)s, (char **)0, 0);
+                return PyInt_FromLong(x);
+        }
+        /* XXX Huge floats may silently fail */
 #ifndef WITHOUT_COMPLEX
-	if (imflag) {
-		c.real = 0.;
-		PyFPE_START_PROTECT("atof", return 0)
-		c.imag = PyOS_ascii_atof(s);
-		PyFPE_END_PROTECT(c)
-		return PyComplex_FromCComplex(c);
-	}
-	else
+        if (imflag) {
+                c.real = 0.;
+                PyFPE_START_PROTECT("atof", return 0)
+                c.imag = PyOS_ascii_atof(s);
+                PyFPE_END_PROTECT(c)
+                return PyComplex_FromCComplex(c);
+        }
+        else
 #endif
-	{
-		PyFPE_START_PROTECT("atof", return 0)
-		dx = PyOS_ascii_atof(s);
-		PyFPE_END_PROTECT(dx)
-		return PyFloat_FromDouble(dx);
-	}
+        {
+                PyFPE_START_PROTECT("atof", return 0)
+                dx = PyOS_ascii_atof(s);
+                PyFPE_END_PROTECT(dx)
+                return PyFloat_FromDouble(dx);
+        }
 }
 
 static PyObject *
 decode_utf8(const char **sPtr, const char *end, char* encoding)
 {
 #ifndef Py_USING_UNICODE
-	Py_FatalError("decode_utf8 should not be called in this build.");
+        Py_FatalError("decode_utf8 should not be called in this build.");
         return NULL;
 #else
-	PyObject *u, *v;
-	char *s, *t;
-	t = s = (char *)*sPtr;
-	/* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
-	while (s < end && (*s & 0x80)) s++;
-	*sPtr = s;
-	u = PyUnicode_DecodeUTF8(t, s - t, NULL);
-	if (u == NULL)
-		return NULL;
-	v = PyUnicode_AsEncodedString(u, encoding, NULL);
-	Py_DECREF(u);
-	return v;
+        PyObject *u, *v;
+        char *s, *t;
+        t = s = (char *)*sPtr;
+        /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
+        while (s < end && (*s & 0x80)) s++;
+        *sPtr = s;
+        u = PyUnicode_DecodeUTF8(t, s - t, NULL);
+        if (u == NULL)
+                return NULL;
+        v = PyUnicode_AsEncodedString(u, encoding, NULL);
+        Py_DECREF(u);
+        return v;
 #endif
 }
 
 static PyObject *
 decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
 {
-	PyObject *v, *u;
-	char *buf;
-	char *p;
-	const char *end;
-	if (encoding == NULL) {
-	     	buf = (char *)s;
-		u = NULL;
-	} else if (strcmp(encoding, "iso-8859-1") == 0) {
-	     	buf = (char *)s;
-		u = NULL;
-	} else {
-		/* "\XX" may become "\u005c\uHHLL" (12 bytes) */
-		u = PyString_FromStringAndSize((char *)NULL, len * 4);
-		if (u == NULL)
-			return NULL;
-		p = buf = PyString_AsString(u);
-		end = s + len;
-		while (s < end) {
-			if (*s == '\\') {
-				*p++ = *s++;
-				if (*s & 0x80) {
-					strcpy(p, "u005c");
-					p += 5;
-				}
-			}
-			if (*s & 0x80) { /* XXX inefficient */
-				PyObject *w;
-				char *r;
-				Py_ssize_t rn, i;
-				w = decode_utf8(&s, end, "utf-16-be");
-				if (w == NULL) {
-					Py_DECREF(u);
-					return NULL;
-				}
-				r = PyString_AsString(w);
-				rn = PyString_Size(w);
-				assert(rn % 2 == 0);
-				for (i = 0; i < rn; i += 2) {
-					sprintf(p, "\\u%02x%02x",
-						r[i + 0] & 0xFF,
-						r[i + 1] & 0xFF);
-					p += 6;
-				}
-				Py_DECREF(w);
-			} else {
-				*p++ = *s++;
-			}
-		}
-		len = p - buf;
-		s = buf;
-	}
-	if (rawmode)
-		v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL);
-	else
-		v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
-	Py_XDECREF(u);
-	return v;
+        PyObject *v, *u;
+        char *buf;
+        char *p;
+        const char *end;
+        if (encoding == NULL) {
+                buf = (char *)s;
+                u = NULL;
+        } else if (strcmp(encoding, "iso-8859-1") == 0) {
+                buf = (char *)s;
+                u = NULL;
+        } else {
+                /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
+                u = PyString_FromStringAndSize((char *)NULL, len * 4);
+                if (u == NULL)
+                        return NULL;
+                p = buf = PyString_AsString(u);
+                end = s + len;
+                while (s < end) {
+                        if (*s == '\\') {
+                                *p++ = *s++;
+                                if (*s & 0x80) {
+                                        strcpy(p, "u005c");
+                                        p += 5;
+                                }
+                        }
+                        if (*s & 0x80) { /* XXX inefficient */
+                                PyObject *w;
+                                char *r;
+                                Py_ssize_t rn, i;
+                                w = decode_utf8(&s, end, "utf-16-be");
+                                if (w == NULL) {
+                                        Py_DECREF(u);
+                                        return NULL;
+                                }
+                                r = PyString_AsString(w);
+                                rn = PyString_Size(w);
+                                assert(rn % 2 == 0);
+                                for (i = 0; i < rn; i += 2) {
+                                        sprintf(p, "\\u%02x%02x",
+                                                r[i + 0] & 0xFF,
+                                                r[i + 1] & 0xFF);
+                                        p += 6;
+                                }
+                                Py_DECREF(w);
+                        } else {
+                                *p++ = *s++;
+                        }
+                }
+                len = p - buf;
+                s = buf;
+        }
+        if (rawmode)
+                v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL);
+        else
+                v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
+        Py_XDECREF(u);
+        return v;
 }
 
 /* s is a Python string literal, including the bracketing quote characters,
@@ -3136,75 +3143,75 @@
 static PyObject *
 parsestr(const char *s, const char *encoding)
 {
-	size_t len;
-	int quote = Py_CHARMASK(*s);
-	int rawmode = 0;
-	int need_encoding;
-	int unicode = 0;
-
-	if (isalpha(quote) || quote == '_') {
-		if (quote == 'u' || quote == 'U') {
-			quote = *++s;
-			unicode = 1;
-		}
-		if (quote == 'r' || quote == 'R') {
-			quote = *++s;
-			rawmode = 1;
-		}
-	}
-	if (quote != '\'' && quote != '\"') {
-		PyErr_BadInternalCall();
-		return NULL;
-	}
-	s++;
-	len = strlen(s);
-	if (len > INT_MAX) {
-		PyErr_SetString(PyExc_OverflowError, 
-				"string to parse is too long");
-		return NULL;
-	}
-	if (s[--len] != quote) {
-		PyErr_BadInternalCall();
-		return NULL;
-	}
-	if (len >= 4 && s[0] == quote && s[1] == quote) {
-		s += 2;
-		len -= 2;
-		if (s[--len] != quote || s[--len] != quote) {
-			PyErr_BadInternalCall();
-			return NULL;
-		}
-	}
+        size_t len;
+        int quote = Py_CHARMASK(*s);
+        int rawmode = 0;
+        int need_encoding;
+        int unicode = 0;
+
+        if (isalpha(quote) || quote == '_') {
+                if (quote == 'u' || quote == 'U') {
+                        quote = *++s;
+                        unicode = 1;
+                }
+                if (quote == 'r' || quote == 'R') {
+                        quote = *++s;
+                        rawmode = 1;
+                }
+        }
+        if (quote != '\'' && quote != '\"') {
+                PyErr_BadInternalCall();
+                return NULL;
+        }
+        s++;
+        len = strlen(s);
+        if (len > INT_MAX) {
+                PyErr_SetString(PyExc_OverflowError, 
+                                "string to parse is too long");
+                return NULL;
+        }
+        if (s[--len] != quote) {
+                PyErr_BadInternalCall();
+                return NULL;
+        }
+        if (len >= 4 && s[0] == quote && s[1] == quote) {
+                s += 2;
+                len -= 2;
+                if (s[--len] != quote || s[--len] != quote) {
+                        PyErr_BadInternalCall();
+                        return NULL;
+                }
+        }
 #ifdef Py_USING_UNICODE
-	if (unicode || Py_UnicodeFlag) {
-		return decode_unicode(s, len, rawmode, encoding);
-	}
+        if (unicode || Py_UnicodeFlag) {
+                return decode_unicode(s, len, rawmode, encoding);
+        }
 #endif
-	need_encoding = (encoding != NULL &&
-			 strcmp(encoding, "utf-8") != 0 &&
-			 strcmp(encoding, "iso-8859-1") != 0);
-	if (rawmode || strchr(s, '\\') == NULL) {
-		if (need_encoding) {
+        need_encoding = (encoding != NULL &&
+                         strcmp(encoding, "utf-8") != 0 &&
+                         strcmp(encoding, "iso-8859-1") != 0);
+        if (rawmode || strchr(s, '\\') == NULL) {
+                if (need_encoding) {
 #ifndef Py_USING_UNICODE
-			/* This should not happen - we never see any other
-			   encoding. */
-			Py_FatalError(
+                        /* This should not happen - we never see any other
+                           encoding. */
+                        Py_FatalError(
                             "cannot deal with encodings in this build.");
 #else
-			PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
-			if (u == NULL)
-				return NULL;
-			v = PyUnicode_AsEncodedString(u, encoding, NULL);
-			Py_DECREF(u);
-			return v;
+                        PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
+                        if (u == NULL)
+                                return NULL;
+                        v = PyUnicode_AsEncodedString(u, encoding, NULL);
+                        Py_DECREF(u);
+                        return v;
 #endif
-		} else {
-			return PyString_FromStringAndSize(s, len);
-		}
-	}
+                } else {
+                        return PyString_FromStringAndSize(s, len);
+                }
+        }
 
-	return PyString_DecodeEscape(s, len, NULL, unicode,
-				     need_encoding ? encoding : NULL);
+        return PyString_DecodeEscape(s, len, NULL, unicode,
+                                     need_encoding ? encoding : NULL);
 }
 
 /* Build a Python string object out of a STRING atom.  This takes care of
@@ -3214,36 +3221,36 @@
 static PyObject *
 parsestrplus(struct compiling *c, const node *n)
 {
-	PyObject *v;
-	int i;
-	REQ(CHILD(n, 0), STRING);
-	if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) {
-		/* String literal concatenation */
-		for (i = 1; i < NCH(n); i++) {
-			PyObject *s;
-			s = parsestr(STR(CHILD(n, i)), c->c_encoding);
-			if (s == NULL)
-				goto onError;
-			if (PyString_Check(v) && PyString_Check(s)) {
-				PyString_ConcatAndDel(&v, s);
-				if (v == NULL)
-				    goto onError;
-			}
+        PyObject *v;
+        int i;
+        REQ(CHILD(n, 0), STRING);
+        if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) {
+                /* String literal concatenation */
+                for (i = 1; i < NCH(n); i++) {
+                        PyObject *s;
+                        s = parsestr(STR(CHILD(n, i)), c->c_encoding);
+                        if (s == NULL)
+                                goto onError;
+                        if (PyString_Check(v) && PyString_Check(s)) {
+                                PyString_ConcatAndDel(&v, s);
+                                if (v == NULL)
+                                    goto onError;
+                        }
 #ifdef Py_USING_UNICODE
-			else {
-				PyObject *temp = PyUnicode_Concat(v, s);
-				Py_DECREF(s);
-				Py_DECREF(v);
-				v = temp;
-				if (v == NULL)
-				    goto onError;
-			}
+                        else {
+                                PyObject *temp = PyUnicode_Concat(v, s);
+                                Py_DECREF(s);
+                                Py_DECREF(v);
+                                v = temp;
+                                if (v == NULL)
+                                    goto onError;
+                        }
 #endif
-		}
-	}
-	return v;
+                }
+        }
+        return v;
 
  onError:
-	Py_XDECREF(v);
-	return NULL;
+        Py_XDECREF(v);
+        return NULL;
 }

Modified: python/branches/bcannon-objcap/Python/bltinmodule.c
==============================================================================
--- python/branches/bcannon-objcap/Python/bltinmodule.c	(original)
+++ python/branches/bcannon-objcap/Python/bltinmodule.c	Tue Sep  5 19:47:00 2006
@@ -607,7 +607,7 @@
 Evaluate the source in the context of globals and locals.\n\
 The source may be a string representing a Python expression\n\
 or a code object as returned by compile().\n\
-The globals must be a dictionary and locals can be any mappping,\n\
+The globals must be a dictionary and locals can be any mapping,\n\
 defaulting to the current globals and locals.\n\
 If only globals is given, locals defaults to it.\n");
 

Modified: python/branches/bcannon-objcap/Python/import.c
==============================================================================
--- python/branches/bcannon-objcap/Python/import.c	(original)
+++ python/branches/bcannon-objcap/Python/import.c	Tue Sep  5 19:47:00 2006
@@ -64,9 +64,10 @@
        Python 2.5b3: 62111 (fix wrong code: x += yield)
        Python 2.5c1: 62121 (fix wrong lnotab with for loops and
        			    storing constants that should have been removed)
+       Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp)
 .
 */
-#define MAGIC (62121 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (62131 | ((long)'\r'<<16) | ((long)'\n'<<24))
 
 /* Magic word as global; note that _PyImport_Init() can change the
    value of this global to accommodate for alterations of how the

Modified: python/branches/bcannon-objcap/Tools/pybench/pybench.py
==============================================================================
--- python/branches/bcannon-objcap/Tools/pybench/pybench.py	(original)
+++ python/branches/bcannon-objcap/Tools/pybench/pybench.py	Tue Sep  5 19:47:00 2006
@@ -885,7 +885,7 @@
                 else:
                     bench.print_benchmark(hidenoise=hidenoise,
                                           limitnames=limitnames)
-            except IOError:
+            except IOError, reason:
                 print '* Error opening/reading file %s: %s' % (
                     repr(show_bench),
                     reason)
@@ -931,8 +931,13 @@
                 bench.name = reportfile
                 pickle.dump(bench,f)
                 f.close()
-            except IOError:
+            except IOError, reason:
                 print '* Error opening/writing reportfile'
+            except IOError, reason:
+                print '* Error opening/writing reportfile %s: %s' % (
+                    reportfile,
+                    reason)
+                print
 
 if __name__ == '__main__':
     PyBenchCmdline()

Modified: python/branches/bcannon-objcap/configure
==============================================================================
--- python/branches/bcannon-objcap/configure	(original)
+++ python/branches/bcannon-objcap/configure	Tue Sep  5 19:47:00 2006
@@ -1553,7 +1553,7 @@
   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
   # even though select is a POSIX function. Reported by J. Ribbens.
   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
-  OpenBSD/2.* | OpenBSD/3.[0123456789])
+  OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0])
     define_xopen_source=no;;
   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
   # of union __?sigval. Reported by Stuart Bishop.

Modified: python/branches/bcannon-objcap/configure.in
==============================================================================
--- python/branches/bcannon-objcap/configure.in	(original)
+++ python/branches/bcannon-objcap/configure.in	Tue Sep  5 19:47:00 2006
@@ -201,7 +201,7 @@
   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
   # even though select is a POSIX function. Reported by J. Ribbens.
   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
-  OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) 
+  OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) 
     define_xopen_source=no;;
   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
   # of union __?sigval. Reported by Stuart Bishop.


More information about the Python-checkins mailing list