From 8060b9b329cc68c69254a4efa992807c1bae5ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 11 Jun 2019 17:17:26 +0200 Subject: [PATCH] Remove .tp_print access from Python 3 See https://bugzilla.redhat.com/show_bug.cgi?id=1717654 --- dbus_bindings/abstract.c | 7 ++++++- dbus_bindings/bytes.c | 4 ++++ dbus_bindings/containers.c | 6 ++++++ dbus_bindings/float.c | 4 ++++ dbus_bindings/int.c | 14 ++++++++++++++ dbus_bindings/signature.c | 2 ++ dbus_bindings/string.c | 4 ++++ 7 files changed, 40 insertions(+), 1 deletion(-) diff --git a/dbus_bindings/abstract.c b/dbus_bindings/abstract.c index 7bdf368..7a6f92f 100644 --- a/dbus_bindings/abstract.c +++ b/dbus_bindings/abstract.c @@ -790,7 +790,6 @@ dbus_py_init_abstract(void) #ifdef PY3 DBusPyBytesBase_Type.tp_base = &PyBytes_Type; if (PyType_Ready(&DBusPyBytesBase_Type) < 0) return 0; - DBusPyBytesBase_Type.tp_print = NULL; #else DBusPyIntBase_Type.tp_base = &PyInt_Type; if (PyType_Ready(&DBusPyIntBase_Type) < 0) return 0; @@ -801,15 +800,21 @@ dbus_py_init_abstract(void) DBusPyFloatBase_Type.tp_base = &PyFloat_Type; if (PyType_Ready(&DBusPyFloatBase_Type) < 0) return 0; +#ifndef PY3 DBusPyFloatBase_Type.tp_print = NULL; +#endif DBusPyLongBase_Type.tp_base = &PyLong_Type; if (PyType_Ready(&DBusPyLongBase_Type) < 0) return 0; +#ifndef PY3 DBusPyLongBase_Type.tp_print = NULL; +#endif DBusPyStrBase_Type.tp_base = &NATIVESTR_TYPE; if (PyType_Ready(&DBusPyStrBase_Type) < 0) return 0; +#ifndef PY3 DBusPyStrBase_Type.tp_print = NULL; +#endif return 1; } diff --git a/dbus_bindings/bytes.c b/dbus_bindings/bytes.c index 873a2fa..7ccb607 100644 --- a/dbus_bindings/bytes.c +++ b/dbus_bindings/bytes.c @@ -278,11 +278,15 @@ dbus_py_init_byte_types(void) { DBusPyByte_Type.tp_base = &DBUS_PY_BYTE_BASE; if (PyType_Ready(&DBusPyByte_Type) < 0) return 0; +#ifndef PY3 DBusPyByte_Type.tp_print = NULL; +#endif DBusPyByteArray_Type.tp_base = &DBUS_PY_BYTEARRAY_BASE; if (PyType_Ready(&DBusPyByteArray_Type) < 0) return 0; +#ifndef PY3 DBusPyByteArray_Type.tp_print = NULL; +#endif return 1; } diff --git a/dbus_bindings/containers.c b/dbus_bindings/containers.c index 26f983b..b1268eb 100644 --- a/dbus_bindings/containers.c +++ b/dbus_bindings/containers.c @@ -775,15 +775,21 @@ dbus_py_init_container_types(void) DBusPyArray_Type.tp_base = &PyList_Type; if (PyType_Ready(&DBusPyArray_Type) < 0) return 0; +#ifndef PY3 DBusPyArray_Type.tp_print = NULL; +#endif DBusPyDict_Type.tp_base = &PyDict_Type; if (PyType_Ready(&DBusPyDict_Type) < 0) return 0; +#ifndef PY3 DBusPyDict_Type.tp_print = NULL; +#endif DBusPyStruct_Type.tp_base = &PyTuple_Type; if (PyType_Ready(&DBusPyStruct_Type) < 0) return 0; +#ifndef PY3 DBusPyStruct_Type.tp_print = NULL; +#endif return 1; } diff --git a/dbus_bindings/float.c b/dbus_bindings/float.c index 9d05c19..c31f224 100644 --- a/dbus_bindings/float.c +++ b/dbus_bindings/float.c @@ -128,12 +128,16 @@ dbus_py_init_float_types(void) { DBusPyDouble_Type.tp_base = &DBusPyFloatBase_Type; if (PyType_Ready(&DBusPyDouble_Type) < 0) return 0; +#ifndef PY3 DBusPyDouble_Type.tp_print = NULL; +#endif #ifdef WITH_DBUS_FLOAT32 DBusPyFloat_Type.tp_base = &DBusPyFloatBase_Type; if (PyType_Ready(&DBusPyFloat_Type) < 0) return 0; +#ifndef PY3 DBusPyFloat_Type.tp_print = NULL; +#endif #endif return 1; diff --git a/dbus_bindings/int.c b/dbus_bindings/int.c index 109d4c7..1b36cd3 100644 --- a/dbus_bindings/int.c +++ b/dbus_bindings/int.c @@ -721,33 +721,47 @@ dbus_py_init_int_types(void) if (PyType_Ready(&DBusPyInt16_Type) < 0) return 0; /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as desired */ +#ifndef PY3 DBusPyInt16_Type.tp_print = NULL; +#endif DBusPyUInt16_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyUInt16_Type) < 0) return 0; +#ifndef PY3 DBusPyUInt16_Type.tp_print = NULL; +#endif DBusPyInt32_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyInt32_Type) < 0) return 0; +#ifndef PY3 DBusPyInt32_Type.tp_print = NULL; +#endif DBusPyUInt32_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyUInt32_Type) < 0) return 0; +#ifndef PY3 DBusPyUInt32_Type.tp_print = NULL; +#endif #if defined(DBUS_HAVE_INT64) && defined(HAVE_LONG_LONG) DBusPyInt64_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyInt64_Type) < 0) return 0; +#ifndef PY3 DBusPyInt64_Type.tp_print = NULL; +#endif DBusPyUInt64_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyUInt64_Type) < 0) return 0; +#ifndef PY3 DBusPyUInt64_Type.tp_print = NULL; +#endif #endif DBusPyBoolean_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; +#ifndef PY3 DBusPyBoolean_Type.tp_print = NULL; +#endif return 1; } diff --git a/dbus_bindings/signature.c b/dbus_bindings/signature.c index c1a32e7..ca2c1d8 100644 --- a/dbus_bindings/signature.c +++ b/dbus_bindings/signature.c @@ -233,7 +233,9 @@ dbus_py_init_signature(void) DBusPySignature_Type.tp_base = &DBusPyStrBase_Type; if (PyType_Ready(&DBusPySignature_Type) < 0) return 0; +#ifndef PY3 DBusPySignature_Type.tp_print = NULL; +#endif return 1; } diff --git a/dbus_bindings/string.c b/dbus_bindings/string.c index ce8f03d..28f7f48 100644 --- a/dbus_bindings/string.c +++ b/dbus_bindings/string.c @@ -337,7 +337,9 @@ dbus_py_init_string_types(void) } DBusPyString_Type.tp_base = &PyUnicode_Type; if (PyType_Ready(&DBusPyString_Type) < 0) return 0; +#ifndef PY3 DBusPyString_Type.tp_print = NULL; +#endif #ifndef PY3 DBusPyUTF8String_Type.tp_base = &DBusPyStrBase_Type; @@ -347,7 +349,9 @@ dbus_py_init_string_types(void) DBusPyObjectPath_Type.tp_base = &DBusPyStrBase_Type; if (PyType_Ready(&DBusPyObjectPath_Type) < 0) return 0; +#ifndef PY3 DBusPyObjectPath_Type.tp_print = NULL; +#endif return 1; } -- 2.21.0