[Python-checkins] r71648 - in python/branches/py3k-short-float-repr: Doc/library/filesys.rst Doc/library/subprocess.rst Doc/whatsnew/3.1.rst Lib/_pyio.py Lib/distutils/cmd.py Lib/distutils/tests/test_cmd.py Lib/test/pickletester.py Lib/test/test_float.py Lib/test/test_pickle.py Misc/NEWS Objects/floatobject.c

eric.smith python-checkins at python.org
Thu Apr 16 14:57:18 CEST 2009


Author: eric.smith
Date: Thu Apr 16 14:57:18 2009
New Revision: 71648

Log:
Merged revisions 71580-71581,71587,71590,71598-71599,71606,71608,71626,71628,71633,71638 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r71580 | r.david.murray | 2009-04-13 13:00:25 -0400 (Mon, 13 Apr 2009) | 9 lines
  
  Merged revisions 71579 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r71579 | r.david.murray | 2009-04-13 12:56:32 -0400 (Mon, 13 Apr 2009) | 2 lines
    
    Add missing NEWS item for issue1161031 fix.
  ........
................
  r71581 | r.david.murray | 2009-04-13 13:06:33 -0400 (Mon, 13 Apr 2009) | 2 lines
  
  Move NEWS item to correct section.
................
  r71587 | tarek.ziade | 2009-04-13 16:07:23 -0400 (Mon, 13 Apr 2009) | 9 lines
  
  Merged revisions 71585 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r71585 | tarek.ziade | 2009-04-13 22:03:44 +0200 (Mon, 13 Apr 2009) | 1 line
    
    improved test coverage for distutils.cmd
  ........
................
  r71590 | tarek.ziade | 2009-04-13 16:19:58 -0400 (Mon, 13 Apr 2009) | 9 lines
  
  Merged revisions 71589 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r71589 | tarek.ziade | 2009-04-13 22:14:54 +0200 (Mon, 13 Apr 2009) | 1 line
    
    pep8-fied
  ........
................
  r71598 | raymond.hettinger | 2009-04-14 04:05:31 -0400 (Tue, 14 Apr 2009) | 1 line
  
  New module names are lowercase
................
  r71599 | raymond.hettinger | 2009-04-14 04:16:50 -0400 (Tue, 14 Apr 2009) | 1 line
  
  Fix-up links.
................
  r71606 | raymond.hettinger | 2009-04-14 16:45:17 -0400 (Tue, 14 Apr 2009) | 1 line
  
  Fix links
................
  r71608 | benjamin.peterson | 2009-04-14 18:02:08 -0400 (Tue, 14 Apr 2009) | 1 line
  
  other places like this just catch IOError
................
  r71626 | benjamin.peterson | 2009-04-15 16:34:30 -0400 (Wed, 15 Apr 2009) | 1 line
  
  reference the io momdule in file and directory section
................
  r71628 | benjamin.peterson | 2009-04-15 17:34:27 -0400 (Wed, 15 Apr 2009) | 11 lines
  
  Merged revisions 71627 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r71627 | benjamin.peterson | 2009-04-15 16:26:36 -0500 (Wed, 15 Apr 2009) | 4 lines
    
    call __float__ on str subclasses #5759
    
    tests by R. David Murray
  ........
................
  r71633 | r.david.murray | 2009-04-15 18:35:15 -0400 (Wed, 15 Apr 2009) | 11 lines
  
  Merged revisions 71631 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r71631 | r.david.murray | 2009-04-15 18:33:07 -0400 (Wed, 15 Apr 2009) | 4 lines
    
    Fix for issue3440: add warning to subprocess discussion of
    env parameter that on Windows SystemRoot is required in order
    to run side-by-side assemblies.
  ........
................
  r71638 | collin.winter | 2009-04-15 23:18:06 -0400 (Wed, 15 Apr 2009) | 1 line
  
  Port r71408 to py3k: issue 5665, add more pickling tests.
................


Modified:
   python/branches/py3k-short-float-repr/   (props changed)
   python/branches/py3k-short-float-repr/Doc/library/filesys.rst
   python/branches/py3k-short-float-repr/Doc/library/subprocess.rst
   python/branches/py3k-short-float-repr/Doc/whatsnew/3.1.rst
   python/branches/py3k-short-float-repr/Lib/_pyio.py
   python/branches/py3k-short-float-repr/Lib/distutils/cmd.py
   python/branches/py3k-short-float-repr/Lib/distutils/tests/test_cmd.py
   python/branches/py3k-short-float-repr/Lib/test/pickletester.py
   python/branches/py3k-short-float-repr/Lib/test/test_float.py
   python/branches/py3k-short-float-repr/Lib/test/test_pickle.py
   python/branches/py3k-short-float-repr/Misc/NEWS
   python/branches/py3k-short-float-repr/Objects/floatobject.c

Modified: python/branches/py3k-short-float-repr/Doc/library/filesys.rst
==============================================================================
--- python/branches/py3k-short-float-repr/Doc/library/filesys.rst	(original)
+++ python/branches/py3k-short-float-repr/Doc/library/filesys.rst	Thu Apr 16 14:57:18 2009
@@ -34,3 +34,7 @@
       Operating system interfaces, including functions to work with files at a lower
       level than the built-in file object.
 
+   Module :mod:`io`
+      Python's framework for dealing with I/O including reading and writing
+      files.
+

Modified: python/branches/py3k-short-float-repr/Doc/library/subprocess.rst
==============================================================================
--- python/branches/py3k-short-float-repr/Doc/library/subprocess.rst	(original)
+++ python/branches/py3k-short-float-repr/Doc/library/subprocess.rst	Thu Apr 16 14:57:18 2009
@@ -97,6 +97,13 @@
    variables for the new process; these are used instead of inheriting the current
    process' environment, which is the default behavior.
 
+   .. warning::
+
+      When replacing the environment you must provide any variables
+      required for the program to execute.  On Windows, in order to run
+      a side-by-side assembly the specified *env* must include a valid
+      :envvar:`SystemRoot`.
+
    If *universal_newlines* is :const:`True`, the file objects stdout and stderr are
    opened as text files, but lines may be terminated by any of ``'\n'``, the Unix
    end-of-line convention, ``'\r'``, the old Macintosh convention or ``'\r\n'``, the

Modified: python/branches/py3k-short-float-repr/Doc/whatsnew/3.1.rst
==============================================================================
--- python/branches/py3k-short-float-repr/Doc/whatsnew/3.1.rst	(original)
+++ python/branches/py3k-short-float-repr/Doc/whatsnew/3.1.rst	Thu Apr 16 14:57:18 2009
@@ -57,8 +57,8 @@
 Regular Python dictionaries iterate over key/value pairs in arbitrary order.
 Over the years, a number of authors have written alternative implementations
 that remember the order that the keys were originally inserted.  Based on
-the experiences from those implementations, the :mod:`collections` module
-now has an :class:`OrderedDict` class.
+the experiences from those implementations, a new
+:class:`collections.OrderedDict` class has been introduced.
 
 The OrderedDict API is substantially the same as regular dictionaries
 but will iterate over keys and values in a guaranteed order depending on
@@ -67,9 +67,9 @@
 reinserting it will move it to the end.
 
 The standard library now supports use of ordered dictionaries in several
-modules.  The :mod:`ConfigParser` module uses them by default.  This lets
+modules.  The :mod:`configparser` module uses them by default.  This lets
 configuration files be read, modified, and then written back in their original
-order.  The :mod:`collections` module's :meth:`namedtuple._asdict` method now
+order.  The *_asdict()* method for :func:`collections.namedtuple` now
 returns an ordered dictionary with the values appearing in the same order as
 the underlying tuple indicies.  The :mod:`json` module is being built-out with
 an *object_pairs_hook* to allow OrderedDicts to be built by the decoder.
@@ -103,7 +103,7 @@
 .. seealso::
 
    :pep:`378` - Format Specifier for Thousands Separator
-      PEP written by Raymond Hettinger; implemented by Eric Smith and
+      PEP written by Raymond Hettinger and implemented by Eric Smith and
       Mark Dickinson.
 
 
@@ -233,15 +233,15 @@
 
   (Contributed by Gregory Smith.)
 
-* The :mod:`logging` module now implements a simple :class:`NullHandler`
+* The :mod:`logging` module now implements a simple :class:`logging.NullHandler`
   class for applications that are not using logging but are calling
   library code that does.  Setting-up a null handler will suppress
-  spurious warnings like "No handlers could be found for logger X.Y.Z"::
+  spurious warnings such as "No handlers could be found for logger foo"::
 
     >>> h = logging.NullHandler()
     >>> logging.getLogger("foo").addHandler(h)
 
-  (Contributed by Vinay Sajip; issue:`4384`).
+  (Contributed by Vinay Sajip; :issue:`4384`).
 
 * The :mod:`runpy` module which supports the ``-m`` command line switch
   now supports the execution of packages by looking for and executing
@@ -279,7 +279,8 @@
         def test_gimzo_without_required_library(self):
             ...
 
-  Also, tests for exceptions have been builtout to work with context managers::
+  Also, tests for exceptions have been builtout to work with context managers
+  using the :keyword:`with` statement::
 
       def test_division_by_zero(self):
           with self.assertRaises(ZeroDivisionError):
@@ -305,7 +306,7 @@
   (Contributed by Ross Light; :issue:`4285`.)
 
 * A new module, :mod:`importlib` was added.  It provides a complete, portable,
-  pure Python reference implementation of the *import* statement and its
+  pure Python reference implementation of the :keyword:`import` statement and its
   counterpart, the :func:`__import__` function.  It represents a substantial
   step forward in documenting and defining the actions that take place during
   imports.

Modified: python/branches/py3k-short-float-repr/Lib/_pyio.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/_pyio.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/_pyio.py	Thu Apr 16 14:57:18 2009
@@ -1438,7 +1438,7 @@
     def close(self):
         try:
             self.flush()
-        except:
+        except IOError:
             pass  # If flush() fails, just give up
         self.buffer.close()
 

Modified: python/branches/py3k-short-float-repr/Lib/distutils/cmd.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/distutils/cmd.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/distutils/cmd.py	Thu Apr 16 14:57:18 2009
@@ -93,9 +93,8 @@
         # always calls 'finalize_options()', to respect/update it.
         self.finalized = 0
 
-
     # XXX A more explicit way to customize dry_run would be better.
-    def __getattr__ (self, attr):
+    def __getattr__(self, attr):
         if attr == 'dry_run':
             myval = getattr(self, "_" + attr)
             if myval is None:
@@ -105,7 +104,7 @@
         else:
             raise AttributeError(attr)
 
-    def ensure_finalized (self):
+    def ensure_finalized(self):
         if not self.finalized:
             self.finalize_options()
         self.finalized = 1
@@ -175,7 +174,6 @@
 
         This method must be implemented by all command classes.
         """
-
         raise RuntimeError("abstract method -- subclass %s must override"
                            % self.__class__)
 
@@ -351,7 +349,7 @@
                                    preserve_times, not self.force, link,
                                    dry_run=self.dry_run)
 
-    def copy_tree (self, infile, outfile, preserve_mode=1, preserve_times=1,
+    def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1,
                    preserve_symlinks=0, level=1):
         """Copy an entire directory tree respecting verbose, dry-run,
         and force flags.
@@ -373,7 +371,6 @@
         return archive_util.make_archive(base_name, format, root_dir, base_dir,
                                          dry_run=self.dry_run)
 
