]> granicus.if.org Git - python/commitdiff
timemodule.c: Cast PyUnicode_AsUTF8() to char* (#1294)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 26 Apr 2017 11:51:48 +0000 (13:51 +0200)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2017 11:51:48 +0000 (13:51 +0200)
bpo-28769 changed PyUnicode_AsUTF8() return type from const char* to
char* in Python 3.7, but tm_zone field type of the tm structure is
char* on FreeBSD.

Cast PyUnicode_AsUTF8() to char* in gettmarg() to fix the warning:

    Modules/timemodule.c:443:20: warning: assigning to 'char *'
    from 'const char *' discards qualifiers

Modules/timemodule.c

index 32062a3a6a7f7b7e36f453706af71191bc7423bb..15c467b9b4074ebfb5fc4699bbbbf6cff5dca4b5 100644 (file)
@@ -440,7 +440,7 @@ gettmarg(PyObject *args, struct tm *p)
     if (Py_TYPE(args) == &StructTimeType) {
         PyObject *item;
         item = PyTuple_GET_ITEM(args, 9);
-        p->tm_zone = item == Py_None ? NULL : PyUnicode_AsUTF8(item);
+        p->tm_zone = item == Py_None ? NULL : (char*)PyUnicode_AsUTF8(item);
         item = PyTuple_GET_ITEM(args, 10);
         p->tm_gmtoff = item == Py_None ? 0 : PyLong_AsLong(item);
         if (PyErr_Occurred())