https://github.com/python/cpython/commit/1d6419572978146dd52dbf9fd9521a084ba1cd6c
commit: 1d6419572978146dd52dbf9fd9521a084ba1cd6c
branch: main
author: sobolevn <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-11-14T09:55:25Z
summary:
gh-101703: Use `PyOS_snprintf` in `_datetimemodule.c` (#161982)
files:
M Modules/_datetimemodule.c
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index b9939d5cc71a31..091da059afd34b 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1870,12 +1870,17 @@ static PyObject *
make_freplacement(PyObject *object)
{
char freplacement[64];
- if (PyTime_Check(object))
- sprintf(freplacement, "%06d", TIME_GET_MICROSECOND(object));
- else if (PyDateTime_Check(object))
- sprintf(freplacement, "%06d", DATE_GET_MICROSECOND(object));
- else
- sprintf(freplacement, "%06d", 0);
+ if (PyTime_Check(object)) {
+ PyOS_snprintf(freplacement, sizeof(freplacement),
+ "%06d", TIME_GET_MICROSECOND(object));
+ }
+ else if (PyDateTime_Check(object)) {
+ PyOS_snprintf(freplacement, sizeof(freplacement),
+ "%06d", DATE_GET_MICROSECOND(object));
+ }
+ else {
+ PyOS_snprintf(freplacement, sizeof(freplacement), "%06d", 0);
+ }
return PyUnicode_FromString(freplacement);
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]