From 121c294b1853a280b01e0504eb1828c6d0e07bbc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Apr 2013 15:44:57 +0100 Subject: Require D-Bus 1.6, drop fallback paths --- NEWS | 6 +++++ _dbus_bindings/compat-internal.h | 19 ---------------- _dbus_bindings/message-append.c | 48 ---------------------------------------- configure.ac | 11 +-------- 4 files changed, 7 insertions(+), 77 deletions(-) diff --git a/NEWS b/NEWS index e71d5a2..9a951e4 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,12 @@ D-Bus Python Bindings 1.1.2 (UNRELEASED) The "compile like it's 1998" release. +Dependencies: + +• libdbus 1.6 or later is now required. + +Fixes: + • Support DBusException('something with non—ASCII') under Python 2 (Michael Vogt, smcv; fd.o #55899) diff --git a/_dbus_bindings/compat-internal.h b/_dbus_bindings/compat-internal.h index 143f23a..535439c 100644 --- a/_dbus_bindings/compat-internal.h +++ b/_dbus_bindings/compat-internal.h @@ -30,23 +30,4 @@ #include "config.h" #include "dbus_bindings-internal.h" -#ifndef HAVE_DBUSBASICVALUE -typedef union { - dbus_bool_t bool_val; - double dbl; - dbus_uint16_t u16; - dbus_int16_t i16; - dbus_uint32_t u32; - dbus_int32_t i32; -#if defined(DBUS_HAVE_INT64) && defined(HAVE_LONG_LONG) - dbus_uint64_t u64; - dbus_int64_t i64; -#endif - const char *str; - unsigned char byt; - float f; - int fd; -} DBusBasicValue; -#endif - #endif diff --git a/_dbus_bindings/message-append.c b/_dbus_bindings/message-append.c index 27522bf..89ca746 100644 --- a/_dbus_bindings/message-append.c +++ b/_dbus_bindings/message-append.c @@ -569,60 +569,12 @@ _message_iter_append_string(DBusMessageIter *appender, return -1; /* Validate UTF-8, strictly */ -#ifdef HAVE_DBUS_VALIDATE_UTF8 if (!dbus_validate_utf8(s, NULL)) { PyErr_SetString(PyExc_UnicodeError, "String parameters " "to be sent over D-Bus must be valid UTF-8 " "with no noncharacter code points"); return -1; } -#else - { - PyObject *back_to_unicode; - PyObject *utf32; - Py_ssize_t i; - - /* This checks for syntactically valid UTF-8, but does not check - * for noncharacters (U+nFFFE, U+nFFFF for any n, or U+FDD0..U+FDEF). - */ - back_to_unicode = PyUnicode_DecodeUTF8(s, PyBytes_GET_SIZE(utf8), - "strict"); - - if (!back_to_unicode) { - return -1; - } - - utf32 = PyUnicode_AsUTF32String(back_to_unicode); - Py_CLEAR(back_to_unicode); - - if (!utf32) { - return -1; - } - - for (i = 0; i < PyBytes_GET_SIZE(utf32) / 4; i++) { - dbus_uint32_t *p; - - p = (dbus_uint32_t *) (PyBytes_AS_STRING(utf32)) + i; - - if (/* noncharacters U+nFFFE, U+nFFFF */ - (*p & 0xFFFF) == 0xFFFE || - (*p & 0xFFFF) == 0xFFFF || - /* noncharacters U+FDD0..U+FDEF */ - (*p >= 0xFDD0 && *p <= 0xFDEF) || - /* surrogates U+D800..U+DBFF (low), U+DC00..U+DFFF (high) */ - (*p >= 0xD800 && *p <= 0xDFFF) || - (*p >= 0x110000)) { - Py_CLEAR(utf32); - PyErr_SetString(PyExc_UnicodeError, "String parameters " - "to be sent over D-Bus must be valid UTF-8 " - "with no noncharacter code points"); - return -1; - } - } - - Py_CLEAR(utf32); - } -#endif DBG("Performing actual append: string (from unicode) %s", s); if (!dbus_message_iter_append_basic(appender, sig_type, &s)) { diff --git a/configure.ac b/configure.ac index 73bd3fa..13eca35 100644 --- a/configure.ac +++ b/configure.ac @@ -168,18 +168,9 @@ AC_SUBST([RST2HTMLFLAGS]) AM_CONDITIONAL([ENABLE_API_DOCS], [test "$enable_api_docs" != no]) AM_CONDITIONAL([ENABLE_DOCS], [test "$enable_html_docs" != no]) -PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.4]) +PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.6]) PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.70]) -dbuspy_save_CFLAGS="$CFLAGS" -dbuspy_save_LIBS="$LIBS" -CFLAGS="$CFLAGS $DBUS_CFLAGS" -LIBS="$CFLAGS $DBUS_LIBS" -AC_CHECK_TYPES([DBusBasicValue], [], [], [#include ]) -AC_CHECK_FUNCS([dbus_validate_utf8]) -CFLAGS="$dbuspy_save_CFLAGS" -LIBS="$dbuspy_save_LIBS" - TP_COMPILER_WARNINGS([CFLAGS_WARNINGS], [test] dbus_python_released [= 0], [all \ extra \ -- cgit v1.2.1