[Python-checkins] cpython (merge default -> default): Merge
michael.foord
python-checkins at python.org
Mon Mar 12 21:54:53 CET 2012
http://hg.python.org/cpython/rev/b154ab2cdb1e
changeset: 75551:b154ab2cdb1e
parent: 75550:06628ec43732
parent: 75549:8538eeb71698
user: Michael Foord <michael at voidspace.org.uk>
date: Mon Mar 12 13:54:03 2012 -0700
summary:
Merge
files:
Lib/pickle.py | 8 ++++++++
Lib/test/pickletester.py | 12 ++++++++++++
Lib/test/test_sys.py | 2 +-
Misc/ACKS | 1 +
Modules/_pickle.c | 21 +++++++++++++++++++++
5 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/Lib/pickle.py b/Lib/pickle.py
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -438,6 +438,14 @@
self.write(NONE)
dispatch[type(None)] = save_none
+ def save_ellipsis(self, obj):
+ self.save_global(Ellipsis, 'Ellipsis')
+ dispatch[type(Ellipsis)] = save_ellipsis
+
+ def save_notimplemented(self, obj):
+ self.save_global(NotImplemented, 'NotImplemented')
+ dispatch[type(NotImplemented)] = save_notimplemented
+
def save_bool(self, obj):
if self.proto >= 2:
self.write(obj and NEWTRUE or NEWFALSE)
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -743,6 +743,18 @@
u = self.loads(s)
self.assertEqual(t, u)
+ def test_ellipsis(self):
+ for proto in protocols:
+ s = self.dumps(..., proto)
+ u = self.loads(s)
+ self.assertEqual(..., u)
+
+ def test_notimplemented(self):
+ for proto in protocols:
+ s = self.dumps(NotImplemented, proto)
+ u = self.loads(s)
+ self.assertEqual(NotImplemented, u)
+
# Tests for protocol 2
def test_proto(self):
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -882,7 +882,7 @@
check = self.check_sizeof
# _ast.AST
import _ast
- check(_ast.AST(), size(h + ''))
+ check(_ast.AST(), size(h + 'P'))
# imp.NullImporter
import imp
check(imp.NullImporter(self.file.name), size(h + ''))
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -883,6 +883,7 @@
Rich Salz
Kevin Samborn
Adrian Sampson
+James Sanders
Ilya Sandler
Mark Sapiro
Ty Sarna
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2812,6 +2812,19 @@
}
static int
+save_ellipsis(PicklerObject *self, PyObject *obj)
+{
+ return save_global(self, Py_Ellipsis, PyUnicode_FromString("Ellipsis"));
+}
+
+static int
+save_notimplemented(PicklerObject *self, PyObject *obj)
+{
+ return save_global(self, Py_NotImplemented,
+ PyUnicode_FromString("NotImplemented"));
+}
+
+static int
save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
{
PyObject *pid = NULL;
@@ -3114,6 +3127,14 @@
status = save_none(self, obj);
goto done;
}
+ else if (obj == Py_Ellipsis) {
+ status = save_ellipsis(self, obj);
+ goto done;
+ }
+ else if (obj == Py_NotImplemented) {
+ status = save_notimplemented(self, obj);
+ goto done;
+ }
else if (obj == Py_False || obj == Py_True) {
status = save_bool(self, obj);
goto done;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list