@@ -362,18 +362,18 @@ _range_error(_structmodulestate *state, const formatdef *f, int is_unsigned, Py_
362362    assert (f -> size  >= 1  &&  f -> size  <= SIZEOF_SIZE_T );
363363    if  (is_unsigned )
364364        PyErr_Format (state -> StructError ,
365-             "'%c' format requires 0 <= arg %zd  <= %zu" ,
365+             "'%c' format requires 0 <= number  <= %zu (at item %zd) " ,
366366            f -> format ,
367-             loc ,
368-             ulargest );
367+             ulargest ,
368+             loc );
369369    else  {
370370        const  Py_ssize_t  largest  =  (Py_ssize_t )(ulargest  >> 1 );
371371        PyErr_Format (state -> StructError ,
372-             "'%c' format requires %zd <= arg  %zd <=  %zd" ,
372+             "'%c' format requires %zd <= number <=  %zd (at item  %zd) " ,
373373            f -> format ,
374374            ~ largest ,
375-             loc ,
376-             largest );
375+             largest ,
376+             loc );
377377    }
378378
379379    return  -1 ;
@@ -747,11 +747,11 @@ np_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
747747    if  (get_longlong (state , v , & x ) <  0 ) {
748748        if  (PyErr_ExceptionMatches (PyExc_OverflowError )) {
749749            PyErr_Format (state -> StructError ,
750-                          "'%c' format requires %lld <= arg %zd  <= %lld" ,
750+                          "'%c' format requires %lld <= number  <= %lld (at item %zd) " ,
751751                         f -> format ,
752752                         LLONG_MIN ,
753-                          state -> current_arg ,
754-                          LLONG_MAX );
753+                          LLONG_MAX ,
754+                          state -> current_arg );
755755        }
756756        return  -1 ;
757757    }
@@ -766,10 +766,10 @@ np_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
766766    if  (get_ulonglong (state , v , & x ) <  0 ) {
767767        if  (PyErr_ExceptionMatches (PyExc_OverflowError )) {
768768            PyErr_Format (state -> StructError ,
769-                          "'%c' format requires 0 <= arg %zd  <= %llu" ,
769+                          "'%c' format requires 0 <= number  <= %llu (at item %zd) " ,
770770                         f -> format ,
771-                          state -> current_arg ,
772-                          ULLONG_MAX );
771+                          ULLONG_MAX ,
772+                          state -> current_arg );
773773        }
774774        return  -1 ;
775775    }
@@ -1132,11 +1132,11 @@ bp_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
11321132    Py_DECREF (v );
11331133    if  (res  <  0 ) {
11341134        PyErr_Format (state -> StructError ,
1135-                      "'%c' format requires %lld <= arg %zd  <= %lld" ,
1135+                      "'%c' format requires %lld <= number  <= %lld (at item %zd) " ,
11361136                     f -> format ,
11371137                     LLONG_MIN ,
1138-                      state -> current_arg ,
1139-                      LLONG_MAX );
1138+                      LLONG_MAX ,
1139+                      state -> current_arg );
11401140        return  -1 ;
11411141    }
11421142    return  res ;
@@ -1158,10 +1158,10 @@ bp_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
11581158    Py_DECREF (v );
11591159    if  (res  <  0 ) {
11601160        PyErr_Format (state -> StructError ,
1161-                      "'%c' format requires 0 <= arg %zd  <= %llu" ,
1161+                      "'%c' format requires 0 <= number  <= %llu (at item %zd) " ,
11621162                     f -> format ,
1163-                      state -> current_arg ,
1164-                      ULLONG_MAX );
1163+                      ULLONG_MAX ,
1164+                      state -> current_arg );
11651165        return  -1 ;
11661166    }
11671167    return  res ;
@@ -1467,11 +1467,11 @@ lp_longlong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
14671467    Py_DECREF (v );
14681468    if  (res  <  0 ) {
14691469        PyErr_Format (state -> StructError ,
1470-                      "'%c' format requires %lld <= arg %zd  <= %lld" ,
1470+                      "'%c' format requires %lld <= number  <= %lld (at item %zd) " ,
14711471                     f -> format ,
14721472                     LLONG_MIN ,
1473-                      state -> current_arg ,
1474-                      LLONG_MAX );
1473+                      LLONG_MAX ,
1474+                      state -> current_arg );
14751475        return  -1 ;
14761476    }
14771477    return  res ;
@@ -1493,9 +1493,10 @@ lp_ulonglong(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
14931493    Py_DECREF (v );
14941494    if  (res  <  0 ) {
14951495        PyErr_Format (state -> StructError ,
1496-                      "'%c' format requires 0 <= number <= %llu" ,
1496+                      "'%c' format requires 0 <= number <= %llu (at item %zd) " ,
14971497                     f -> format ,
1498-                      ULLONG_MAX );
1498+                      ULLONG_MAX ,
1499+                      state -> current_arg );
14991500        return  -1 ;
15001501    }
15011502    return  res ;
0 commit comments