Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

................
  r62425 | andrew.kuchling | 2008-04-21 03:45:57 +0200 (Mon, 21 Apr 2008) | 1 line

  Comment typo
................
  r62426 | mark.dickinson | 2008-04-21 03:55:50 +0200 (Mon, 21 Apr 2008) | 2 lines

  Silence 'r may be used uninitialized' compiler warning.
................
  r62427 | andrew.kuchling | 2008-04-21 04:08:00 +0200 (Mon, 21 Apr 2008) | 1 line

  Markup fix
................
  r62428 | andrew.kuchling | 2008-04-21 04:08:13 +0200 (Mon, 21 Apr 2008) | 1 line

  Wording changes
................
  r62429 | andrew.kuchling | 2008-04-21 04:14:24 +0200 (Mon, 21 Apr 2008) | 1 line

  Add various items
................
  r62434 | thomas.heller | 2008-04-21 15:46:55 +0200 (Mon, 21 Apr 2008) | 1 line

  Fix typo.
................
  r62435 | david.goodger | 2008-04-21 16:40:22 +0200 (Mon, 21 Apr 2008) | 1 line

  corrections ("reStructuredText" is one word)
................
  r62436 | david.goodger | 2008-04-21 16:43:33 +0200 (Mon, 21 Apr 2008) | 1 line

  capitalization
................
  r62441 | gregory.p.smith | 2008-04-21 19:46:40 +0200 (Mon, 21 Apr 2008) | 2 lines

  explicitly flush after the ... since there wasn't a newline
................
  r62444 | jeroen.ruigrok | 2008-04-21 22:15:39 +0200 (Mon, 21 Apr 2008) | 2 lines

  Windows x64 also falls under VER_PLATFORM_WIN32_NT.
................
  r62446 | gregory.p.smith | 2008-04-21 23:31:08 +0200 (Mon, 21 Apr 2008) | 3 lines

  If sys.stdin is not a tty, fall back to default_getpass after printing
  a warning instead of failing with a termios.error.
................
  r62447 | mark.dickinson | 2008-04-22 00:32:24 +0200 (Tue, 22 Apr 2008) | 8 lines

  test_math and test_cmath are failing on the FreeBSD 6.2 trunk buildbot,
  apparently because tanh(-0.) loses the sign of zero on that platform.
  If true, this is a bug in FreeBSD.

  Added a configure test to verify this.  I still need to figure out
  how best to deal with this failure.
................
  r62448 | amaury.forgeotdarc | 2008-04-22 00:35:30 +0200 (Tue, 22 Apr 2008) | 7 lines

  Issue 2665: On Windows, sys.stderr does not contain a valid file when running without a console.
  It seems to work, but will fail at the first flush.

  This causes IDLE to crash when too many warnings are printed.

  Will backport.
................
  r62450 | benjamin.peterson | 2008-04-22 00:57:00 +0200 (Tue, 22 Apr 2008) | 2 lines

  Fix Sphinx warnings
................
  r62451 | mark.dickinson | 2008-04-22 02:54:27 +0200 (Tue, 22 Apr 2008) | 3 lines

  Make configure test for tanh(-0.) == -0. committed in r62447 actually
  work.  (The test wasn't properly linked with libm.  Sigh.)
................
  r62452 | benjamin.peterson | 2008-04-22 04:16:03 +0200 (Tue, 22 Apr 2008) | 2 lines

  Various io doc updates
................
  r62453 | neal.norwitz | 2008-04-22 07:07:47 +0200 (Tue, 22 Apr 2008) | 1 line

  Add Thomas Lee
................
  r62454 | gregory.p.smith | 2008-04-22 10:08:41 +0200 (Tue, 22 Apr 2008) | 8 lines

  Major improvements:
  * Default to using /dev/tty for the password prompt and input before
    falling back to sys.stdin and sys.stderr.
  * Use sys.stderr instead of sys.stdout.
  * print the 'password may be echoed' warning to stream used to display
    the prompt rather than always sys.stderr.
  * warn() with GetPassWarning when input may be echoed.
................
  r62455 | gregory.p.smith | 2008-04-22 10:11:33 +0200 (Tue, 22 Apr 2008) | 2 lines

  update the getpass entry
................
  r62463 | amaury.forgeotdarc | 2008-04-22 23:14:41 +0200 (Tue, 22 Apr 2008) | 5 lines

  Issue #2670: urllib2.build_opener() failed when two handlers
  derive the same default base class.

  Will backport.
................
  r62465 | skip.montanaro | 2008-04-23 00:45:09 +0200 (Wed, 23 Apr 2008) | 3 lines

  Factor in documentation changes from issue 1753732.
................
  r62466 | gregory.p.smith | 2008-04-23 03:06:42 +0200 (Wed, 23 Apr 2008) | 2 lines

  syntax fixup
................
  r62469 | benjamin.peterson | 2008-04-23 22:38:06 +0200 (Wed, 23 Apr 2008) | 2 lines

  #2673 Fix example typo in optparse docs
................
  r62474 | martin.v.loewis | 2008-04-24 11:50:50 +0200 (Thu, 24 Apr 2008) | 2 lines

  Add Guilherme Polo.
................
  r62476 | martin.v.loewis | 2008-04-24 15:16:36 +0200 (Thu, 24 Apr 2008) | 3 lines

  Remove Py_Refcnt, Py_Type, Py_Size, as they were added only
  for backwards compatibility, yet 2.5 did not have them at all.
................
  r62477 | martin.v.loewis | 2008-04-24 15:17:24 +0200 (Thu, 24 Apr 2008) | 2 lines

  Fix typo.
................
  r62478 | martin.v.loewis | 2008-04-24 15:18:03 +0200 (Thu, 24 Apr 2008) | 2 lines

  Add Jesus Cea.
................
  r62480 | amaury.forgeotdarc | 2008-04-24 20:07:05 +0200 (Thu, 24 Apr 2008) | 4 lines

  Issue2681: the literal 0o8 was wrongly accepted, and evaluated as float(0.0).
  This happened only when 8 is the first digit.
  Credits go to Lukas Meuser.
................
  r62485 | amaury.forgeotdarc | 2008-04-24 22:10:26 +0200 (Thu, 24 Apr 2008) | 5 lines

  Disable gc when running test_trace, or we may record the __del__ of collected objects.

  See http://mail.python.org/pipermail/python-checkins/2008-April/068633.html
  the extra events perfectly match several calls to socket._fileobject.__del__()
................
  r62492 | neal.norwitz | 2008-04-25 05:40:17 +0200 (Fri, 25 Apr 2008) | 1 line

  Fix typo (now -> no)
................
  r62497 | armin.rigo | 2008-04-25 11:35:18 +0200 (Fri, 25 Apr 2008) | 2 lines

  A new crasher.
................
  r62498 | thomas.heller | 2008-04-25 17:44:16 +0200 (Fri, 25 Apr 2008) | 1 line

  Add from_buffer and from_buffer_copy class methods to ctypes types.
................
  r62500 | mark.dickinson | 2008-04-25 18:59:09 +0200 (Fri, 25 Apr 2008) | 3 lines

  Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
................
  r62507 | benjamin.peterson | 2008-04-25 23:43:56 +0200 (Fri, 25 Apr 2008) | 2 lines

  Allow test_import to work when it is invoked directly
................
  r62513 | georg.brandl | 2008-04-26 20:31:07 +0200 (Sat, 26 Apr 2008) | 2 lines

  #2691: document PyLong (s)size_t APIs, patch by Alexander Belopolsky.
................
  r62514 | georg.brandl | 2008-04-26 20:32:17 +0200 (Sat, 26 Apr 2008) | 2 lines

  Add missing return type to dealloc.
................
  r62516 | alexandre.vassalotti | 2008-04-27 02:52:24 +0200 (Sun, 27 Apr 2008) | 2 lines

  Fixed URL of PEP 205 in weakref's module docstring.
................
  r62521 | georg.brandl | 2008-04-27 11:39:59 +0200 (Sun, 27 Apr 2008) | 2 lines

  #2677: add note that not all functions may accept keyword args.
................
  r62531 | georg.brandl | 2008-04-27 19:38:55 +0200 (Sun, 27 Apr 2008) | 2 lines

  Use correct XHTML tags.
................
  r62535 | benjamin.peterson | 2008-04-27 20:14:39 +0200 (Sun, 27 Apr 2008) | 2 lines

  #2700 Document PyNumber_ToBase
................
  r62545 | skip.montanaro | 2008-04-27 22:53:57 +0200 (Sun, 27 Apr 2008) | 1 line

  minor wording changes, rewrap a few lines
................
  r62546 | kurt.kaiser | 2008-04-27 23:07:41 +0200 (Sun, 27 Apr 2008) | 7 lines

  Home / Control-A toggles between left margin and end of leading white
  space.  Patch 1196903 Jeff Shute.

  M    idlelib/PyShell.py
  M    idlelib/EditorWindow.py
  M    idlelib/NEWS.txt
................
  r62548 | kurt.kaiser | 2008-04-27 23:38:05 +0200 (Sun, 27 Apr 2008) | 2 lines

  Improved AutoCompleteWindow logic.  Patch 2062 Tal Einat.
................
  r62549 | kurt.kaiser | 2008-04-27 23:52:19 +0200 (Sun, 27 Apr 2008) | 4 lines

  Autocompletion of filenames now support alternate separators, e.g. the
  '/' char on Windows.  Patch 2061 Tal Einat.
................
  r62550 | skip.montanaro | 2008-04-28 00:49:56 +0200 (Mon, 28 Apr 2008) | 6 lines

  A few small changes:
  * The only exception we should catch when trying to import cStringIO is an
    ImportError.
  * Delete the function signatures embedded in the mk*temp docstrings.
  * The tempdir global variable was initialized twice.
................
  r62551 | skip.montanaro | 2008-04-28 00:52:02 +0200 (Mon, 28 Apr 2008) | 4 lines

  Wrap some long paragraphs and include the default values for optional
  function parameters.
................
  r62553 | skip.montanaro | 2008-04-28 04:57:23 +0200 (Mon, 28 Apr 2008) | 7 lines

  Minor cleanups:
  * Avoid creating unused local variables where we can.  Where we can't prefix
    the unused variables with '_'.
  * Avoid shadowing builtins where it won't change the external interface of a
    function.
  * Use None as default path arg to readmodule and readmodule_ex.
................
  r62554 | skip.montanaro | 2008-04-28 04:59:45 +0200 (Mon, 28 Apr 2008) | 6 lines

  Correct documentation to match implementation: "Class" instead of
  "class_descriptor", "Function" instead of "function_descriptor".  Note
  default path value for readmodule*.  Wrap some long paragraphs.  Don't
  mention 'inpackage' which isn't part of the public API.
................
  r62555 | brett.cannon | 2008-04-28 05:23:50 +0200 (Mon, 28 Apr 2008) | 5 lines

  Fix a bug introduced by the warnings rewrite where tracebacks were being
  improperly indented.

  Closes issue #2699.
................
  r62556 | skip.montanaro | 2008-04-28 05:25:37 +0200 (Mon, 28 Apr 2008) | 2 lines

  Wrap some long lines.
................
  r62557 | skip.montanaro | 2008-04-28 05:27:53 +0200 (Mon, 28 Apr 2008) | 6 lines

  Get rid of _test(), _main(), _debug() and _check().  Tests are no longer
  needed (better set available in Lib/test/test_robotparser.py).  Clean up a
  few PEP 8 nits (compound statements on a single line, whitespace around
  operators).
................
  r62558 | brett.cannon | 2008-04-28 06:50:06 +0200 (Mon, 28 Apr 2008) | 3 lines

  Rename the test_traceback_print() function to traceback_print() to prevent
  test_capi from automatically calling the function.
................
  r62559 | georg.brandl | 2008-04-28 07:16:30 +0200 (Mon, 28 Apr 2008) | 2 lines

  Fix markup.
................
  r62569 | amaury.forgeotdarc | 2008-04-28 23:07:06 +0200 (Mon, 28 Apr 2008) | 5 lines

  test_sundry performs minimal tests (a simple import...) on modules that are not tested otherwise.

  Some of them now have tests and can be removed.
  Only 70 to go...
................
  r62574 | andrew.kuchling | 2008-04-29 04:03:54 +0200 (Tue, 29 Apr 2008) | 1 line

  Strip down SSL docs; I'm not managing to get test programs working, so I'll just give a minimal description
................
  r62577 | martin.v.loewis | 2008-04-29 08:10:53 +0200 (Tue, 29 Apr 2008) | 2 lines

  Add Rodrigo and Heiko.
................
  r62593 | nick.coghlan | 2008-04-30 16:23:36 +0200 (Wed, 30 Apr 2008) | 1 line

  Update command line usage documentation to reflect 2.6 changes (also includes some minor cleanups). Addresses TODO list issue 2258
................
  r62595 | andrew.kuchling | 2008-04-30 18:19:55 +0200 (Wed, 30 Apr 2008) | 1 line

  Typo fix
................
  r62604 | benjamin.peterson | 2008-04-30 23:03:58 +0200 (Wed, 30 Apr 2008) | 2 lines

  make test_support's captured_output a bit more robust when exceptions happen
................
  r62605 | georg.brandl | 2008-04-30 23:08:42 +0200 (Wed, 30 Apr 2008) | 2 lines

  #1748: use functools.wraps instead of rolling own metadata update.
................
  r62606 | benjamin.peterson | 2008-04-30 23:25:55 +0200 (Wed, 30 Apr 2008) | 2 lines

  Remove some from __future__ import with_statements
................
  r62608 | benjamin.peterson | 2008-05-01 00:03:36 +0200 (Thu, 01 May 2008) | 2 lines

  Fix typo in whatsnew
................
  r62616 | georg.brandl | 2008-05-01 20:24:32 +0200 (Thu, 01 May 2008) | 2 lines

  Fix synopsis.
................
  r62626 | brett.cannon | 2008-05-02 04:25:09 +0200 (Fri, 02 May 2008) | 6 lines

  Fix a backwards-compatibility mistake where a new optional argument for
  warnings.showwarning() was being used. This broke pre-existing replacements for
  the function since they didn't support the extra argument.

  Closes issue 2705.
................
  r62627 | gregory.p.smith | 2008-05-02 09:26:52 +0200 (Fri, 02 May 2008) | 20 lines

  This should fix issue2632.  A long description of the two competing
  problems is in the bug report (one old, one recently introduced trying
  to fix the old one).  In short:

  buffer data during socket._fileobject.read() and readlines() within a
  cStringIO object instead of a [] of str()s returned from the recv()
  call.

  This prevents excessive memory use due to the size parameter being
  passed to recv() being grossly larger than the actual size of the data
  returned *and* prevents excessive cpu usage due to looping in python
  calling recv() with a very tiny size value if min() is used as the
  previous memory-use bug "fix" did.

  It also documents what the socket._fileobject._rbufsize member is
  actually used for.

  This is a candidate for back porting to 2.5.
................
  r62636 | mark.hammond | 2008-05-02 14:48:15 +0200 (Fri, 02 May 2008) | 2 lines

  #2581: Vista UAC/elevation support for bdist_wininst
................
  r62638 | facundo.batista | 2008-05-02 19:39:00 +0200 (Fri, 02 May 2008) | 3 lines


  Fixed some test structures. Thanks Mark Dickinson.
................
  r62644 | ronald.oussoren | 2008-05-02 21:45:11 +0200 (Fri, 02 May 2008) | 7 lines

  Fix for issue #2573: Can't change the framework name on OS X builds

  This introduces a new configure option: --with-framework-name=NAME
  (defaulting to 'Python'). This allows you to install several copies
  of the Python framework with different names (such as a normal build
  and a debug build).
................
  r62645 | ronald.oussoren | 2008-05-02 21:58:56 +0200 (Fri, 02 May 2008) | 2 lines

  Finish fix for issue2573, previous patch was incomplete.
................
  r62647 | martin.v.loewis | 2008-05-02 23:30:20 +0200 (Fri, 02 May 2008) | 13 lines

  Merged revisions 62263-62646 via svnmerge from
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

  ........
    r62470 | david.wolever | 2008-04-24 02:11:07 +0200 (Do, 24 Apr 2008) | 3 lines

    Fixed up and applied the patch for #2431 -- speeding up 2to3 with a lookup table.
  ........
    r62646 | martin.v.loewis | 2008-05-02 23:29:27 +0200 (Fr, 02 Mai 2008) | 2 lines

    Fix whitespace.
  ........
................
  r62648 | ronald.oussoren | 2008-05-02 23:42:35 +0200 (Fri, 02 May 2008) | 4 lines

  Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard

  This fixes both Python Launchar and the terminalcommand module.
................
  r62651 | ronald.oussoren | 2008-05-02 23:54:56 +0200 (Fri, 02 May 2008) | 2 lines

  Fix for issue #2520 (cannot import macerrors)
................
  r62652 | benjamin.peterson | 2008-05-03 00:12:58 +0200 (Sat, 03 May 2008) | 2 lines

  capitalization nit for reStructuredText
................
  r62653 | brett.cannon | 2008-05-03 03:02:41 +0200 (Sat, 03 May 2008) | 2 lines

  Fix some indentation errors.
................
  r62656 | brett.cannon | 2008-05-03 05:19:39 +0200 (Sat, 03 May 2008) | 6 lines

  Fix the C implementation of 'warnings' to infer the filename of the module that
  raised an exception properly when __file__ is not set, __name__ == '__main__',
  and sys.argv[0] is a false value.

  Closes issue2743.
................
  r62661 | amaury.forgeotdarc | 2008-05-03 14:21:13 +0200 (Sat, 03 May 2008) | 8 lines

  In test_io, StatefulIncrementalDecoderTest was not part of the test suite.
  And of course, the test failed:
  a bytearray was used without reason in io.TextIOWrapper.tell().

  The difference is that iterating over bytes (i.e. str in python2.6) returns 1-char bytes,
  whereas bytearrays yield integers.
  This code should still work with python3.0
................
  r62663 | benjamin.peterson | 2008-05-03 17:56:42 +0200 (Sat, 03 May 2008) | 2 lines

  The compiling struct is now passed around to all AST helpers (see issue 2720)
................
  r62680 | benjamin.peterson | 2008-05-03 23:35:18 +0200 (Sat, 03 May 2008) | 2 lines

  Moved testing of builtin types out of test_builtin and into type specific modules
................
  r62686 | mark.dickinson | 2008-05-04 04:25:46 +0200 (Sun, 04 May 2008) | 4 lines

  Make sure that Context traps and flags dictionaries have values 0 and 1
  (as documented) rather than True and False.
................
  r62687 | benjamin.peterson | 2008-05-04 05:05:49 +0200 (Sun, 04 May 2008) | 2 lines

  Fix typo in whatsnew
................
  r62696 | georg.brandl | 2008-05-04 11:15:04 +0200 (Sun, 04 May 2008) | 2 lines

  #2752: wrong meaning of '' for socket host.
................
  r62699 | christian.heimes | 2008-05-04 13:50:53 +0200 (Sun, 04 May 2008) | 1 line

  Added note that Python requires at least Win2k SP4
................
  r62700 | gerhard.haering | 2008-05-04 14:59:57 +0200 (Sun, 04 May 2008) | 3 lines

  SQLite requires 64-bit integers in order to build. So the whole HAVE_LONG_LONG
  #ifdefing was useless.
................
  r62701 | gerhard.haering | 2008-05-04 15:15:12 +0200 (Sun, 04 May 2008) | 3 lines

  Applied sqliterow-richcmp.diff patch from Thomas Heller in Issue2152. The
  sqlite3.Row type is now correctly hashable.
................
  r62702 | gerhard.haering | 2008-05-04 15:42:44 +0200 (Sun, 04 May 2008) | 5 lines

  Implemented feature request 2157: Converter names are cut off at '('
  characters. This avoids the common case of something like 'NUMBER(10)' not
  being parsed as 'NUMBER', like expected. Also corrected the docs about
  converter names being case-sensitive. They aren't any longer.
................
  r62703 | georg.brandl | 2008-05-04 17:45:05 +0200 (Sun, 04 May 2008) | 2 lines

  #2757: Remove spare newline.
................
  r62711 | benjamin.peterson | 2008-05-04 21:10:02 +0200 (Sun, 04 May 2008) | 2 lines

  Fix typo in bugs.rst
................
diff --git a/Lib/test/crashers/mutation_inside_cyclegc.py b/Lib/test/crashers/mutation_inside_cyclegc.py
new file mode 100644
index 0000000..2b67398
--- /dev/null
+++ b/Lib/test/crashers/mutation_inside_cyclegc.py
@@ -0,0 +1,31 @@
+
+# The cycle GC collector can be executed when any GC-tracked object is
+# allocated, e.g. during a call to PyList_New(), PyDict_New(), ...
+# Moreover, it can invoke arbitrary Python code via a weakref callback.
+# This means that there are many places in the source where an arbitrary
+# mutation could unexpectedly occur.
+
+# The example below shows list_slice() not expecting the call to
+# PyList_New to mutate the input list.  (Of course there are many
+# more examples like this one.)
+
+
+import weakref
+
+class A(object):
+    pass
+
+def callback(x):
+    del lst[:]
+
+
+keepalive = []
+
+for i in range(100):
+    lst = [str(i)]
+    a = A()
+    a.cycle = a
+    keepalive.append(weakref.ref(a, callback))
+    del a
+    while lst:
+        keepalive.append(lst[:])
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 7244aff..52b337c 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -484,201 +484,6 @@
         self.assertEqual(list(filter(lambda x: x>=3, (1, 2, 3, 4))), [3, 4])
         self.assertRaises(TypeError, list, filter(42, (1, 2)))
 
-    def test_float(self):
-        self.assertEqual(float(3.14), 3.14)
-        self.assertEqual(float(314), 314.0)
-        self.assertEqual(float(314), 314.0)
-        self.assertEqual(float("  3.14  "), 3.14)
-        self.assertRaises(ValueError, float, "  0x3.1  ")
-        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
-        self.assertEqual(float(str(b"  \u0663.\u0661\u0664  ",'raw-unicode-escape')), 3.14)
-        self.assertEqual(float("1"*10000), 1e10000) # Inf on both sides
-
-    @run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
-    def test_float_with_comma(self):
-        # set locale to something that doesn't use '.' for the decimal point
-        # float must not accept the locale specific decimal point but
-        # it still has to accept the normal python syntac
-        import locale
-        if not locale.localeconv()['decimal_point'] == ',':
-            return
-
-        self.assertEqual(float("  3.14  "), 3.14)
-        self.assertEqual(float("+3.14  "), 3.14)
-        self.assertEqual(float("-3.14  "), -3.14)
-        self.assertEqual(float(".14  "), .14)
-        self.assertEqual(float("3.  "), 3.0)
-        self.assertEqual(float("3.e3  "), 3000.0)
-        self.assertEqual(float("3.2e3  "), 3200.0)
-        self.assertEqual(float("2.5e-1  "), 0.25)
-        self.assertEqual(float("5e-1"), 0.5)
-        self.assertRaises(ValueError, float, "  3,14  ")
-        self.assertRaises(ValueError, float, "  +3,14  ")
-        self.assertRaises(ValueError, float, "  -3,14  ")
-        self.assertRaises(ValueError, float, "  0x3.1  ")
-        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
-        self.assertEqual(float("  25.e-1  "), 2.5)
-        self.assertEqual(fcmp(float("  .25e-1  "), .025), 0)
-
-    def test_floatconversion(self):
-        # Make sure that calls to __float__() work properly
-        class Foo0:
-            def __float__(self):
-                return 42.
-
-        class Foo1(object):
-            def __float__(self):
-                return 42.
-
-        class Foo2(float):
-            def __float__(self):
-                return 42.
-
-        class Foo3(float):
-            def __new__(cls, value=0.):
-                return float.__new__(cls, 2*value)
-
-            def __float__(self):
-                return self
-
-        class Foo4(float):
-            def __float__(self):
-                return 42
-
-        self.assertAlmostEqual(float(Foo0()), 42.)
-        self.assertAlmostEqual(float(Foo1()), 42.)
-        self.assertAlmostEqual(float(Foo2()), 42.)
-        self.assertAlmostEqual(float(Foo3(21)), 42.)
-        self.assertRaises(TypeError, float, Foo4(42))
-
-    def test_format(self):
-        # Test the basic machinery of the format() builtin.  Don't test
-        #  the specifics of the various formatters
-        self.assertEqual(format(3, ''), '3')
-
-        # Returns some classes to use for various tests.  There's
-        #  an old-style version, and a new-style version
-        def classes_new():
-            class A(object):
-                def __init__(self, x):
-                    self.x = x
-                def __format__(self, format_spec):
-                    return str(self.x) + format_spec
-            class DerivedFromA(A):
-                pass
-
-            class Simple(object): pass
-            class DerivedFromSimple(Simple):
-                def __init__(self, x):
-                    self.x = x
-                def __format__(self, format_spec):
-                    return str(self.x) + format_spec
-            class DerivedFromSimple2(DerivedFromSimple): pass
-            return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2
-
-        # In 3.0, classes_classic has the same meaning as classes_new
-        def classes_classic():
-            class A:
-                def __init__(self, x):
-                    self.x = x
-                def __format__(self, format_spec):
-                    return str(self.x) + format_spec
-            class DerivedFromA(A):
-                pass
-
-            class Simple: pass
-            class DerivedFromSimple(Simple):
-                def __init__(self, x):
-                    self.x = x
-                def __format__(self, format_spec):
-                    return str(self.x) + format_spec
-            class DerivedFromSimple2(DerivedFromSimple): pass
-            return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2
-
-        def class_test(A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2):
-            self.assertEqual(format(A(3), 'spec'), '3spec')
-            self.assertEqual(format(DerivedFromA(4), 'spec'), '4spec')
-            self.assertEqual(format(DerivedFromSimple(5), 'abc'), '5abc')
-            self.assertEqual(format(DerivedFromSimple2(10), 'abcdef'),
-                             '10abcdef')
-
-        class_test(*classes_new())
-        class_test(*classes_classic())
-
-        def empty_format_spec(value):
-            # test that:
-            #  format(x, '') == str(x)
-            #  format(x) == str(x)
-            self.assertEqual(format(value, ""), str(value))
-            self.assertEqual(format(value), str(value))
-
-        # for builtin types, format(x, "") == str(x)
-        empty_format_spec(17**13)
-        empty_format_spec(1.0)
-        empty_format_spec(3.1415e104)
-        empty_format_spec(-3.1415e104)
-        empty_format_spec(3.1415e-104)
-        empty_format_spec(-3.1415e-104)
-        empty_format_spec(object)
-        empty_format_spec(None)
-
-        # TypeError because self.__format__ returns the wrong type
-        class BadFormatResult:
-            def __format__(self, format_spec):
-                return 1.0
-        self.assertRaises(TypeError, format, BadFormatResult(), "")
-
-        # TypeError because format_spec is not unicode or str
-        self.assertRaises(TypeError, format, object(), 4)
-        self.assertRaises(TypeError, format, object(), object())
-
-        # tests for object.__format__ really belong elsewhere, but
-        #  there's no good place to put them
-        x = object().__format__('')
-        self.assert_(x.startswith('<object object at'))
-
-        # first argument to object.__format__ must be string
-        self.assertRaises(TypeError, object().__format__, 3)
-        self.assertRaises(TypeError, object().__format__, object())
-        self.assertRaises(TypeError, object().__format__, None)
-
-        # make sure we can take a subclass of str as a format spec
-        class DerivedFromStr(str): pass
-        self.assertEqual(format(0, DerivedFromStr('10')), '         0')
-
-    def test_floatasratio(self):
-        for f, ratio in [
-                (0.875, (7, 8)),
-                (-0.875, (-7, 8)),
-                (0.0, (0, 1)),
-                (11.5, (23, 2)),
-            ]:
-            self.assertEqual(f.as_integer_ratio(), ratio)
-
-        for i in range(10000):
-            f = random.random()
-            f *= 10 ** random.randint(-100, 100)
-            n, d = f.as_integer_ratio()
-            self.assertEqual(float(n).__truediv__(d), f)
-
-        R = fractions.Fraction
-        self.assertEqual(R(0, 1),
-                         R(*float(0.0).as_integer_ratio()))
-        self.assertEqual(R(5, 2),
-                         R(*float(2.5).as_integer_ratio()))
-        self.assertEqual(R(1, 2),
-                         R(*float(0.5).as_integer_ratio()))
-        self.assertEqual(R(4728779608739021, 2251799813685248),
-                         R(*float(2.1).as_integer_ratio()))
-        self.assertEqual(R(-4728779608739021, 2251799813685248),
-                         R(*float(-2.1).as_integer_ratio()))
-        self.assertEqual(R(-2100, 1),
-                         R(*float(-2100.0).as_integer_ratio()))
-
-        self.assertRaises(OverflowError, float('inf').as_integer_ratio)
-        self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
-        self.assertRaises(ValueError, float('nan').as_integer_ratio)
-
     def test_getattr(self):
         import sys
         self.assert_(getattr(sys, 'stdout') is sys.stdout)
@@ -737,266 +542,6 @@
 
     # Test input() later, alphabetized as if it were raw_input
 
-    def test_int(self):
-        self.assertEqual(int(314), 314)
-        self.assertEqual(int(3.14), 3)
-        self.assertEqual(int(314), 314)
-        # Check that conversion from float truncates towards zero
-        self.assertEqual(int(-3.14), -3)
-        self.assertEqual(int(3.9), 3)
-        self.assertEqual(int(-3.9), -3)
-        self.assertEqual(int(3.5), 3)
-        self.assertEqual(int(-3.5), -3)
-        # Different base:
-        self.assertEqual(int("10",16), 16)
-        # Test conversion from strings and various anomalies
-        # Testing with no sign at front
-        for s, v in test_conv_no_sign:
-            for prefix in "", " ", "\t", "  \t\t  ":
-                ss = prefix + s
-                vv = v
-                try:
-                    self.assertEqual(int(ss), vv)
-                except v:
-                    pass
-        # No whitespaces allowed between + or - sign and the number
-        for s, v in test_conv_sign:
-            for sign in "+", "-":
-                for prefix in "", " ", "\t", "  \t\t  ":
-                    ss = prefix + sign + s
-                    vv = v
-                    if sign == "-" and v is not ValueError:
-                        vv = -v
-                    try:
-                        self.assertEqual(int(ss), vv)
-                    except v:
-                        pass
-
-        s = repr(-1-sys.maxsize)
-        x = int(s)
-        self.assertEqual(x+1, -sys.maxsize)
-        self.assert_(isinstance(x, int))
-        # should return long
-        self.assertEqual(int(s[1:]), sys.maxsize+1)
-
-        # should return long
-        x = int(1e100)
-        self.assert_(isinstance(x, int))
-        x = int(-1e100)
-        self.assert_(isinstance(x, int))
-
-
-        # SF bug 434186:  0x80000000/2 != 0x80000000>>1.
-        # Worked by accident in Windows release build, but failed in debug build.
-        # Failed in all Linux builds.
-        x = -1-sys.maxsize
-        self.assertEqual(x >> 1, x//2)
-
-        self.assertRaises(ValueError, int, '123\0')
-        self.assertRaises(ValueError, int, '53', 40)
-
-        # SF bug 1545497: embedded NULs were not detected with
-        # explicit base
-        self.assertRaises(ValueError, int, '123\0', 10)
-        self.assertRaises(ValueError, int, '123\x00 245', 20)
-
-        x = int('1' * 600)
-        self.assert_(isinstance(x, int))
-
-        x = int(chr(0x661) * 600)
-        self.assert_(isinstance(x, int))
-
-        self.assertRaises(TypeError, int, 1, 12)
-
-        # tests with base 0
-        self.assertRaises(ValueError, int, ' 0123  ', 0) # old octal syntax
-        self.assertEqual(int('000', 0), 0)
-        self.assertEqual(int('0o123', 0), 83)
-        self.assertEqual(int('0x123', 0), 291)
-        self.assertEqual(int('0b100', 0), 4)
-        self.assertEqual(int(' 0O123   ', 0), 83)
-        self.assertEqual(int(' 0X123  ', 0), 291)
-        self.assertEqual(int(' 0B100 ', 0), 4)
-
-        # without base still base 10
-        self.assertEqual(int('0123'), 123)
-        self.assertEqual(int('0123', 10), 123)
-
-        # tests with prefix and base != 0
-        self.assertEqual(int('0x123', 16), 291)
-        self.assertEqual(int('0o123', 8), 83)
-        self.assertEqual(int('0b100', 2), 4)
-        self.assertEqual(int('0X123', 16), 291)
-        self.assertEqual(int('0O123', 8), 83)
-        self.assertEqual(int('0B100', 2), 4)
-
-        # Bug 1679: "0x" is not a valid hex literal
-        self.assertRaises(ValueError, int, "0x", 16)
-        self.assertRaises(ValueError, int, "0x", 0)
-
-
-        # SF bug 1334662: int(string, base) wrong answers
-        # Various representations of 2**32 evaluated to 0
-        # rather than 2**32 in previous versions
-
-        self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296)
-        self.assertEqual(int('102002022201221111211', 3), 4294967296)
-        self.assertEqual(int('10000000000000000', 4), 4294967296)
-        self.assertEqual(int('32244002423141', 5), 4294967296)
-        self.assertEqual(int('1550104015504', 6), 4294967296)
-        self.assertEqual(int('211301422354', 7), 4294967296)
-        self.assertEqual(int('40000000000', 8), 4294967296)
-        self.assertEqual(int('12068657454', 9), 4294967296)
-        self.assertEqual(int('4294967296', 10), 4294967296)
-        self.assertEqual(int('1904440554', 11), 4294967296)
-        self.assertEqual(int('9ba461594', 12), 4294967296)
-        self.assertEqual(int('535a79889', 13), 4294967296)
-        self.assertEqual(int('2ca5b7464', 14), 4294967296)
-        self.assertEqual(int('1a20dcd81', 15), 4294967296)
-        self.assertEqual(int('100000000', 16), 4294967296)
-        self.assertEqual(int('a7ffda91', 17), 4294967296)
-        self.assertEqual(int('704he7g4', 18), 4294967296)
-        self.assertEqual(int('4f5aff66', 19), 4294967296)
-        self.assertEqual(int('3723ai4g', 20), 4294967296)
-        self.assertEqual(int('281d55i4', 21), 4294967296)
-        self.assertEqual(int('1fj8b184', 22), 4294967296)
-        self.assertEqual(int('1606k7ic', 23), 4294967296)
-        self.assertEqual(int('mb994ag', 24), 4294967296)
-        self.assertEqual(int('hek2mgl', 25), 4294967296)
-        self.assertEqual(int('dnchbnm', 26), 4294967296)
-        self.assertEqual(int('b28jpdm', 27), 4294967296)
-        self.assertEqual(int('8pfgih4', 28), 4294967296)
-        self.assertEqual(int('76beigg', 29), 4294967296)
-        self.assertEqual(int('5qmcpqg', 30), 4294967296)
-        self.assertEqual(int('4q0jto4', 31), 4294967296)
-        self.assertEqual(int('4000000', 32), 4294967296)
-        self.assertEqual(int('3aokq94', 33), 4294967296)
-        self.assertEqual(int('2qhxjli', 34), 4294967296)
-        self.assertEqual(int('2br45qb', 35), 4294967296)
-        self.assertEqual(int('1z141z4', 36), 4294967296)
-
-        # SF bug 1334662: int(string, base) wrong answers
-        # Checks for proper evaluation of 2**32 + 1
-        self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297)
-        self.assertEqual(int('102002022201221111212', 3), 4294967297)
-        self.assertEqual(int('10000000000000001', 4), 4294967297)
-        self.assertEqual(int('32244002423142', 5), 4294967297)
-        self.assertEqual(int('1550104015505', 6), 4294967297)
-        self.assertEqual(int('211301422355', 7), 4294967297)
-        self.assertEqual(int('40000000001', 8), 4294967297)
-        self.assertEqual(int('12068657455', 9), 4294967297)
-        self.assertEqual(int('4294967297', 10), 4294967297)
-        self.assertEqual(int('1904440555', 11), 4294967297)
-        self.assertEqual(int('9ba461595', 12), 4294967297)
-        self.assertEqual(int('535a7988a', 13), 4294967297)
-        self.assertEqual(int('2ca5b7465', 14), 4294967297)
-        self.assertEqual(int('1a20dcd82', 15), 4294967297)
-        self.assertEqual(int('100000001', 16), 4294967297)
-        self.assertEqual(int('a7ffda92', 17), 4294967297)
-        self.assertEqual(int('704he7g5', 18), 4294967297)
-        self.assertEqual(int('4f5aff67', 19), 4294967297)
-        self.assertEqual(int('3723ai4h', 20), 4294967297)
-        self.assertEqual(int('281d55i5', 21), 4294967297)
-        self.assertEqual(int('1fj8b185', 22), 4294967297)
-        self.assertEqual(int('1606k7id', 23), 4294967297)
-        self.assertEqual(int('mb994ah', 24), 4294967297)
-        self.assertEqual(int('hek2mgm', 25), 4294967297)
-        self.assertEqual(int('dnchbnn', 26), 4294967297)
-        self.assertEqual(int('b28jpdn', 27), 4294967297)
-        self.assertEqual(int('8pfgih5', 28), 4294967297)
-        self.assertEqual(int('76beigh', 29), 4294967297)
-        self.assertEqual(int('5qmcpqh', 30), 4294967297)
-        self.assertEqual(int('4q0jto5', 31), 4294967297)
-        self.assertEqual(int('4000001', 32), 4294967297)
-        self.assertEqual(int('3aokq95', 33), 4294967297)
-        self.assertEqual(int('2qhxjlj', 34), 4294967297)
-        self.assertEqual(int('2br45qc', 35), 4294967297)
-        self.assertEqual(int('1z141z5', 36), 4294967297)
-
-    def test_intconversion(self):
-        # Test __int__()
-        class ClassicMissingMethods:
-            pass
-        self.assertRaises(TypeError, int, ClassicMissingMethods())
-
-        class MissingMethods(object):
-            pass
-        self.assertRaises(TypeError, int, MissingMethods())
-
-        class Foo0:
-            def __int__(self):
-                return 42
-
-        class Foo1(object):
-            def __int__(self):
-                return 42
-
-        class Foo2(int):
-            def __int__(self):
-                return 42
-
-        class Foo3(int):
-            def __int__(self):
-                return self
-
-        class Foo4(int):
-            def __int__(self):
-                return 42
-
-        class Foo5(int):
-            def __int__(self):
-                return 42.
-
-        self.assertEqual(int(Foo0()), 42)
-        self.assertEqual(int(Foo1()), 42)
-        self.assertEqual(int(Foo2()), 42)
-        self.assertEqual(int(Foo3()), 0)
-        self.assertEqual(int(Foo4()), 42)
-        self.assertRaises(TypeError, int, Foo5())
-
-        class Classic:
-            pass
-        for base in (object, Classic):
-            class IntOverridesTrunc(base):
-                def __int__(self):
-                    return 42
-                def __trunc__(self):
-                    return -12
-            self.assertEqual(int(IntOverridesTrunc()), 42)
-
-            class JustTrunc(base):
-                def __trunc__(self):
-                    return 42
-            self.assertEqual(int(JustTrunc()), 42)
-
-            for trunc_result_base in (object, Classic):
-                class Integral(trunc_result_base):
-                    def __int__(self):
-                        return 42
-
-                class TruncReturnsNonInt(base):
-                    def __trunc__(self):
-                        return Integral()
-                self.assertEqual(int(TruncReturnsNonInt()), 42)
-
-                class NonIntegral(trunc_result_base):
-                    def __trunc__(self):
-                        # Check that we avoid infinite recursion.
-                        return NonIntegral()
-
-                class TruncReturnsNonIntegral(base):
-                    def __trunc__(self):
-                        return NonIntegral()
-                try:
-                    int(TruncReturnsNonIntegral())
-                except TypeError as e:
-                    self.assertEquals(str(e),
-                                      "__trunc__ returned non-Integral"
-                                      " (type NonIntegral)")
-                else:
-                    self.fail("Failed to raise TypeError with %s" %
-                              ((base, trunc_result_base),))
-
     def test_iter(self):
         self.assertRaises(TypeError, iter)
         self.assertRaises(TypeError, iter, 42, 42)
