Merge
This commit is contained in:
commit
c1f5d8af57
|
@ -438,6 +438,14 @@ class _Pickler:
|
|||
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)
|
||||
|
|
|
@ -743,6 +743,18 @@ class AbstractPickleTests(unittest.TestCase):
|
|||
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):
|
||||
|
|
|
@ -882,7 +882,7 @@ class SizeofTest(unittest.TestCase):
|
|||
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 + ''))
|
||||
|
|
|
@ -883,6 +883,7 @@ George Sakkis
|
|||
Rich Salz
|
||||
Kevin Samborn
|
||||
Adrian Sampson
|
||||
James Sanders
|
||||
Ilya Sandler
|
||||
Mark Sapiro
|
||||
Ty Sarna
|
||||
|
|
|
@ -2811,6 +2811,19 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
|
|||
return status;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -3114,6 +3127,14 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue