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
4b80ef54
Commit
4b80ef54
authored
Jun 12, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8973: Add __all__ to struct module, so that help(struct) correctly
displays information for the struct.Struct class.
parent
3a810e68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
21 deletions
+42
-21
Lib/struct.py
Lib/struct.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_struct.c
Modules/_struct.c
+28
-21
No files found.
Lib/struct.py
View file @
4b80ef54
__all__
=
[
# Functions
'calcsize'
,
'pack'
,
'unpack'
,
'unpack'
,
'unpack_from'
,
# Classes
'Struct'
,
# Exceptions
'error'
]
from
_struct
import
*
from
_struct
import
*
from
_struct
import
_clearcache
from
_struct
import
_clearcache
from
_struct
import
__doc__
from
_struct
import
__doc__
Misc/NEWS
View file @
4b80ef54
...
@@ -1299,6 +1299,9 @@ Library
...
@@ -1299,6 +1299,9 @@ Library
Extension Modules
Extension Modules
-----------------
-----------------
- Issue #8973: Add __all__ to struct module; this ensures that
help(struct) includes documentation for the struct.Struct class.
- Issue #3129: Trailing digits in format string are no longer ignored.
- Issue #3129: Trailing digits in format string are no longer ignored.
For example, "1" or "ilib123" are now invalid formats and cause
For example, "1" or "ilib123" are now invalid formats and cause
``struct.error`` to be raised.
``struct.error`` to be raised.
...
...
Modules/_struct.c
View file @
4b80ef54
...
@@ -1398,9 +1398,8 @@ fail:
...
@@ -1398,9 +1398,8 @@ fail:
PyDoc_STRVAR
(
s_unpack__doc__
,
PyDoc_STRVAR
(
s_unpack__doc__
,
"S.unpack(buffer) -> (v1, v2, ...)
\n
\
"S.unpack(buffer) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return tuple containing values unpacked according to this Struct's format.
\n
\
Return a tuple containing values unpacked according to S.format. Requires
\n
\
Requires len(buffer) == self.size. See struct.__doc__ for more on format
\n
\
len(buffer) == S.size. See help(struct) for more on format strings."
);
strings."
);
static
PyObject
*
static
PyObject
*
s_unpack
(
PyObject
*
self
,
PyObject
*
input
)
s_unpack
(
PyObject
*
self
,
PyObject
*
input
)
...
@@ -1426,12 +1425,10 @@ s_unpack(PyObject *self, PyObject *input)
...
@@ -1426,12 +1425,10 @@ s_unpack(PyObject *self, PyObject *input)
}
}
PyDoc_STRVAR
(
s_unpack_from__doc__
,
PyDoc_STRVAR
(
s_unpack_from__doc__
,
"S.unpack_from(buffer[, offset]) -> (v1, v2, ...)
\n
\
"S.unpack_from(buffer[, offset
=0
]) -> (v1, v2, ...)
\n
\
\n
\
\n
\
Return tuple containing values unpacked according to this Struct's format.
\n
\
Return a tuple containing values unpacked according to S.format. Requires
\n
\
Unlike unpack, unpack_from can unpack values from any object supporting
\n
\
len(buffer[offset:]) >= S.size. See help(struct) for more on format strings."
);
the buffer API, not just str. Requires len(buffer[offset:]) >= self.size.
\n
\
See struct.__doc__ 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
)
...
@@ -1566,8 +1563,8 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
...
@@ -1566,8 +1563,8 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
PyDoc_STRVAR
(
s_pack__doc__
,
PyDoc_STRVAR
(
s_pack__doc__
,
"S.pack(v1, v2, ...) -> bytes
\n
\
"S.pack(v1, v2, ...) -> bytes
\n
\
\n
\
\n
\
Return a bytes
containing values v1, v2, ... packed according to this
\n
\
Return a bytes
object containing values v1, v2, ... packed according to
\n
\
S
truct's format. See struct.__doc__
for more on format strings."
);
S
.format. See help(struct)
for more on format strings."
);
static
PyObject
*
static
PyObject
*
s_pack
(
PyObject
*
self
,
PyObject
*
args
)
s_pack
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -1603,10 +1600,9 @@ s_pack(PyObject *self, PyObject *args)
...
@@ -1603,10 +1600,9 @@ s_pack(PyObject *self, PyObject *args)
PyDoc_STRVAR
(
s_pack_into__doc__
,
PyDoc_STRVAR
(
s_pack_into__doc__
,
"S.pack_into(buffer, offset, v1, v2, ...)
\n
\
"S.pack_into(buffer, offset, v1, v2, ...)
\n
\
\n
\
\n
\
Pack the values v1, v2, ... according to this Struct's format, write
\n
\
Pack the values v1, v2, ... according to S.format and write the packed bytes
\n
\
the packed bytes into the writable buffer buf starting at offset. Note
\n
\
into the writable buffer buf starting at offset. Note that the offset is not
\n
\
that the offset is not an optional argument. See struct.__doc__ for
\n
\
an optional argument. See help(struct) for more on format strings."
);
more on format strings."
);
static
PyObject
*
static
PyObject
*
s_pack_into
(
PyObject
*
self
,
PyObject
*
args
)
s_pack_into
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -1796,7 +1792,10 @@ calcsize(PyObject *self, PyObject *fmt)
...
@@ -1796,7 +1792,10 @@ calcsize(PyObject *self, PyObject *fmt)
}
}
PyDoc_STRVAR
(
pack_doc
,
PyDoc_STRVAR
(
pack_doc
,
"Return bytes containing values v1, v2, ... packed according to fmt."
);
"pack(fmt, v1, v2, ...) -> bytes
\n
\
\n
\
Return a bytes object containing values v1, v2, ... packed according to fmt.
\n
\
See help(struct) for more on format strings."
);
static
PyObject
*
static
PyObject
*
pack
(
PyObject
*
self
,
PyObject
*
args
)
pack
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -1825,8 +1824,11 @@ pack(PyObject *self, PyObject *args)
...
@@ -1825,8 +1824,11 @@ pack(PyObject *self, PyObject *args)
}
}
PyDoc_STRVAR
(
pack_into_doc
,
PyDoc_STRVAR
(
pack_into_doc
,
"Pack the values v1, v2, ... according to fmt.
\n
\
"pack_into(fmt, buffer, offset, v1, v2, ...)
\n
\
Write the packed bytes into the writable buffer buf starting at offset."
);
\n
\
Pack the values v1, v2, ... according to fmt and write the packed bytes into
\n
\
the writable buffer buf starting at offset. Note that the offset is not an
\n
\
optional argument. See help(struct) for more on format strings."
);
static
PyObject
*
static
PyObject
*
pack_into
(
PyObject
*
self
,
PyObject
*
args
)
pack_into
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -1855,8 +1857,10 @@ pack_into(PyObject *self, PyObject *args)
...
@@ -1855,8 +1857,10 @@ pack_into(PyObject *self, PyObject *args)
}
}
PyDoc_STRVAR
(
unpack_doc
,
PyDoc_STRVAR
(
unpack_doc
,
"Unpack the bytes containing packed C structure data, according to fmt.
\n
\
"unpack(fmt, buffer) -> (v1, v2, ...)
\n
\
Requires len(bytes) == calcsize(fmt)."
);
\n
\
Return a tuple containing values unpacked according to fmt. Requires
\n
\
len(buffer) == calcsize(fmt). See help(struct) for more on format strings."
);
static
PyObject
*
static
PyObject
*
unpack
(
PyObject
*
self
,
PyObject
*
args
)
unpack
(
PyObject
*
self
,
PyObject
*
args
)
...
@@ -1875,8 +1879,11 @@ unpack(PyObject *self, PyObject *args)
...
@@ -1875,8 +1879,11 @@ unpack(PyObject *self, PyObject *args)
}
}
PyDoc_STRVAR
(
unpack_from_doc
,
PyDoc_STRVAR
(
unpack_from_doc
,
"Unpack the buffer, containing packed C structure data, according to
\n
\
"unpack_from(fmt, buffer[, offset=0]) -> (v1, v2, ...)
\n
\
fmt, starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt)."
);
\n
\
Return a tuple containing values unpacked according to fmt. Requires
\n
\
len(buffer[offset:]) >= calcsize(fmt). See help(struct) for more on format
\n
\
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