diff --git a/Doc/library/xdrlib.rst b/Doc/library/xdrlib.rst index 42a03a4..0d86e9f 100644 --- a/Doc/library/xdrlib.rst +++ b/Doc/library/xdrlib.rst @@ -30,7 +30,7 @@ also two exception classes. .. class:: Unpacker(data) ``Unpacker`` is the complementary class which unpacks XDR data values from a - string buffer. The input buffer is given as *data*. + bytestring buffer. The input buffer is given as *data*. .. seealso:: @@ -53,12 +53,12 @@ Packer Objects .. method:: Packer.get_buffer() - Returns the current pack buffer as a string. + Returns the current pack buffer as a bytestring. .. method:: Packer.reset() - Resets the pack buffer to the empty string. + Resets the pack buffer to the empty bytestring. In general, you can pack any of the most common XDR data types by calling the appropriate ``pack_type()`` method. Each method takes a single argument, the @@ -76,36 +76,26 @@ value to pack. The following simple data type packing methods are supported: Packs the double-precision floating point number *value*. -The following methods support packing strings, bytes, and opaque data: +An XDR ``string`` is defined as a sequence of ASCII bytes. In Python 3 it is +represented as a bytestring. The following methods support packing bytestrings. .. method:: Packer.pack_fstring(n, s) + Packer.pack_fopaque(n, s) - Packs a fixed length string, *s*. *n* is the length of the string but it is - *not* packed into the data buffer. The string is padded with null bytes if - necessary to guaranteed 4 byte alignment. - - -.. method:: Packer.pack_fopaque(n, data) - - Packs a fixed length opaque data stream, similarly to :meth:`pack_fstring`. + Packs a fixed length bytestring, *s*. *n* is the length of the + bytestring but it is *not* packed into the data buffer. The data is + padded with null bytes if necessary to guaranteed 4 byte alignment. .. method:: Packer.pack_string(s) + Packer.pack_opaque(s) + Packer.pack_bytes(s) - Packs a variable length string, *s*. The length of the string is first packed - as an unsigned integer, then the string data is packed with - :meth:`pack_fstring`. - - -.. method:: Packer.pack_opaque(data) + Packs a variable length bytestring, *s*. The length of the + bytestring is first packed as an unsigned integer, then the data is + packed with :meth:`pack_fstring`. - Packs a variable length opaque data string, similarly to :meth:`pack_string`. - - -.. method:: Packer.pack_bytes(bytes) - - Packs a variable length byte stream, similarly to :meth:`pack_string`. The following methods support packing arrays and lists: @@ -151,7 +141,7 @@ The :class:`Unpacker` class offers the following methods: .. method:: Unpacker.reset(data) - Resets the string buffer with the given *data*. + Resets the bytestring buffer with the given *data*. .. method:: Unpacker.get_position() @@ -167,7 +157,7 @@ The :class:`Unpacker` class offers the following methods: .. method:: Unpacker.get_buffer() - Returns the current unpack data buffer as a string. + Returns the current unpack data buffer as a bytestring. .. method:: Unpacker.done() @@ -190,38 +180,23 @@ unpacked with an :class:`Unpacker`. Unpacking methods are of the form Unpacks a double-precision floating point number, similarly to :meth:`unpack_float`. -In addition, the following methods unpack strings, bytes, and opaque data: +In addition, the following methods unpack bytesstrings: .. method:: Unpacker.unpack_fstring(n) + Unpacker.unpack_fopaque(n) - Unpacks and returns a fixed length string. *n* is the number of characters + Unpacks and returns a fixed length bytestring. *n* is the number of characters expected. Padding with null bytes to guaranteed 4 byte alignment is assumed. -.. method:: Unpacker.unpack_fopaque(n) - - Unpacks and returns a fixed length opaque data stream, similarly to - :meth:`unpack_fstring`. - - .. method:: Unpacker.unpack_string() + Unpacker.unpack_opaque() + Unpacker.unpack_bytes() - Unpacks and returns a variable length string. The length of the string is first - unpacked as an unsigned integer, then the string data is unpacked with - :meth:`unpack_fstring`. - - -.. method:: Unpacker.unpack_opaque() - - Unpacks and returns a variable length opaque data string, similarly to - :meth:`unpack_string`. - - -.. method:: Unpacker.unpack_bytes() - - Unpacks and returns a variable length byte stream, similarly to - :meth:`unpack_string`. + Unpacks and returns a variable length bytestring. The length of the + bytesstring is first unpacked as an unsigned integer, then the bytestring + data is unpacked with :meth:`unpack_fstring`. The following methods support unpacking arrays and lists: