diff -r ab4432daf69f Modules/_struct.c --- a/Modules/_struct.c Mon Oct 22 21:50:27 2012 -0700 +++ b/Modules/_struct.c Wed Oct 24 09:15:30 2012 +0300 @@ -1661,7 +1661,7 @@ 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; } @@ -1700,9 +1700,19 @@ 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; }