|
| 1 | +Index: python-dmidecode-3.12.3/src/dmidecodemodule.c |
| 2 | +=================================================================== |
| 3 | +--- python-dmidecode-3.12.3.orig/src/dmidecodemodule.c |
| 4 | ++++ python-dmidecode-3.12.3/src/dmidecodemodule.c |
| 5 | +@@ -54,13 +54,13 @@ |
| 6 | + #include <mcheck.h> |
| 7 | + |
| 8 | + #if (PY_VERSION_HEX < 0x03030000) |
| 9 | +-char *PyUnicode_AsUTF8(PyObject *unicode) { |
| 10 | ++const char *PyUnicode_AsUTF8(PyObject *unicode) { |
| 11 | + PyObject *as_bytes = PyUnicode_AsUTF8String(unicode); |
| 12 | + if (!as_bytes) { |
| 13 | + return NULL; |
| 14 | + } |
| 15 | + |
| 16 | +- return PyBytes_AsString(as_bytes); |
| 17 | ++ return (const char*)PyBytes_AsString(as_bytes); |
| 18 | + } |
| 19 | + #endif |
| 20 | + |
| 21 | +@@ -479,7 +479,7 @@ xmlNode *__dmidecode_xml_getsection(opti |
| 22 | + if(opt->type == -1) { |
| 23 | + char *err = log_retrieve(opt->logdata, LOG_ERR); |
| 24 | + log_clear_partial(opt->logdata, LOG_ERR, 0); |
| 25 | +- _pyReturnError(PyExc_RuntimeError, "Invalid type id '%s' -- %s", typeid, err); |
| 26 | ++ PyReturnError(PyExc_RuntimeError, "Invalid type id '%s' -- %s", typeid, err); |
| 27 | + free(err); |
| 28 | + return NULL; |
| 29 | + } |
| 30 | +@@ -657,7 +657,7 @@ static PyObject *dmidecode_get_slot(PyOb |
| 31 | + |
| 32 | + static PyObject *dmidecode_get_section(PyObject *self, PyObject *args) |
| 33 | + { |
| 34 | +- char *section = NULL; |
| 35 | ++ const char *section = NULL; |
| 36 | + if (PyUnicode_Check(args)) { |
| 37 | + section = PyUnicode_AsUTF8(args); |
| 38 | + } else if (PyBytes_Check(args)) { |
| 39 | +@@ -788,7 +788,7 @@ static PyObject *dmidecode_get_dev(PyObj |
| 40 | + |
| 41 | + static PyObject *dmidecode_set_dev(PyObject * self, PyObject * arg) |
| 42 | + { |
| 43 | +- char *f = NULL; |
| 44 | ++ const char *f = NULL; |
| 45 | + if(PyUnicode_Check(arg)) { |
| 46 | + f = PyUnicode_AsUTF8(arg); |
| 47 | + } else if(PyBytes_Check(arg)) { |
| 48 | +@@ -835,7 +835,7 @@ static PyObject *dmidecode_set_dev(PyObj |
| 49 | + |
| 50 | + static PyObject *dmidecode_set_pythonxmlmap(PyObject * self, PyObject * arg) |
| 51 | + { |
| 52 | +- char *fname = NULL; |
| 53 | ++ const char *fname = NULL; |
| 54 | + |
| 55 | + if (PyUnicode_Check(arg)) { |
| 56 | + fname = PyUnicode_AsUTF8(arg); |
| 57 | +@@ -913,7 +913,7 @@ static PyMethodDef DMIDataMethods[] = { |
| 58 | + {(char *)"pythonmap", dmidecode_set_pythonxmlmap, METH_O, |
| 59 | + (char *) "Use another python dict map definition. The default file is " PYTHON_XML_MAP}, |
| 60 | + |
| 61 | +- {(char *)"xmlapi", dmidecode_xmlapi, METH_VARARGS | METH_KEYWORDS, |
| 62 | ++ {(char *)"xmlapi", (PyCFunction)dmidecode_xmlapi, METH_VARARGS | METH_KEYWORDS, |
| 63 | + (char *) "Internal API for retrieving data as raw XML data"}, |
| 64 | + |
| 65 | + |
| 66 | +@@ -1024,7 +1024,7 @@ initdmidecodemod(void) |
| 67 | + // Assign this options struct to the module as well with a destructor, that way it will |
| 68 | + // clean up the memory for us. |
| 69 | + // TODO: destructor has wrong type under py3? |
| 70 | +- PyModule_AddObject(module, "options", PyCapsule_New(opt, NULL, destruct_options)); |
| 71 | ++ PyModule_AddObject(module, "options", PyCapsule_New(opt, NULL, (PyCapsule_Destructor)destruct_options)); |
| 72 | + global_options = opt; |
| 73 | + #ifdef IS_PY3K |
| 74 | + return module; |
0 commit comments