summaryrefslogtreecommitdiffstats
path: root/Lib/struct.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-04 19:56:22 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-04 19:56:22 (GMT)
commit2e6a4b37baf560adeee13e9a5702b23f275cc7bd (patch)
tree7d42319c83cc31c016df389a7bb41ef02afd3858 /Lib/struct.py
parent612344f12774cbbefd735d9fcbfb2001fe187362 (diff)
downloadcpython-2e6a4b37baf560adeee13e9a5702b23f275cc7bd.zip
cpython-2e6a4b37baf560adeee13e9a5702b23f275cc7bd.tar.gz
cpython-2e6a4b37baf560adeee13e9a5702b23f275cc7bd.tar.bz2
Checkpoint. Make pickle.py read/write bytes.
Fix strict.py so it reads/writes bytes and accepts both string types as format.
Diffstat (limited to 'Lib/struct.py')
-rw-r--r--Lib/struct.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/struct.py b/Lib/struct.py
index 07c21bf..1077437 100644
--- a/Lib/struct.py
+++ b/Lib/struct.py
@@ -25,7 +25,11 @@ Whitespace between formats is ignored.
The variable struct.error is an exception raised on errors.
"""
-__version__ = '0.1'
+
+# XXX Move the bytes and str8 casts into the _struct module
+
+__version__ = '3.0'
+
from _struct import Struct, error
@@ -36,7 +40,7 @@ def _compile(fmt):
# Internal: compile struct pattern
if len(_cache) >= _MAXCACHE:
_cache.clear()
- s = Struct(fmt)
+ s = Struct(str8(fmt))
_cache[fmt] = s
return s
@@ -60,7 +64,7 @@ def pack(fmt, *args):
o = _cache[fmt]
except KeyError:
o = _compile(fmt)
- return o.pack(*args)
+ return bytes(o.pack(*args))
def pack_into(fmt, buf, offset, *args):
"""
@@ -72,7 +76,7 @@ def pack_into(fmt, buf, offset, *args):
o = _cache[fmt]
except KeyError:
o = _compile(fmt)
- return o.pack_into(buf, offset, *args)
+ return bytes(o.pack_into(buf, offset, *args))
def unpack(fmt, s):
"""