mirror of
https://github.com/python/cpython.git
synced 2025-09-28 11:15:17 +00:00
time: fix gcc warning
* Create format_arg variable to use the right types * Strip trailing spaces
This commit is contained in:
parent
4726e40e00
commit
ef12810f0c
1 changed files with 28 additions and 27 deletions
|
@ -472,6 +472,7 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
#else
|
#else
|
||||||
PyObject *format;
|
PyObject *format;
|
||||||
#endif
|
#endif
|
||||||
|
PyObject *format_arg;
|
||||||
size_t fmtlen, buflen;
|
size_t fmtlen, buflen;
|
||||||
time_char *outbuf = NULL;
|
time_char *outbuf = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -482,7 +483,7 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
/* Will always expect a unicode string to be passed as format.
|
/* Will always expect a unicode string to be passed as format.
|
||||||
Given that there's no str type anymore in py3k this seems safe.
|
Given that there's no str type anymore in py3k this seems safe.
|
||||||
*/
|
*/
|
||||||
if (!PyArg_ParseTuple(args, "U|O:strftime", &format, &tup))
|
if (!PyArg_ParseTuple(args, "U|O:strftime", &format_arg, &tup))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (tup == NULL) {
|
if (tup == NULL) {
|
||||||
|
@ -501,13 +502,13 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
buf.tm_isdst = 1;
|
buf.tm_isdst = 1;
|
||||||
|
|
||||||
#ifdef HAVE_WCSFTIME
|
#ifdef HAVE_WCSFTIME
|
||||||
format = PyUnicode_AsWideCharString((PyUnicodeObject*)format, NULL);
|
format = PyUnicode_AsWideCharString((PyUnicodeObject*)format_arg, NULL);
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
fmt = format;
|
fmt = format;
|
||||||
#else
|
#else
|
||||||
/* Convert the unicode string to an ascii one */
|
/* Convert the unicode string to an ascii one */
|
||||||
format = PyUnicode_AsEncodedString(format, TZNAME_ENCODING, NULL);
|
format = PyUnicode_AsEncodedString(format_arg, TZNAME_ENCODING, NULL);
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
fmt = PyBytes_AS_STRING(format);
|
fmt = PyBytes_AS_STRING(format);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue