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
842d921a
Commit
842d921a
authored
Sep 02, 2011
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctypes: Slightly better error message when a struct field name is not a string.
parent
154f2b47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
Modules/_ctypes/stgdict.c
Modules/_ctypes/stgdict.c
+5
-7
No files found.
Modules/_ctypes/stgdict.c
View file @
842d921a
...
...
@@ -426,9 +426,9 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
StgDictObject
*
dict
;
int
bitsize
=
0
;
if
(
!
pair
||
!
PyArg_ParseTuple
(
pair
,
"
O
O|i"
,
&
name
,
&
desc
,
&
bitsize
))
{
PyErr_SetString
(
PyExc_
Attribut
eError
,
"'_fields_' must be a sequence of pairs"
);
if
(
!
pair
||
!
PyArg_ParseTuple
(
pair
,
"
U
O|i"
,
&
name
,
&
desc
,
&
bitsize
))
{
PyErr_SetString
(
PyExc_
Typ
eError
,
"'_fields_' must be a sequence of
(name, C type)
pairs"
);
Py_XDECREF
(
pair
);
return
-
1
;
}
...
...
@@ -478,6 +478,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
}
}
else
bitsize
=
0
;
if
(
isStruct
&&
!
isPacked
)
{
char
*
fieldfmt
=
dict
->
format
?
dict
->
format
:
"B"
;
char
*
fieldname
=
_PyUnicode_AsString
(
name
);
...
...
@@ -487,10 +488,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
if
(
fieldname
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
"structure field name must be string not %s"
,
name
->
ob_type
->
tp_name
);
Py_DECREF
(
pair
);
return
-
1
;
}
...
...
@@ -509,6 +506,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
return
-
1
;
}
}
if
(
isStruct
)
{
prop
=
PyCField_FromDesc
(
desc
,
i
,
&
field_size
,
bitsize
,
&
bitofs
,
...
...
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