diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | .version | 2 | ||||
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | PKG-INFO | 2 | ||||
-rwxr-xr-x | configure | 26 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | dbus_bindings/abstract.c | 30 | ||||
-rw-r--r-- | dbus_bindings/int.c | 8 | ||||
-rw-r--r-- | dbus_python.egg-info/PKG-INFO | 2 | ||||
-rwxr-xr-x | test/test-standalone.py | 82 |
10 files changed, 151 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml index 0192a6d..62e671a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ python: - "3.6" - "3.6-dev" - "3.7-dev" + - "3.8-dev" - "nightly" script: - PATH="/usr/lib/ccache:$PATH" ./tools/ci-build.sh @@ -1 +1 @@ -1.2.12 +1.2.14 @@ -1,3 +1,19 @@ +dbus Python Bindings 1.2.14 (2019-11-25) +======================================== + +The “don't stand in the fire” release. + +Fixes: + +• Ensure that the numeric types from dbus.types get the same str() + under Python 3.8 that they did under previous versions. Previously, + Python 3.8 used their repr() for the str(), which was not intended. + (dbus-python#31; matclab, Simon McVittie) + +• Disable -Winline (Simon McVittie) + +• Add Python 3.8 to CI (Simon McVittie) + dbus Python Bindings 1.2.12 (2019-09-12) ======================================== @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: dbus-python -Version: 1.2.12 +Version: 1.2.14 Summary: Python bindings for libdbus Home-page: http://www.freedesktop.org/wiki/Software/DBusBindings/#python Maintainer: The D-Bus maintainers @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dbus-python 1.2.12. +# Generated by GNU Autoconf 2.69 for dbus-python 1.2.14. # # Report bugs to <http://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=python>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dbus-python' PACKAGE_TARNAME='dbus-python' -PACKAGE_VERSION='1.2.12' -PACKAGE_STRING='dbus-python 1.2.12' +PACKAGE_VERSION='1.2.14' +PACKAGE_STRING='dbus-python 1.2.14' PACKAGE_BUGREPORT='http://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=python' PACKAGE_URL='' @@ -1387,7 +1387,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dbus-python 1.2.12 to adapt to many kinds of systems. +\`configure' configures dbus-python 1.2.14 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1458,7 +1458,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dbus-python 1.2.12:";; + short | recursive ) echo "Configuration of dbus-python 1.2.14:";; esac cat <<\_ACEOF @@ -1610,7 +1610,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dbus-python configure 1.2.12 +dbus-python configure 1.2.14 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1979,7 +1979,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dbus-python $as_me 1.2.12, which was +It was created by dbus-python $as_me 1.2.14, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2450,9 +2450,9 @@ $as_echo "#define DBUS_PYTHON_MINOR_VERSION 2" >>confdefs.h DBUS_PYTHON_MINOR_VERSION=2 -$as_echo "#define DBUS_PYTHON_MICRO_VERSION 12" >>confdefs.h +$as_echo "#define DBUS_PYTHON_MICRO_VERSION 14" >>confdefs.h -DBUS_PYTHON_MICRO_VERSION=12 +DBUS_PYTHON_MICRO_VERSION=14 @@ -4276,7 +4276,7 @@ fi # Define the identity of the package. PACKAGE='dbus-python' - VERSION='1.2.12' + VERSION='1.2.14' cat >>confdefs.h <<_ACEOF @@ -13638,6 +13638,7 @@ fi for flag in -fno-strict-aliasing \ -Wdeprecated-declarations \ -Wno-duplicated-branches \ + -Wno-inline \ -Wno-redundant-decls \ -Wno-switch-default \ -Wno-write-strings \ @@ -15095,6 +15096,7 @@ fi WARN_CFLAGS="$(echo "${WARN_CFLAGS}" | ${SED} \ -e s/-Wduplicated-branches// \ + -e s/-Winline// \ -e s/-Wredundant-decls// \ -e s/-Wswitch-default// \ -e s/-Wwrite-strings// \ @@ -15663,7 +15665,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dbus-python $as_me 1.2.12, which was +This file was extended by dbus-python $as_me 1.2.14, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15729,7 +15731,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dbus-python config.status 1.2.12 +dbus-python config.status 1.2.14 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 0815878..7af706e 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl The dbus-python version number m4_define(dbus_python_major_version, 1) m4_define(dbus_python_minor_version, 2) dnl Micro version is odd for non-releases -m4_define(dbus_python_micro_version, 12) +m4_define(dbus_python_micro_version, 14) AC_INIT([dbus-python], dbus_python_major_version.dbus_python_minor_version.dbus_python_micro_version, @@ -133,6 +133,7 @@ AX_COMPILER_FLAGS([WARN_CFLAGS], [ \ -Wdeprecated-declarations \ -Wno-duplicated-branches \ + -Wno-inline \ -Wno-redundant-decls \ -Wno-switch-default \ -Wno-write-strings \ @@ -141,6 +142,7 @@ dnl AX_COMPILER_FLAGS doesn't order the compiler flags correctly to be able dnl to disable flags that it would normally enable WARN_CFLAGS="$(echo "${WARN_CFLAGS}" | ${SED} \ -e s/-Wduplicated-branches// \ + -e s/-Winline// \ -e s/-Wredundant-decls// \ -e s/-Wswitch-default// \ -e s/-Wwrite-strings// \ diff --git a/dbus_bindings/abstract.c b/dbus_bindings/abstract.c index 2e3b914..4eca52a 100644 --- a/dbus_bindings/abstract.c +++ b/dbus_bindings/abstract.c @@ -287,6 +287,19 @@ PyTypeObject DBusPyIntBase_Type = { /* There's only one subclass at the moment (Double) but these are factored out to make room for Float later. (Float is implemented and #if'd out) */ +#ifdef PY3 +/* In Python >= 3.8 the tp_str for subclasses of built-in types prints + * the subclass repr(), which does not match dbus-python's historical + * behaviour. */ +static PyObject * +DBusPythonFloat_tp_str(PyObject *self) +{ + return (PyFloat_Type.tp_repr)(self); +} +#else +#define DBusPythonFloat_tp_str 0 +#endif + PyDoc_STRVAR(DBusPythonFloat_tp_doc,\ "Base class for float subclasses with a ``variant_level`` attribute.\n" "Do not rely on the existence of this class outside dbus-python.\n" @@ -367,7 +380,7 @@ PyTypeObject DBusPyFloatBase_Type = { 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - 0, /* tp_str */ + DBusPythonFloat_tp_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -713,6 +726,19 @@ DBusPythonLong_tp_repr(PyObject *self) return my_repr; } +#ifdef PY3 +/* In Python >= 3.8 the tp_str for subclasses of built-in types prints + * the subclass repr(), which does not match dbus-python's historical + * behaviour. */ +static PyObject * +DBusPythonLong_tp_str(PyObject *self) +{ + return (PyLong_Type.tp_repr)(self); +} +#else +#define DBusPythonLong_tp_str 0 +#endif + static void DBusPyLongBase_tp_dealloc(PyObject *self) { @@ -736,7 +762,7 @@ PyTypeObject DBusPyLongBase_Type = { 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - 0, /* tp_str */ + DBusPythonLong_tp_str, /* tp_str */ dbus_py_variant_level_getattro, /* tp_getattro */ dbus_py_immutable_setattro, /* tp_setattro */ 0, /* tp_as_buffer */ diff --git a/dbus_bindings/int.c b/dbus_bindings/int.c index 696f93e..5944314 100644 --- a/dbus_bindings/int.c +++ b/dbus_bindings/int.c @@ -81,6 +81,12 @@ Boolean_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) } static PyObject * +Boolean_tp_str(PyObject *self) +{ + return PyUnicode_FromString(PyObject_IsTrue(self) ? "1" : "0"); +} + +static PyObject * Boolean_tp_repr(PyObject *self) { int is_true = PyObject_IsTrue(self); @@ -122,7 +128,7 @@ PyTypeObject DBusPyBoolean_Type = { 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ - 0, /* tp_str */ + Boolean_tp_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ diff --git a/dbus_python.egg-info/PKG-INFO b/dbus_python.egg-info/PKG-INFO index 9f4a8bd..4e2110e 100644 --- a/dbus_python.egg-info/PKG-INFO +++ b/dbus_python.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: dbus-python -Version: 1.2.12 +Version: 1.2.14 Summary: Python bindings for libdbus Home-page: http://www.freedesktop.org/wiki/Software/DBusBindings/#python Maintainer: The D-Bus maintainers diff --git a/test/test-standalone.py b/test/test-standalone.py index e5ba6d3..21d4b62 100755 --- a/test/test-standalone.py +++ b/test/test-standalone.py @@ -50,10 +50,14 @@ from dbus._compat import is_py2, is_py3 if is_py3: def make_long(n): return n + + UNICODE = str else: def make_long(n): return long(n) + UNICODE = unicode + if 'DBUS_TEST_UNINSTALLED' in os.environ: builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) @@ -110,6 +114,9 @@ class TestTypes(unittest.TestCase): self.assertEqual(types.Double(0.0), 0.0) self.assertEqual(types.Double(0.125, variant_level=2), 0.125) self.assertEqual(types.Double(0.125, variant_level=2).variant_level, 2) + self.assertEqual(str(types.Double(0.125)), '0.125') + self.assertEqual(float(types.Double(0.125)), 0.125) + self.assertIs(type(float(types.Double(0.125))), float) def test_Struct(self): x = types.Struct(('',)) @@ -126,6 +133,7 @@ class TestTypes(unittest.TestCase): self.assertEqual(types.Byte(make_long(1)), 1) self.assertRaises(Exception, lambda: types.Byte(b'ab')) self.assertRaises(TypeError, types.Byte, '\x12xxxxxxxxxxxxx') + self.assertEqual(str(types.Byte(b'x')), 'x') # Byte from a unicode object: what would that even mean? self.assertRaises(Exception, @@ -154,6 +162,16 @@ class TestTypes(unittest.TestCase): self.assertEqual(cls(0), 0) self.assertEqual(cls(23, variant_level=1), 23) self.assertEqual(cls(23, variant_level=1).variant_level, 1) + self.assertEqual(int(cls(42)), 42) + self.assertIs(type(int(cls(42))), int) + self.assertEqual(str(cls(42)), '42') + self.assertIs(type(str(cls(42))), str) + + if is_py2: + self.assertEqual(long(cls(42)), make_long(42)) + self.assertIs(type(long(cls(42))), long) + self.assertEqual(unicode(cls(42)), '42'.decode('ascii')) + self.assertIs(type(unicode(cls(42))), unicode) def test_integer_limits_16(self): self.assertEqual(types.Int16(0x7fff), 0x7fff) @@ -180,11 +198,11 @@ class TestTypes(unittest.TestCase): make_long(-0x8000000000000000)) self.assertEqual(types.UInt64(make_long(0xffffffffffffffff)), make_long(0xffffffffffffffff)) - self.assertRaises(Exception, types.Int16, + self.assertRaises(Exception, types.Int64, make_long(0x8000000000000000)) - self.assertRaises(Exception, types.Int16, + self.assertRaises(Exception, types.Int64, make_long(-0x8000000000000001)) - self.assertRaises(Exception, types.UInt16, + self.assertRaises(Exception, types.UInt64, make_long(0x10000000000000000)) def test_Signature(self): @@ -195,6 +213,61 @@ class TestTypes(unittest.TestCase): ('ab', '(xt)', 'a{sv}')) self.assertTrue(isinstance(tuple(types.Signature('ab'))[0], types.Signature)) + self.assertEqual(str(types.Signature('ab')), 'ab') + self.assertIs(type(str(types.Signature('ab'))), str) + + if is_py2: + self.assertEqual(str(types.Signature('ab')), 'ab') + self.assertIs(type(str(types.Signature('ab'))), str) + self.assertEqual(unicode(types.Signature('ab')), 'ab'.decode('ascii')) + self.assertIs(type(unicode(types.Signature('ab'))), unicode) + + def test_string(self): + self.assertEqual(types.String('hello', variant_level=23), 'hello') + self.assertEqual(types.String('hello', variant_level=23).variant_level, 23) + self.assertTrue(isinstance(types.String('hello'), UNICODE)) + self.assertEqual(str(types.String('hello')), 'hello') + self.assertIs(type(str(types.String('hello'))), str) + + if is_py2: + self.assertEqual(unicode(types.String('hello')), 'hello'.decode('ascii')) + self.assertIs(type(unicode(types.String('hello'))), unicode) + + self.assertEqual(types.UTF8String('hello', variant_level=23), 'hello') + self.assertEqual(types.UTF8String('hello', variant_level=23).variant_level, 23) + self.assertTrue(isinstance(types.UTF8String('hello'), str)) + self.assertEqual(str(types.UTF8String('hello')), 'hello') + self.assertIs(type(str(types.UTF8String('hello'))), str) + self.assertEqual(unicode(types.UTF8String('hello')), 'hello'.decode('ascii')) + self.assertIs(type(unicode(types.UTF8String('hello'))), unicode) + + def test_object_path(self): + self.assertRaises(Exception, types.ObjectPath, 'a') + self.assertEqual(types.ObjectPath('/ab', variant_level=23), '/ab') + self.assertEqual(types.ObjectPath('/ab', variant_level=23).variant_level, 23) + self.assertTrue(isinstance(types.ObjectPath('/ab'), str)) + self.assertEqual(str(types.ObjectPath('/ab')), '/ab') + self.assertIs(type(str(types.ObjectPath('/ab'))), str) + + if is_py2: + self.assertEqual(unicode(types.ObjectPath('/ab')), '/ab'.decode('ascii')) + self.assertIs(type(unicode(types.ObjectPath('/ab'))), unicode) + + def test_boolean(self): + self.assertEqual(types.Boolean(True, variant_level=23), True) + self.assertEqual(types.Boolean(True, variant_level=23).variant_level, 23) + self.assertEqual(str(types.Boolean(False)), '0') + self.assertEqual(str(types.Boolean(True)), '1') + self.assertEqual(str(types.Boolean(47)), '1') + self.assertEqual(int(types.Boolean(False)), 0) + self.assertEqual(int(types.Boolean(True)), 1) + self.assertEqual(int(types.Boolean(47)), 1) + self.assertIs(type(int(types.Boolean(False))), int) + self.assertIs(type(int(types.Boolean(True))), int) + + if is_py2: + self.assertEqual(unicode(types.Boolean(True)), '1'.decode('ascii')) + self.assertIs(type(unicode(types.Boolean(True))), unicode) class TestMessageMarshalling(unittest.TestCase): @@ -537,6 +610,9 @@ class TestMessageMarshalling(unittest.TestCase): self.assertEqual(fd.variant_level, 42) with self.assertRaises(TypeError): + int(fd) + + with self.assertRaises(TypeError): types.UnixFd(plain_fd, invalid_kwarg='nope') with self.assertRaises(TypeError): |