summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-01-24 09:38:26 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-01-24 09:38:26 (GMT)
commit7b7ce7854c2e36d04adb42beec5f673071cf1fd4 (patch)
tree4f329e6b777309aa8bb79ea8b79d0072fb50766f /Doc
parent7070094d7ffd4308e12188b39d0f346473581335 (diff)
downloadcpython-7b7ce7854c2e36d04adb42beec5f673071cf1fd4.zip
cpython-7b7ce7854c2e36d04adb42beec5f673071cf1fd4.tar.gz
cpython-7b7ce7854c2e36d04adb42beec5f673071cf1fd4.tar.bz2
Fix issue1789: The tutorial contained a misuse of the struct module.
(also remove an unneeded import struct from test_largefile)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/struct.rst4
-rw-r--r--Doc/tutorial/stdlib2.rst8
2 files changed, 7 insertions, 5 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index d4952bb..d0960ed 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -85,7 +85,7 @@ Python values should be obvious given their types:
+--------+-------------------------+--------------------+-------+
| ``i`` | :ctype:`int` | integer | |
+--------+-------------------------+--------------------+-------+
-| ``I`` | :ctype:`unsigned int` | long | |
+| ``I`` | :ctype:`unsigned int` | integer or long | |
+--------+-------------------------+--------------------+-------+
| ``l`` | :ctype:`long` | integer | |
+--------+-------------------------+--------------------+-------+
@@ -104,7 +104,7 @@ Python values should be obvious given their types:
+--------+-------------------------+--------------------+-------+
| ``p`` | :ctype:`char[]` | string | |
+--------+-------------------------+--------------------+-------+
-| ``P`` | :ctype:`void \*` | integer | |
+| ``P`` | :ctype:`void \*` | long | |
+--------+-------------------------+--------------------+-------+
Notes:
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 14c60dd..73a896d 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -134,8 +134,10 @@ Working with Binary Data Record Layouts
The :mod:`struct` module provides :func:`pack` and :func:`unpack` functions for
working with variable length binary record formats. The following example shows
-how to loop through header information in a ZIP file (with pack codes ``"H"``
-and ``"L"`` representing two and four byte unsigned numbers respectively)::
+how to loop through header information in a ZIP file without using the
+:mod:`zipfile` module. Pack codes ``"H"`` and ``"I"`` represent two and four
+byte unsigned numbers respectively. The ``"<"`` indicates that they are
+standard size and in little-endian byte order::
import struct
@@ -143,7 +145,7 @@ and ``"L"`` representing two and four byte unsigned numbers respectively)::
start = 0
for i in range(3): # show the first 3 file headers
start += 14
- fields = struct.unpack('LLLHH', data[start:start+16])
+ fields = struct.unpack('<IIIHH', data[start:start+16])
crc32, comp_size, uncomp_size, filenamesize, extra_size = fields
start += 16