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
5c89c19e
Commit
5c89c19e
authored
Oct 29, 2012
by
Petri Lehtinen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#14897: Enhance error messages of struct.pack and struct.pack_into
Patch by Matti Mäki.
parent
64c0b2ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
Misc/ACKS
Misc/ACKS
+2
-1
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_struct.c
Modules/_struct.c
+14
-4
No files found.
Misc/ACKS
View file @
5c89c19e
...
...
@@ -655,6 +655,7 @@ Brian Merrell
Luke Mewburn
Carl Meyer
Mike Meyer
Piotr Meyer
Steven Miale
Trent Mick
Tom Middleton
...
...
@@ -685,7 +686,7 @@ Sape Mullender
Michael Muller
Neil Muller
R. David Murray
Piotr Meyer
Matti Mäki
Dale Nagata
John Nagle
Takahiro Nakayama
...
...
Misc/NEWS
View file @
5c89c19e
...
...
@@ -125,6 +125,9 @@ Core and Builtins
Library
-------
-
Issue
#
14897
:
Enhance
error
messages
of
struct
.
pack
and
struct
.
pack_into
.
Patch
by
Matti
M
ä
ki
.
-
Issue
#
12890
:
cgitb
no
longer
prints
spurious
<
p
>
tags
in
text
mode
when
the
logdir
option
is
specified
.
...
...
Modules/_struct.c
View file @
5c89c19e
...
...
@@ -1603,7 +1603,7 @@ s_pack(PyObject *self, PyObject *args)
if
(
PyTuple_GET_SIZE
(
args
)
!=
soself
->
s_len
)
{
PyErr_Format
(
StructError
,
"pack
requires exactly %zd arguments"
,
soself
->
s_len
);
"pack
expected %zd items for packing (got %zd)"
,
soself
->
s_len
,
PyTuple_GET_SIZE
(
args
)
);
return
NULL
;
}
...
...
@@ -1642,9 +1642,19 @@ s_pack_into(PyObject *self, PyObject *args)
assert
(
soself
->
s_codes
!=
NULL
);
if
(
PyTuple_GET_SIZE
(
args
)
!=
(
soself
->
s_len
+
2
))
{
PyErr_Format
(
StructError
,
"pack_into requires exactly %zd arguments"
,
(
soself
->
s_len
+
2
));
if
(
PyTuple_GET_SIZE
(
args
)
==
0
)
{
PyErr_Format
(
StructError
,
"pack_into expected buffer argument"
);
}
else
if
(
PyTuple_GET_SIZE
(
args
)
==
1
)
{
PyErr_Format
(
StructError
,
"pack_into expected offset argument"
);
}
else
{
PyErr_Format
(
StructError
,
"pack_into expected %zd items for packing (got %zd)"
,
soself
->
s_len
,
(
PyTuple_GET_SIZE
(
args
)
-
2
));
}
return
NULL
;
}
...
...
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