Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1ff6b6ab
Commit
1ff6b6ab
authored
Apr 15, 2016
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Plain Diff
merge heads
parents
ad45ab87
b030991a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
Doc/library/struct.rst
Doc/library/struct.rst
+11
-10
Modules/_struct.c
Modules/_struct.c
+8
-8
No files found.
Doc/library/struct.rst
View file @
1ff6b6ab
...
@@ -62,16 +62,16 @@ The module defines the following exception and functions:
...
@@ -62,16 +62,16 @@ The module defines the following exception and functions:
Unpack from the buffer *buffer* (presumably packed by ``pack(fmt, ...)``)
Unpack from the buffer *buffer* (presumably packed by ``pack(fmt, ...)``)
according to the format string *fmt*. The result is a tuple even if it
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
contains exactly one item. The buffer
's size in bytes must match the
data required by the format (``len(bytes)`` must equal ``calcsize(fmt)``)
.
size required by the format, as reflected by :func:`calcsize`
.
.. function:: unpack_from(fmt, buffer, offset=0)
.. function:: unpack_from(fmt, buffer, offset=0)
Unpack from *buffer* starting at position *offset*, according to the format
Unpack from *buffer* starting at position *offset*, according to the format
string *fmt*. The result is a tuple even if it contains exactly one
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
item.
The buffer's size in bytes, minus *offset*, must be at least
format (``len(buffer[offset:])`` must be at least ``calcsize(fmt)``)
.
the size required by the format, as reflected by :func:`calcsize`
.
.. function:: iter_unpack(fmt, buffer)
.. function:: iter_unpack(fmt, buffer)
...
@@ -79,8 +79,8 @@ The module defines the following exception and functions:
...
@@ -79,8 +79,8 @@ The module defines the following exception and functions:
Iteratively unpack from the buffer *buffer* according to the format
Iteratively unpack from the buffer *buffer* according to the format
string *fmt*. This function returns an iterator which will read
string *fmt*. This function returns an iterator which will read
equally-sized chunks from the buffer until all its contents have been
equally-sized chunks from the buffer until all its contents have been
consumed. The buffer's size in bytes must be a multiple of the
amount
consumed. The buffer's size in bytes must be a multiple of the
size
of data
required by the format, as reflected by :func:`calcsize`.
required by the format, as reflected by :func:`calcsize`.
Each iteration yields a tuple as specified by the format string.
Each iteration yields a tuple as specified by the format string.
...
@@ -389,7 +389,7 @@ The :mod:`struct` module also defines the following type:
...
@@ -389,7 +389,7 @@ The :mod:`struct` module also defines the following type:
.. method:: pack(v1, v2, ...)
.. method:: pack(v1, v2, ...)
Identical to the :func:`pack` function, using the compiled format.
Identical to the :func:`pack` function, using the compiled format.
(``len(result)`` will equal :attr:`s
elf.s
ize`.)
(``len(result)`` will equal :attr:`size`.)
.. method:: pack_into(buffer, offset, v1, v2, ...)
.. method:: pack_into(buffer, offset, v1, v2, ...)
...
@@ -400,19 +400,20 @@ The :mod:`struct` module also defines the following type:
...
@@ -400,19 +400,20 @@ The :mod:`struct` module also defines the following type:
.. method:: unpack(buffer)
.. method:: unpack(buffer)
Identical to the :func:`unpack` function, using the compiled format.
Identical to the :func:`unpack` function, using the compiled format.
(``len(buffer)`` must equal :attr:`self.size`)
.
The buffer's size in bytes must equal :attr:`size`
.
.. method:: unpack_from(buffer, offset=0)
.. method:: unpack_from(buffer, offset=0)
Identical to the :func:`unpack_from` function, using the compiled format.
Identical to the :func:`unpack_from` function, using the compiled format.
(``len(buffer[offset:])`` must be at least :attr:`self.size`).
The buffer's size in bytes, minus *offset*, must be at least
:attr:`size`.
.. method:: iter_unpack(buffer)
.. method:: iter_unpack(buffer)
Identical to the :func:`iter_unpack` function, using the compiled format.
Identical to the :func:`iter_unpack` function, using the compiled format.
(``len(buffer)`` must be a multiple of :attr:`self.size`)
.
The buffer's size in bytes must be a multiple of :attr:`size`
.
.. versionadded:: 3.4
.. versionadded:: 3.4
...
...
Modules/_struct.c
View file @
1ff6b6ab
...
@@ -1497,8 +1497,8 @@ PyDoc_STRVAR(s_unpack__doc__,
...
@@ -1497,8 +1497,8 @@ PyDoc_STRVAR(s_unpack__doc__,
"S.unpack(buffer) -> (v1, v2, ...)
\n
\
"S.unpack(buffer) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return a tuple containing values unpacked according to the format
\n
\
Return a tuple containing values unpacked according to the format
\n
\
string S.format.
Requires len(buffer) == S.size. See help(struct)
\n
\
string S.format.
The buffer's size in bytes must be S.size. See
\n
\
for more on format strings."
);
help(struct)
for more on format strings."
);
static
PyObject
*
static
PyObject
*
s_unpack
(
PyObject
*
self
,
PyObject
*
input
)
s_unpack
(
PyObject
*
self
,
PyObject
*
input
)
...
@@ -1527,8 +1527,8 @@ PyDoc_STRVAR(s_unpack_from__doc__,
...
@@ -1527,8 +1527,8 @@ PyDoc_STRVAR(s_unpack_from__doc__,
"S.unpack_from(buffer, offset=0) -> (v1, v2, ...)
\n
\
"S.unpack_from(buffer, offset=0) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return a tuple containing values unpacked according to the format
\n
\
Return a tuple containing values unpacked according to the format
\n
\
string S.format.
Requires len(buffer[offset:]) >= S.size. See
\n
\
string S.format.
The buffer's size in bytes, minus offset, must be at
\n
\
help(struct) for more on format strings."
);
least S.size. See
help(struct) for more on format strings."
);
static
PyObject
*
static
PyObject
*
s_unpack_from
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
s_unpack_from
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
...
@@ -2130,8 +2130,8 @@ PyDoc_STRVAR(unpack_doc,
...
@@ -2130,8 +2130,8 @@ PyDoc_STRVAR(unpack_doc,
"unpack(fmt, buffer) -> (v1, v2, ...)
\n
\
"unpack(fmt, buffer) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return a tuple containing values unpacked according to the format string
\n
\
Return a tuple containing values unpacked according to the format string
\n
\
fmt.
Requires len(buffer) == calcsize(fmt). See help(struct) for more
\n
\
fmt.
The buffer's size in bytes must be calcsize(fmt). See help(struct)
\n
\
on format strings."
);
for more
on format strings."
);
static
PyObject
*
static
PyObject
*
unpack
(
PyObject
*
self
,
PyObject
*
args
)
unpack
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -2153,8 +2153,8 @@ PyDoc_STRVAR(unpack_from_doc,
...
@@ -2153,8 +2153,8 @@ PyDoc_STRVAR(unpack_from_doc,
"unpack_from(fmt, buffer, offset=0) -> (v1, v2, ...)
\n
\
"unpack_from(fmt, buffer, offset=0) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return a tuple containing values unpacked according to the format string
\n
\
Return a tuple containing values unpacked according to the format string
\n
\
fmt.
Requires len(buffer[offset:]) >= calcsize(fmt). See help(struct)
\n
\
fmt.
The buffer's size, minus offset, must be at least calcsize(fmt).
\n
\
for more on format strings."
);
See help(struct)
for more on format strings."
);
static
PyObject
*
static
PyObject
*
unpack_from
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
unpack_from
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment