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 *
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 *
mode = "Unknown mode";
}
- return PyString_FromFormat("<createrepo_c.CrFile %s object>", mode);
+ return PyBytes_FromFormat("<createrepo_c.CrFile %s object>", mode);
}
/* CrFile methods */
static PyObject *
contentstat_repr(G_GNUC_UNUSED _ContentStatObject *self)
{
- return PyString_FromFormat("<createrepo_c.ContentStat object>");
+ return PyBytes_FromFormat("<createrepo_c.ContentStat object>");
}
/* getsetters */
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
{
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;
}
static PyObject *
metadata_repr(G_GNUC_UNUSED _MetadataObject *self)
{
- return PyString_FromFormat("<createrepo_c.Metadata object>");
+ return PyBytes_FromFormat("<createrepo_c.Metadata object>");
}
/* Getters */
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);
static PyObject *
metadatalocation_repr(G_GNUC_UNUSED _MetadataLocationObject *self)
{
- return PyString_FromFormat("<createrepo_c.MetadataLocation object>");
+ return PyBytes_FromFormat("<createrepo_c.MetadataLocation object>");
}
/* MetadataLocation methods */
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")) {
}
if (value)
- return PyString_FromString(value);
+ return PyBytes_FromString(value);
else
Py_RETURN_NONE;
}
cr_Package *pkg = self->package;
PyObject *repr;
if (pkg) {
- repr = PyString_FromFormat("<createrepo_c.Package object id %s, %s>",
+ repr = PyBytes_FromFormat("<createrepo_c.Package object id %s, %s>",
(pkg->pkgId ? pkg->pkgId : "-"),
(pkg->name ? pkg->name : "-"));
} else {
- repr = PyString_FromFormat("<createrepo_c.Package object id -, ->");
+ repr = PyBytes_FromFormat("<createrepo_c.Package object id -, ->");
}
return repr;
}
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;
}
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;
}
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;
}
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. */
{
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;
}
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;
}
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);
static PyObject *
repomd_repr(G_GNUC_UNUSED _RepomdObject *self)
{
- return PyString_FromFormat("<createrepo_c.Repomd object>");
+ return PyBytes_FromString("<createrepo_c.Repomd object>");
}
/* Repomd methods */
nice_exception(&tmp_err, NULL);
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
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;
}
/** 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,
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 *
{
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;
}
repomdrecord_repr(G_GNUC_UNUSED _RepomdRecordObject *self)
{
if (self->record->type)
- return PyString_FromFormat("<createrepo_c.RepomdRecord %s object>",
+ return PyBytes_FromFormat("<createrepo_c.RepomdRecord %s object>",
self->record->type);
else
- return PyString_FromFormat("<createrepo_c.RepomdRecord object>");
+ return PyBytes_FromFormat("<createrepo_c.RepomdRecord object>");
}
/* RepomdRecord methods */
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
{
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;
}
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("<createrepo_c.Sqlite %s object>", type);
+ return PyBytes_FromFormat("<createrepo_c.Sqlite %s object>", type);
}
/* Sqlite methods */
"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;
}
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;
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;
}
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;
}
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;
}
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;
// 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);
static PyObject *
updatecollection_repr(G_GNUC_UNUSED _UpdateCollectionObject *self)
{
- return PyString_FromFormat("<createrepo_c.UpdateCollection object>");
+ return PyBytes_FromFormat("<createrepo_c.UpdateCollection object>");
}
/* UpdateCollection methods */
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 *
{
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;
}
static PyObject *
updatecollectionpackage_repr(G_GNUC_UNUSED _UpdateCollectionPackageObject *self)
{
- return PyString_FromFormat("<createrepo_c.UpdateCollectionPackage object>");
+ return PyBytes_FromFormat("<createrepo_c.UpdateCollectionPackage object>");
}
/* UpdateCollectionPackage methods */
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
{
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;
}
static PyObject *
updateinfo_repr(G_GNUC_UNUSED _UpdateInfoObject *self)
{
- return PyString_FromFormat("<createrepo_c.UpdateInfo object>");
+ return PyBytes_FromFormat("<createrepo_c.UpdateInfo object>");
}
/* UpdateInfo methods */
nice_exception(&tmp_err, NULL);
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
static PyObject *
updaterecord_repr(G_GNUC_UNUSED _UpdateRecordObject *self)
{
- return PyString_FromFormat("<createrepo_c.UpdateRecord object>");
+ return PyBytes_FromFormat("<createrepo_c.UpdateRecord object>");
}
/* UpdateRecord methods */
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 *
{
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;
}
updatereference_repr(G_GNUC_UNUSED _UpdateReferenceObject *self)
{
if (self->reference->type)
- return PyString_FromFormat("<createrepo_c.UpdateReference %s object>",
+ return PyBytes_FromFormat("<createrepo_c.UpdateReference %s object>",
self->reference->type);
else
- return PyString_FromFormat("<createrepo_c.UpdateReference object>");
+ return PyBytes_FromFormat("<createrepo_c.UpdateReference object>");
}
/* UpdateReference methods */
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
{
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;
}
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
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);
return NULL;
}
- py_str = PyStringOrNone_FromString(xml);
+ py_str = PyBytesOrNone_FromString(xml);
free(xml);
return py_str;
}
type = "Unknown";
}
- return PyString_FromFormat("<createrepo_c.XmlFile %s object>", type);
+ return PyBytes_FromFormat("<createrepo_c.XmlFile %s object>", type);
}
/* XmlFile methods */