diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-07-26 03:19:46 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-07-26 03:19:46 (GMT) |
commit | 1eb79cfd6dfc5bb96a180fefc871fa1dc600a510 (patch) | |
tree | 0dd003abfbdf3a9bd305f53d924ded366ec7a3a9 | |
parent | d24fffe7c67c2097aa33e04498dc6b3ae0cc17ab (diff) | |
download | cpython-1eb79cfd6dfc5bb96a180fefc871fa1dc600a510.zip cpython-1eb79cfd6dfc5bb96a180fefc871fa1dc600a510.tar.gz cpython-1eb79cfd6dfc5bb96a180fefc871fa1dc600a510.tar.bz2 |
Move xdrlib over to the bytes type.
-rw-r--r-- | Lib/test/test_xdrlib.py | 4 | ||||
-rw-r--r-- | Lib/xdrlib.py | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py index d0fb1e5..44d5a82 100644 --- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -8,8 +8,8 @@ class XDRTest(unittest.TestCase): def test_xdr(self): p = xdrlib.Packer() - s = 'hello world' - a = ['what', 'is', 'hapnin', 'doctor'] + s = b'hello world' + a = [b'what', b'is', b'hapnin', b'doctor'] p.pack_int(42) p.pack_uint(9) diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py index 055ee82..98bdedb 100644 --- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -5,7 +5,7 @@ See: RFC 1014 """ import struct -from io import StringIO as _StringIO +from io import BytesIO __all__ = ["Error", "Packer", "Unpacker", "ConversionError"] @@ -40,7 +40,7 @@ class Packer: self.reset() def reset(self): - self.__buf = _StringIO() + self.__buf = BytesIO() def get_buffer(self): return self.__buf.getvalue() @@ -54,8 +54,8 @@ class Packer: pack_enum = pack_int def pack_bool(self, x): - if x: self.__buf.write('\0\0\0\1') - else: self.__buf.write('\0\0\0\0') + if x: self.__buf.write(b'\0\0\0\1') + else: self.__buf.write(b'\0\0\0\0') def pack_uhyper(self, x): self.pack_uint(x>>32 & 0xffffffff) @@ -78,7 +78,7 @@ class Packer: raise ValueError, 'fstring size must be nonnegative' data = s[:n] n = ((n+3)//4)*4 - data = data + (n - len(data)) * '\0' + data = data + (n - len(data)) * b'\0' self.__buf.write(data) pack_fopaque = pack_fstring |