summaryrefslogtreecommitdiff
path: root/Lib/pickle.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 21ea21536f..96ee5c17e2 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -101,6 +101,9 @@ TUPLE = 't'
EMPTY_TUPLE = ')'
SETITEMS = 'u'
BINFLOAT = 'G'
+TRUE = 'Z'
+FALSE = 'z'
+
__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)])
del x
@@ -256,6 +259,13 @@ class Pickler:
self.write(NONE)
dispatch[NoneType] = save_none
+ def save_bool(self, object):
+ if object:
+ self.write(TRUE)
+ else:
+ self.write(FALSE)
+ dispatch[bool] = save_bool
+
def save_int(self, object):
if self.bin:
# If the int is small enough to fit in a signed 4-byte 2's-comp
@@ -629,6 +639,14 @@ class Unpickler:
self.append(None)
dispatch[NONE] = load_none
+ def load_false(self):
+ self.append(False)
+ dispatch[FALSE] = load_false
+
+ def load_true(self):
+ self.append(True)
+ dispatch[TRUE] = load_true
+
def load_int(self):
data = self.readline()
try: