@@ -418,7 +418,8 @@ void unicode_dealloc(register PyUnicodeObject *unicode)
418418 }
419419}
420420
421- int PyUnicode_Resize (PyObject * * unicode , Py_ssize_t length )
421+ static
422+ int _PyUnicode_Resize (PyUnicodeObject * * unicode , Py_ssize_t length )
422423{
423424 register PyUnicodeObject * v ;
424425
@@ -427,7 +428,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
427428 PyErr_BadInternalCall ();
428429 return -1 ;
429430 }
430- v = ( PyUnicodeObject * ) * unicode ;
431+ v = * unicode ;
431432 if (v == NULL || !PyUnicode_Check (v ) || Py_REFCNT (v ) != 1 || length < 0 ) {
432433 PyErr_BadInternalCall ();
433434 return -1 ;
@@ -444,7 +445,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
444445 Py_UNICODE_COPY (w -> str , v -> str ,
445446 length < v -> length ? length : v -> length );
446447 Py_DECREF (* unicode );
447- * unicode = ( PyObject * ) w ;
448+ * unicode = w ;
448449 return 0 ;
449450 }
450451
@@ -453,9 +454,10 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
453454 return unicode_resize (v , length );
454455}
455456
456- /* Internal API for use in unicodeobject.c only ! */
457- #define _PyUnicode_Resize (unicodevar , length ) \
458- PyUnicode_Resize(((PyObject **)(unicodevar)), length)
457+ int PyUnicode_Resize (PyObject * * unicode , Py_ssize_t length )
458+ {
459+ return _PyUnicode_Resize ((PyUnicodeObject * * )unicode , length );
460+ }
459461
460462PyObject * PyUnicode_FromUnicode (const Py_UNICODE * u ,
461463 Py_ssize_t size )
@@ -989,7 +991,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
989991 PyObject_Free (callresults );
990992 if (abuffer )
991993 PyObject_Free (abuffer );
992- _PyUnicode_Resize (& string , s - PyUnicode_AS_UNICODE (string ));
994+ PyUnicode_Resize (& string , s - PyUnicode_AS_UNICODE (string ));
993995 return string ;
994996 fail :
995997 if (callresults ) {
@@ -1549,7 +1551,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler
15491551 const char * encoding , const char * reason ,
15501552 const char * * input , const char * * inend , Py_ssize_t * startinpos ,
15511553 Py_ssize_t * endinpos , PyObject * * exceptionObject , const char * * inptr ,
1552- PyObject * * output , Py_ssize_t * outpos , Py_UNICODE * * outptr )
1554+ PyUnicodeObject * * output , Py_ssize_t * outpos , Py_UNICODE * * outptr )
15531555{
15541556 static char * argparse = "O!n;decoding error handler must return (str, int) tuple" ;
15551557
@@ -1627,7 +1629,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler
16271629 if (requiredsize > outsize ) {
16281630 if (requiredsize < 2 * outsize )
16291631 requiredsize = 2 * outsize ;
1630- if (PyUnicode_Resize (output , requiredsize ) < 0 )
1632+ if (_PyUnicode_Resize (output , requiredsize ) < 0 )
16311633 goto onError ;
16321634 * outptr = PyUnicode_AS_UNICODE (* output ) + * outpos ;
16331635 }
@@ -1827,7 +1829,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
18271829 errors , & errorHandler ,
18281830 "utf7" , errmsg ,
18291831 & starts , & e , & startinpos , & endinpos , & exc , & s ,
1830- ( PyObject * * ) & unicode , & outpos , & p ))
1832+ & unicode , & outpos , & p ))
18311833 goto onError ;
18321834 }
18331835
@@ -1838,7 +1840,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
18381840 errors , & errorHandler ,
18391841 "utf7" , "unterminated shift sequence" ,
18401842 & starts , & e , & startinpos , & endinpos , & exc , & s ,
1841- ( PyObject * * ) & unicode , & outpos , & p ))
1843+ & unicode , & outpos , & p ))
18421844 goto onError ;
18431845 if (s < e )
18441846 goto restart ;
@@ -2166,7 +2168,7 @@ PyObject *PyUnicode_DecodeUTF8Stateful(const char *s,
21662168 errors , & errorHandler ,
21672169 "utf8" , errmsg ,
21682170 & starts , & e , & startinpos , & endinpos , & exc , & s ,
2169- ( PyObject * * ) & unicode , & outpos , & p ))
2171+ & unicode , & outpos , & p ))
21702172 goto onError ;
21712173 }
21722174 if (consumed )
@@ -2446,7 +2448,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
24462448 errors , & errorHandler ,
24472449 "utf32" , errmsg ,
24482450 & starts , (const char * * )& e , & startinpos , & endinpos , & exc , (const char * * )& q ,
2449- ( PyObject * * ) & unicode , & outpos , & p ))
2451+ & unicode , & outpos , & p ))
24502452 goto onError ;
24512453 }
24522454
@@ -2724,7 +2726,7 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
27242726 errors , & errorHandler ,
27252727 "utf16" , errmsg ,
27262728 & starts , (const char * * )& e , & startinpos , & endinpos , & exc , (const char * * )& q ,
2727- ( PyObject * * ) & unicode , & outpos , & p ))
2729+ & unicode , & outpos , & p ))
27282730 goto onError ;
27292731 }
27302732
@@ -2949,7 +2951,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
29492951 errors , & errorHandler ,
29502952 "unicodeescape" , "end of string in escape sequence" ,
29512953 & starts , & end , & startinpos , & endinpos , & exc , & s ,
2952- ( PyObject * * ) & v , & outpos , & p ))
2954+ & v , & outpos , & p ))
29532955 goto onError ;
29542956 goto nextByte ;
29552957 }
@@ -2961,7 +2963,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
29612963 errors , & errorHandler ,
29622964 "unicodeescape" , message ,
29632965 & starts , & end , & startinpos , & endinpos , & exc , & s ,
2964- ( PyObject * * ) & v , & outpos , & p ))
2966+ & v , & outpos , & p ))
29652967 goto onError ;
29662968 goto nextByte ;
29672969 }
@@ -3000,7 +3002,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
30003002 errors , & errorHandler ,
30013003 "unicodeescape" , "illegal Unicode character" ,
30023004 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3003- ( PyObject * * ) & v , & outpos , & p ))
3005+ & v , & outpos , & p ))
30043006 goto onError ;
30053007 }
30063008 break ;
@@ -3042,7 +3044,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
30423044 errors , & errorHandler ,
30433045 "unicodeescape" , message ,
30443046 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3045- ( PyObject * * ) & v , & outpos , & p ))
3047+ & v , & outpos , & p ))
30463048 goto onError ;
30473049 break ;
30483050
@@ -3056,7 +3058,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
30563058 errors , & errorHandler ,
30573059 "unicodeescape" , message ,
30583060 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3059- ( PyObject * * ) & v , & outpos , & p ))
3061+ & v , & outpos , & p ))
30603062 goto onError ;
30613063 }
30623064 else {
@@ -3339,7 +3341,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s,
33393341 errors , & errorHandler ,
33403342 "rawunicodeescape" , "truncated \\uXXXX" ,
33413343 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3342- ( PyObject * * ) & v , & outpos , & p ))
3344+ & v , & outpos , & p ))
33433345 goto onError ;
33443346 goto nextByte ;
33453347 }
@@ -3371,7 +3373,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s,
33713373 errors , & errorHandler ,
33723374 "rawunicodeescape" , "\\Uxxxxxxxx out of range" ,
33733375 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3374- ( PyObject * * ) & v , & outpos , & p ))
3376+ & v , & outpos , & p ))
33753377 goto onError ;
33763378 }
33773379 nextByte :
@@ -3551,7 +3553,7 @@ PyObject *_PyUnicode_DecodeUnicodeInternal(const char *s,
35513553 errors , & errorHandler ,
35523554 "unicode_internal" , reason ,
35533555 & starts , & end , & startinpos , & endinpos , & exc , & s ,
3554- ( PyObject * * ) & v , & outpos , & p )) {
3556+ & v , & outpos , & p )) {
35553557 goto onError ;
35563558 }
35573559 }
@@ -3924,7 +3926,7 @@ PyObject *PyUnicode_DecodeASCII(const char *s,
39243926 errors , & errorHandler ,
39253927 "ascii" , "ordinal not in range(128)" ,
39263928 & starts , & e , & startinpos , & endinpos , & exc , & s ,
3927- ( PyObject * * ) & v , & outpos , & p ))
3929+ & v , & outpos , & p ))
39283930 goto onError ;
39293931 }
39303932 }
@@ -4225,7 +4227,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s,
42254227 errors , & errorHandler ,
42264228 "charmap" , "character maps to <undefined>" ,
42274229 & starts , & e , & startinpos , & endinpos , & exc , & s ,
4228- ( PyObject * * ) & v , & outpos , & p )) {
4230+ & v , & outpos , & p )) {
42294231 goto onError ;
42304232 }
42314233 continue ;
@@ -4275,7 +4277,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s,
42754277 errors , & errorHandler ,
42764278 "charmap" , "character maps to <undefined>" ,
42774279 & starts , & e , & startinpos , & endinpos , & exc , & s ,
4278- ( PyObject * * ) & v , & outpos , & p )) {
4280+ & v , & outpos , & p )) {
42794281 Py_DECREF (x );
42804282 goto onError ;
42814283 }
@@ -5025,7 +5027,7 @@ int charmaptranslate_makespace(PyObject **outobj, Py_UNICODE **outp,
50255027 /* exponentially overallocate to minimize reallocations */
50265028 if (requiredsize < 2 * oldsize )
50275029 requiredsize = 2 * oldsize ;
5028- if (_PyUnicode_Resize (outobj , requiredsize ) < 0 )
5030+ if (PyUnicode_Resize (outobj , requiredsize ) < 0 )
50295031 return -1 ;
50305032 * outp = PyUnicode_AS_UNICODE (* outobj ) + outpos ;
50315033 }
@@ -5204,7 +5206,7 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p,
52045206 /* Resize if we allocated to much */
52055207 respos = str - PyUnicode_AS_UNICODE (res );
52065208 if (respos < PyUnicode_GET_SIZE (res )) {
5207- if (_PyUnicode_Resize (& res , respos ) < 0 )
5209+ if (PyUnicode_Resize (& res , respos ) < 0 )
52085210 goto onError ;
52095211 }
52105212 Py_XDECREF (exc );
@@ -7743,7 +7745,7 @@ PyObject *unicode_repr(PyObject *unicode)
77437745 * p ++ = PyUnicode_AS_UNICODE (repr )[0 ];
77447746
77457747 * p = '\0' ;
7746- _PyUnicode_Resize (& repr , p - PyUnicode_AS_UNICODE (repr ));
7748+ PyUnicode_Resize (& repr , p - PyUnicode_AS_UNICODE (repr ));
77477749 return repr ;
77487750}
77497751
0 commit comments