@@ -1054,187 +599,6 @@
                 raise ValueError
         self.assertRaises(ValueError, len, BadSeq())
 
-    def test_list(self):
-        self.assertEqual(list([]), [])
-        l0_3 = [0, 1, 2, 3]
-        l0_3_bis = list(l0_3)
-        self.assertEqual(l0_3, l0_3_bis)
-        self.assert_(l0_3 is not l0_3_bis)
-        self.assertEqual(list(()), [])
-        self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
-        self.assertEqual(list(''), [])
-        self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
-
-        if sys.maxsize == 0x7fffffff:
-            # This test can currently only work on 32-bit machines.
-            # XXX If/when PySequence_Length() returns a ssize_t, it should be
-            # XXX re-enabled.
-            # Verify clearing of bug #556025.
-            # This assumes that the max data size (sys.maxsize) == max
-            # address size this also assumes that the address size is at
-            # least 4 bytes with 8 byte addresses, the bug is not well
-            # tested
-            #
-            # Note: This test is expected to SEGV under Cygwin 1.3.12 or
-            # earlier due to a newlib bug.  See the following mailing list
-            # thread for the details:
-
-            #     http://sources.redhat.com/ml/newlib/2002/msg00369.html
-            self.assertRaises(MemoryError, list, range(sys.maxsize // 2))
-
-        # This code used to segfault in Py2.4a3
-        x = []
-        x.extend(-y for y in x)
-        self.assertEqual(x, [])
-
-    def test_long(self):
-        self.assertEqual(int(314), 314)
-        self.assertEqual(int(3.14), 3)
-        self.assertEqual(int(314), 314)
-        # Check that conversion from float truncates towards zero
-        self.assertEqual(int(-3.14), -3)
-        self.assertEqual(int(3.9), 3)
-        self.assertEqual(int(-3.9), -3)
-        self.assertEqual(int(3.5), 3)
-        self.assertEqual(int(-3.5), -3)
-        self.assertEqual(int("-3"), -3)
-        # Different base:
-        self.assertEqual(int("10",16), 16)
-        # Check conversions from string (same test set as for int(), and then some)
-        LL = [
-                ('1' + '0'*20, 10**20),
-                ('1' + '0'*100, 10**100)
-        ]
-        for s, v in LL:
-            for sign in "", "+", "-":
-                for prefix in "", " ", "\t", "  \t\t  ":
-                    ss = prefix + sign + s
-                    vv = v
-                    if sign == "-" and v is not ValueError:
-                        vv = -v
-                    try:
-                        self.assertEqual(int(ss), int(vv))
-                    except v:
-                        pass
-
-        self.assertRaises(ValueError, int, '123\0')
-        self.assertRaises(ValueError, int, '53', 40)
-        self.assertRaises(TypeError, int, 1, 12)
-
-        # SF patch #1638879: embedded NULs were not detected with
-        # explicit base
-        self.assertRaises(ValueError, int, '123\0', 10)
-        self.assertRaises(ValueError, int, '123\x00 245', 20)
-
-        self.assertEqual(int('100000000000000000000000000000000', 2),
-                         4294967296)
-        self.assertEqual(int('102002022201221111211', 3), 4294967296)
-        self.assertEqual(int('10000000000000000', 4), 4294967296)
-        self.assertEqual(int('32244002423141', 5), 4294967296)
-        self.assertEqual(int('1550104015504', 6), 4294967296)
-        self.assertEqual(int('211301422354', 7), 4294967296)
-        self.assertEqual(int('40000000000', 8), 4294967296)
-        self.assertEqual(int('12068657454', 9), 4294967296)
-        self.assertEqual(int('4294967296', 10), 4294967296)
-        self.assertEqual(int('1904440554', 11), 4294967296)
-        self.assertEqual(int('9ba461594', 12), 4294967296)
-        self.assertEqual(int('535a79889', 13), 4294967296)
-        self.assertEqual(int('2ca5b7464', 14), 4294967296)
-        self.assertEqual(int('1a20dcd81', 15), 4294967296)
-        self.assertEqual(int('100000000', 16), 4294967296)
-        self.assertEqual(int('a7ffda91', 17), 4294967296)
-        self.assertEqual(int('704he7g4', 18), 4294967296)
-        self.assertEqual(int('4f5aff66', 19), 4294967296)
-        self.assertEqual(int('3723ai4g', 20), 4294967296)
-        self.assertEqual(int('281d55i4', 21), 4294967296)
-        self.assertEqual(int('1fj8b184', 22), 4294967296)
-        self.assertEqual(int('1606k7ic', 23), 4294967296)
-        self.assertEqual(int('mb994ag', 24), 4294967296)
-        self.assertEqual(int('hek2mgl', 25), 4294967296)
-        self.assertEqual(int('dnchbnm', 26), 4294967296)
-        self.assertEqual(int('b28jpdm', 27), 4294967296)
-        self.assertEqual(int('8pfgih4', 28), 4294967296)
-        self.assertEqual(int('76beigg', 29), 4294967296)
-        self.assertEqual(int('5qmcpqg', 30), 4294967296)
-        self.assertEqual(int('4q0jto4', 31), 4294967296)
-        self.assertEqual(int('4000000', 32), 4294967296)
-        self.assertEqual(int('3aokq94', 33), 4294967296)
-        self.assertEqual(int('2qhxjli', 34), 4294967296)
-        self.assertEqual(int('2br45qb', 35), 4294967296)
-        self.assertEqual(int('1z141z4', 36), 4294967296)
-
-        self.assertEqual(int('100000000000000000000000000000001', 2),
-                         4294967297)
-        self.assertEqual(int('102002022201221111212', 3), 4294967297)
-        self.assertEqual(int('10000000000000001', 4), 4294967297)
-        self.assertEqual(int('32244002423142', 5), 4294967297)
-        self.assertEqual(int('1550104015505', 6), 4294967297)
-        self.assertEqual(int('211301422355', 7), 4294967297)
-        self.assertEqual(int('40000000001', 8), 4294967297)
-        self.assertEqual(int('12068657455', 9), 4294967297)
-        self.assertEqual(int('4294967297', 10), 4294967297)
-        self.assertEqual(int('1904440555', 11), 4294967297)
-        self.assertEqual(int('9ba461595', 12), 4294967297)
-        self.assertEqual(int('535a7988a', 13), 4294967297)
-        self.assertEqual(int('2ca5b7465', 14), 4294967297)
-        self.assertEqual(int('1a20dcd82', 15), 4294967297)
-        self.assertEqual(int('100000001', 16), 4294967297)
-        self.assertEqual(int('a7ffda92', 17), 4294967297)
-        self.assertEqual(int('704he7g5', 18), 4294967297)
-        self.assertEqual(int('4f5aff67', 19), 4294967297)
-        self.assertEqual(int('3723ai4h', 20), 4294967297)
-        self.assertEqual(int('281d55i5', 21), 4294967297)
-        self.assertEqual(int('1fj8b185', 22), 4294967297)
-        self.assertEqual(int('1606k7id', 23), 4294967297)
-        self.assertEqual(int('mb994ah', 24), 4294967297)
-        self.assertEqual(int('hek2mgm', 25), 4294967297)
-        self.assertEqual(int('dnchbnn', 26), 4294967297)
-        self.assertEqual(int('b28jpdn', 27), 4294967297)
-        self.assertEqual(int('8pfgih5', 28), 4294967297)
-        self.assertEqual(int('76beigh', 29), 4294967297)
-        self.assertEqual(int('5qmcpqh', 30), 4294967297)
-        self.assertEqual(int('4q0jto5', 31), 4294967297)
-        self.assertEqual(int('4000001', 32), 4294967297)
-        self.assertEqual(int('3aokq95', 33), 4294967297)
-        self.assertEqual(int('2qhxjlj', 34), 4294967297)
-        self.assertEqual(int('2br45qc', 35), 4294967297)
-        self.assertEqual(int('1z141z5', 36), 4294967297)
-
-    def test_longconversion(self):
-        # Test __long__()
-        class Foo0:
-            def __long__(self):
-                return 42
-
-        class Foo1(object):
-            def __long__(self):
-                return 42
-
-        class Foo2(int):
-            def __long__(self):
-                return 42
-
-        class Foo3(int):
-            def __long__(self):
-                return self
-
-        class Foo4(int):
-            def __long__(self):
-                return 42
-
-        class Foo5(int):
-            def __long__(self):
-                return 42.
-
-        self.assertEqual(int(Foo0()), 42)
-        self.assertEqual(int(Foo1()), 42)
-        # XXX invokes __int__ now
-        # self.assertEqual(long(Foo2()), 42L)
-        self.assertEqual(int(Foo3()), 0)
-        # XXX likewise
-        # self.assertEqual(long(Foo4()), 42)
-        # self.assertRaises(TypeError, long, Foo5())
-
     def test_map(self):
         self.assertEqual(
             list(map(lambda x: x*x, range(1,4))),
@@ -1726,19 +1090,6 @@
         self.assertRaises(TypeError, setattr, sys, 1, 'spam')
         self.assertRaises(TypeError, setattr)
 
-    def test_str(self):
-        self.assertEqual(str(''), '')
-        self.assertEqual(str(0), '0')
-        self.assertEqual(str(0), '0')
-        self.assertEqual(str(()), '()')
-        self.assertEqual(str([]), '[]')
-        self.assertEqual(str({}), '{}')
-        a = []
-        a.append(a)
-        self.assertEqual(str(a), '[[...]]')
-        a = {}
-        a[0] = a
-        self.assertEqual(str(a), '{0: {...}}')
 
     def test_sum(self):
         self.assertEqual(sum([]), 0)
@@ -1761,16 +1112,6 @@
                 raise ValueError
         self.assertRaises(ValueError, sum, BadSeq())
 
-    def test_tuple(self):
-        self.assertEqual(tuple(()), ())
-        t0_3 = (0, 1, 2, 3)
-        t0_3_bis = tuple(t0_3)
-        self.assert_(t0_3 is t0_3_bis)
-        self.assertEqual(tuple([]), ())
-        self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3))
-        self.assertEqual(tuple(''), ())
-        self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
-
     def test_type(self):
         self.assertEqual(type(''),  type('123'))
         self.assertNotEqual(type(''), type(()))
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index e211916..74031c9 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -1,5 +1,4 @@
 # Tests command line execution of scripts
-from __future__ import with_statement
 
 import unittest
 import os
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index a3a9a5b..51d2436 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -1,6 +1,5 @@
 """Unit tests for contextlib.py, and other context managers."""
 
-from __future__ import with_statement
 
 import sys
 import os
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index a76b505..bb27eec 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -23,7 +23,6 @@
 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 glob
 import math
@@ -47,10 +46,12 @@
 def init():
     global ORIGINAL_CONTEXT
     ORIGINAL_CONTEXT = getcontext().copy()
-    DefaultContext.prec = 9
-    DefaultContext.rounding = ROUND_HALF_EVEN
-    DefaultContext.traps = dict.fromkeys(Signals, 0)
-    setcontext(DefaultContext)
+    DefaultTestContext = Context(
+        prec = 9,
+        rounding = ROUND_HALF_EVEN,
+        traps = dict.fromkeys(Signals, 0)
+        )
+    setcontext(DefaultTestContext)
 
 TESTDATADIR = 'decimaltestdata'
 if __name__ == '__main__':
@@ -180,8 +181,6 @@
     """
     def setUp(self):
         self.context = Context()
-        for key in DefaultContext.traps.keys():
-            DefaultContext.traps[key] = 1
         self.ignore_list = ['#']
         # Basically, a # means return NaN InvalidOperation.
         # Different from a sNaN in trim
@@ -192,13 +191,6 @@
                       'minexponent' : self.change_min_exponent,
                       'clamp' : self.change_clamp}
 
-    def tearDown(self):
-        """Cleaning up enviroment."""
-        # leaving context in original state
-        for key in DefaultContext.traps.keys():
-            DefaultContext.traps[key] = 0
-        return
-
     def eval_file(self, file):
         global skip_expected
         if skip_expected:
@@ -949,8 +941,8 @@
     test2 = d1/d3
     cls.finish1.set()
 
-    cls.assertEqual(test1, Decimal('0.333333333'))
-    cls.assertEqual(test2, Decimal('0.333333333'))
+    cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
+    cls.assertEqual(test2, Decimal('0.3333333333333333333333333333'))
     return
 
 def thfunc2(cls):
@@ -963,7 +955,7 @@
     cls.synchro.set()
     cls.finish2.set()
 
-    cls.assertEqual(test1, Decimal('0.333333333'))
+    cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
     cls.assertEqual(test2, Decimal('0.333333333333333333'))
     return
 
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index e89d723..5653c16 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -9,6 +9,116 @@
 INF = float("inf")
 NAN = float("nan")
 
+class GeneralFloatCases(unittest.TestCase):
+
+    def test_float(self):
+        self.assertEqual(float(3.14), 3.14)
+        self.assertEqual(float(314), 314.0)
+        self.assertEqual(float("  3.14  "), 3.14)
+        self.assertRaises(ValueError, float, "  0x3.1  ")
+        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
+        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
+        self.assertRaises(ValueError, float, "++3.14")
+        self.assertRaises(ValueError, float, "+-3.14")
+        self.assertRaises(ValueError, float, "-+3.14")
+        self.assertRaises(ValueError, float, "--3.14")
+        if have_unicode:
+            self.assertEqual(float(unicode("  3.14  ")), 3.14)
+            self.assertEqual(float(unicode("  \u0663.\u0661\u0664  ",'raw-unicode-escape')), 3.14)
+            # Implementation limitation in PyFloat_FromString()
+            self.assertRaises(ValueError, float, unicode("1"*10000))
+
+    @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
+    def test_float_with_comma(self):
+        # set locale to something that doesn't use '.' for the decimal point
+        # float must not accept the locale specific decimal point but
+        # it still has to accept the normal python syntac
+        import locale
+        if not locale.localeconv()['decimal_point'] == ',':
+            return
+
+        self.assertEqual(float("  3.14  "), 3.14)
+        self.assertEqual(float("+3.14  "), 3.14)
+        self.assertEqual(float("-3.14  "), -3.14)
+        self.assertEqual(float(".14  "), .14)
+        self.assertEqual(float("3.  "), 3.0)
+        self.assertEqual(float("3.e3  "), 3000.0)
+        self.assertEqual(float("3.2e3  "), 3200.0)
+        self.assertEqual(float("2.5e-1  "), 0.25)
+        self.assertEqual(float("5e-1"), 0.5)
+        self.assertRaises(ValueError, float, "  3,14  ")
+        self.assertRaises(ValueError, float, "  +3,14  ")
+        self.assertRaises(ValueError, float, "  -3,14  ")
+        self.assertRaises(ValueError, float, "  0x3.1  ")
+        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
+        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
+        self.assertEqual(float("  25.e-1  "), 2.5)
+        self.assertEqual(fcmp(float("  .25e-1  "), .025), 0)
+
+    def test_floatconversion(self):
+        # Make sure that calls to __float__() work properly
+        class Foo0:
+            def __float__(self):
+                return 42.
+
+        class Foo1(object):
+            def __float__(self):
+                return 42.
+
+        class Foo2(float):
+            def __float__(self):
+                return 42.
+
+        class Foo3(float):
+            def __new__(cls, value=0.):
+                return float.__new__(cls, 2*value)
+
+            def __float__(self):
+                return self
+
+        class Foo4(float):
+            def __float__(self):
+                return 42
+
+        self.assertAlmostEqual(float(Foo0()), 42.)
+        self.assertAlmostEqual(float(Foo1()), 42.)
+        self.assertAlmostEqual(float(Foo2()), 42.)
+        self.assertAlmostEqual(float(Foo3(21)), 42.)
+        self.assertRaises(TypeError, float, Foo4(42))
+
+    def test_floatasratio(self):
+        for f, ratio in [
+                (0.875, (7, 8)),
+                (-0.875, (-7, 8)),
+                (0.0, (0, 1)),
+                (11.5, (23, 2)),
+            ]:
+            self.assertEqual(f.as_integer_ratio(), ratio)
+
+        for i in range(10000):
+            f = random.random()
+            f *= 10 ** random.randint(-100, 100)
+            n, d = f.as_integer_ratio()
+            self.assertEqual(float(n).__truediv__(d), f)
+
+        R = fractions.Fraction
+        self.assertEqual(R(0, 1),
+                         R(*float(0.0).as_integer_ratio()))
+        self.assertEqual(R(5, 2),
+                         R(*float(2.5).as_integer_ratio()))
+        self.assertEqual(R(1, 2),
+                         R(*float(0.5).as_integer_ratio()))
+        self.assertEqual(R(4728779608739021, 2251799813685248),
+                         R(*float(2.1).as_integer_ratio()))
+        self.assertEqual(R(-4728779608739021, 2251799813685248),
+                         R(*float(-2.1).as_integer_ratio()))
+        self.assertEqual(R(-2100, 1),
+                         R(*float(-2100.0).as_integer_ratio()))
+
+        self.assertRaises(OverflowError, float('inf').as_integer_ratio)
+        self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
+        self.assertRaises(ValueError, float('nan').as_integer_ratio)
+
 class FormatFunctionsTestCase(unittest.TestCase):
 
     def setUp(self):
diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py
index c86a24d..de45b23 100644
--- a/Lib/test/test_frozen.py
+++ b/Lib/test/test_frozen.py
@@ -1,5 +1,4 @@
 # Test the frozen module defined in frozen.c.
-from __future__ import with_statement
 
 from test.test_support import captured_stdout, run_unittest
 import unittest
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index fe1da52..1c9dd3a 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -271,4 +271,6 @@
     run_unittest(ImportTest, PathsTests, RelativeImport)
 
 if __name__ == '__main__':
+    # test needs to be a package, so we can do relative import
+    from test.test_import import test_main
     test_main()
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
new file mode 100644
index 0000000..91d5273
--- /dev/null
+++ b/Lib/test/test_int.py
@@ -0,0 +1,304 @@
+import sys
+
+import unittest
+from test.test_support import run_unittest
+
+L = [
+        ('0', 0),
+        ('1', 1),
+        ('9', 9),
+        ('10', 10),
+        ('99', 99),
+        ('100', 100),
+        ('314', 314),
+        (' 314', 314),
+        ('314 ', 314),
+        ('  \t\t  314  \t\t  ', 314),
+        (repr(sys.maxsize), sys.maxsize),
+        ('  1x', ValueError),
+        ('  1  ', 1),
+        ('  1\02  ', ValueError),
+        ('', ValueError),
+        (' ', ValueError),
+        ('  \t\t  ', ValueError)
+]
+
+class IntTestCases(unittest.TestCase):
+
+    def test_basic(self):
+        self.assertEqual(int(314), 314)
+        self.assertEqual(int(3.14), 3)
+        # Check that conversion from float truncates towards zero
+        self.assertEqual(int(-3.14), -3)
+        self.assertEqual(int(3.9), 3)
+        self.assertEqual(int(-3.9), -3)
+        self.assertEqual(int(3.5), 3)
+        self.assertEqual(int(-3.5), -3)
+        # Different base:
+        self.assertEqual(int("10",16), 16)
+        # Test conversion from strings and various anomalies
+        for s, v in L:
+            for sign in "", "+", "-":
+                for prefix in "", " ", "\t", "  \t\t  ":
+                    ss = prefix + sign + s
+                    vv = v
+                    if sign == "-" and v is not ValueError:
+                        vv = -v
+                    try:
+                        self.assertEqual(int(ss), vv)
+                    except ValueError:
+                        pass
+
+        s = repr(-1-sys.maxsize)
+        x = int(s)
+        self.assertEqual(x+1, -sys.maxsize)
+        self.assert_(isinstance(x, int))
+        # should return long
+        self.assertEqual(int(s[1:]), sys.maxsize+1)
+
+        # should return long
+        x = int(1e100)
+        self.assert_(isinstance(x, int))
+        x = int(-1e100)
+        self.assert_(isinstance(x, int))
+
+
+        # SF bug 434186:  0x80000000/2 != 0x80000000>>1.
+        # Worked by accident in Windows release build, but failed in debug build.
+        # Failed in all Linux builds.
+        x = -1-sys.maxsize
+        self.assertEqual(x >> 1, x//2)
+
+        self.assertRaises(ValueError, int, '123\0')
+        self.assertRaises(ValueError, int, '53', 40)
+
+        # SF bug 1545497: embedded NULs were not detected with
+        # explicit base
+        self.assertRaises(ValueError, int, '123\0', 10)
+        self.assertRaises(ValueError, int, '123\x00 245', 20)
+
+        x = int('1' * 600)
+        self.assert_(isinstance(x, int))
+
+        self.assertRaises(TypeError, int, 1, 12)
+
+        self.assertEqual(int('0o123', 0), 83)
+        self.assertEqual(int('0x123', 16), 291)
+
+        # Bug 1679: "0x" is not a valid hex literal
+        self.assertRaises(ValueError, int, "0x", 16)
+        self.assertRaises(ValueError, int, "0x", 0)
+
+        self.assertRaises(ValueError, int, "0o", 8)
+        self.assertRaises(ValueError, int, "0o", 0)
+
+        self.assertRaises(ValueError, int, "0b", 2)
+        self.assertRaises(ValueError, int, "0b", 0)
+
+
+        # SF bug 1334662: int(string, base) wrong answers
+        # Various representations of 2**32 evaluated to 0
+        # rather than 2**32 in previous versions
+
+        self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296)
+        self.assertEqual(int('102002022201221111211', 3), 4294967296)
+        self.assertEqual(int('10000000000000000', 4), 4294967296)
+        self.assertEqual(int('32244002423141', 5), 4294967296)
+        self.assertEqual(int('1550104015504', 6), 4294967296)
+        self.assertEqual(int('211301422354', 7), 4294967296)
+        self.assertEqual(int('40000000000', 8), 4294967296)
+        self.assertEqual(int('12068657454', 9), 4294967296)
+        self.assertEqual(int('4294967296', 10), 4294967296)
+        self.assertEqual(int('1904440554', 11), 4294967296)
+        self.assertEqual(int('9ba461594', 12), 4294967296)
+        self.assertEqual(int('535a79889', 13), 4294967296)
+        self.assertEqual(int('2ca5b7464', 14), 4294967296)
+        self.assertEqual(int('1a20dcd81', 15), 4294967296)
+        self.assertEqual(int('100000000', 16), 4294967296)
+        self.assertEqual(int('a7ffda91', 17), 4294967296)
+        self.assertEqual(int('704he7g4', 18), 4294967296)
+        self.assertEqual(int('4f5aff66', 19), 4294967296)
+        self.assertEqual(int('3723ai4g', 20), 4294967296)
+        self.assertEqual(int('281d55i4', 21), 4294967296)
+        self.assertEqual(int('1fj8b184', 22), 4294967296)
+        self.assertEqual(int('1606k7ic', 23), 4294967296)
+        self.assertEqual(int('mb994ag', 24), 4294967296)
+        self.assertEqual(int('hek2mgl', 25), 4294967296)
+        self.assertEqual(int('dnchbnm', 26), 4294967296)
+        self.assertEqual(int('b28jpdm', 27), 4294967296)
+        self.assertEqual(int('8pfgih4', 28), 4294967296)
+        self.assertEqual(int('76beigg', 29), 4294967296)
+        self.assertEqual(int('5qmcpqg', 30), 4294967296)
+        self.assertEqual(int('4q0jto4', 31), 4294967296)
+        self.assertEqual(int('4000000', 32), 4294967296)
+        self.assertEqual(int('3aokq94', 33), 4294967296)
+        self.assertEqual(int('2qhxjli', 34), 4294967296)
+        self.assertEqual(int('2br45qb', 35), 4294967296)
+        self.assertEqual(int('1z141z4', 36), 4294967296)
+
+        # tests with base 0
+        # this fails on 3.0, but in 2.x the old octal syntax is allowed
+        self.assertEqual(int(' 0o123  ', 0), 83)
+        self.assertEqual(int(' 0o123  ', 0), 83)
+        self.assertEqual(int('000', 0), 0)
+        self.assertEqual(int('0o123', 0), 83)
+        self.assertEqual(int('0x123', 0), 291)
+        self.assertEqual(int('0b100', 0), 4)
+        self.assertEqual(int(' 0O123   ', 0), 83)
+        self.assertEqual(int(' 0X123  ', 0), 291)
+        self.assertEqual(int(' 0B100 ', 0), 4)
+
+        # without base still base 10
+        self.assertEqual(int('0123'), 123)
+        self.assertEqual(int('0123', 10), 123)
+
+        # tests with prefix and base != 0
+        self.assertEqual(int('0x123', 16), 291)
+        self.assertEqual(int('0o123', 8), 83)
+        self.assertEqual(int('0b100', 2), 4)
+        self.assertEqual(int('0X123', 16), 291)
+        self.assertEqual(int('0O123', 8), 83)
+        self.assertEqual(int('0B100', 2), 4)
+
+        # the code has special checks for the first character after the
+        #  type prefix
+        self.assertRaises(ValueError, int, '0b2', 2)
+        self.assertRaises(ValueError, int, '0b02', 2)
+        self.assertRaises(ValueError, int, '0B2', 2)
+        self.assertRaises(ValueError, int, '0B02', 2)
+        self.assertRaises(ValueError, int, '0o8', 8)
+        self.assertRaises(ValueError, int, '0o08', 8)
+        self.assertRaises(ValueError, int, '0O8', 8)
+        self.assertRaises(ValueError, int, '0O08', 8)
+        self.assertRaises(ValueError, int, '0xg', 16)
+        self.assertRaises(ValueError, int, '0x0g', 16)
+        self.assertRaises(ValueError, int, '0Xg', 16)
+        self.assertRaises(ValueError, int, '0X0g', 16)
+
+        # SF bug 1334662: int(string, base) wrong answers
+        # Checks for proper evaluation of 2**32 + 1
+        self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297)
+        self.assertEqual(int('102002022201221111212', 3), 4294967297)
+        self.assertEqual(int('10000000000000001', 4), 4294967297)
+        self.assertEqual(int('32244002423142', 5), 4294967297)
+        self.assertEqual(int('1550104015505', 6), 4294967297)
+        self.assertEqual(int('211301422355', 7), 4294967297)
+        self.assertEqual(int('40000000001', 8), 4294967297)
+        self.assertEqual(int('12068657455', 9), 4294967297)
+        self.assertEqual(int('4294967297', 10), 4294967297)
+        self.assertEqual(int('1904440555', 11), 4294967297)
+        self.assertEqual(int('9ba461595', 12), 4294967297)
+        self.assertEqual(int('535a7988a', 13), 4294967297)
+        self.assertEqual(int('2ca5b7465', 14), 4294967297)
+        self.assertEqual(int('1a20dcd82', 15), 4294967297)
+        self.assertEqual(int('100000001', 16), 4294967297)
+        self.assertEqual(int('a7ffda92', 17), 4294967297)
+        self.assertEqual(int('704he7g5', 18), 4294967297)
+        self.assertEqual(int('4f5aff67', 19), 4294967297)
+        self.assertEqual(int('3723ai4h', 20), 4294967297)
+        self.assertEqual(int('281d55i5', 21), 4294967297)
+        self.assertEqual(int('1fj8b185', 22), 4294967297)
+        self.assertEqual(int('1606k7id', 23), 4294967297)
+        self.assertEqual(int('mb994ah', 24), 4294967297)
+        self.assertEqual(int('hek2mgm', 25), 4294967297)
+        self.assertEqual(int('dnchbnn', 26), 4294967297)
+        self.assertEqual(int('b28jpdn', 27), 4294967297)
+        self.assertEqual(int('8pfgih5', 28), 4294967297)
+        self.assertEqual(int('76beigh', 29), 4294967297)
+        self.assertEqual(int('5qmcpqh', 30), 4294967297)
+        self.assertEqual(int('4q0jto5', 31), 4294967297)
+        self.assertEqual(int('4000001', 32), 4294967297)
+        self.assertEqual(int('3aokq95', 33), 4294967297)
+        self.assertEqual(int('2qhxjlj', 34), 4294967297)
+        self.assertEqual(int('2br45qc', 35), 4294967297)
+        self.assertEqual(int('1z141z5', 36), 4294967297)
+
+    def test_intconversion(self):
+        # Test __int__()
+        class ClassicMissingMethods:
+            pass
+        self.assertRaises(TypeError, int, ClassicMissingMethods())
+
+        class MissingMethods(object):
+            pass
+        self.assertRaises(TypeError, int, MissingMethods())
+
+        class Foo0:
+            def __int__(self):
+                return 42
+
+        class Foo1(object):
+            def __int__(self):
+                return 42
+
+        class Foo2(int):
+            def __int__(self):
+                return 42
+
+        class Foo3(int):
+            def __int__(self):
+                return self
+
+        class Foo4(int):
+            def __int__(self):
+                return 42
+
+        class Foo5(int):
+            def __int__(self):
+                return 42.
+
+        self.assertEqual(int(Foo0()), 42)
+        self.assertEqual(int(Foo1()), 42)
+        self.assertEqual(int(Foo2()), 42)
+        self.assertEqual(int(Foo3()), 0)
+        self.assertEqual(int(Foo4()), 42)
+        self.assertRaises(TypeError, int, Foo5())
+
+        class Classic:
+            pass
+        for base in (object, Classic):
+            class IntOverridesTrunc(base):
+                def __int__(self):
+                    return 42
+                def __trunc__(self):
+                    return -12
+            self.assertEqual(int(IntOverridesTrunc()), 42)
+
+            class JustTrunc(base):
+                def __trunc__(self):
+                    return 42
+            self.assertEqual(int(JustTrunc()), 42)
+
+            for trunc_result_base in (object, Classic):
+                class Integral(trunc_result_base):
+                    def __int__(self):
+                        return 42
+
+                class TruncReturnsNonInt(base):
+                    def __trunc__(self):
+                        return Integral()
+                self.assertEqual(int(TruncReturnsNonInt()), 42)
+
+                class NonIntegral(trunc_result_base):
+                    def __trunc__(self):
+                        # Check that we avoid infinite recursion.
+                        return NonIntegral()
+
+                class TruncReturnsNonIntegral(base):
+                    def __trunc__(self):
+                        return NonIntegral()
+                try:
+                    int(TruncReturnsNonIntegral())
+                except TypeError as e:
+                    self.assertEquals(str(e),
+                                      "__trunc__ returned non-Integral"
+                                      " (type NonIntegral)")
+                else:
+                    self.fail("Failed to raise TypeError with %s" %
+                              ((base, trunc_result_base),))
+
+def test_main():
+    run_unittest(IntTestCases)
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 0c37cc7..ba3ceeb 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1161,10 +1161,10 @@
 
 def test_main():
     test_support.run_unittest(IOTest, BytesIOTest, StringIOTest,
-                              BufferedReaderTest,
-                              BufferedWriterTest, BufferedRWPairTest,
-                              BufferedRandomTest, TextIOWrapperTest,
-                              MiscIOTest)
+                              BufferedReaderTest, BufferedWriterTest,
+                              BufferedRWPairTest, BufferedRandomTest,
+                              StatefulIncrementalDecoderTest,
+                              TextIOWrapperTest, MiscIOTest)
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index b3b2195..3b85117 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -4,6 +4,22 @@
 class ListTest(list_tests.CommonTest):
     type2test = list
 
+    def test_basic(self):
+        self.assertEqual(list([]), [])
+        l0_3 = [0, 1, 2, 3]
+        l0_3_bis = list(l0_3)
+        self.assertEqual(l0_3, l0_3_bis)
+        self.assert_(l0_3 is not l0_3_bis)
+        self.assertEqual(list(()), [])
+        self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
+        self.assertEqual(list(''), [])
+        self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
+
+        # This code used to segfault in Py2.4a3
+        x = []
+        x.extend(-y for y in x)
+        self.assertEqual(x, [])
+
     def test_truth(self):
         super().test_truth()
         self.assert_(not [])
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index f98ba8d..7e159aa 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -1,5 +1,6 @@
 import unittest
 from test import test_support
+import sys
 
 import random
 
@@ -33,6 +34,26 @@
 # add complements & negations
 special += [~x for x in special] + [-x for x in special]
 
+L = [
+        ('0', 0),
+        ('1', 1),
+        ('9', 9),
+        ('10', 10),
+        ('99', 99),
+        ('100', 100),
+        ('314', 314),
+        (' 314', 314),
+        ('314 ', 314),
+        ('  \t\t  314  \t\t  ', 314),
+        (repr(sys.maxsize), sys.maxsize),
+        ('  1x', ValueError),
+        ('  1  ', 1),
+        ('  1\02  ', ValueError),
+        ('', ValueError),
+        (' ', ValueError),
+        ('  \t\t  ', ValueError)
+]
+
 
 class LongTest(unittest.TestCase):
 
@@ -229,8 +250,206 @@
                 x = self.getran(lenx)
                 self.check_format_1(x)
 
+    def test_long(self):
+        self.assertEqual(int(314), 314)
+        self.assertEqual(int(3.14), 3)
+        self.assertEqual(int(314), 314)
+        # Check that conversion from float truncates towards zero
+        self.assertEqual(int(-3.14), -3)
+        self.assertEqual(int(3.9), 3)
+        self.assertEqual(int(-3.9), -3)
+        self.assertEqual(int(3.5), 3)
+        self.assertEqual(int(-3.5), -3)
+        self.assertEqual(int("-3"), -3)
+        # Different base:
+        self.assertEqual(int("10",16), 16)
+        # Check conversions from string (same test set as for int(), and then some)
+        LL = [
+                ('1' + '0'*20, 10**20),
+                ('1' + '0'*100, 10**100)
+        ]
+        L2 = L[:]
+        for s, v in L2 + LL:
+            for sign in "", "+", "-":
+                for prefix in "", " ", "\t", "  \t\t  ":
+                    ss = prefix + sign + s
+                    vv = v
+                    if sign == "-" and v is not ValueError:
+                        vv = -v
+                    try:
+                        self.assertEqual(int(ss), int(vv))
+                    except ValueError:
+                        pass
+
+        self.assertRaises(ValueError, int, '123\0')
+        self.assertRaises(ValueError, int, '53', 40)
+        self.assertRaises(TypeError, int, 1, 12)
+
+        # SF patch #1638879: embedded NULs were not detected with
+        # explicit base
+        self.assertRaises(ValueError, int, '123\0', 10)
+        self.assertRaises(ValueError, int, '123\x00 245', 20)
+
+        self.assertEqual(int('100000000000000000000000000000000', 2),
+                         4294967296)
+        self.assertEqual(int('102002022201221111211', 3), 4294967296)
+        self.assertEqual(int('10000000000000000', 4), 4294967296)
+        self.assertEqual(int('32244002423141', 5), 4294967296)
+        self.assertEqual(int('1550104015504', 6), 4294967296)
+        self.assertEqual(int('211301422354', 7), 4294967296)
+        self.assertEqual(int('40000000000', 8), 4294967296)
+        self.assertEqual(int('12068657454', 9), 4294967296)
+        self.assertEqual(int('4294967296', 10), 4294967296)
+        self.assertEqual(int('1904440554', 11), 4294967296)
+        self.assertEqual(int('9ba461594', 12), 4294967296)
+        self.assertEqual(int('535a79889', 13), 4294967296)
+        self.assertEqual(int('2ca5b7464', 14), 4294967296)
+        self.assertEqual(int('1a20dcd81', 15), 4294967296)
+        self.assertEqual(int('100000000', 16), 4294967296)
+        self.assertEqual(int('a7ffda91', 17), 4294967296)
+        self.assertEqual(int('704he7g4', 18), 4294967296)
+        self.assertEqual(int('4f5aff66', 19), 4294967296)
+        self.assertEqual(int('3723ai4g', 20), 4294967296)
+        self.assertEqual(int('281d55i4', 21), 4294967296)
+        self.assertEqual(int('1fj8b184', 22), 4294967296)
+        self.assertEqual(int('1606k7ic', 23), 4294967296)
+        self.assertEqual(int('mb994ag', 24), 4294967296)
+        self.assertEqual(int('hek2mgl', 25), 4294967296)
+        self.assertEqual(int('dnchbnm', 26), 4294967296)
+        self.assertEqual(int('b28jpdm', 27), 4294967296)
+        self.assertEqual(int('8pfgih4', 28), 4294967296)
+        self.assertEqual(int('76beigg', 29), 4294967296)
+        self.assertEqual(int('5qmcpqg', 30), 4294967296)
+        self.assertEqual(int('4q0jto4', 31), 4294967296)
+        self.assertEqual(int('4000000', 32), 4294967296)
+        self.assertEqual(int('3aokq94', 33), 4294967296)
+        self.assertEqual(int('2qhxjli', 34), 4294967296)
+        self.assertEqual(int('2br45qb', 35), 4294967296)
+        self.assertEqual(int('1z141z4', 36), 4294967296)
+
+        self.assertEqual(int('100000000000000000000000000000001', 2),
+                         4294967297)
+        self.assertEqual(int('102002022201221111212', 3), 4294967297)
+        self.assertEqual(int('10000000000000001', 4), 4294967297)
+        self.assertEqual(int('32244002423142', 5), 4294967297)
+        self.assertEqual(int('1550104015505', 6), 4294967297)
+        self.assertEqual(int('211301422355', 7), 4294967297)
+        self.assertEqual(int('40000000001', 8), 4294967297)
+        self.assertEqual(int('12068657455', 9), 4294967297)
+        self.assertEqual(int('4294967297', 10), 4294967297)
+        self.assertEqual(int('1904440555', 11), 4294967297)
+        self.assertEqual(int('9ba461595', 12), 4294967297)
+        self.assertEqual(int('535a7988a', 13), 4294967297)
+        self.assertEqual(int('2ca5b7465', 14), 4294967297)
+        self.assertEqual(int('1a20dcd82', 15), 4294967297)
+        self.assertEqual(int('100000001', 16), 4294967297)
+        self.assertEqual(int('a7ffda92', 17), 4294967297)
+        self.assertEqual(int('704he7g5', 18), 4294967297)
+        self.assertEqual(int('4f5aff67', 19), 4294967297)
+        self.assertEqual(int('3723ai4h', 20), 4294967297)
+        self.assertEqual(int('281d55i5', 21), 4294967297)
+        self.assertEqual(int('1fj8b185', 22), 4294967297)
+        self.assertEqual(int('1606k7id', 23), 4294967297)
+        self.assertEqual(int('mb994ah', 24), 4294967297)
+        self.assertEqual(int('hek2mgm', 25), 4294967297)
+        self.assertEqual(int('dnchbnn', 26), 4294967297)
+        self.assertEqual(int('b28jpdn', 27), 4294967297)
+        self.assertEqual(int('8pfgih5', 28), 4294967297)
+        self.assertEqual(int('76beigh', 29), 4294967297)
+        self.assertEqual(int('5qmcpqh', 30), 4294967297)
+        self.assertEqual(int('4q0jto5', 31), 4294967297)
+        self.assertEqual(int('4000001', 32), 4294967297)
+        self.assertEqual(int('3aokq95', 33), 4294967297)
+        self.assertEqual(int('2qhxjlj', 34), 4294967297)
+        self.assertEqual(int('2br45qc', 35), 4294967297)
+        self.assertEqual(int('1z141z5', 36), 4294967297)
+
+
+    def test_conversion(self):
+        # Test __long__()
+        class ClassicMissingMethods:
+            pass
+        self.assertRaises(TypeError, int, ClassicMissingMethods())
+
+        class MissingMethods(object):
+            pass
+        self.assertRaises(TypeError, int, MissingMethods())
+
+        class Foo0:
+            def __int__(self):
+                return 42
+
+        class Foo1(object):
+            def __int__(self):
+                return 42
+
+        class Foo2(int):
+            def __int__(self):
+                return 42
+
+        class Foo3(int):
+            def __int__(self):
+                return self
+
+        class Foo4(int):
+            def __int__(self):
+                return 42
+
+        class Foo5(int):
+            def __int__(self):
+                return 42.
+
+        self.assertEqual(int(Foo0()), 42)
+        self.assertEqual(int(Foo1()), 42)
+        self.assertEqual(int(Foo2()), 42)
+        self.assertEqual(int(Foo3()), 0)
+        self.assertEqual(int(Foo4()), 42)
+        self.assertRaises(TypeError, int, Foo5())
+
+        class Classic:
+            pass
+        for base in (object, Classic):
+            class LongOverridesTrunc(base):
+                def __long__(self):
+                    return 42
+                def __trunc__(self):
+                    return -12
+            self.assertEqual(int(LongOverridesTrunc()), 42)
+
+            class JustTrunc(base):
+                def __trunc__(self):
+                    return 42
+            self.assertEqual(int(JustTrunc()), 42)
+
+            for trunc_result_base in (object, Classic):
+                class Integral(trunc_result_base):
+                    def __int__(self):
+                        return 42
+
+                class TruncReturnsNonLong(base):
+                    def __trunc__(self):
+                        return Integral()
+                self.assertEqual(int(TruncReturnsNonLong()), 42)
+
+                class NonIntegral(trunc_result_base):
+                    def __trunc__(self):
+                        # Check that we avoid infinite recursion.
+                        return NonIntegral()
+
+                class TruncReturnsNonIntegral(base):
+                    def __trunc__(self):
+                        return NonIntegral()
+                try:
+                    int(TruncReturnsNonIntegral())
+                except TypeError as e:
+                    self.assertEquals(str(e),
+                                      "__trunc__ returned non-Integral"
+                                      " (type NonIntegral)")
+                else:
+                    self.fail("Failed to raise TypeError with %s" %
+                              ((base, trunc_result_base),))
+
     def test_misc(self):
-        import sys
 
         # check the extremes in int<->long conversion
         hugepos = sys.maxsize
@@ -403,7 +622,6 @@
     def test_mixed_compares(self):
         eq = self.assertEqual
         import math
-        import sys
 
         # We're mostly concerned with that mixing floats and longs does the
         # right stuff, even when longs are too large to fit in a float.
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index 77d3f88..9f58706 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -8,40 +8,23 @@
 class TestUntestedModules(unittest.TestCase):
     def test_at_least_import_untested_modules(self):
         with test_support.catch_warning():
-            import BaseHTTPServer
-            import DocXMLRPCServer
             import CGIHTTPServer
-            import SimpleHTTPServer
-            import SimpleXMLRPCServer
             import aifc
             import bdb
             import cgitb
-            import cmd
             import code
             import compileall
 
-            import distutils.archive_util
             import distutils.bcppcompiler
             import distutils.ccompiler
-            import distutils.cmd
-            import distutils.core
             import distutils.cygwinccompiler
-            import distutils.dep_util
-            import distutils.dir_util
             import distutils.emxccompiler
-            import distutils.errors
-            import distutils.extension
-            import distutils.file_util
             import distutils.filelist
-            import distutils.log
             if sys.platform.startswith('win'):
                 import distutils.msvccompiler
             import distutils.mwerkscompiler
-            import distutils.sysconfig
             import distutils.text_file
             import distutils.unixccompiler
-            import distutils.util
-            import distutils.version
 
             import distutils.command.bdist_dumb
             if sys.platform.startswith('win'):
@@ -52,23 +35,18 @@
             import distutils.command.build_clib
             import distutils.command.build_ext
             import distutils.command.build
-            import distutils.command.build_py
-            import distutils.command.build_scripts
             import distutils.command.clean
             import distutils.command.config
             import distutils.command.install_data
             import distutils.command.install_egg_info
             import distutils.command.install_headers
             import distutils.command.install_lib
-            import distutils.command.install
-            import distutils.command.install_scripts
             import distutils.command.register
             import distutils.command.sdist
             import distutils.command.upload
 
             import encodings
             import formatter
-            import ftplib
             import getpass
             import htmlentitydefs
             import ihooks
@@ -78,7 +56,6 @@
             import linecache
             import macurl2path
             import mailcap
-            import mutex
             import nntplib
             import nturl2path
             import opcode
@@ -88,14 +65,12 @@
             import py_compile
             import rlcompleter
             import sched
-            import smtplib
             import sndhdr
             import statvfs
             import sunau
             import sunaudio
             import symbol
             import tabnanny
-            import telnetlib
             import timeit
             import token
             try:
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index f61e70a..431b66b 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -473,8 +473,10 @@
     import io
     orig_stdout = getattr(sys, stream_name)
     setattr(sys, stream_name, io.StringIO())
-    yield getattr(sys, stream_name)
-    setattr(sys, stream_name, orig_stdout)
+    try:
+        yield getattr(sys, stream_name)
+    finally:
+        setattr(sys, stream_name, orig_stdout)
 
 def captured_stdout():
     return captured_output("stdout")
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 3f2239d..dc97d40 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -129,6 +129,10 @@
         expect = ['And she said, "Go to hell!"  Can you believe that?']
         self.check(wrapper.wrap(text), expect)
 
+        text = 'File stdio.h is nice.'
+        expect = ['File stdio.h is nice.']
+        self.check(wrapper.wrap(text), expect)
+
     def test_wrap_short(self):
         # Wrapping to make short lines longer
 
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 635e1bc..9ecd995 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -4,6 +4,7 @@
 import unittest
 import sys
 import difflib
+import gc
 
 # A very basic example.  If this fails, we're in deep trouble.
 def basic():
@@ -244,6 +245,17 @@
         return self.trace
 
 class TraceTestCase(unittest.TestCase):
+
+    # Disable gc collection when tracing, otherwise the
+    # deallocators may be traced as well.
+    def setUp(self):
+        self.using_gc = gc.isenabled()
+        gc.disable()
+
+    def tearDown(self):
+        if self.using_gc:
+            gc.enable()
+
     def compare_events(self, line_offset, events, expected_events):
         events = [(l - line_offset, e) for (l, e) in events]
         if events != expected_events:
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 93e5126..600c7b5 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1,10 +1,24 @@
 """Test cases for traceback module"""
 
+from _testcapi import traceback_print
+from io import StringIO
+import sys
 import unittest
-from test.test_support import run_unittest, is_jython
+from test.test_support import run_unittest, is_jython, Error
 
 import traceback
 
+try:
+    raise KeyError
+except KeyError:
+    type_, value, tb = sys.exc_info()
+    file_ = StringIO()
+    traceback_print(tb, file_)
+    example_traceback = file_.getvalue()
+else:
+    raise Error("unable to create test traceback string")
+
+
 class TracebackCases(unittest.TestCase):
     # For now, a very minimal set of tests.  I want to be sure that
     # formatting of SyntaxErrors works based on changes for 2.1.
@@ -76,8 +90,20 @@
         self.assertEqual(err, ['None\n'])
 
 
+class TracebackFormatTests(unittest.TestCase):
+
+    def test_traceback_indentation(self):
+        # Make sure that the traceback is properly indented.
+        tb_lines = example_traceback.splitlines()
+        self.assertEquals(len(tb_lines), 3)
+        banner, location, source_line = tb_lines
+        self.assert_(banner.startswith('Traceback'))
+        self.assert_(location.startswith('  File'))
+        self.assert_(source_line.startswith('raise'))
+
+
 def test_main():
-    run_unittest(TracebackCases)
+    run_unittest(TracebackCases, TracebackFormatTests)
 
 
 if __name__ == "__main__":
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index 62c5d71..77672e7 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -7,6 +7,13 @@
         super().test_len()
         # calling built-in types without argument must return empty
         self.assertEqual(tuple(), ())
+        t0_3 = (0, 1, 2, 3)
+        t0_3_bis = tuple(t0_3)
+        self.assert_(t0_3 is t0_3_bis)
+        self.assertEqual(tuple([]), ())
+        self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3))
+        self.assertEqual(tuple(''), ())
+        self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
 
     def test_truth(self):
         super().test_truth()
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 9f0b2c4..d34a177 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1059,6 +1059,12 @@
         o = build_opener(urllib2.HTTPHandler())
         self.opener_has_handler(o, urllib2.HTTPHandler)
 
+        # Issue2670: multiple handlers sharing the same base class
+        class MyOtherHTTPHandler(urllib2.HTTPHandler): pass
+        o = build_opener(MyHTTPHandler, MyOtherHTTPHandler)
+        self.opener_has_handler(o, MyHTTPHandler)
+        self.opener_has_handler(o, MyOtherHTTPHandler)
+
     def opener_has_handler(self, opener, handler_class):
         for h in opener.handlers:
             if h.__class__ == handler_class:
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index a6cbddf..0f3ee8b 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -229,6 +229,77 @@
                 warning_tests.inner("spam7", stacklevel=9999)
                 self.assertEqual(os.path.basename(w.filename), "sys")
 
+    def test_missing_filename_not_main(self):
+        # If __file__ is not specified and __main__ is not the module name,
+        # then __file__ should be set to the module name.
+        filename = warning_tests.__file__
+        try:
+            del warning_tests.__file__
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner("spam8", stacklevel=1)
+                    self.assertEqual(w.filename, warning_tests.__name__)
+        finally:
+            warning_tests.__file__ = filename
+
+    def test_missing_filename_main_with_argv(self):
+        # If __file__ is not specified and the caller is __main__ and sys.argv
+        # exists, then use sys.argv[0] as the file.
+        if not hasattr(sys, 'argv'):
+            return
+        filename = warning_tests.__file__
+        module_name = warning_tests.__name__
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam9', stacklevel=1)
+                    self.assertEqual(w.filename, sys.argv[0])
+        finally:
+            warning_tests.__file__ = filename
+            warning_tests.__name__ = module_name
+
+    def test_missing_filename_main_without_argv(self):
+        # If __file__ is not specified, the caller is __main__, and sys.argv
+        # is not set, then '__main__' is the file name.
+        filename = warning_tests.__file__
+        module_name = warning_tests.__name__
+        argv = sys.argv
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            del sys.argv
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam10', stacklevel=1)
+                    self.assertEqual(w.filename, '__main__')
+        finally:
+            warning_tests.__file__ = filename
+            warning_tests.__name__ = module_name
+            sys.argv = argv
+
+    def BROKEN_test_missing_filename_main_with_argv_empty_string(self):
+        # If __file__ is not specified, the caller is __main__, and sys.argv[0]
+        # is the empty string, then '__main__ is the file name.
+        # Tests issue 2743.
+        file_name = warning_tests.__file__
+        module_name = warning_tests.__name__
+        argv = sys.argv
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            sys.argv = ['']
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam11', stacklevel=1)
+                    self.assertEqual(w.filename, '__main__')
+        finally:
+            warning_tests.__file__ = file_name
+            warning_tests.__name__ = module_name
+            sys.argv = argv
+
+
 
 class CWarnTests(BaseTest, WarnTests):
     module = c_warnings
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index e778463..6e439ac 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -2,7 +2,6 @@
 
 """Unit tests for the with statement specified in PEP 343."""
 
-from __future__ import with_statement
 
 __author__ = "Mike Bland"
 __email__ = "mbland at acm dot org"
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index a254eee..7ff078d 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -50,7 +50,7 @@
         self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))
 
     def test_datetime_before_1900(self):
-        # same as before but with an date before 1900
+        # same as before but with a date before 1900
         dt = datetime.datetime(1,  2, 10, 11, 41, 23)
         s = xmlrpclib.dumps((dt,))
         (newdt,), m = xmlrpclib.loads(s, use_datetime=1)