@@ -813,9 +813,7 @@ time_strftime1(time_char **outbuf, size_t *bufsize,
813
813
/* I hate these functions that presume you know how big the output
814
814
* will be ahead of time...
815
815
*/
816
- int attempts = 0 ;
817
816
while (1 ) {
818
- attempts ++ ;
819
817
if (* bufsize > PY_SSIZE_T_MAX /sizeof (time_char )) {
820
818
PyErr_NoMemory ();
821
819
return NULL ;
@@ -851,13 +849,15 @@ time_strftime1(time_char **outbuf, size_t *bufsize,
851
849
return NULL ;
852
850
}
853
851
if (* bufsize >= 256 * fmtlen ) {
854
- /* If the buffer is 256 times as long as the format, it's probably not
855
- failing for lack of room! More likely, `format_time` doesn't like the
856
- format string. For instance we end up here with musl if the format
857
- string ends with a '%'.
852
+ /* If the buffer is 256 times as long as the format, it's probably
853
+ not failing for lack of room! More likely, `format_time` doesn't
854
+ like the format string. For instance we end up here with musl if
855
+ the format string ends with a '%'.
856
+
857
+ Ideally we should raise ValueError("Invalid format string")
858
+ here. For backwards compatibility, return empty string instead.
858
859
*/
859
- PyErr_Format (PyExc_ValueError , "Invalid format string attempts: %d *outbuf: '%.8s'" , attempts , * outbuf );
860
- return NULL ;
860
+ return PyUnicode_FromStringAndSize (NULL , 0 );
861
861
}
862
862
* bufsize += * bufsize ;
863
863
}
0 commit comments