[Python-checkins] cpython (merge default -> default): Merge heads
serhiy.storchaka
python-checkins at python.org
Sat Nov 23 21:13:15 CET 2013
http://hg.python.org/cpython/rev/d469b3e557d2
changeset: 87449:d469b3e557d2
parent: 87448:70bd6f7e013b
parent: 87447:3c222d1f81e9
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Nov 23 22:12:36 2013 +0200
summary:
Merge heads
files:
Lib/test/test_range.py | 7 +++--
Modules/_pickle.c | 35 ++++++++++++++++++++---------
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -353,9 +353,10 @@
(13, 21, 3), (-2, 2, 2), (2**65, 2**65+2)]
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
for t in testcases:
- r = range(*t)
- self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))),
- list(r))
+ with self.subTest(proto=proto, test=t):
+ r = range(*t)
+ self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))),
+ list(r))
def test_iterator_pickling(self):
testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -700,17 +700,27 @@
}
static void
+_write_size64(char *out, size_t value)
+{
+ out[0] = (unsigned char)(value & 0xff);
+ out[1] = (unsigned char)((value >> 8) & 0xff);
+ out[2] = (unsigned char)((value >> 16) & 0xff);
+ out[3] = (unsigned char)((value >> 24) & 0xff);
+#if SIZEOF_SIZE_T >= 8
+ out[4] = (unsigned char)((value >> 32) & 0xff);
+ out[5] = (unsigned char)((value >> 40) & 0xff);
+ out[6] = (unsigned char)((value >> 48) & 0xff);
+ out[7] = (unsigned char)((value >> 56) & 0xff);
+#else
+ out[4] = out[5] = out[6] = out[7] = 0;
+#endif
+}
+
+static void
_Pickler_WriteFrameHeader(PicklerObject *self, char *qdata, size_t frame_len)
{
- qdata[0] = (unsigned char)FRAME;
- qdata[1] = (unsigned char)(frame_len & 0xff);
- qdata[2] = (unsigned char)((frame_len >> 8) & 0xff);
- qdata[3] = (unsigned char)((frame_len >> 16) & 0xff);
- qdata[4] = (unsigned char)((frame_len >> 24) & 0xff);
- qdata[5] = (unsigned char)((frame_len >> 32) & 0xff);
- qdata[6] = (unsigned char)((frame_len >> 40) & 0xff);
- qdata[7] = (unsigned char)((frame_len >> 48) & 0xff);
- qdata[8] = (unsigned char)((frame_len >> 56) & 0xff);
+ qdata[0] = FRAME;
+ _write_size64(qdata + 1, frame_len);
}
static int
@@ -2017,7 +2027,7 @@
int i;
header[0] = BINBYTES8;
for (i = 0; i < 8; i++) {
- header[i+1] = (unsigned char)((size >> (8 * i)) & 0xff);
+ _write_size64(header + 1, size);
}
len = 8;
}
@@ -2131,7 +2141,7 @@
header[0] = BINUNICODE8;
for (i = 0; i < 8; i++) {
- header[i+1] = (unsigned char)((size >> (8 * i)) & 0xff);
+ _write_size64(header + 1, size);
}
len = 9;
}
@@ -2940,6 +2950,9 @@
return -1;
iter = PyObject_GetIter(obj);
+ if (iter == NULL) {
+ return -1;
+ }
for (;;) {
PyObject *item;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list