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
d91e676f
Commit
d91e676f
authored
Jun 18, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #27343: Fixed error message for conflicting initializers of ctypes.Structure.
parents
5d062d7b
886a5f35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
10 deletions
+5
-10
Lib/ctypes/test/test_structures.py
Lib/ctypes/test/test_structures.py
+3
-3
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+2
-7
No files found.
Lib/ctypes/test/test_structures.py
View file @
d91e676f
...
...
@@ -227,10 +227,10 @@ class StructureTestCase(unittest.TestCase):
def
test_conflicting_initializers
(
self
):
class
POINT
(
Structure
):
_fields_
=
[(
"
x"
,
c_int
),
(
"y"
,
c_in
t
)]
_fields_
=
[(
"
phi"
,
c_float
),
(
"rho"
,
c_floa
t
)]
# conflicting positional and keyword args
self
.
assertRaises
(
TypeError
,
POINT
,
2
,
3
,
x
=
4
)
self
.
assertRaises
(
TypeError
,
POINT
,
2
,
3
,
y
=
4
)
self
.
assertRaises
Regex
(
TypeError
,
"phi"
,
POINT
,
2
,
3
,
phi
=
4
)
self
.
assertRaises
Regex
(
TypeError
,
"rho"
,
POINT
,
2
,
3
,
rho
=
4
)
# too many initializers
self
.
assertRaises
(
TypeError
,
POINT
,
2
,
3
,
4
)
...
...
Modules/_ctypes/_ctypes.c
View file @
d91e676f
...
...
@@ -4065,14 +4065,9 @@ _init_pos_args(PyObject *self, PyTypeObject *type,
}
val
=
PyTuple_GET_ITEM
(
args
,
i
+
index
);
if
(
kwds
&&
PyDict_GetItem
(
kwds
,
name
))
{
char
*
field
=
PyBytes_AsString
(
name
);
if
(
field
==
NULL
)
{
PyErr_Clear
();
field
=
"???"
;
}
PyErr_Format
(
PyExc_TypeError
,
"duplicate values for field
'%s'
"
,
field
);
"duplicate values for field
%R
"
,
name
);
Py_DECREF
(
pair
);
Py_DECREF
(
name
);
return
-
1
;
...
...
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