@@ -172,8 +172,8 @@ extern "C" {
172172#define _PyUnicode_CONVERT_BYTES (from_type , to_type , begin , end , to ) \
173173 do { \
174174 to_type *_to = (to_type *)(to); \
175- const from_type *_iter = (from_type *)(begin); \
176- const from_type *_end = (from_type *)(end); \
175+ const from_type *_iter = (const from_type *)(begin);\
176+ const from_type *_end = (const from_type *)(end);\
177177 Py_ssize_t n = (_end) - (_iter); \
178178 const from_type *_unrolled_end = \
179179 _iter + _Py_SIZE_ROUND_DOWN(n, 4); \
@@ -964,21 +964,21 @@ findchar(const void *s, int kind,
964964 if ((Py_UCS1 ) ch != ch )
965965 return -1 ;
966966 if (direction > 0 )
967- return ucs1lib_find_char ((Py_UCS1 * ) s , size , (Py_UCS1 ) ch );
967+ return ucs1lib_find_char ((const Py_UCS1 * ) s , size , (Py_UCS1 ) ch );
968968 else
969- return ucs1lib_rfind_char ((Py_UCS1 * ) s , size , (Py_UCS1 ) ch );
969+ return ucs1lib_rfind_char ((const Py_UCS1 * ) s , size , (Py_UCS1 ) ch );
970970 case PyUnicode_2BYTE_KIND :
971971 if ((Py_UCS2 ) ch != ch )
972972 return -1 ;
973973 if (direction > 0 )
974- return ucs2lib_find_char ((Py_UCS2 * ) s , size , (Py_UCS2 ) ch );
974+ return ucs2lib_find_char ((const Py_UCS2 * ) s , size , (Py_UCS2 ) ch );
975975 else
976- return ucs2lib_rfind_char ((Py_UCS2 * ) s , size , (Py_UCS2 ) ch );
976+ return ucs2lib_rfind_char ((const Py_UCS2 * ) s , size , (Py_UCS2 ) ch );
977977 case PyUnicode_4BYTE_KIND :
978978 if (direction > 0 )
979- return ucs4lib_find_char ((Py_UCS4 * ) s , size , ch );
979+ return ucs4lib_find_char ((const Py_UCS4 * ) s , size , ch );
980980 else
981- return ucs4lib_rfind_char ((Py_UCS4 * ) s , size , ch );
981+ return ucs4lib_rfind_char ((const Py_UCS4 * ) s , size , ch );
982982 default :
983983 Py_UNREACHABLE ();
984984 }
@@ -3420,7 +3420,7 @@ PyUnicode_Decode(const char *s,
34203420
34213421 /* Decode via the codec registry */
34223422 buffer = NULL;
3423- if (PyBuffer_FillInfo (& info , NULL , (void * )s , size , 1 , PyBUF_FULL_RO ) < 0 )
3423+ if (PyBuffer_FillInfo (& info , NULL , (const void * )s , size , 1 , PyBUF_FULL_RO ) < 0 )
34243424 goto onError ;
34253425 buffer = PyMemoryView_FromBuffer (& info );
34263426 if (buffer == NULL)
@@ -4921,7 +4921,7 @@ ascii_decode(const char *start, const char *end, Py_UCS1 *dest)
49214921 /* Help allocation */
49224922 const char * _p = p ;
49234923 while (_p < aligned_end ) {
4924- unsigned long value = * (unsigned long * ) _p ;
4924+ unsigned long value = * (const unsigned long * ) _p ;
49254925 if (value & ASCII_CHAR_MASK )
49264926 break ;
49274927 _p += SIZEOF_LONG ;
@@ -5472,7 +5472,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
54725472 PyObject * errorHandler = NULL ;
54735473 PyObject * exc = NULL ;
54745474
5475- q = (unsigned char * )s ;
5475+ q = (const unsigned char * )s ;
54765476 e = q + size ;
54775477
54785478 if (byteorder )
@@ -5797,7 +5797,7 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
57975797 PyObject * exc = NULL ;
57985798 const char * encoding ;
57995799
5800- q = (unsigned char * )s ;
5800+ q = (const unsigned char * )s ;
58015801 e = q + size ;
58025802
58035803 if (byteorder )
@@ -6726,7 +6726,7 @@ PyUnicode_DecodeLatin1(const char *s,
67266726 const char * errors )
67276727{
67286728 /* Latin-1 is equivalent to the first 256 ordinals in Unicode. */
6729- return _PyUnicode_FromUCS1 ((unsigned char * )s , size );
6729+ return _PyUnicode_FromUCS1 ((const unsigned char * )s , size );
67306730}
67316731
67326732/* create or adjust a UnicodeEncodeError */
@@ -13803,7 +13803,7 @@ _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
1380313803 if (len == -1 )
1380413804 len = strlen (ascii );
1380513805
13806- assert (ucs1lib_find_max_char ((Py_UCS1 * )ascii , (Py_UCS1 * )ascii + len ) < 128 );
13806+ assert (ucs1lib_find_max_char ((const Py_UCS1 * )ascii , (const Py_UCS1 * )ascii + len ) < 128 );
1380713807
1380813808 if (writer -> buffer == NULL && !writer -> overallocate ) {
1380913809 PyObject * str ;
@@ -13862,7 +13862,7 @@ _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
1386213862{
1386313863 Py_UCS4 maxchar ;
1386413864
13865- maxchar = ucs1lib_find_max_char ((Py_UCS1 * )str , (Py_UCS1 * )str + len );
13865+ maxchar = ucs1lib_find_max_char ((const Py_UCS1 * )str , (const Py_UCS1 * )str + len );
1386613866 if (_PyUnicodeWriter_Prepare (writer , len , maxchar ) == -1 )
1386713867 return -1 ;
1386813868 unicode_write_cstr (writer -> buffer , writer -> pos , str , len );
0 commit comments