[Python-3000-checkins] r55987 - in python/branches/py3k-struni: Lib/pickle.py Lib/test/test_popen.py Modules/cPickle.c

guido.van.rossum python-3000-checkins at python.org
Fri Jun 15 05:35:50 CEST 2007


Author: guido.van.rossum
Date: Fri Jun 15 05:35:38 2007
New Revision: 55987

Modified:
   python/branches/py3k-struni/Lib/pickle.py
   python/branches/py3k-struni/Lib/test/test_popen.py
   python/branches/py3k-struni/Modules/cPickle.c
Log:
Fix some problems introduced by the str8 repr change.


Modified: python/branches/py3k-struni/Lib/pickle.py
==============================================================================
--- python/branches/py3k-struni/Lib/pickle.py	(original)
+++ python/branches/py3k-struni/Lib/pickle.py	Fri Jun 15 05:35:38 2007
@@ -501,7 +501,8 @@
             else:
                 self.write(BINSTRING + pack("<i", n) + bytes(obj))
         else:
-            self.write(STRING + bytes(repr(obj)) + b'\n')
+            # Strip leading 's' due to repr() of str8() returning s'...'
+            self.write(STRING + bytes(repr(obj).lstrip("s")) + b'\n')
         self.memoize(obj)
     dispatch[str8] = save_string
 

Modified: python/branches/py3k-struni/Lib/test/test_popen.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_popen.py	(original)
+++ python/branches/py3k-struni/Lib/test/test_popen.py	Fri Jun 15 05:35:38 2007
@@ -18,8 +18,10 @@
     python = '"' + python + '"'     # quote embedded space for cmdline
 
 class PopenTest(unittest.TestCase):
+
     def _do_test_commandline(self, cmdline, expected):
-        cmd = '%s -c "import sys; print(sys.argv)" %s' % (python, cmdline)
+        cmd = '%s -c "import sys; print(list(map(str, sys.argv)))" %s'
+        cmd = cmd % (python, cmdline)
         data = os.popen(cmd).read()
         got = eval(data)[1:] # strip off argv[0]
         self.assertEqual(got, expected)

Modified: python/branches/py3k-struni/Modules/cPickle.c
==============================================================================
--- python/branches/py3k-struni/Modules/cPickle.c	(original)
+++ python/branches/py3k-struni/Modules/cPickle.c	Fri Jun 15 05:35:38 2007
@@ -1085,6 +1085,10 @@
 			goto err;
 		repr_str = PyString_AS_STRING((PyStringObject *)repr);
 
+                /* Strip leading 's' due to repr() of str8() returning s'...' */
+                if (repr_str[0] == 's')
+			repr_str++;
+
 		if (self->write_func(self, &string, 1) < 0)
 			goto err;
 


More information about the Python-3000-checkins mailing list