-
     def make_file(self, infiles, outfile, func, args,
                   exec_msg=None, skip_msg=None, level=1):
         """Special case of 'execute()' for operations that process one or
@@ -406,7 +403,6 @@
         else:
             log.debug(skip_msg)
 
-
 # XXX 'install_misc' class not currently used -- it was the base class for
 # both 'install_scripts' and 'install_data', but they outgrew it.  It might
 # still be useful for 'install_headers', though, so I'm keeping it around
@@ -423,10 +419,10 @@
         self.install_dir = None
         self.outfiles = []
 
-    def _install_dir_from (self, dirname):
+    def _install_dir_from(self, dirname):
         self.set_undefined_options('install', (dirname, 'install_dir'))
 
-    def _copy_files (self, filelist):
+    def _copy_files(self, filelist):
         self.outfiles = []
         if not filelist:
             return
@@ -435,5 +431,5 @@
             self.copy_file(f, self.install_dir)
             self.outfiles.append(os.path.join(self.install_dir, f))
 
-    def get_outputs (self):
+    def get_outputs(self):
         return self.outfiles

Modified: python/branches/py3k-short-float-repr/Lib/distutils/tests/test_cmd.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/distutils/tests/test_cmd.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/distutils/tests/test_cmd.py	Thu Apr 16 14:57:18 2009
@@ -1,5 +1,6 @@
 """Tests for distutils.cmd."""
 import unittest
+import os
 
 from distutils.cmd import Command
 from distutils.dist import Distribution
@@ -62,6 +63,45 @@
                   '  option2 = 1']
         self.assertEquals(msgs, wanted)
 
+    def test_ensure_string(self):
+        cmd = self.cmd
+        cmd.option1 = 'ok'
+        cmd.ensure_string('option1')
+
+        cmd.option2 = None
+        cmd.ensure_string('option2', 'xxx')
+        self.assert_(hasattr(cmd, 'option2'))
+
+        cmd.option3 = 1
+        self.assertRaises(DistutilsOptionError, cmd.ensure_string, 'option3')
+
+    def test_ensure_string_list(self):
+        cmd = self.cmd
+        cmd.option1 = 'ok,dok'
+        cmd.ensure_string_list('option1')
+        self.assertEquals(cmd.option1, ['ok', 'dok'])
+
+        cmd.option2 = ['xxx', 'www']
+        cmd.ensure_string_list('option2')
+
+        cmd.option3 = ['ok', 2]
+        self.assertRaises(DistutilsOptionError, cmd.ensure_string_list,
+                          'option3')
+
+    def test_ensure_filename(self):
+        cmd = self.cmd
+        cmd.option1 = __file__
+        cmd.ensure_filename('option1')
+        cmd.option2 = 'xxx'
+        self.assertRaises(DistutilsOptionError, cmd.ensure_filename, 'option2')
+
+    def test_ensure_dirname(self):
+        cmd = self.cmd
+        cmd.option1 = os.path.dirname(__file__)
+        cmd.ensure_dirname('option1')
+        cmd.option2 = 'xxx'
+        self.assertRaises(DistutilsOptionError, cmd.ensure_dirname, 'option2')
+
 def test_suite():
     return unittest.makeSuite(CommandTestCase)
 

Modified: python/branches/py3k-short-float-repr/Lib/test/pickletester.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/test/pickletester.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/test/pickletester.py	Thu Apr 16 14:57:18 2009
@@ -1,3 +1,4 @@
+import io
 import unittest
 import pickle
 import pickletools
@@ -842,7 +843,7 @@
         self.assertEqual(x.bar, y.bar)
 
     def test_reduce_overrides_default_reduce_ex(self):
-        for proto in 0, 1, 2:
+        for proto in protocols:
             x = REX_one()
             self.assertEqual(x._reduce_called, 0)
             s = self.dumps(x, proto)
@@ -851,7 +852,7 @@
             self.assertEqual(y._reduce_called, 0)
 
     def test_reduce_ex_called(self):
-        for proto in 0, 1, 2:
+        for proto in protocols:
             x = REX_two()
             self.assertEqual(x._proto, None)
             s = self.dumps(x, proto)
@@ -860,7 +861,7 @@
             self.assertEqual(y._proto, None)
 
     def test_reduce_ex_overrides_reduce(self):
-        for proto in 0, 1, 2:
+        for proto in protocols:
             x = REX_three()
             self.assertEqual(x._proto, None)
             s = self.dumps(x, proto)
@@ -869,7 +870,7 @@
             self.assertEqual(y._proto, None)
 
     def test_reduce_ex_calls_base(self):
-        for proto in 0, 1, 2:
+        for proto in protocols:
             x = REX_four()
             self.assertEqual(x._proto, None)
             s = self.dumps(x, proto)
@@ -878,7 +879,7 @@
             self.assertEqual(y._proto, proto)
 
     def test_reduce_calls_base(self):
-        for proto in 0, 1, 2:
+        for proto in protocols:
             x = REX_five()
             self.assertEqual(x._reduce_called, 0)
             s = self.dumps(x, proto)
@@ -917,6 +918,20 @@
             except (pickle.PickleError):
                 pass
 
+    def test_many_puts_and_gets(self):
+        # Test that internal data structures correctly deal with lots of
+        # puts/gets.
+        keys = ("aaa" + str(i) for i in range(100))
+        large_dict = dict((k, [4, 5, 6]) for k in keys)
+        obj = [dict(large_dict), dict(large_dict), dict(large_dict)]
+
+        for proto in protocols:
+            dumped = self.dumps(obj, proto)
+            loaded = self.loads(dumped)
+            self.assertEqual(loaded, obj,
+                             "Failed protocol %d: %r != %r"
+                             % (proto, obj, loaded))
+
 # Test classes for reduce_ex
 
 class REX_one(object):
@@ -1002,6 +1017,7 @@
     def __getattr__(self, key):
         self.foo
 
+
 class AbstractPickleModuleTests(unittest.TestCase):
 
     def test_dump_closed_file(self):
@@ -1022,13 +1038,20 @@
         finally:
             os.remove(TESTFN)
 
+    def test_load_from_and_dump_to_file(self):
+        stream = io.BytesIO()
+        data = [123, {}, 124]
+        pickle.dump(data, stream)
+        stream.seek(0)
+        unpickled = pickle.load(stream)
+        self.assertEqual(unpickled, data)
+
     def test_highest_protocol(self):
         # Of course this needs to be changed when HIGHEST_PROTOCOL changes.
         self.assertEqual(pickle.HIGHEST_PROTOCOL, 3)
 
     def test_callapi(self):
-        from io import BytesIO
-        f = BytesIO()
+        f = io.BytesIO()
         # With and without keyword arguments
         pickle.dump(123, f, -1)
         pickle.dump(123, file=f, protocol=-1)
@@ -1039,7 +1062,6 @@
 
     def test_bad_init(self):
         # Test issue3664 (pickle can segfault from a badly initialized Pickler).
-        from io import BytesIO
         # Override initialization without calling __init__() of the superclass.
         class BadPickler(pickle.Pickler):
             def __init__(self): pass
@@ -1091,6 +1113,121 @@
         self.assertEqual(self.id_count, 5)
         self.assertEqual(self.load_count, 5)
 
+
+class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
+
+    pickler_class = None
+    unpickler_class = None
+
+    def setUp(self):
+        assert self.pickler_class
+        assert self.unpickler_class
+
+    def test_clear_pickler_memo(self):
+        # To test whether clear_memo() has any effect, we pickle an object,
+        # then pickle it again without clearing the memo; the two serialized
+        # forms should be different. If we clear_memo() and then pickle the
+        # object again, the third serialized form should be identical to the
+        # first one we obtained.
+        data = ["abcdefg", "abcdefg", 44]
+        f = io.BytesIO()
+        pickler = self.pickler_class(f)
+
+        pickler.dump(data)
+        first_pickled = f.getvalue()
+
+        # Reset StringIO object.
+        f.seek(0)
+        f.truncate()
+
+        pickler.dump(data)
+        second_pickled = f.getvalue()
+
+        # Reset the Pickler and StringIO objects.
+        pickler.clear_memo()
+        f.seek(0)
+        f.truncate()
+
+        pickler.dump(data)
+        third_pickled = f.getvalue()
+
+        self.assertNotEqual(first_pickled, second_pickled)
+        self.assertEqual(first_pickled, third_pickled)
+
+    def test_priming_pickler_memo(self):
+        # Verify that we can set the Pickler's memo attribute.
+        data = ["abcdefg", "abcdefg", 44]
+        f = io.BytesIO()
+        pickler = self.pickler_class(f)
+
+        pickler.dump(data)
+        first_pickled = f.getvalue()
+
+        f = io.BytesIO()
+        primed = self.pickler_class(f)
+        primed.memo = pickler.memo
+
+        primed.dump(data)
+        primed_pickled = f.getvalue()
+
+        self.assertNotEqual(first_pickled, primed_pickled)
+
+    def test_priming_unpickler_memo(self):
+        # Verify that we can set the Unpickler's memo attribute.
+        data = ["abcdefg", "abcdefg", 44]
+        f = io.BytesIO()
+        pickler = self.pickler_class(f)
+
+        pickler.dump(data)
+        first_pickled = f.getvalue()
+
+        f = io.BytesIO()
+        primed = self.pickler_class(f)
+        primed.memo = pickler.memo
+
+        primed.dump(data)
+        primed_pickled = f.getvalue()
+
+        unpickler = self.unpickler_class(io.BytesIO(first_pickled))
+        unpickled_data1 = unpickler.load()
+
+        self.assertEqual(unpickled_data1, data)
+
+        primed = self.unpickler_class(io.BytesIO(primed_pickled))
+        primed.memo = unpickler.memo
+        unpickled_data2 = primed.load()
+
+        primed.memo.clear()
+
+        self.assertEqual(unpickled_data2, data)
+        self.assertTrue(unpickled_data2 is unpickled_data1)
+
+    def test_reusing_unpickler_objects(self):
+        data1 = ["abcdefg", "abcdefg", 44]
+        f = io.BytesIO()
+        pickler = self.pickler_class(f)
+        pickler.dump(data1)
+        pickled1 = f.getvalue()
+
+        data2 = ["abcdefg", 44, 44]
+        f = io.BytesIO()
+        pickler = self.pickler_class(f)
+        pickler.dump(data2)
+        pickled2 = f.getvalue()
+
+        f = io.BytesIO()
+        f.write(pickled1)
+        f.seek(0)
+        unpickler = self.unpickler_class(f)
+        self.assertEqual(unpickler.load(), data1)
+
+        f.seek(0)
+        f.truncate()
+        f.write(pickled2)
+        f.seek(0)
+        self.assertEqual(unpickler.load(), data2)
+
+
 if __name__ == "__main__":
     # Print some stuff that can be used to rewrite DATA{0,1,2}
     from pickletools import dis

Modified: python/branches/py3k-short-float-repr/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/test/test_float.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/test/test_float.py	Thu Apr 16 14:57:18 2009
@@ -87,11 +87,18 @@
             def __float__(self):
                 return 42
 
+        # Issue 5759: __float__ not called on str subclasses (though it is on
+        # unicode subclasses).
+        class FooStr(str):
+            def __float__(self):
+                return float(str(self)) + 1
+
         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))
+        self.assertAlmostEqual(float(FooStr('8')), 9.)
 
     def test_floatasratio(self):
         for f, ratio in [

Modified: python/branches/py3k-short-float-repr/Lib/test/test_pickle.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/test/test_pickle.py	(original)
+++ python/branches/py3k-short-float-repr/Lib/test/test_pickle.py	Thu Apr 16 14:57:18 2009
@@ -6,6 +6,7 @@
 from test.pickletester import AbstractPickleTests
 from test.pickletester import AbstractPickleModuleTests
 from test.pickletester import AbstractPersistentPicklerTests
+from test.pickletester import AbstractPicklerUnpicklerObjectTests
 
 try:
     import _pickle
@@ -60,6 +61,12 @@
         return u.load()
 
 
+class PyPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
+
+    pickler_class = pickle._Pickler
+    unpickler_class = pickle._Unpickler
+
+
 if has_c_implementation:
     class CPicklerTests(PyPicklerTests):
         pickler = _pickle.Pickler
@@ -69,11 +76,26 @@
         pickler = _pickle.Pickler
         unpickler = _pickle.Unpickler
 
+    class CDumpPickle_LoadPickle(PyPicklerTests):
+        pickler = _pickle.Pickler
+        unpickler = pickle._Unpickler
+
+    class DumpPickle_CLoadPickle(PyPicklerTests):
+        pickler = pickle._Pickler
+        unpickler = _pickle.Unpickler
+
+    class CPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
+        pickler_class = _pickle.Pickler
+        unpickler_class = _pickle.Unpickler
+
 
 def test_main():
     tests = [PickleTests, PyPicklerTests, PyPersPicklerTests]
     if has_c_implementation:
-        tests.extend([CPicklerTests, CPersPicklerTests])
+        tests.extend([CPicklerTests, CPersPicklerTests,
+                      CDumpPickle_LoadPickle, DumpPickle_CLoadPickle,
+                      PyPicklerUnpicklerObjectTests,
+                      CPicklerUnpicklerObjectTests])
     support.run_unittest(*tests)
     support.run_doctest(pickle)
 

Modified: python/branches/py3k-short-float-repr/Misc/NEWS
==============================================================================
--- python/branches/py3k-short-float-repr/Misc/NEWS	(original)
+++ python/branches/py3k-short-float-repr/Misc/NEWS	Thu Apr 16 14:57:18 2009
@@ -12,6 +12,8 @@
 Core and Builtins
 -----------------
 
+- Issue #5759: float() didn't call __float__ on str subclasses.
+
 - The string.maketrans() function is deprecated; there is a new static method
   maketrans() on the bytes and bytearray classes.  This removes confusion about
   the types string.maketrans() is supposed to work with, and mirrors the
@@ -26,6 +28,12 @@
 Library
 -------
 
+- Issue #1161031: fix readwrite select flag handling: POLLPRI now
+  results in a handle_expt_event call, not handle_read_event, and POLLERR
+  and POLLNVAL now call handle_close, not handle_expt_event.  Also,
+  dispatcher now has an 'ignore_log_types' attribute for suppressing
+  log messages, which is set to 'warning' by default.
+
 - Issue #2703: SimpleXMLRPCDispatcher.__init__: Provide default values for
   new arguments introduced in 2.5.
 

Modified: python/branches/py3k-short-float-repr/Objects/floatobject.c
==============================================================================
--- python/branches/py3k-short-float-repr/Objects/floatobject.c	(original)
+++ python/branches/py3k-short-float-repr/Objects/floatobject.c	Thu Apr 16 14:57:18 2009
@@ -1452,7 +1452,9 @@
 		return float_subtype_new(type, args, kwds); /* Wimp out */
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
 		return NULL;
-	if (PyUnicode_Check(x))
+	/* If it's a string, but not a string subclass, use
+	   PyFloat_FromString. */
+	if (PyUnicode_CheckExact(x))
 		return PyFloat_FromString(x);
 	return PyNumber_Float(x);
 }


More information about the Python-checkins mailing list