Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1f5d8a

Browse files
committed
Merge
2 parents 5f99ced + 17591c1 commit c1f5d8a

5 files changed

Lines changed: 43 additions & 1 deletion

File tree

Lib/pickle.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,14 @@ def save_none(self, obj):
438438
self.write(NONE)
439439
dispatch[type(None)] = save_none
440440

441+
def save_ellipsis(self, obj):
442+
self.save_global(Ellipsis, 'Ellipsis')
443+
dispatch[type(Ellipsis)] = save_ellipsis
444+
445+
def save_notimplemented(self, obj):
446+
self.save_global(NotImplemented, 'NotImplemented')
447+
dispatch[type(NotImplemented)] = save_notimplemented
448+
441449
def save_bool(self, obj):
442450
if self.proto >= 2:
443451
self.write(obj and NEWTRUE or NEWFALSE)

Lib/test/pickletester.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,18 @@ def test_structseq(self):
743743
u = self.loads(s)
744744
self.assertEqual(t, u)
745745

746+
def test_ellipsis(self):
747+
for proto in protocols:
748+
s = self.dumps(..., proto)
749+
u = self.loads(s)
750+
self.assertEqual(..., u)
751+
752+
def test_notimplemented(self):
753+
for proto in protocols:
754+
s = self.dumps(NotImplemented, proto)
755+
u = self.loads(s)
756+
self.assertEqual(NotImplemented, u)
757+
746758
# Tests for protocol 2
747759

748760
def test_proto(self):

Lib/test/test_sys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ def test_pythontypes(self):
882882
check = self.check_sizeof
883883
# _ast.AST
884884
import _ast
885-
check(_ast.AST(), size(h + ''))
885+
check(_ast.AST(), size(h + 'P'))
886886
# imp.NullImporter
887887
import imp
888888
check(imp.NullImporter(self.file.name), size(h + ''))

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ George Sakkis
883883
Rich Salz
884884
Kevin Samborn
885885
Adrian Sampson
886+
James Sanders
886887
Ilya Sandler
887888
Mark Sapiro
888889
Ty Sarna

Modules/_pickle.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,19 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
28112811
return status;
28122812
}
28132813

2814+
static int
2815+
save_ellipsis(PicklerObject *self, PyObject *obj)
2816+
{
2817+
return save_global(self, Py_Ellipsis, PyUnicode_FromString("Ellipsis"));
2818+
}
2819+
2820+
static int
2821+
save_notimplemented(PicklerObject *self, PyObject *obj)
2822+
{
2823+
return save_global(self, Py_NotImplemented,
2824+
PyUnicode_FromString("NotImplemented"));
2825+
}
2826+
28142827
static int
28152828
save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
28162829
{
@@ -3114,6 +3127,14 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
31143127
status = save_none(self, obj);
31153128
goto done;
31163129
}
3130+
else if (obj == Py_Ellipsis) {
3131+
status = save_ellipsis(self, obj);
3132+
goto done;
3133+
}
3134+
else if (obj == Py_NotImplemented) {
3135+
status = save_notimplemented(self, obj);
3136+
goto done;
3137+
}
31173138
else if (obj == Py_False || obj == Py_True) {
31183139
status = save_bool(self, obj);
31193140
goto done;

0 commit comments

Comments
 (0)