diff -r b7c0137cccbe Lib/test/test_xdrlib.py --- a/Lib/test/test_xdrlib.py Thu Mar 26 23:50:57 2015 +0100 +++ b/Lib/test/test_xdrlib.py Fri Mar 27 13:59:03 2015 +0100 @@ -51,6 +51,13 @@ up.done() self.assertRaises(EOFError, up.unpack_uint) + def test_pack_string(self): + p = xdrlib.Packer() + + with self.assertRaises(TypeError): + p.pack_string('hello world') + self.assertFalse(p.get_buffer()) + class ConversionErrorTest(unittest.TestCase): def setUp(self): diff -r b7c0137cccbe Lib/xdrlib.py --- a/Lib/xdrlib.py Thu Mar 26 23:50:57 2015 +0100 +++ b/Lib/xdrlib.py Fri Mar 27 13:59:03 2015 +0100 @@ -103,6 +103,7 @@ pack_fopaque = pack_fstring def pack_string(self, s): + s + b'\0' # Test that s can be combined with bytes n = len(s) self.pack_uint(n) self.pack_fstring(n, s)