https://github.com/python/cpython/commit/d7b60c8da1b1caef5acb44a7dcc591d84511c827 commit: d7b60c8da1b1caef5acb44a7dcc591d84511c827 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: StanFromIreland <[email protected]> date: 2026-11-14T10:38:20Z summary:
[3.15] gh-101703: Use `PyOS_snprintf` in `_datetimemodule.c` (GH-161982) (#161992) (cherry picked from commit 1d6419572978146dd52dbf9fd9521a084ba1cd6c) Co-authored-by: sobolevn <[email protected]> files: M Modules/_datetimemodule.c diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b5e43eebc3b013..23eec54cb6c182 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]
