diff -r c10ea224392d Lib/test/test_struct.py --- a/Lib/test/test_struct.py Sat Dec 14 20:34:33 2013 +0200 +++ b/Lib/test/test_struct.py Sun Dec 15 17:25:31 2013 +0800 @@ -585,6 +585,13 @@ self.assertIs(type(s.format), str) self.assertRaises(ValueError, struct.Struct, unichr(0x80)) + def test_invalid_argument(self): + with self.assertRaises(TypeError) as cx: + struct.Struct(1) + self.assertEqual(str(cx.exception), + "Struct() argument 1 must be string or unicode, not " + "int") + def test_main(): support.run_unittest(StructTest) diff -r c10ea224392d Modules/_struct.c --- a/Modules/_struct.c Sat Dec 14 20:34:33 2013 +0200 +++ b/Modules/_struct.c Sun Dec 15 17:25:31 2013 +0800 @@ -1389,7 +1389,7 @@ } else { PyErr_Format(PyExc_TypeError, - "Struct() argument 1 must be string, not %s", + "Struct() argument 1 must be string or unicode, not %s", Py_TYPE(o_format)->tp_name); return -1; }