Skip to content

Commit 81e12cd

Browse files
committed
Restore backwards compatibility
1 parent ca016d7 commit 81e12cd

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Lib/unittest/case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ def _callCleanup(self, function, /, *args, **kwargs):
623623
function(*args, **kwargs)
624624

625625
def run(self, result=None):
626+
print(self._testMethodName)
626627
if result is None:
627628
result = self.defaultTestResult()
628629
startTestRun = getattr(result, 'startTestRun', None)

Modules/timemodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,7 @@ time_strftime1(time_char **outbuf, size_t *bufsize,
813813
/* I hate these functions that presume you know how big the output
814814
* will be ahead of time...
815815
*/
816-
int attempts = 0;
817816
while (1) {
818-
attempts ++;
819817
if (*bufsize > PY_SSIZE_T_MAX/sizeof(time_char)) {
820818
PyErr_NoMemory();
821819
return NULL;
@@ -851,13 +849,15 @@ time_strftime1(time_char **outbuf, size_t *bufsize,
851849
return NULL;
852850
}
853851
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.
858859
*/
859-
PyErr_Format(PyExc_ValueError, "Invalid format string attempts: %d *outbuf: '%.8s'", attempts, *outbuf);
860-
return NULL;
860+
return PyUnicode_FromStringAndSize(NULL, 0);
861861
}
862862
*bufsize += *bufsize;
863863
}

0 commit comments

Comments
 (0)