2008-07-31 12:03:40 -03:00
|
|
|
:mod:`struct` --- Interpret bytes as packed binary data
|
Merged revisions 74821,74828-74831,74833,74835 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r74821 | georg.brandl | 2009-09-16 11:42:19 +0200 (Mi, 16 Sep 2009) | 1 line
#6885: run python 3 as python3.
................
r74828 | georg.brandl | 2009-09-16 16:23:20 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74829 | georg.brandl | 2009-09-16 16:24:29 +0200 (Mi, 16 Sep 2009) | 1 line
Small PEP8 correction.
................
r74830 | georg.brandl | 2009-09-16 16:36:22 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74831 | georg.brandl | 2009-09-16 17:54:04 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans and PEP8 for argdefaults.
................
r74833 | georg.brandl | 2009-09-16 17:58:14 +0200 (Mi, 16 Sep 2009) | 1 line
Last round of adapting style of documenting argument default values.
................
r74835 | georg.brandl | 2009-09-16 18:00:31 +0200 (Mi, 16 Sep 2009) | 33 lines
Merged revisions 74817-74820,74822-74824 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line
Make deprecation notices as visible as warnings are right now.
........
r74818 | georg.brandl | 2009-09-16 11:23:04 +0200 (Mi, 16 Sep 2009) | 1 line
#6880: add reference to classes section in exceptions section, which comes earlier.
........
r74819 | georg.brandl | 2009-09-16 11:24:57 +0200 (Mi, 16 Sep 2009) | 1 line
#6876: fix base class constructor invocation in example.
........
r74820 | georg.brandl | 2009-09-16 11:30:48 +0200 (Mi, 16 Sep 2009) | 1 line
#6891: comment out dead link to Unicode article.
........
r74822 | georg.brandl | 2009-09-16 12:12:06 +0200 (Mi, 16 Sep 2009) | 1 line
#5621: refactor description of how class/instance attributes interact on a.x=a.x+1 or augassign.
........
r74823 | georg.brandl | 2009-09-16 15:06:22 +0200 (Mi, 16 Sep 2009) | 1 line
Remove strange trailing commas.
........
r74824 | georg.brandl | 2009-09-16 15:11:06 +0200 (Mi, 16 Sep 2009) | 1 line
#6892: fix optparse example involving help option.
........
................
2009-09-16 13:05:59 -03:00
|
|
|
=======================================================
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
.. module:: struct
|
2008-07-31 12:03:40 -03:00
|
|
|
:synopsis: Interpret bytes as packed binary data.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
.. index::
|
|
|
|
pair: C; structures
|
|
|
|
triple: packing; binary; data
|
|
|
|
|
|
|
|
This module performs conversions between Python values and C structs represented
|
2010-05-22 15:58:39 -03:00
|
|
|
as Python :class:`bytes` objects. This can be used in handling binary data
|
|
|
|
stored in files or from network connections, among other sources. It uses
|
|
|
|
:ref:`struct-format-strings` as compact descriptions of the layout of the C
|
|
|
|
structs and the intended conversion to/from Python values.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
By default, the result of packing a given C struct includes pad bytes in
|
|
|
|
order to maintain proper alignment for the C types involved; similarly,
|
|
|
|
alignment is taken into account when unpacking. This behavior is chosen so
|
|
|
|
that the bytes of a packed struct correspond exactly to the layout in memory
|
2010-06-15 05:45:06 -03:00
|
|
|
of the corresponding C struct. To handle platform-independent data formats
|
|
|
|
or omit implicit pad bytes, use `standard` size and alignment instead of
|
|
|
|
`native` size and alignment: see :ref:`struct-alignment` for details.
|
2010-05-22 15:58:39 -03:00
|
|
|
|
|
|
|
Functions and Exceptions
|
|
|
|
------------------------
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
The module defines the following exception and functions:
|
|
|
|
|
|
|
|
|
|
|
|
.. exception:: error
|
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
Exception raised on various occasions; argument is a string describing what
|
|
|
|
is wrong.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. function:: pack(fmt, v1, v2, ...)
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Return a bytes object containing the values *v1*, *v2*, ... packed according
|
|
|
|
to the format string *fmt*. The arguments must match the values required by
|
|
|
|
the format exactly.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. function:: pack_into(fmt, buffer, offset, v1, v2, ...)
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Pack the values *v1*, *v2*, ... according to the format string *fmt* and
|
|
|
|
write the packed bytes into the writable buffer *buffer* starting at
|
|
|
|
position *offset*. Note that *offset* is a required argument.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
.. function:: unpack(fmt, buffer)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Unpack from the buffer *buffer* (presumably packed by ``pack(fmt, ...)``)
|
|
|
|
according to the format string *fmt*. The result is a tuple even if it
|
|
|
|
contains exactly one item. The buffer must contain exactly the amount of
|
|
|
|
data required by the format (``len(bytes)`` must equal ``calcsize(fmt)``).
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
Merged revisions 74821,74828-74831,74833,74835 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r74821 | georg.brandl | 2009-09-16 11:42:19 +0200 (Mi, 16 Sep 2009) | 1 line
#6885: run python 3 as python3.
................
r74828 | georg.brandl | 2009-09-16 16:23:20 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74829 | georg.brandl | 2009-09-16 16:24:29 +0200 (Mi, 16 Sep 2009) | 1 line
Small PEP8 correction.
................
r74830 | georg.brandl | 2009-09-16 16:36:22 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74831 | georg.brandl | 2009-09-16 17:54:04 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans and PEP8 for argdefaults.
................
r74833 | georg.brandl | 2009-09-16 17:58:14 +0200 (Mi, 16 Sep 2009) | 1 line
Last round of adapting style of documenting argument default values.
................
r74835 | georg.brandl | 2009-09-16 18:00:31 +0200 (Mi, 16 Sep 2009) | 33 lines
Merged revisions 74817-74820,74822-74824 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line
Make deprecation notices as visible as warnings are right now.
........
r74818 | georg.brandl | 2009-09-16 11:23:04 +0200 (Mi, 16 Sep 2009) | 1 line
#6880: add reference to classes section in exceptions section, which comes earlier.
........
r74819 | georg.brandl | 2009-09-16 11:24:57 +0200 (Mi, 16 Sep 2009) | 1 line
#6876: fix base class constructor invocation in example.
........
r74820 | georg.brandl | 2009-09-16 11:30:48 +0200 (Mi, 16 Sep 2009) | 1 line
#6891: comment out dead link to Unicode article.
........
r74822 | georg.brandl | 2009-09-16 12:12:06 +0200 (Mi, 16 Sep 2009) | 1 line
#5621: refactor description of how class/instance attributes interact on a.x=a.x+1 or augassign.
........
r74823 | georg.brandl | 2009-09-16 15:06:22 +0200 (Mi, 16 Sep 2009) | 1 line
Remove strange trailing commas.
........
r74824 | georg.brandl | 2009-09-16 15:11:06 +0200 (Mi, 16 Sep 2009) | 1 line
#6892: fix optparse example involving help option.
........
................
2009-09-16 13:05:59 -03:00
|
|
|
.. function:: unpack_from(fmt, buffer, offset=0)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Unpack from *buffer* starting at position *offset*, according to the format
|
|
|
|
string *fmt*. The result is a tuple even if it contains exactly one
|
|
|
|
item. *buffer* must contain at least the amount of data required by the
|
|
|
|
format (``len(buffer[offset:])`` must be at least ``calcsize(fmt)``).
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. function:: calcsize(fmt)
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Return the size of the struct (and hence of the bytes object produced by
|
|
|
|
``pack(fmt, ...)``) corresponding to the format string *fmt*.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
.. _struct-format-strings:
|
|
|
|
|
|
|
|
Format Strings
|
|
|
|
--------------
|
|
|
|
|
|
|
|
Format strings are the mechanism used to specify the expected layout when
|
2010-06-12 16:18:51 -03:00
|
|
|
packing and unpacking data. They are built up from :ref:`format-characters`,
|
|
|
|
which specify the type of data being packed/unpacked. In addition, there are
|
|
|
|
special characters for controlling the :ref:`struct-alignment`.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
|
|
|
|
.. _struct-alignment:
|
|
|
|
|
|
|
|
Byte Order, Size, and Alignment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
By default, C types are represented in the machine's native format and byte
|
2007-08-15 11:28:22 -03:00
|
|
|
order, and properly aligned by skipping pad bytes if necessary (according to the
|
|
|
|
rules used by the C compiler).
|
|
|
|
|
|
|
|
Alternatively, the first character of the format string can be used to indicate
|
|
|
|
the byte order, size and alignment of the packed data, according to the
|
|
|
|
following table:
|
|
|
|
|
2010-06-15 05:45:06 -03:00
|
|
|
+-----------+------------------------+----------+-----------+
|
|
|
|
| Character | Byte order | Size | Alignment |
|
|
|
|
+===========+========================+==========+===========+
|
|
|
|
| ``@`` | native | native | native |
|
|
|
|
+-----------+------------------------+----------+-----------+
|
|
|
|
| ``=`` | native | standard | none |
|
|
|
|
+-----------+------------------------+----------+-----------+
|
|
|
|
| ``<`` | little-endian | standard | none |
|
|
|
|
+-----------+------------------------+----------+-----------+
|
|
|
|
| ``>`` | big-endian | standard | none |
|
|
|
|
+-----------+------------------------+----------+-----------+
|
|
|
|
| ``!`` | network (= big-endian) | standard | none |
|
|
|
|
+-----------+------------------------+----------+-----------+
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
If the first character is not one of these, ``'@'`` is assumed.
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Native byte order is big-endian or little-endian, depending on the host
|
|
|
|
system. For example, Intel x86 and AMD64 (x86-64) are little-endian;
|
|
|
|
Motorola 68000 and PowerPC G5 are big-endian; ARM and Intel Itanium feature
|
|
|
|
switchable endianness (bi-endian). Use ``sys.byteorder`` to check the
|
|
|
|
endianness of your system.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
Native size and alignment are determined using the C compiler's
|
Merged revisions 59605-59624 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59606 | georg.brandl | 2007-12-29 11:57:00 +0100 (Sat, 29 Dec 2007) | 2 lines
Some cleanup in the docs.
........
r59611 | martin.v.loewis | 2007-12-29 19:49:21 +0100 (Sat, 29 Dec 2007) | 2 lines
Bug #1699: Define _BSD_SOURCE only on OpenBSD.
........
r59612 | raymond.hettinger | 2007-12-29 23:09:34 +0100 (Sat, 29 Dec 2007) | 1 line
Simpler documentation for itertools.tee(). Should be backported.
........
r59613 | raymond.hettinger | 2007-12-29 23:16:24 +0100 (Sat, 29 Dec 2007) | 1 line
Improve docs for itertools.groupby(). The use of xrange(0) to create a unique object is less obvious than object().
........
r59620 | christian.heimes | 2007-12-31 15:47:07 +0100 (Mon, 31 Dec 2007) | 3 lines
Added wininst-9.0.exe executable for VS 2008
Integrated bdist_wininst into PCBuild9 directory
........
r59621 | christian.heimes | 2007-12-31 15:51:18 +0100 (Mon, 31 Dec 2007) | 1 line
Moved PCbuild directory to PC/VS7.1
........
r59622 | christian.heimes | 2007-12-31 15:59:26 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot
........
r59623 | christian.heimes | 2007-12-31 16:02:41 +0100 (Mon, 31 Dec 2007) | 1 line
Fix paths for build bot, part 2
........
r59624 | christian.heimes | 2007-12-31 16:18:55 +0100 (Mon, 31 Dec 2007) | 1 line
Renamed PCBuild9 directory to PCBuild
........
2007-12-31 12:14:33 -04:00
|
|
|
``sizeof`` expression. This is always combined with native byte order.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-06-15 05:45:06 -03:00
|
|
|
Standard size depends only on the format character; see the table in
|
|
|
|
the :ref:`format-characters` section.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
Note the difference between ``'@'`` and ``'='``: both use native byte order, but
|
|
|
|
the size and alignment of the latter is standardized.
|
|
|
|
|
|
|
|
The form ``'!'`` is available for those poor souls who claim they can't remember
|
|
|
|
whether network byte order is big-endian or little-endian.
|
|
|
|
|
|
|
|
There is no way to indicate non-native byte order (force byte-swapping); use the
|
|
|
|
appropriate choice of ``'<'`` or ``'>'``.
|
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
Notes:
|
|
|
|
|
|
|
|
(1) Padding is only automatically added between successive structure members.
|
|
|
|
No padding is added at the beginning or the end of the encoded struct.
|
|
|
|
|
|
|
|
(2) No padding is added when using non-native size and alignment, e.g.
|
|
|
|
with '<', '>', '=', and '!'.
|
|
|
|
|
|
|
|
(3) To align the end of a structure to the alignment requirement of a
|
|
|
|
particular type, end the format with the code for that type with a repeat
|
|
|
|
count of zero. See :ref:`struct-examples`.
|
|
|
|
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
.. _format-characters:
|
|
|
|
|
|
|
|
Format Characters
|
|
|
|
^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Format characters have the following meaning; the conversion between C and
|
|
|
|
Python values should be obvious given their types:
|
|
|
|
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| Format | C Type | Python type | Standard size | Notes |
|
|
|
|
+========+=========================+====================+================+============+
|
|
|
|
| ``x`` | pad byte | no value | | |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``c`` | :ctype:`char` | bytes of length 1 | 1 | |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``b`` | :ctype:`signed char` | integer | 1 | \(1),\(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``B`` | :ctype:`unsigned char` | integer | 1 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``?`` | :ctype:`_Bool` | bool | 1 | \(2) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``h`` | :ctype:`short` | integer | 2 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``H`` | :ctype:`unsigned short` | integer | 2 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``i`` | :ctype:`int` | integer | 4 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``I`` | :ctype:`unsigned int` | integer | 4 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``l`` | :ctype:`long` | integer | 4 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``L`` | :ctype:`unsigned long` | integer | 4 | \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``q`` | :ctype:`long long` | integer | 8 | \(3), \(4) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``Q`` | :ctype:`unsigned long | integer | 8 | \(3), \(4) |
|
|
|
|
| | long` | | | |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
2010-06-15 05:45:06 -03:00
|
|
|
| ``f`` | :ctype:`float` | float | 4 | \(5) |
|
2010-06-12 16:18:51 -03:00
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
2010-06-15 05:45:06 -03:00
|
|
|
| ``d`` | :ctype:`double` | float | 8 | \(5) |
|
2010-06-12 16:18:51 -03:00
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``s`` | :ctype:`char[]` | bytes | | \(1) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
| ``p`` | :ctype:`char[]` | bytes | | \(1) |
|
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
2010-06-15 05:45:06 -03:00
|
|
|
| ``P`` | :ctype:`void \*` | integer | | \(6) |
|
2010-06-12 16:18:51 -03:00
|
|
|
+--------+-------------------------+--------------------+----------------+------------+
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
|
|
|
|
(1)
|
|
|
|
The ``c``, ``s`` and ``p`` conversion codes operate on :class:`bytes`
|
|
|
|
objects, but packing with such codes also supports :class:`str` objects,
|
|
|
|
which are encoded using UTF-8.
|
|
|
|
|
|
|
|
(2)
|
|
|
|
The ``'?'`` conversion code corresponds to the :ctype:`_Bool` type defined by
|
|
|
|
C99. If this type is not available, it is simulated using a :ctype:`char`. In
|
|
|
|
standard mode, it is always represented by one byte.
|
|
|
|
|
|
|
|
(3)
|
|
|
|
The ``'q'`` and ``'Q'`` conversion codes are available in native mode only if
|
|
|
|
the platform C compiler supports C :ctype:`long long`, or, on Windows,
|
|
|
|
:ctype:`__int64`. They are always available in standard modes.
|
|
|
|
|
2010-06-15 05:45:06 -03:00
|
|
|
(4)
|
|
|
|
When attempting to pack a non-integer using any of the integer conversion
|
|
|
|
codes, if the non-integer has a :meth:`__index__` method then that method is
|
|
|
|
called to convert the argument to an integer before packing.
|
|
|
|
|
|
|
|
.. versionchanged:: 3.2
|
|
|
|
Use of the :meth:`__index__` method for non-integers is new in 3.2.
|
|
|
|
|
|
|
|
(5)
|
|
|
|
For the ``'f'`` and ``'d'`` conversion codes, the packed representation uses
|
|
|
|
the IEEE 754 binary32 (for ``'f'``) or binary64 (for ``'d'``) format,
|
|
|
|
regardless of the floating-point format used by the platform.
|
|
|
|
|
|
|
|
(6)
|
|
|
|
The ``'P'`` format character is only available for the native byte ordering
|
|
|
|
(selected as the default or with the ``'@'`` byte order character). The byte
|
|
|
|
order character ``'='`` chooses to use little- or big-endian ordering based
|
|
|
|
on the host system. The struct module does not interpret this as native
|
|
|
|
ordering, so the ``'P'`` format is not available.
|
|
|
|
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
A format character may be preceded by an integral repeat count. For example,
|
|
|
|
the format string ``'4h'`` means exactly the same as ``'hhhh'``.
|
|
|
|
|
|
|
|
Whitespace characters between formats are ignored; a count and its format must
|
|
|
|
not contain whitespace though.
|
|
|
|
|
|
|
|
For the ``'s'`` format character, the count is interpreted as the length of the
|
|
|
|
bytes, not a repeat count like for the other format characters; for example,
|
|
|
|
``'10s'`` means a single 10-byte string, while ``'10c'`` means 10 characters.
|
|
|
|
For packing, the string is truncated or padded with null bytes as appropriate to
|
|
|
|
make it fit. For unpacking, the resulting bytes object always has exactly the
|
|
|
|
specified number of bytes. As a special case, ``'0s'`` means a single, empty
|
|
|
|
string (while ``'0c'`` means 0 characters).
|
|
|
|
|
|
|
|
When packing a value ``x`` using one of the integer formats (``'b'``,
|
|
|
|
``'B'``, ``'h'``, ``'H'``, ``'i'``, ``'I'``, ``'l'``, ``'L'``,
|
|
|
|
``'q'``, ``'Q'``), if ``x`` is outside the valid range for that format
|
|
|
|
then :exc:`struct.error` is raised.
|
|
|
|
|
|
|
|
.. versionchanged:: 3.1
|
|
|
|
In 3.0, some of the integer formats wrapped out-of-range values and
|
|
|
|
raised :exc:`DeprecationWarning` instead of :exc:`struct.error`.
|
|
|
|
|
|
|
|
|
|
|
|
The ``'p'`` format character encodes a "Pascal string", meaning a short
|
|
|
|
variable-length string stored in a fixed number of bytes. The count is the total
|
|
|
|
number of bytes stored. The first byte stored is the length of the string, or
|
|
|
|
255, whichever is smaller. The bytes of the string follow. If the string
|
|
|
|
passed in to :func:`pack` is too long (longer than the count minus 1), only the
|
|
|
|
leading count-1 bytes of the string are stored. If the string is shorter than
|
|
|
|
count-1, it is padded with null bytes so that exactly count bytes in all are
|
|
|
|
used. Note that for :func:`unpack`, the ``'p'`` format character consumes count
|
|
|
|
bytes, but that the string returned can never contain more than 255 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For the ``'?'`` format character, the return value is either :const:`True` or
|
|
|
|
:const:`False`. When packing, the truth value of the argument object is used.
|
|
|
|
Either 0 or 1 in the native or standard bool representation will be packed, and
|
|
|
|
any non-zero value will be True when unpacking.
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
.. _struct-examples:
|
|
|
|
|
|
|
|
Examples
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
All examples assume a native byte order, size, and alignment with a
|
|
|
|
big-endian machine.
|
|
|
|
|
|
|
|
A basic example of packing/unpacking three integers::
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
>>> from struct import *
|
|
|
|
>>> pack('hhl', 1, 2, 3)
|
2008-07-31 12:03:40 -03:00
|
|
|
b'\x00\x01\x00\x02\x00\x00\x00\x03'
|
|
|
|
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
|
2007-08-15 11:28:22 -03:00
|
|
|
(1, 2, 3)
|
|
|
|
>>> calcsize('hhl')
|
|
|
|
8
|
|
|
|
|
Merged revisions 63542-63544,63546,63553,63563-63564,63567,63569,63576 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63542 | mark.dickinson | 2008-05-22 20:35:30 -0500 (Thu, 22 May 2008) | 5 lines
Issue #2819: Add math.sum, a function that sums a sequence of floats
efficiently but with no intermediate loss of precision. Based on
Raymond Hettinger's ASPN recipe. Thanks Jean Brouwers for the patch.
........
r63543 | mark.dickinson | 2008-05-22 21:36:48 -0500 (Thu, 22 May 2008) | 2 lines
Add tests for math.sum (Issue #2819)
........
r63544 | mark.dickinson | 2008-05-22 22:30:01 -0500 (Thu, 22 May 2008) | 2 lines
Better error reporting in test_math.py
........
r63546 | raymond.hettinger | 2008-05-22 23:32:43 -0500 (Thu, 22 May 2008) | 1 line
Tweak the comments and formatting.
........
r63553 | mark.dickinson | 2008-05-23 07:07:36 -0500 (Fri, 23 May 2008) | 3 lines
Skip math.sum tests on non IEEE 754 platforms, and on IEEE 754 platforms
that exhibit the problem described in issue #2937.
........
r63563 | martin.v.loewis | 2008-05-23 10:18:28 -0500 (Fri, 23 May 2008) | 3 lines
Issue #1390: Raise ValueError in toxml when an invalid comment would
otherwise be produced.
........
r63564 | raymond.hettinger | 2008-05-23 12:21:44 -0500 (Fri, 23 May 2008) | 1 line
Issue 2909: show how to name unpacked fields.
........
r63567 | raymond.hettinger | 2008-05-23 12:34:34 -0500 (Fri, 23 May 2008) | 1 line
Fix typo
........
r63569 | martin.v.loewis | 2008-05-23 14:33:13 -0500 (Fri, 23 May 2008) | 3 lines
Mention that the leaking of variables from list comprehensions
is fixed in 3.0.
........
r63576 | martin.v.loewis | 2008-05-24 04:36:45 -0500 (Sat, 24 May 2008) | 3 lines
Don't try to get the window size if it was never set before.
Fixes the test failure on Solaris.
........
2008-05-26 14:36:47 -03:00
|
|
|
Unpacked fields can be named by assigning them to variables or by wrapping
|
|
|
|
the result in a named tuple::
|
|
|
|
|
2008-07-31 12:03:40 -03:00
|
|
|
>>> record = b'raymond \x32\x12\x08\x01\x08'
|
Merged revisions 63542-63544,63546,63553,63563-63564,63567,63569,63576 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63542 | mark.dickinson | 2008-05-22 20:35:30 -0500 (Thu, 22 May 2008) | 5 lines
Issue #2819: Add math.sum, a function that sums a sequence of floats
efficiently but with no intermediate loss of precision. Based on
Raymond Hettinger's ASPN recipe. Thanks Jean Brouwers for the patch.
........
r63543 | mark.dickinson | 2008-05-22 21:36:48 -0500 (Thu, 22 May 2008) | 2 lines
Add tests for math.sum (Issue #2819)
........
r63544 | mark.dickinson | 2008-05-22 22:30:01 -0500 (Thu, 22 May 2008) | 2 lines
Better error reporting in test_math.py
........
r63546 | raymond.hettinger | 2008-05-22 23:32:43 -0500 (Thu, 22 May 2008) | 1 line
Tweak the comments and formatting.
........
r63553 | mark.dickinson | 2008-05-23 07:07:36 -0500 (Fri, 23 May 2008) | 3 lines
Skip math.sum tests on non IEEE 754 platforms, and on IEEE 754 platforms
that exhibit the problem described in issue #2937.
........
r63563 | martin.v.loewis | 2008-05-23 10:18:28 -0500 (Fri, 23 May 2008) | 3 lines
Issue #1390: Raise ValueError in toxml when an invalid comment would
otherwise be produced.
........
r63564 | raymond.hettinger | 2008-05-23 12:21:44 -0500 (Fri, 23 May 2008) | 1 line
Issue 2909: show how to name unpacked fields.
........
r63567 | raymond.hettinger | 2008-05-23 12:34:34 -0500 (Fri, 23 May 2008) | 1 line
Fix typo
........
r63569 | martin.v.loewis | 2008-05-23 14:33:13 -0500 (Fri, 23 May 2008) | 3 lines
Mention that the leaking of variables from list comprehensions
is fixed in 3.0.
........
r63576 | martin.v.loewis | 2008-05-24 04:36:45 -0500 (Sat, 24 May 2008) | 3 lines
Don't try to get the window size if it was never set before.
Fixes the test failure on Solaris.
........
2008-05-26 14:36:47 -03:00
|
|
|
>>> name, serialnum, school, gradelevel = unpack('<10sHHb', record)
|
|
|
|
|
|
|
|
>>> from collections import namedtuple
|
|
|
|
>>> Student = namedtuple('Student', 'name serialnum school gradelevel')
|
2008-07-31 12:03:40 -03:00
|
|
|
>>> Student._make(unpack('<10sHHb', record))
|
|
|
|
Student(name=b'raymond ', serialnum=4658, school=264, gradelevel=8)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
The ordering of format characters may have an impact on size since the padding
|
|
|
|
needed to satisfy alignment requirements is different::
|
|
|
|
|
|
|
|
>>> pack('ci', '*', 0x12131415)
|
|
|
|
b'*\x00\x00\x00\x12\x13\x14\x15'
|
|
|
|
>>> pack('ic', 0x12131415, '*')
|
|
|
|
b'\x12\x13\x14\x15*'
|
|
|
|
>>> calcsize('ci')
|
|
|
|
8
|
|
|
|
>>> calcsize('ic')
|
|
|
|
5
|
|
|
|
|
|
|
|
The following format ``'llh0l'`` specifies two pad bytes at the end, assuming
|
|
|
|
longs are aligned on 4-byte boundaries::
|
|
|
|
|
|
|
|
>>> pack('llh0l', 1, 2, 3)
|
|
|
|
b'\x00\x00\x00\x01\x00\x00\x00\x02\x00\x03\x00\x00'
|
|
|
|
|
|
|
|
This only works when native size and alignment are in effect; standard size and
|
|
|
|
alignment does not enforce any alignment.
|
|
|
|
|
|
|
|
|
2007-08-15 11:28:22 -03:00
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
Module :mod:`array`
|
|
|
|
Packed binary storage of homogeneous data.
|
|
|
|
|
|
|
|
Module :mod:`xdrlib`
|
|
|
|
Packing and unpacking of XDR data.
|
|
|
|
|
|
|
|
|
|
|
|
.. _struct-objects:
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
Classes
|
2010-05-22 15:58:39 -03:00
|
|
|
-------
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
The :mod:`struct` module also defines the following type:
|
|
|
|
|
|
|
|
|
|
|
|
.. class:: Struct(format)
|
|
|
|
|
2010-05-22 15:58:39 -03:00
|
|
|
Return a new Struct object which writes and reads binary data according to
|
|
|
|
the format string *format*. Creating a Struct object once and calling its
|
|
|
|
methods is more efficient than calling the :mod:`struct` functions with the
|
|
|
|
same format since the format string only needs to be compiled once.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
Compiled Struct objects support the following methods and attributes:
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
.. method:: pack(v1, v2, ...)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
Identical to the :func:`pack` function, using the compiled format.
|
|
|
|
(``len(result)`` will equal :attr:`self.size`.)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
.. method:: pack_into(buffer, offset, v1, v2, ...)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
Identical to the :func:`pack_into` function, using the compiled format.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
.. method:: unpack(buffer)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
Identical to the :func:`unpack` function, using the compiled format.
|
2010-06-12 16:18:51 -03:00
|
|
|
(``len(buffer)`` must equal :attr:`self.size`).
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
Merged revisions 74821,74828-74831,74833,74835 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r74821 | georg.brandl | 2009-09-16 11:42:19 +0200 (Mi, 16 Sep 2009) | 1 line
#6885: run python 3 as python3.
................
r74828 | georg.brandl | 2009-09-16 16:23:20 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74829 | georg.brandl | 2009-09-16 16:24:29 +0200 (Mi, 16 Sep 2009) | 1 line
Small PEP8 correction.
................
r74830 | georg.brandl | 2009-09-16 16:36:22 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans.
................
r74831 | georg.brandl | 2009-09-16 17:54:04 +0200 (Mi, 16 Sep 2009) | 1 line
Use true booleans and PEP8 for argdefaults.
................
r74833 | georg.brandl | 2009-09-16 17:58:14 +0200 (Mi, 16 Sep 2009) | 1 line
Last round of adapting style of documenting argument default values.
................
r74835 | georg.brandl | 2009-09-16 18:00:31 +0200 (Mi, 16 Sep 2009) | 33 lines
Merged revisions 74817-74820,74822-74824 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line
Make deprecation notices as visible as warnings are right now.
........
r74818 | georg.brandl | 2009-09-16 11:23:04 +0200 (Mi, 16 Sep 2009) | 1 line
#6880: add reference to classes section in exceptions section, which comes earlier.
........
r74819 | georg.brandl | 2009-09-16 11:24:57 +0200 (Mi, 16 Sep 2009) | 1 line
#6876: fix base class constructor invocation in example.
........
r74820 | georg.brandl | 2009-09-16 11:30:48 +0200 (Mi, 16 Sep 2009) | 1 line
#6891: comment out dead link to Unicode article.
........
r74822 | georg.brandl | 2009-09-16 12:12:06 +0200 (Mi, 16 Sep 2009) | 1 line
#5621: refactor description of how class/instance attributes interact on a.x=a.x+1 or augassign.
........
r74823 | georg.brandl | 2009-09-16 15:06:22 +0200 (Mi, 16 Sep 2009) | 1 line
Remove strange trailing commas.
........
r74824 | georg.brandl | 2009-09-16 15:11:06 +0200 (Mi, 16 Sep 2009) | 1 line
#6892: fix optparse example involving help option.
........
................
2009-09-16 13:05:59 -03:00
|
|
|
.. method:: unpack_from(buffer, offset=0)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
Identical to the :func:`unpack_from` function, using the compiled format.
|
|
|
|
(``len(buffer[offset:])`` must be at least :attr:`self.size`).
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
.. attribute:: format
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
The format string used to construct this Struct object.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-04-24 22:59:09 -03:00
|
|
|
.. attribute:: size
|
Merged revisions 57221-57391 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r57227 | facundo.batista | 2007-08-20 17:16:21 -0700 (Mon, 20 Aug 2007) | 5 lines
Catch ProtocolError exceptions and include the header information in
test output (to make it easier to debug test failures caused by
problems in the server). [GSoC - Alan McIntyre]
........
r57229 | mark.hammond | 2007-08-20 18:04:47 -0700 (Mon, 20 Aug 2007) | 5 lines
[ 1761786 ] distutils.util.get_platform() return value on 64bit Windows
As discussed on distutils-sig: Allows the generated installer name on
64bit Windows platforms to be different than the name generated for
32bit Windows platforms.
........
r57230 | mark.hammond | 2007-08-20 18:05:16 -0700 (Mon, 20 Aug 2007) | 5 lines
[ 1761786 ] distutils.util.get_platform() return value on 64bit Windows
As discussed on distutils-sig: Allows the generated installer name on
64bit Windows platforms to be different than the name generated for
32bit Windows platforms.
........
r57253 | georg.brandl | 2007-08-20 23:01:18 -0700 (Mon, 20 Aug 2007) | 2 lines
Demand version 2.5.1 since 2.5 has a bug with codecs.open context managers.
........
r57254 | georg.brandl | 2007-08-20 23:03:43 -0700 (Mon, 20 Aug 2007) | 2 lines
Revert accidental checkins from last commit.
........
r57255 | georg.brandl | 2007-08-20 23:07:08 -0700 (Mon, 20 Aug 2007) | 2 lines
Bug #1777160: mention explicitly that e.g. -1**2 is -1.
........
r57256 | georg.brandl | 2007-08-20 23:12:19 -0700 (Mon, 20 Aug 2007) | 3 lines
Bug #1777168: replace operator names "opa"... with "op1"... and mark everything up as literal,
to enhance readability.
........
r57259 | facundo.batista | 2007-08-21 09:57:18 -0700 (Tue, 21 Aug 2007) | 8 lines
Added test for behavior of operations on an unconnected SMTP object,
and tests for NOOP, RSET, and VRFY. Corrected typo in a comment for
testNonnumericPort. Added a check for constructing SMTP objects when
non-numeric ports are included in the host name. Derived a server from
SMTPServer to test various ESMTP/SMTP capabilities. Check that a
second HELO to DebuggingServer returns an error. [GSoC - Alan McIntyre]
........
r57279 | skip.montanaro | 2007-08-22 12:02:16 -0700 (Wed, 22 Aug 2007) | 2 lines
Note that BeOS is unsupported as of Python 2.6.
........
r57280 | skip.montanaro | 2007-08-22 12:05:21 -0700 (Wed, 22 Aug 2007) | 1 line
whoops - need to check in configure as well
........
r57284 | alex.martelli | 2007-08-22 14:14:17 -0700 (Wed, 22 Aug 2007) | 5 lines
Fix compile.c so that it records 0.0 and -0.0 as separate constants in a code
object's co_consts tuple; add a test to show that the previous behavior (where
these two constants were "collapsed" into one) causes serious malfunctioning.
........
r57286 | gregory.p.smith | 2007-08-22 14:32:34 -0700 (Wed, 22 Aug 2007) | 3 lines
stop leaving log.0000001 __db.00* and xxx.db turds in developer
sandboxes when bsddb3 tests are run.
........
r57301 | jeffrey.yasskin | 2007-08-22 16:14:27 -0700 (Wed, 22 Aug 2007) | 3 lines
When setup.py fails to find the necessary bits to build some modules, have it
print a slightly more informative message.
........
r57320 | brett.cannon | 2007-08-23 07:53:17 -0700 (Thu, 23 Aug 2007) | 2 lines
Make test_runpy re-entrant.
........
r57324 | georg.brandl | 2007-08-23 10:54:11 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1768121: fix wrong/missing opcode docs.
........
r57326 | georg.brandl | 2007-08-23 10:57:05 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1766421: "return code" vs. "status code".
........
r57328 | georg.brandl | 2007-08-23 11:08:06 -0700 (Thu, 23 Aug 2007) | 2 lines
Second half of #1752175: #ifdef out references to PyImport_DynLoadFiletab if HAVE_DYNAMIC_LOADING is not defined.
........
r57331 | georg.brandl | 2007-08-23 11:11:33 -0700 (Thu, 23 Aug 2007) | 2 lines
Use try-except-finally in contextlib.
........
r57343 | georg.brandl | 2007-08-23 13:35:00 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1697820: document that the old slice protocol is still used by builtin types.
........
r57345 | georg.brandl | 2007-08-23 13:40:01 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1573854: fix docs for sqlite3 cursor rowcount attr.
........
r57347 | georg.brandl | 2007-08-23 13:50:23 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1694833: fix imp.find_module() docs wrt. packages.
........
r57348 | georg.brandl | 2007-08-23 13:53:28 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1594966: fix misleading usage example
........
r57349 | georg.brandl | 2007-08-23 13:55:44 -0700 (Thu, 23 Aug 2007) | 2 lines
Clarify wording a bit.
........
r57351 | georg.brandl | 2007-08-23 14:18:44 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1752332: httplib no longer uses socket.getaddrinfo().
........
r57352 | georg.brandl | 2007-08-23 14:21:36 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1734111: document struct.Struct.size.
........
r57353 | georg.brandl | 2007-08-23 14:27:57 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1688564: document os.path.join's absolute path behavior in the docstring.
........
r57354 | georg.brandl | 2007-08-23 14:36:05 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1625381: clarify match vs search introduction.
........
r57355 | georg.brandl | 2007-08-23 14:42:54 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1758696: more info about descriptors.
........
r57357 | georg.brandl | 2007-08-23 14:55:57 -0700 (Thu, 23 Aug 2007) | 2 lines
Patch #1779550: remove redundant code in logging.
........
r57378 | gregory.p.smith | 2007-08-23 22:11:38 -0700 (Thu, 23 Aug 2007) | 2 lines
Fix bug 1725856.
........
r57382 | georg.brandl | 2007-08-23 23:10:01 -0700 (Thu, 23 Aug 2007) | 2 lines
uuid creation is now threadsafe, backport from py3k rev. 57375.
........
r57389 | georg.brandl | 2007-08-24 04:47:37 -0700 (Fri, 24 Aug 2007) | 2 lines
Bug #1765375: fix stripping of unwanted LDFLAGS.
........
r57391 | guido.van.rossum | 2007-08-24 07:53:14 -0700 (Fri, 24 Aug 2007) | 2 lines
Fix silly typo in test name.
........
2007-08-24 13:32:05 -03:00
|
|
|
|
2010-06-12 16:18:51 -03:00
|
|
|
The calculated size of the struct (and hence of the bytes object produced
|
|
|
|
by the :meth:`pack` method) corresponding to :attr:`format`.
|
Merged revisions 57221-57391 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r57227 | facundo.batista | 2007-08-20 17:16:21 -0700 (Mon, 20 Aug 2007) | 5 lines
Catch ProtocolError exceptions and include the header information in
test output (to make it easier to debug test failures caused by
problems in the server). [GSoC - Alan McIntyre]
........
r57229 | mark.hammond | 2007-08-20 18:04:47 -0700 (Mon, 20 Aug 2007) | 5 lines
[ 1761786 ] distutils.util.get_platform() return value on 64bit Windows
As discussed on distutils-sig: Allows the generated installer name on
64bit Windows platforms to be different than the name generated for
32bit Windows platforms.
........
r57230 | mark.hammond | 2007-08-20 18:05:16 -0700 (Mon, 20 Aug 2007) | 5 lines
[ 1761786 ] distutils.util.get_platform() return value on 64bit Windows
As discussed on distutils-sig: Allows the generated installer name on
64bit Windows platforms to be different than the name generated for
32bit Windows platforms.
........
r57253 | georg.brandl | 2007-08-20 23:01:18 -0700 (Mon, 20 Aug 2007) | 2 lines
Demand version 2.5.1 since 2.5 has a bug with codecs.open context managers.
........
r57254 | georg.brandl | 2007-08-20 23:03:43 -0700 (Mon, 20 Aug 2007) | 2 lines
Revert accidental checkins from last commit.
........
r57255 | georg.brandl | 2007-08-20 23:07:08 -0700 (Mon, 20 Aug 2007) | 2 lines
Bug #1777160: mention explicitly that e.g. -1**2 is -1.
........
r57256 | georg.brandl | 2007-08-20 23:12:19 -0700 (Mon, 20 Aug 2007) | 3 lines
Bug #1777168: replace operator names "opa"... with "op1"... and mark everything up as literal,
to enhance readability.
........
r57259 | facundo.batista | 2007-08-21 09:57:18 -0700 (Tue, 21 Aug 2007) | 8 lines
Added test for behavior of operations on an unconnected SMTP object,
and tests for NOOP, RSET, and VRFY. Corrected typo in a comment for
testNonnumericPort. Added a check for constructing SMTP objects when
non-numeric ports are included in the host name. Derived a server from
SMTPServer to test various ESMTP/SMTP capabilities. Check that a
second HELO to DebuggingServer returns an error. [GSoC - Alan McIntyre]
........
r57279 | skip.montanaro | 2007-08-22 12:02:16 -0700 (Wed, 22 Aug 2007) | 2 lines
Note that BeOS is unsupported as of Python 2.6.
........
r57280 | skip.montanaro | 2007-08-22 12:05:21 -0700 (Wed, 22 Aug 2007) | 1 line
whoops - need to check in configure as well
........
r57284 | alex.martelli | 2007-08-22 14:14:17 -0700 (Wed, 22 Aug 2007) | 5 lines
Fix compile.c so that it records 0.0 and -0.0 as separate constants in a code
object's co_consts tuple; add a test to show that the previous behavior (where
these two constants were "collapsed" into one) causes serious malfunctioning.
........
r57286 | gregory.p.smith | 2007-08-22 14:32:34 -0700 (Wed, 22 Aug 2007) | 3 lines
stop leaving log.0000001 __db.00* and xxx.db turds in developer
sandboxes when bsddb3 tests are run.
........
r57301 | jeffrey.yasskin | 2007-08-22 16:14:27 -0700 (Wed, 22 Aug 2007) | 3 lines
When setup.py fails to find the necessary bits to build some modules, have it
print a slightly more informative message.
........
r57320 | brett.cannon | 2007-08-23 07:53:17 -0700 (Thu, 23 Aug 2007) | 2 lines
Make test_runpy re-entrant.
........
r57324 | georg.brandl | 2007-08-23 10:54:11 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1768121: fix wrong/missing opcode docs.
........
r57326 | georg.brandl | 2007-08-23 10:57:05 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1766421: "return code" vs. "status code".
........
r57328 | georg.brandl | 2007-08-23 11:08:06 -0700 (Thu, 23 Aug 2007) | 2 lines
Second half of #1752175: #ifdef out references to PyImport_DynLoadFiletab if HAVE_DYNAMIC_LOADING is not defined.
........
r57331 | georg.brandl | 2007-08-23 11:11:33 -0700 (Thu, 23 Aug 2007) | 2 lines
Use try-except-finally in contextlib.
........
r57343 | georg.brandl | 2007-08-23 13:35:00 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1697820: document that the old slice protocol is still used by builtin types.
........
r57345 | georg.brandl | 2007-08-23 13:40:01 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1573854: fix docs for sqlite3 cursor rowcount attr.
........
r57347 | georg.brandl | 2007-08-23 13:50:23 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1694833: fix imp.find_module() docs wrt. packages.
........
r57348 | georg.brandl | 2007-08-23 13:53:28 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1594966: fix misleading usage example
........
r57349 | georg.brandl | 2007-08-23 13:55:44 -0700 (Thu, 23 Aug 2007) | 2 lines
Clarify wording a bit.
........
r57351 | georg.brandl | 2007-08-23 14:18:44 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1752332: httplib no longer uses socket.getaddrinfo().
........
r57352 | georg.brandl | 2007-08-23 14:21:36 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1734111: document struct.Struct.size.
........
r57353 | georg.brandl | 2007-08-23 14:27:57 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1688564: document os.path.join's absolute path behavior in the docstring.
........
r57354 | georg.brandl | 2007-08-23 14:36:05 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1625381: clarify match vs search introduction.
........
r57355 | georg.brandl | 2007-08-23 14:42:54 -0700 (Thu, 23 Aug 2007) | 2 lines
Bug #1758696: more info about descriptors.
........
r57357 | georg.brandl | 2007-08-23 14:55:57 -0700 (Thu, 23 Aug 2007) | 2 lines
Patch #1779550: remove redundant code in logging.
........
r57378 | gregory.p.smith | 2007-08-23 22:11:38 -0700 (Thu, 23 Aug 2007) | 2 lines
Fix bug 1725856.
........
r57382 | georg.brandl | 2007-08-23 23:10:01 -0700 (Thu, 23 Aug 2007) | 2 lines
uuid creation is now threadsafe, backport from py3k rev. 57375.
........
r57389 | georg.brandl | 2007-08-24 04:47:37 -0700 (Fri, 24 Aug 2007) | 2 lines
Bug #1765375: fix stripping of unwanted LDFLAGS.
........
r57391 | guido.van.rossum | 2007-08-24 07:53:14 -0700 (Fri, 24 Aug 2007) | 2 lines
Fix silly typo in test name.
........
2007-08-24 13:32:05 -03:00
|
|
|
|