@@ -1849,9 +1849,10 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
1849
1849
* is expensive, don't unless they're actually used.
1850
1850
*/
1851
1851
1852
- _PyUnicodeWriter writer ;
1853
- _PyUnicodeWriter_Init (& writer );
1854
- writer .overallocate = 1 ;
1852
+ PyUnicodeWriter * writer = PyUnicodeWriter_Create (0 );
1853
+ if (writer == NULL ) {
1854
+ goto Error ;
1855
+ }
1855
1856
1856
1857
Py_ssize_t flen = PyUnicode_GET_LENGTH (format );
1857
1858
Py_ssize_t i = 0 ;
@@ -1955,11 +1956,11 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
1955
1956
if (ch == 'C' ) {
1956
1957
n -= 2 ;
1957
1958
}
1958
- if (_PyUnicodeWriter_WriteSubstring ( & writer , format , start , end ) < 0 ) {
1959
+ if (PyUnicodeWriter_WriteSubstring ( writer , format , start , end ) < 0 ) {
1959
1960
goto Error ;
1960
1961
}
1961
1962
start = i ;
1962
- if (_PyUnicodeWriter_WriteASCIIString ( & writer , buf , n ) < 0 ) {
1963
+ if (PyUnicodeWriter_WriteUTF8 ( writer , buf , n ) < 0 ) {
1963
1964
goto Error ;
1964
1965
}
1965
1966
continue ;
@@ -1971,25 +1972,25 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
1971
1972
}
1972
1973
assert (replacement != NULL );
1973
1974
assert (PyUnicode_Check (replacement ));
1974
- if (_PyUnicodeWriter_WriteSubstring ( & writer , format , start , end ) < 0 ) {
1975
+ if (PyUnicodeWriter_WriteSubstring ( writer , format , start , end ) < 0 ) {
1975
1976
goto Error ;
1976
1977
}
1977
1978
start = i ;
1978
- if (_PyUnicodeWriter_WriteStr ( & writer , replacement ) < 0 ) {
1979
+ if (PyUnicodeWriter_WriteStr ( writer , replacement ) < 0 ) {
1979
1980
goto Error ;
1980
1981
}
1981
1982
} /* end while() */
1982
1983
1983
1984
PyObject * newformat ;
1984
1985
if (start == 0 ) {
1985
- _PyUnicodeWriter_Dealloc ( & writer );
1986
+ PyUnicodeWriter_Discard ( writer );
1986
1987
newformat = Py_NewRef (format );
1987
1988
}
1988
1989
else {
1989
- if (_PyUnicodeWriter_WriteSubstring ( & writer , format , start , flen ) < 0 ) {
1990
+ if (PyUnicodeWriter_WriteSubstring ( writer , format , start , flen ) < 0 ) {
1990
1991
goto Error ;
1991
1992
}
1992
- newformat = _PyUnicodeWriter_Finish ( & writer );
1993
+ newformat = PyUnicodeWriter_Finish ( writer );
1993
1994
if (newformat == NULL ) {
1994
1995
goto Done ;
1995
1996
}
@@ -2007,7 +2008,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
2007
2008
return result ;
2008
2009
2009
2010
Error :
2010
- _PyUnicodeWriter_Dealloc ( & writer );
2011
+ PyUnicodeWriter_Discard ( writer );
2011
2012
goto Done ;
2012
2013
}
2013
2014
0 commit comments