Commit e80500e7 authored by Julian Andres Klode's avatar Julian Andres Klode

python: Use PyVarObject_HEAD_INIT() instead of PyObject_HEAD_INIT().

This is related to PEP 3123 and fixes some compiler warnings.
parent a4e69e11
......@@ -105,10 +105,7 @@ static PyObject *AcquireItemRepr(PyObject *Self)
PyTypeObject AcquireItemType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.AcquireItem", // tp_name
sizeof(CppOwnedPyObject<pkgAcquire::ItemIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -267,10 +264,7 @@ static char *doc_PkgAcquire = "Acquire(progress) -> Acquire() object.\n\n"
PyTypeObject PkgAcquireType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Acquire", // tp_name
sizeof(CppPyObject<pkgAcquire*>), // tp_basicsize
0, // tp_itemsize
......@@ -360,11 +354,8 @@ static char *doc_PkgAcquireFile =
PyTypeObject PkgAcquireFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
"apt_pkg.AcquireFile", // tp_name
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.AcquireFile", // tp_name
sizeof(CppOwnedPyObject<pkgAcqFile*>),// tp_basicsize
0, // tp_itemsize
// Methods
......
......@@ -299,10 +299,7 @@ static char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n"
static PyMappingMethods CacheMap = {0,CacheMapOp,0};
PyTypeObject PkgCacheType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Cache", // tp_name
sizeof(CppOwnedPyObject<pkgCache *>), // tp_basicsize
0, // tp_itemsize
......@@ -349,10 +346,7 @@ PyTypeObject PkgCacheType =
// ---------------------------------------------------------------------
PyTypeObject PkgCacheFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"pkgCacheFile", // tp_name
sizeof(CppOwnedPyObject<pkgCacheFile*>), // tp_basicsize
0, // tp_itemsize
......@@ -425,10 +419,7 @@ static PySequenceMethods PkgListSeq =
PyTypeObject PkgListType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.PackageList", // tp_name
sizeof(CppOwnedPyObject<PkgListStruct>), // tp_basicsize
0, // tp_itemsize
......@@ -550,10 +541,7 @@ static PyObject *PackageRepr(PyObject *Self)
PyTypeObject PackageType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Package", // tp_name
sizeof(CppOwnedPyObject<pkgCache::PkgIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -641,10 +629,7 @@ static PyObject *DescriptionRepr(PyObject *Self)
PyTypeObject DescriptionType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Description", // tp_name
sizeof(CppOwnedPyObject<pkgCache::DescIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -904,10 +889,7 @@ static PyGetSetDef VersionGetSet[] = {
PyTypeObject VersionType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Version", // tp_name
sizeof(CppOwnedPyObject<pkgCache::VerIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -1068,10 +1050,7 @@ static PyGetSetDef PackageFileGetSet[] = {
};
PyTypeObject PackageFileType = {
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.PackageFile", // tp_name
sizeof(CppOwnedPyObject<pkgCache::PkgFileIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -1243,10 +1222,7 @@ static PyGetSetDef DependencyGetSet[] = {
PyTypeObject DependencyType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Dependency", // tp_name
sizeof(CppOwnedPyObject<pkgCache::DepIterator>), // tp_basicsize
0, // tp_itemsize
......@@ -1331,10 +1307,7 @@ static PySequenceMethods RDepListSeq =
PyTypeObject RDepListType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.DependencyList", // tp_name
sizeof(CppOwnedPyObject<RDepListStruct>), // tp_basicsize
0, // tp_itemsize
......
......@@ -85,10 +85,7 @@ static PyObject *PkgCdromNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
PyTypeObject PkgCdromType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Cdrom", // tp_name
sizeof(CppOwnedPyObject<PkgCdromStruct>), // tp_basicsize
0, // tp_itemsize
......
......@@ -503,10 +503,7 @@ static PySequenceMethods ConfigurationSeq = {0,0,0,0,0,0,0,CnfContains,0,0};
static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet};
PyTypeObject ConfigurationType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Configuration", // tp_name
sizeof(CppPyObject<Configuration>), // tp_basicsize
0, // tp_itemsize
......@@ -550,10 +547,7 @@ PyTypeObject ConfigurationType =
PyTypeObject ConfigurationPtrType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.ConfigurationPtr", // tp_name
sizeof(CppPyObject<Configuration *>), // tp_basicsize
0, // tp_itemsize
......@@ -589,10 +583,7 @@ PyTypeObject ConfigurationPtrType =
PyTypeObject ConfigurationSubType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.ConfigurationSub", // tp_name
sizeof(SubConfiguration), // tp_basicsize
0, // tp_itemsize
......
......@@ -667,10 +667,7 @@ static char *doc_PkgDepCache = "DepCache(cache) -> DepCache() object\n\n"
"The parameter *cache* refers to an apt_pkg.Cache() object.";
PyTypeObject PkgDepCacheType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.DepCache", // tp_name
sizeof(CppOwnedPyObject<pkgDepCache *>), // tp_basicsize
0, // tp_itemsize
......@@ -858,10 +855,7 @@ static PyMethodDef PkgProblemResolverMethods[] =
PyTypeObject PkgProblemResolverType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.ProblemResolver", // tp_name
sizeof(CppOwnedPyObject<pkgProblemResolver *>), // tp_basicsize
0, // tp_itemsize
......@@ -977,10 +971,7 @@ static char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n"
PyTypeObject PkgActionGroupType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.ActionGroup", // tp_name
sizeof(CppOwnedPyObject<pkgDepCache::ActionGroup*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -63,6 +63,7 @@ typedef int Py_ssize_t;
#define PyBytes_Check PyString_Check
#define PyBytes_AsString PyString_AsString
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
#endif
#endif
......
......@@ -95,10 +95,7 @@ static char *HashString_doc =
" HashString('MD5Sum', '6cc1b6e6655e3555ac47e5b5fe26d04e')\n\n"
"Valid options for 'type' are: MD5Sum, SHA1, SHA256.";
PyTypeObject PyHashString_Type = {
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.HashString", // tp_name
sizeof(CppPyObject<HashString*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -90,10 +90,7 @@ static PyGetSetDef PackageIndexFileGetSet[] = {
PyTypeObject PackageIndexFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.PackageIndexFile", // tp_name
sizeof(CppOwnedPyObject<pkgIndexFile*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -81,10 +81,7 @@ static PyMethodDef IndexRecords_Methods[] = {
static char *IndexRecords_doc = "IndexRecords()\n\n"
"Representation of a release file.";
PyTypeObject PyIndexRecords_Type = {
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.IndexRecords", // tp_name
sizeof(CppPyObject<indexRecords*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -72,10 +72,7 @@ static PyObject *MetaIndexRepr(PyObject *Self)
PyTypeObject MetaIndexType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.MetaIndex", // tp_name
sizeof(CppOwnedPyObject<metaIndex*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -133,10 +133,7 @@ static PyGetSetDef PkgManagerGetSet[] = {
PyTypeObject PkgManagerType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.PackageManager", // tp_name
sizeof(CppPyObject<pkgPackageManager*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -163,10 +163,7 @@ static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
PyTypeObject PkgRecordsType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.PackageRecords", // tp_name
sizeof(CppOwnedPyObject<PkgRecordsStruct>), // tp_basicsize
0, // tp_itemsize
......
......@@ -204,10 +204,7 @@ static PyObject *PkgSrcRecordsNew(PyTypeObject *type,PyObject *args,PyObject *kw
PyTypeObject PkgSrcRecordsType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.SourceRecords", // tp_name
sizeof(CppPyObject<PkgSrcRecordsStruct>), // tp_basicsize
0, // tp_itemsize
......
......@@ -143,10 +143,7 @@ static char *Policy_doc = "Policy(cache)\n\n"
"may be some cases where a special policy class is needed.";
PyTypeObject PyPolicy_Type = {
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.Policy", // tp_name
sizeof(CppOwnedPyObject<pkgPolicy*>),// tp_basicsize
0, // tp_itemsize
......
......@@ -115,10 +115,7 @@ static PyObject *PkgSourceListNew(PyTypeObject *type,PyObject *args,PyObject *kw
PyTypeObject PkgSourceListType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.SourceList", // tp_name
sizeof(CppPyObject<pkgSourceList*>), // tp_basicsize
0, // tp_itemsize
......
......@@ -175,6 +175,7 @@ static PyObject *TagSecKeys(PyObject *Self,PyObject *Args)
return List;
}
#if PY_MAJOR_VERSION < 3
static char *doc_Exists = "Exists(Name) -> integer";
static PyObject *TagSecExists(PyObject *Self,PyObject *Args)
{
......@@ -188,6 +189,7 @@ static PyObject *TagSecExists(PyObject *Self,PyObject *Args)
return Py_BuildValue("i",0);
return Py_BuildValue("i",1);
}
#endif
static int TagSecContains(PyObject *Self,PyObject *Arg)
{
......@@ -436,10 +438,7 @@ static char *doc_TagSec = "TagSection(text) -> Create a new object.\n\n"
"to the functions provided by the C++ class (e.g. Find)";
PyTypeObject TagSecType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.TagSection", // tp_name
sizeof(TagSecData), // tp_basicsize
0, // tp_itemsize
......@@ -525,10 +524,7 @@ static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n"
// Type for a Tag File
PyTypeObject TagFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
#if PY_MAJOR_VERSION < 3
0, // ob_size
#endif
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"apt_pkg.TagFile", // tp_name
sizeof(TagFileData), // tp_basicsize
0, // tp_itemsize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment