From: Ralph Bean Date: Mon, 16 Nov 2015 03:51:02 +0000 (-0500) Subject: Treat strings as explicit byte strings. X-Git-Tag: upstream/0.10.0~20^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b928b7cf1e30d5a56d229459a4869db3008c62a;p=services%2Fcreaterepo_c.git Treat strings as explicit byte strings. --- diff --git a/src/python/checksum-py.c b/src/python/checksum-py.c index 7c3cb56..cff92a1 100644 --- a/src/python/checksum-py.c +++ b/src/python/checksum-py.c @@ -34,7 +34,7 @@ py_checksum_name_str(G_GNUC_UNUSED PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:py_checksum_name_Str", &type)) return NULL; - return PyStringOrNone_FromString(cr_checksum_name_str(type)); + return PyBytesOrNone_FromString(cr_checksum_name_str(type)); } PyObject * diff --git a/src/python/compression_wrapper-py.c b/src/python/compression_wrapper-py.c index fec802a..2598121 100644 --- a/src/python/compression_wrapper-py.c +++ b/src/python/compression_wrapper-py.c @@ -38,7 +38,7 @@ py_compression_suffix(G_GNUC_UNUSED PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:py_compression_suffix", &type)) return NULL; - return PyStringOrNone_FromString(cr_compression_suffix(type)); + return PyBytesOrNone_FromString(cr_compression_suffix(type)); } PyObject * @@ -192,7 +192,7 @@ crfile_repr(_CrFileObject *self) mode = "Unknown mode"; } - return PyString_FromFormat("", mode); + return PyBytes_FromFormat("", mode); } /* CrFile methods */ diff --git a/src/python/contentstat-py.c b/src/python/contentstat-py.c index d947620..1883aac 100644 --- a/src/python/contentstat-py.c +++ b/src/python/contentstat-py.c @@ -106,7 +106,7 @@ contentstat_dealloc(_ContentStatObject *self) static PyObject * contentstat_repr(G_GNUC_UNUSED _ContentStatObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* getsetters */ @@ -142,7 +142,7 @@ get_str(_ContentStatObject *self, void *member_offset) char *str = *((char **) ((size_t) rec + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static int @@ -196,7 +196,7 @@ set_str(_ContentStatObject *self, PyObject *value, void *member_offset) { if (check_ContentStatStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/load_metadata-py.c b/src/python/load_metadata-py.c index 7fcc0e0..fc9a272 100644 --- a/src/python/load_metadata-py.c +++ b/src/python/load_metadata-py.c @@ -111,7 +111,7 @@ metadata_dealloc(_MetadataObject *self) static PyObject * metadata_repr(G_GNUC_UNUSED _MetadataObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* Getters */ @@ -256,7 +256,7 @@ ht_keys(_MetadataObject *self, G_GNUC_UNUSED PyObject *args) PyObject *list = PyList_New(0); for (GList *elem = keys; elem; elem = g_list_next(elem)) { - PyObject *py_str = PyString_FromString(elem->data); + PyObject *py_str = PyBytes_FromString(elem->data); assert(py_str); if (PyList_Append(list, py_str) == -1) { Py_XDECREF(list); diff --git a/src/python/locate_metadata-py.c b/src/python/locate_metadata-py.c index e69eab3..ba3e6f0 100644 --- a/src/python/locate_metadata-py.c +++ b/src/python/locate_metadata-py.c @@ -109,7 +109,7 @@ metadatalocation_dealloc(_MetadataLocationObject *self) static PyObject * metadatalocation_repr(G_GNUC_UNUSED _MetadataLocationObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* MetadataLocation methods */ @@ -136,12 +136,12 @@ getitem(_MetadataLocationObject *self, PyObject *pykey) if (check_MetadataLocationStatus(self)) return NULL; - if (!PyString_Check(pykey)) { + if (!PyBytes_Check(pykey)) { PyErr_SetString(PyExc_TypeError, "String expected!"); return NULL; } - key = PyString_AsString(pykey); + key = PyBytes_AsString(pykey); value = NULL; if (!strcmp(key, "primary")) { @@ -165,7 +165,7 @@ getitem(_MetadataLocationObject *self, PyObject *pykey) } if (value) - return PyString_FromString(value); + return PyBytes_FromString(value); else Py_RETURN_NONE; } diff --git a/src/python/package-py.c b/src/python/package-py.c index 34a911d..eb6314b 100644 --- a/src/python/package-py.c +++ b/src/python/package-py.c @@ -148,11 +148,11 @@ package_repr(_PackageObject *self) cr_Package *pkg = self->package; PyObject *repr; if (pkg) { - repr = PyString_FromFormat("", + repr = PyBytes_FromFormat("", (pkg->pkgId ? pkg->pkgId : "-"), (pkg->name ? pkg->name : "-")); } else { - repr = PyString_FromFormat(""); + repr = PyBytes_FromFormat(""); } return repr; } @@ -165,10 +165,10 @@ package_str(_PackageObject *self) return NULL; if (self->package) { char *nevra = cr_package_nvra(self->package); - ret = PyString_FromString(nevra); + ret = PyBytes_FromString(nevra); free(nevra); } else { - ret = PyString_FromString("-"); + ret = PyBytes_FromString("-"); } return ret; } @@ -186,7 +186,7 @@ nvra(_PackageObject *self, G_GNUC_UNUSED void *nothing) if (check_PackageStatus(self)) return NULL; char *nvra = cr_package_nvra(self->package); - pystr = PyStringOrNone_FromString(nvra); + pystr = PyBytesOrNone_FromString(nvra); free(nvra); return pystr; } @@ -202,7 +202,7 @@ nevra(_PackageObject *self, G_GNUC_UNUSED void *nothing) if (check_PackageStatus(self)) return NULL; char *nevra = cr_package_nevra(self->package); - pystr = PyStringOrNone_FromString(nevra); + pystr = PyBytesOrNone_FromString(nevra); free(nevra); return pystr; } @@ -261,7 +261,7 @@ get_str(_PackageObject *self, void *member_offset) char *str = *((char **) ((size_t) pkg + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } /** Return offset of a selected member of cr_Package structure. */ @@ -395,7 +395,7 @@ set_str(_PackageObject *self, PyObject *value, void *member_offset) { if (check_PackageStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } @@ -416,7 +416,7 @@ set_str(_PackageObject *self, PyObject *value, void *member_offset) if (!pkg->chunk) pkg->chunk = g_string_chunk_new(0); - char *str = g_string_chunk_insert(pkg->chunk, PyString_AsString(value)); + char *str = g_string_chunk_insert(pkg->chunk, PyBytes_AsString(value)); *((char **) ((size_t) pkg + (size_t) member_offset)) = str; return 0; } diff --git a/src/python/parsepkg-py.c b/src/python/parsepkg-py.c index 73ec983..7ead059 100644 --- a/src/python/parsepkg-py.c +++ b/src/python/parsepkg-py.c @@ -87,9 +87,9 @@ py_xml_from_rpm(G_GNUC_UNUSED PyObject *self, PyObject *args) if ((tuple = PyTuple_New(3)) == NULL) goto py_xml_from_rpm_end; // Free xml_res and return NULL - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(xml_res.primary)); - PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(xml_res.filelists)); - PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(xml_res.other)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(xml_res.primary)); + PyTuple_SetItem(tuple, 1, PyBytesOrNone_FromString(xml_res.filelists)); + PyTuple_SetItem(tuple, 2, PyBytesOrNone_FromString(xml_res.other)); py_xml_from_rpm_end: free(xml_res.primary); diff --git a/src/python/repomd-py.c b/src/python/repomd-py.c index f90b4b8..1e21e68 100644 --- a/src/python/repomd-py.c +++ b/src/python/repomd-py.c @@ -101,7 +101,7 @@ repomd_dealloc(_RepomdObject *self) static PyObject * repomd_repr(G_GNUC_UNUSED _RepomdObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromString(""); } /* Repomd methods */ @@ -251,7 +251,7 @@ xml_dump(_RepomdObject *self, G_GNUC_UNUSED void *nothing) nice_exception(&tmp_err, NULL); return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } @@ -299,9 +299,9 @@ typedef int (*ConversionToCheckFunc)(PyObject *); typedef void *(*ConversionToFunc)(PyObject *, GStringChunk *); static int -CheckPyString(PyObject *dep) +CheckPyBytes(PyObject *dep) { - if (!PyString_Check(dep)) { + if (!PyBytes_Check(dep)) { PyErr_SetString(PyExc_TypeError, "Element of list has to be a string"); return 1; } @@ -334,16 +334,16 @@ typedef struct { /** List of convertors for converting a lists in cr_Package. */ static ListConvertor list_convertors[] = { { offsetof(cr_Repomd, repo_tags), - (ConversionFromFunc) PyStringOrNone_FromString, - (ConversionToCheckFunc) CheckPyString, + (ConversionFromFunc) PyBytesOrNone_FromString, + (ConversionToCheckFunc) CheckPyBytes, (ConversionToFunc) PyObject_ToChunkedString }, { offsetof(cr_Repomd, distro_tags), (ConversionFromFunc) PyObject_FromDistroTag, (ConversionToCheckFunc) CheckPyDistroTag, (ConversionToFunc) PyObject_ToDistroTag }, { offsetof(cr_Repomd, content_tags), - (ConversionFromFunc) PyStringOrNone_FromString, - (ConversionToCheckFunc) CheckPyString, + (ConversionFromFunc) PyBytesOrNone_FromString, + (ConversionToCheckFunc) CheckPyBytes, (ConversionToFunc) PyObject_ToChunkedString }, { offsetof(cr_Repomd, records), (ConversionFromFunc) PyObject_FromRepomdRecord, @@ -362,7 +362,7 @@ get_str(_RepomdObject *self, void *member_offset) char *str = *((char **) ((size_t) repomd + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static PyObject * @@ -396,7 +396,7 @@ set_str(_RepomdObject *self, PyObject *value, void *member_offset) { if (check_RepomdStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/repomdrecord-py.c b/src/python/repomdrecord-py.c index 778c90d..504fb0a 100644 --- a/src/python/repomdrecord-py.c +++ b/src/python/repomdrecord-py.c @@ -125,10 +125,10 @@ static PyObject * repomdrecord_repr(G_GNUC_UNUSED _RepomdRecordObject *self) { if (self->record->type) - return PyString_FromFormat("", + return PyBytes_FromFormat("", self->record->type); else - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* RepomdRecord methods */ @@ -296,7 +296,7 @@ get_str(_RepomdRecordObject *self, void *member_offset) char *str = *((char **) ((size_t) rec + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static int @@ -350,7 +350,7 @@ set_str(_RepomdRecordObject *self, PyObject *value, void *member_offset) { if (check_RepomdRecordStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/sqlite-py.c b/src/python/sqlite-py.c index eb45b80..06e9541 100644 --- a/src/python/sqlite-py.c +++ b/src/python/sqlite-py.c @@ -119,7 +119,7 @@ sqlite_repr(_SqliteObject *self) else if (self->db->type == CR_DB_FILELISTS) type = "FilelistsDb"; else if (self->db->type == CR_DB_OTHER) type = "OtherDb"; else type = "UnknownDb"; - return PyString_FromFormat("", type); + return PyBytes_FromFormat("", type); } /* Sqlite methods */ diff --git a/src/python/typeconversion.c b/src/python/typeconversion.c index 808b53d..2c4d474 100644 --- a/src/python/typeconversion.c +++ b/src/python/typeconversion.c @@ -50,26 +50,26 @@ PyErr_ToGError(GError **err) "Error while error handling"); } else { g_set_error(err, ERR_DOMAIN, CRE_XMLPARSER, - "%s", PyString_AsString(pystr)); + "%s", PyBytes_AsString(pystr)); } Py_XDECREF(pystr); } PyObject * -PyStringOrNone_FromString(const char *str) +PyBytesOrNone_FromString(const char *str) { if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } char * PyObject_ToStrOrNull(PyObject *pyobj) { // String returned by this function shoud not be freed or modified - if (PyString_Check(pyobj)) - return PyString_AsString(pyobj); + if (PyBytes_Check(pyobj)) + return PyBytes_AsString(pyobj); // TODO: ? Add support for pyobj like: ("xxx",) and ["xxx"] return NULL; } @@ -104,11 +104,11 @@ PyObject_FromDependency(cr_Dependency *dep) if ((tuple = PyTuple_New(6)) == NULL) return NULL; - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(dep->name)); - PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(dep->flags)); - PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(dep->epoch)); - PyTuple_SetItem(tuple, 3, PyStringOrNone_FromString(dep->version)); - PyTuple_SetItem(tuple, 4, PyStringOrNone_FromString(dep->release)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(dep->name)); + PyTuple_SetItem(tuple, 1, PyBytesOrNone_FromString(dep->flags)); + PyTuple_SetItem(tuple, 2, PyBytesOrNone_FromString(dep->epoch)); + PyTuple_SetItem(tuple, 3, PyBytesOrNone_FromString(dep->version)); + PyTuple_SetItem(tuple, 4, PyBytesOrNone_FromString(dep->release)); PyTuple_SetItem(tuple, 5, PyBool_FromLong((long) dep->pre)); return tuple; @@ -149,9 +149,9 @@ PyObject_FromPackageFile(cr_PackageFile *file) if ((tuple = PyTuple_New(3)) == NULL) return NULL; - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(file->type)); - PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(file->path)); - PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(file->name)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(file->type)); + PyTuple_SetItem(tuple, 1, PyBytesOrNone_FromString(file->path)); + PyTuple_SetItem(tuple, 2, PyBytesOrNone_FromString(file->name)); return tuple; } @@ -182,9 +182,9 @@ PyObject_FromChangelogEntry(cr_ChangelogEntry *log) if ((tuple = PyTuple_New(3)) == NULL) return NULL; - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(log->author)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(log->author)); PyTuple_SetItem(tuple, 1, PyLong_FromLong((long) log->date)); - PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(log->changelog)); + PyTuple_SetItem(tuple, 2, PyBytesOrNone_FromString(log->changelog)); return tuple; } @@ -215,8 +215,8 @@ PyObject_FromDistroTag(cr_DistroTag *tag) if ((tuple = PyTuple_New(2)) == NULL) return NULL; - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(tag->cpeid)); - PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(tag->val)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(tag->cpeid)); + PyTuple_SetItem(tuple, 1, PyBytesOrNone_FromString(tag->val)); return tuple; } @@ -251,10 +251,10 @@ GSList_FromPyList_Str(PyObject *py_list) for (Py_ssize_t x=0; x < size; x++) { PyObject *py_str = PyList_GetItem(py_list, x); assert(py_str != NULL); - if (!PyString_Check(py_str)) + if (!PyBytes_Check(py_str)) // Hmm, element is not a string, just skip it continue; - list = g_slist_prepend(list, PyString_AsString(py_str)); + list = g_slist_prepend(list, PyBytes_AsString(py_str)); } return list; diff --git a/src/python/typeconversion.h b/src/python/typeconversion.h index dbc651d..40cae4d 100644 --- a/src/python/typeconversion.h +++ b/src/python/typeconversion.h @@ -26,7 +26,7 @@ // Clears the current Python Exception and return its representation in GError void PyErr_ToGError(GError **err); -PyObject *PyStringOrNone_FromString(const char *str); +PyObject *PyBytesOrNone_FromString(const char *str); char *PyObject_ToStrOrNull(PyObject *pyobj); char *PyObject_ToChunkedString(PyObject *pyobj, GStringChunk *chunk); diff --git a/src/python/updatecollection-py.c b/src/python/updatecollection-py.c index 98d5250..5d36f40 100644 --- a/src/python/updatecollection-py.c +++ b/src/python/updatecollection-py.c @@ -118,7 +118,7 @@ updatecollection_dealloc(_UpdateCollectionObject *self) static PyObject * updatecollection_repr(G_GNUC_UNUSED _UpdateCollectionObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* UpdateCollection methods */ @@ -222,7 +222,7 @@ get_str(_UpdateCollectionObject *self, void *member_offset) char *str = *((char **) ((size_t) rec + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static PyObject * @@ -254,7 +254,7 @@ set_str(_UpdateCollectionObject *self, PyObject *value, void *member_offset) { if (check_UpdateCollectionStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/updatecollectionpackage-py.c b/src/python/updatecollectionpackage-py.c index 6acbfe7..1144554 100644 --- a/src/python/updatecollectionpackage-py.c +++ b/src/python/updatecollectionpackage-py.c @@ -117,7 +117,7 @@ updatecollectionpackage_dealloc(_UpdateCollectionPackageObject *self) static PyObject * updatecollectionpackage_repr(G_GNUC_UNUSED _UpdateCollectionPackageObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* UpdateCollectionPackage methods */ @@ -164,7 +164,7 @@ get_str(_UpdateCollectionPackageObject *self, void *member_offset) char *str = *((char **) ((size_t) pkg + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static int @@ -195,7 +195,7 @@ set_str(_UpdateCollectionPackageObject *self, PyObject *value, void *member_offs { if (check_UpdateCollectionPackageStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/updateinfo-py.c b/src/python/updateinfo-py.c index a7b9775..b0035e7 100644 --- a/src/python/updateinfo-py.c +++ b/src/python/updateinfo-py.c @@ -101,7 +101,7 @@ updateinfo_dealloc(_UpdateInfoObject *self) static PyObject * updateinfo_repr(G_GNUC_UNUSED _UpdateInfoObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* UpdateInfo methods */ @@ -141,7 +141,7 @@ xml_dump(_UpdateInfoObject *self, G_GNUC_UNUSED void *nothing) nice_exception(&tmp_err, NULL); return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } diff --git a/src/python/updaterecord-py.c b/src/python/updaterecord-py.c index 9d5a5c0..37aef08 100644 --- a/src/python/updaterecord-py.c +++ b/src/python/updaterecord-py.c @@ -121,7 +121,7 @@ updaterecord_dealloc(_UpdateRecordObject *self) static PyObject * updaterecord_repr(G_GNUC_UNUSED _UpdateRecordObject *self) { - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* UpdateRecord methods */ @@ -257,7 +257,7 @@ get_str(_UpdateRecordObject *self, void *member_offset) char *str = *((char **) ((size_t) rec + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static PyObject * @@ -316,7 +316,7 @@ set_str(_UpdateRecordObject *self, PyObject *value, void *member_offset) { if (check_UpdateRecordStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/updatereference-py.c b/src/python/updatereference-py.c index 02478a6..def1ba8 100644 --- a/src/python/updatereference-py.c +++ b/src/python/updatereference-py.c @@ -118,10 +118,10 @@ static PyObject * updatereference_repr(G_GNUC_UNUSED _UpdateReferenceObject *self) { if (self->reference->type) - return PyString_FromFormat("", + return PyBytes_FromFormat("", self->reference->type); else - return PyString_FromFormat(""); + return PyBytes_FromFormat(""); } /* UpdateReference methods */ @@ -157,7 +157,7 @@ get_str(_UpdateReferenceObject *self, void *member_offset) char *str = *((char **) ((size_t) ref + (size_t) member_offset)); if (str == NULL) Py_RETURN_NONE; - return PyString_FromString(str); + return PyBytes_FromString(str); } static int @@ -165,7 +165,7 @@ set_str(_UpdateReferenceObject *self, PyObject *value, void *member_offset) { if (check_UpdateReferenceStatus(self)) return -1; - if (!PyString_Check(value) && value != Py_None) { + if (!PyBytes_Check(value) && value != Py_None) { PyErr_SetString(PyExc_TypeError, "String or None expected!"); return -1; } diff --git a/src/python/xml_dump-py.c b/src/python/xml_dump-py.c index 1e73788..c901b2b 100644 --- a/src/python/xml_dump-py.c +++ b/src/python/xml_dump-py.c @@ -44,7 +44,7 @@ py_xml_dump_primary(G_GNUC_UNUSED PyObject *self, PyObject *args) return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } @@ -65,7 +65,7 @@ py_xml_dump_filelists(G_GNUC_UNUSED PyObject *self, PyObject *args) return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } @@ -86,7 +86,7 @@ py_xml_dump_other(G_GNUC_UNUSED PyObject *self, PyObject *args) return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } @@ -115,9 +115,9 @@ py_xml_dump(G_GNUC_UNUSED PyObject *self, PyObject *args) return NULL; } - PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(xml_res.primary)); - PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(xml_res.filelists)); - PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(xml_res.other)); + PyTuple_SetItem(tuple, 0, PyBytesOrNone_FromString(xml_res.primary)); + PyTuple_SetItem(tuple, 1, PyBytesOrNone_FromString(xml_res.filelists)); + PyTuple_SetItem(tuple, 2, PyBytesOrNone_FromString(xml_res.other)); free(xml_res.primary); free(xml_res.filelists); @@ -144,7 +144,7 @@ py_xml_dump_updaterecord(G_GNUC_UNUSED PyObject *self, PyObject *args) return NULL; } - py_str = PyStringOrNone_FromString(xml); + py_str = PyBytesOrNone_FromString(xml); free(xml); return py_str; } diff --git a/src/python/xml_file-py.c b/src/python/xml_file-py.c index 1d83a0a..af86cad 100644 --- a/src/python/xml_file-py.c +++ b/src/python/xml_file-py.c @@ -155,7 +155,7 @@ xmlfile_repr(_XmlFileObject *self) type = "Unknown"; } - return PyString_FromFormat("", type); + return PyBytes_FromFormat("", type); } /* XmlFile methods */