diff -r 7efe1a5239e3 Lib/ctypes/test/test_structures.py --- a/Lib/ctypes/test/test_structures.py Fri Jun 17 11:13:03 2016 +0300 +++ b/Lib/ctypes/test/test_structures.py Fri Jun 17 11:29:21 2016 +0300 @@ -227,10 +227,10 @@ class StructureTestCase(unittest.TestCas def test_conflicting_initializers(self): class POINT(Structure): - _fields_ = [("x", c_int), ("y", c_int)] + _fields_ = [("x", c_int), ("ÿ", c_int)] # conflicting positional and keyword args self.assertRaises(TypeError, POINT, 2, 3, x=4) - self.assertRaises(TypeError, POINT, 2, 3, y=4) + self.assertRaisesRegex(TypeError, "ÿ", POINT, 2, 3, ÿ=4) # too many initializers self.assertRaises(TypeError, POINT, 2, 3, 4) diff -r 7efe1a5239e3 Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Fri Jun 17 11:13:03 2016 +0300 +++ b/Modules/_ctypes/_ctypes.c Fri Jun 17 11:29:21 2016 +0300 @@ -4065,14 +4065,9 @@ static Py_ssize_t } 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;