summaryrefslogtreecommitdiffstats
path: root/Lib/Cookie.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-20 00:22:32 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-20 00:22:32 (GMT)
commit99603b0c1edb4b8ca2a30fa90470170b959321ee (patch)
treef0fef33a9c03529354c01f5fd374fd36ebc024d7 /Lib/Cookie.py
parentbe6fe5476cc3233ac20e02c0063355a5884663f7 (diff)
downloadcpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.zip
cpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.tar.gz
cpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.tar.bz2
Getting rid of cPickle. Mmm, feels good!
Diffstat (limited to 'Lib/Cookie.py')
-rw-r--r--Lib/Cookie.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
index 52a766d..ca559e8 100644
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -149,11 +149,10 @@ the value to a string, when the values are set dictionary-style.
SerialCookie
The SerialCookie expects that all values should be serialized using
-cPickle (or pickle, if cPickle isn't available). As a result of
-serializing, SerialCookie can save almost any Python object to a
-value, and recover the exact same object when the cookie has been
-returned. (SerialCookie can yield some strange-looking cookie
-values, however.)
+pickle. As a result of serializing, SerialCookie can save almost any
+Python object to a value, and recover the exact same object when the
+cookie has been returned. (SerialCookie can yield some
+strange-looking cookie values, however.)
>>> C = Cookie.SerialCookie()
>>> C["number"] = 7
@@ -162,7 +161,7 @@ values, however.)
7
>>> C["string"].value
'seven'
- >>> C.output().replace('p0', 'p1') # Hack for cPickle/pickle differences
+ >>> C.output().replace('p0', 'p1') # Hack for pickling differences
'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="Vseven\\012p1\\012."'
Be warned, however, if SerialCookie cannot de-serialize a value (because
@@ -173,7 +172,7 @@ SmartCookie
The SmartCookie combines aspects of each of the other two flavors.
When setting a value in a dictionary-fashion, the SmartCookie will
-serialize (ala cPickle) the value *if and only if* it isn't a
+serialize (ala pickle) the value *if and only if* it isn't a
Python string. String objects are *not* serialized. Similarly,
when the load() method parses out values, it attempts to de-serialize
the value. If it fails, then it fallsback to treating the value
@@ -212,10 +211,7 @@ Finis.
#
import string
-try:
- from cPickle import dumps, loads
-except ImportError:
- from pickle import dumps, loads
+from pickle import dumps, loads
import re, warnings
@@ -660,7 +656,7 @@ class SimpleCookie(BaseCookie):
class SerialCookie(BaseCookie):
"""SerialCookie
SerialCookie supports arbitrary objects as cookie values. All
- values are serialized (using cPickle) before being sent to the
+ values are serialized (using pickle) before being sent to the
client. All incoming values are assumed to be valid Pickle
representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE
FORMAT, THEN AN EXCEPTION WILL BE RAISED.
@@ -687,7 +683,7 @@ class SmartCookie(BaseCookie):
"""SmartCookie
SmartCookie supports arbitrary objects as cookie values. If the
object is a string, then it is quoted. If the object is not a
- string, however, then SmartCookie will use cPickle to serialize
+ string, however, then SmartCookie will use pickle to serialize
the object into a string representation.
Note: Large cookie values add overhead because they must be