diff -Nru dbus-python-0.84.0/aclocal.m4 dbus-python-1.0.0/aclocal.m4 --- dbus-python-0.84.0/aclocal.m4 2011-05-25 11:50:03.000000000 +0000 +++ dbus-python-1.0.0/aclocal.m4 2012-01-24 16:37:28.000000000 +0000 @@ -1,7 +1,8 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.11.2 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, +# Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -179,12 +180,15 @@ fi[]dnl ])# PKG_CHECK_MODULES -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software +# Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been @@ -194,7 +198,7 @@ [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], +m4_if([$1], [1.11.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -210,19 +214,21 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl +[AM_AUTOMAKE_VERSION([1.11.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. @@ -304,14 +310,14 @@ Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, +# 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 10 +# serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, @@ -351,6 +357,7 @@ # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -415,7 +422,7 @@ break fi ;; - msvisualcpp | msvcmsys) + msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. @@ -480,10 +487,13 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' + am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- @@ -717,12 +727,15 @@ done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, +# Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. @@ -889,12 +902,15 @@ fi ]) -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, +# Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. @@ -917,13 +933,14 @@ # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software +# Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 +# serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- @@ -931,13 +948,13 @@ [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# ------------------------------ +# -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- +# ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -948,13 +965,15 @@ AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, +# 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To @@ -982,8 +1001,10 @@ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported. (2.0 was released on October 16, 2000). m4_define_default([_AM_PYTHON_INTERPRETER_LIST], - [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl -python2.1 python2.0]) +[python python2 python3 python3.2 python3.1 python3.0 python2.7 dnl + python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0]) + + AC_ARG_VAR([PYTHON], [the Python interpreter]) m4_if([$1],[],[ dnl No version check is needed. @@ -1153,12 +1174,14 @@ sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. @@ -1262,12 +1285,14 @@ _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't @@ -1290,13 +1315,13 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 +# serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- @@ -1305,7 +1330,7 @@ AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- +# -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) diff -Nru dbus-python-0.84.0/ChangeLog dbus-python-1.0.0/ChangeLog --- dbus-python-0.84.0/ChangeLog 2011-05-25 11:50:09.000000000 +0000 +++ dbus-python-1.0.0/ChangeLog 2012-01-24 16:44:54.000000000 +0000 @@ -1,11 +1,745 @@ -commit 064ad1c53c08116b3acec43fa8740da0876d6e63 +commit 5a8eb939ab4603a931457c5d4e8dfcdc323eaf89 +Author: Barry Warsaw +Date: 2012-01-24 16:43:05 +0000 + + Install _compat.py + + Makefile.am | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +commit d1ccc12dd1dee34faae52c7b325048ea801599fd +Author: Simon McVittie +Date: 2012-01-24 16:41:46 +0000 + + Generate ChangeLog correctly when out-of-tree + + Makefile.am | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +commit 1ee2b1a8cf729a71ae56e5671564c5fd62504707 +Author: Simon McVittie +Date: 2012-01-24 16:36:49 +0000 + + Let's call this 1.0 + + NEWS | 6 ++++-- + configure.ac | 6 +++--- + 2 files changed, 7 insertions(+), 5 deletions(-) + +commit 5b76f66e79f9bc07241a44c0277d4bbebc08ce20 +Author: Simon McVittie +Date: 2012-01-24 16:35:45 +0000 + + Remove duplicate -Werror machinery + + configure.ac | 8 -------- + 1 files changed, 0 insertions(+), 8 deletions(-) + +commit cd4e91c65624062b5504c10b2af0a05aefbf4878 +Author: Simon McVittie +Date: 2012-01-24 16:35:38 +0000 + + Move PY3PORT into doc, use the same extension as other rst, and render it + + Makefile.am | 16 +++- + NEWS | 3 + + PY3PORT.rst | 224 ------------------------------------------------------- + configure.ac | 2 +- + doc/PY3PORT.txt | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 240 insertions(+), 229 deletions(-) + +commit 09ca5de0f38d3cc30b8d149b2a8c9f0ad810a09a +Author: Simon McVittie +Date: 2012-01-24 16:21:15 +0000 + + Describe problems, alternatives + + README | 24 ++++++++++++++++++++++++ + 1 files changed, 24 insertions(+), 0 deletions(-) + +commit b486edf800ecb9d2e23a35f7ac3151657ee39250 +Author: Simon McVittie +Date: 2012-01-24 16:06:35 +0000 + + Deprecate dbus.glib (use dbus.mainloop.glib or dbus.mainloop.qt4) + + dbus/glib.py | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +commit 50fa5eb54992c28d63b0532533f755ff39f082e2 +Author: Simon McVittie +Date: 2012-01-11 15:02:40 +0000 + + Add INTORLONG_CHECK macro so we don't have to conditionalize PyInt_Check + + _dbus_bindings/bus.c | 7 ++----- + _dbus_bindings/bytes.c | 8 ++------ + _dbus_bindings/dbus_bindings-internal.h | 2 ++ + _dbus_bindings/message-append.c | 8 +++----- + _dbus_bindings/unixfd.c | 7 ++----- + 5 files changed, 11 insertions(+), 21 deletions(-) + +commit 4f043cf34a8001c071644eb8c89dc7d43e86b62a +Author: Simon McVittie +Date: 2012-01-11 15:01:39 +0000 + + Use native 'int' (whatever that means) for variant_level etc. + + This reverts the Python 2 API to be in terms of PyInt, leaving the + Python 3 API in terms of PyLong (which is called 'int' in Python code). + + NEWS | 3 --- + PY3PORT.rst | 2 -- + _dbus_bindings/abstract.c | 12 ++++++------ + _dbus_bindings/bytes.c | 4 ++-- + _dbus_bindings/conn-methods.c | 2 +- + _dbus_bindings/dbus_bindings-internal.h | 6 ++++++ + _dbus_bindings/message-get-args.c | 2 +- + _dbus_bindings/message.c | 2 +- + 8 files changed, 17 insertions(+), 16 deletions(-) + +commit cdc0ca5c72686aab38a172f14da3b38fe304baa9 +Author: Simon McVittie +Date: 2012-01-11 14:59:36 +0000 + + update NEWS, PY3PORT.rst + + NEWS | 20 +++++++++++++++++--- + PY3PORT.rst | 9 ++++----- + 2 files changed, 21 insertions(+), 8 deletions(-) + +commit ae61078cc90917c20b14298aaec18e87e149d337 Author: Simon McVittie -Date: 2011-05-25 11:57:46 +0100 +Date: 2012-01-11 14:04:14 +0000 + + Test behaviour of various Message methods + + test/test-standalone.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 54 insertions(+), 0 deletions(-) + +commit 69342f86b0d036ca41a19363efaf4e8352837c24 +Author: Simon McVittie +Date: 2012-01-11 14:03:53 +0000 + + Do not allow Byte(unicode(x)) (i.e. Byte(str(x)) in Python 3) + + Unicode strings aren't bytestrings, so there's no obvious meaning for + the byte value of a Unicode string of length 1. + + PY3PORT.rst | 12 ++++++------ + _dbus_bindings/bytes.c | 14 -------------- + test/cross-test-client.py | 18 +++++++++--------- + test/test-standalone.py | 38 +++++++++++++++++++++++++++++++------- + 4 files changed, 46 insertions(+), 36 deletions(-) + +commit cada4883df6b67f4059eedd2def1f5cffa41c7d8 +Author: Simon McVittie +Date: 2012-01-11 12:58:21 +0000 + + Use better names for the superclasses of Byte and ByteArray + + Strictly speaking, DBUS_FOO is libdbus' namespace, not ours. Use + DBUS_PY_FOO. + + DBUS_BYTES_BASE was misleading: it's the base class for a single byte, + so call it DBUS_PY_BYTE_BASE. + + _dbus_bindings/bytes.c | 18 +++++++++--------- + 1 files changed, 9 insertions(+), 9 deletions(-) + +commit beaa479066a0139bbb09f058818cd5476f1a79d2 +Author: Simon McVittie +Date: 2012-01-11 12:57:15 +0000 + + Consistently use the str type for identifier-like (ASCII) strings + + Porting to Python 3 left these methods returning unicode, which is + arguably an API break in Python 2: + + * Message.get_member + * Message.get_path_decomposed (array of unicode) + * Message.get_sender + * Message.get_destination + * Message.get_interface + * Message.get_error_name + * Server.get_address + * Server.get_id + + Instead, make them return whatever the natural str type is (bytes in + Python 2, unicode in Python 3). + + _dbus_bindings/bus.c | 6 +----- + _dbus_bindings/conn-methods.c | 6 +----- + _dbus_bindings/exceptions.c | 4 ++-- + _dbus_bindings/message.c | 12 ++++++------ + _dbus_bindings/server.c | 4 ++-- + 5 files changed, 12 insertions(+), 20 deletions(-) + +commit a5c77b73651f8f288f7ea2eb9029895eed3cacab +Author: Simon McVittie +Date: 2012-01-11 12:54:26 +0000 + + DBusPythonString base class: use "native str" as base class instead of reinventing it + + _dbus_bindings/abstract.c | 16 +++++----------- + _dbus_bindings/dbus_bindings-internal.h | 2 ++ + 2 files changed, 7 insertions(+), 11 deletions(-) + +commit 0daad225ff9085c4013da69e5733e8846e9b8de3 +Author: Simon McVittie +Date: 2012-01-11 12:50:43 +0000 + + SignalMessage.__repr__: include the destination and abbreviate "interface" more conventionally + + Yes, signals can have a destination. The default is to broadcast. + + _dbus_bindings/message.c | 7 +++++-- + 1 files changed, 5 insertions(+), 2 deletions(-) + +commit 9201d65b31305c8bef86ab072b7c33b197ede562 +Author: Barry Warsaw +Date: 2011-12-17 12:09:57 -0500 + + Quash a few more deprecations. + + test/test-p2p.py | 10 +++++----- + test/test-signals.py | 2 +- + 2 files changed, 6 insertions(+), 6 deletions(-) + +commit f8dab5af0bef5d26a51df41a564a5285c16a9cb5 +Author: Barry Warsaw +Date: 2011-12-16 17:07:07 -0500 + + More Python 3 porting, this time primarily to get test-client.py working. + Changes include: + + - DBusException.get_dbus_message(): In Python 3, the str of the exception will + already be a unicode, so don't try to decode it unless it's a bytes object + (a.k.a. 8-bit str in Python 2). + - gobject_service.py: Switch to pygi and rewrite the metaclass instantiation + code to be portable between Python 2 and Python 3. + - run-test.sh: echo a few more useful environment variables + - test-client.py: + - Globally replace deprecated assertEquals with assertEqual + - Globally replace deprecated assert_ with assertTrue + - Use bytes objects for both 'ay' signatured methods on the server + - AcceptUnicodeString will return a native unicode, i.e. a str in Python 3 + and a unicode in Python 2. Python 3 has no `unicode` built-in. + - Reformat some long lines for debugging. + - test-service.py: + - Open the log file in 'a' mode for easier tailing. + - AcceptUnicodeString will return a native unicode, i.e. a str in Python 3 + and a unicode in Python 2. Python 3 has no `unicode` built-in. + - reformat some long lines for debugging. + - Put module-scope code into a main() function and add a bunch of logger + output for better debugging. `session_bus` must still be global though. + Wrap main() in a bit try/except to log all top-level exceptions. + + dbus/exceptions.py | 5 +- + dbus/gobject_service.py | 76 +++++++++------- + test/run-test.sh | 2 + + test/test-client.py | 231 +++++++++++++++++++++++++---------------------- + test/test-service.py | 57 +++++++++---- + 5 files changed, 214 insertions(+), 157 deletions(-) + +commit 2167b305db78b8345b0f5ea23bfa445fa7cfca4d +Author: Barry Warsaw +Date: 2011-12-16 11:15:01 -0500 + + Re-enable the other tests, even though these still fail for me (b.f.o #43303). + Fix another except syntax problem. + + test/run-test.sh | 12 ++++++------ + test/test-client.py | 6 +++--- + 2 files changed, 9 insertions(+), 9 deletions(-) + +commit 0c71d7dd6eb843a74931c714d6142921f1971f88 +Author: Barry Warsaw +Date: 2011-12-15 19:58:06 -0500 + + Re-enable previously disabled test. + + test/cross-test-client.py | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +commit ef05d294e85978cf96a86535321cf914b605fa48 +Author: Barry Warsaw +Date: 2011-12-15 19:37:23 -0500 + + Fix the match rule semantics so that a match rule of "arg0='/'" does not match + object paths in Python3, as per Simon's review comments. + + dbus/connection.py | 18 +++++++++--------- + test/test-standalone.py | 19 +++++++++++++++++++ + 2 files changed, 28 insertions(+), 9 deletions(-) + +commit 8e87ac365f6b08c0617985488dd5d27148c9281d +Author: Barry Warsaw +Date: 2011-12-15 17:55:20 -0500 + + Consistency; clean-up. + + _dbus_bindings/abstract.c | 8 ++++---- + _dbus_bindings/bytes.c | 8 ++++---- + 2 files changed, 8 insertions(+), 8 deletions(-) + +commit f2909c23abc4f8fa55d71673785f8e70a843f6ce +Author: Barry Warsaw +Date: 2011-12-15 16:50:02 -0500 + + - Added back the missing PY3PORT.rst file, with updates. + - Disallow appending unicode objects with 'y' (bytes) signatures. This now + requires either a bytes object or an integer. Update the tests to reflect + - this change. + - Fix broken __all__ in Python 3. + + PY3PORT.rst | 227 +++++++++++++++++++++++++++++++++++++++ + _dbus_bindings/message-append.c | 26 +---- + dbus/types.py | 5 +- + test/cross-test-client.py | 9 +- + test/run-test.sh | 1 + + test/test-standalone.py | 10 +- + 6 files changed, 249 insertions(+), 29 deletions(-) + +commit 4c1c2eade1c5b383adad94a7a4fd6553873fecf0 +Author: Barry Warsaw +Date: 2011-12-15 06:57:21 -0500 + + This is the big one; it adds Python 3 support. + + _dbus_bindings/Makefile.am | 3 +- + _dbus_bindings/abstract.c | 182 +++++++++++++++++++++++++++-- + _dbus_bindings/bus.c | 20 +++- + _dbus_bindings/bytes.c | 59 ++++++++-- + _dbus_bindings/conn-methods.c | 30 +++-- + _dbus_bindings/conn.c | 32 +++++- + _dbus_bindings/containers.c | 59 +++++++++- + _dbus_bindings/dbus_bindings-internal.h | 31 ++++- + _dbus_bindings/exceptions.c | 4 +- + _dbus_bindings/int.c | 44 +++++-- + _dbus_bindings/message-append.c | 195 +++++++++++++++++++++++++------ + _dbus_bindings/message-get-args.c | 27 ++++- + _dbus_bindings/message.c | 60 ++++++++-- + _dbus_bindings/module.c | 143 +++++++++++++++-------- + _dbus_bindings/server.c | 40 +++++-- + _dbus_bindings/signature.c | 34 ++++-- + _dbus_bindings/string.c | 17 ++- + _dbus_bindings/types-internal.h | 12 ++- + _dbus_bindings/unixfd.c | 7 +- + _dbus_glib_bindings/Makefile.am | 2 +- + _dbus_glib_bindings/module.c | 32 +++++ + configure.ac | 2 +- + dbus/__init__.py | 19 ++- + dbus/_compat.py | 8 ++ + dbus/_dbus.py | 11 +- + dbus/_expat_introspect_parser.py | 2 +- + dbus/bus.py | 23 +++- + dbus/connection.py | 79 ++++++++----- + dbus/decorators.py | 19 ++- + dbus/proxies.py | 12 +- + dbus/service.py | 25 +++-- + dbus/types.py | 6 +- + include/dbus-python.h | 18 +++ + test/cross-test-client.py | 107 ++++++++++------- + test/cross-test-server.py | 34 ++++-- + test/dbus_py_test.c | 26 ++++ + test/run-test.sh | 14 ++- + test/test-client.py | 149 +++++++++++++---------- + test/test-p2p.py | 21 ++-- + test/test-service.py | 9 +- + test/test-standalone.py | 173 +++++++++++++++++---------- + test/test-unusable-main-loop.py | 5 +- + 42 files changed, 1333 insertions(+), 462 deletions(-) + +commit 667082d0b4aef9c438a2e7fec89614b5b8ef960a +Author: Barry Warsaw +Date: 2011-12-14 15:05:16 -0500 + + First round of PyInt -> PyLong changes. These are only compatible with Python + 2, since there are still some unconditional PyInt calls, which are not valid + in Python 3. However, it lays the framework for conditionalizing on Python 3 + and using only PyLong in that case. Where it doesn't matter, PyLong is used + unconditionally. + + _dbus_bindings/abstract.c | 20 ++++++-- + _dbus_bindings/bus.c | 6 ++- + _dbus_bindings/bytes.c | 34 ++++++++++--- + _dbus_bindings/conn-methods.c | 2 +- + _dbus_bindings/conn.c | 2 +- + _dbus_bindings/containers.c | 11 +++-- + _dbus_bindings/generic.c | 4 +- + _dbus_bindings/int.c | 33 +++++++++---- + _dbus_bindings/message-append.c | 21 ++++++-- + _dbus_bindings/message-get-args.c | 2 +- + _dbus_bindings/message.c | 2 +- + _dbus_bindings/types-internal.h | 3 + + _dbus_bindings/unixfd.c | 95 ++++++++++++++++++++++++------------ + test/test-standalone.py | 7 ++- + 14 files changed, 166 insertions(+), 76 deletions(-) + +commit 11c639e3bd2ca3e6a87f349155dda2acc3cd92ea +Author: Barry Warsaw +Date: 2011-12-14 13:54:31 -0500 + + Add error checking to dbus_py_variant_level_get() and call sites. + + _dbus_bindings/abstract.c | 22 +++++++++++++++++++--- + _dbus_bindings/containers.c | 4 ++++ + _dbus_bindings/message-append.c | 4 ++++ + 3 files changed, 27 insertions(+), 3 deletions(-) + +commit 71f4481c1876785572170ef68d5624ed23f91333 +Author: Barry Warsaw +Date: 2011-12-14 13:36:39 -0500 + + In preparation for Python 3 support, use the Python 2 PyBytes aliases for the + PyString API. This makes the code compilable in Python 2.x (x >= 6) and + Python 3. + + _dbus_bindings/abstract.c | 21 +++--- + _dbus_bindings/bus.c | 4 +- + _dbus_bindings/bytes.c | 8 +- + _dbus_bindings/conn-methods.c | 40 ++++++------ + _dbus_bindings/conn.c | 2 +- + _dbus_bindings/containers.c | 8 +- + _dbus_bindings/exceptions.c | 4 +- + _dbus_bindings/message-append.c | 128 ++++++++++++++++++++------------------- + _dbus_bindings/message.c | 12 ++-- + _dbus_bindings/server.c | 6 +- + _dbus_bindings/signature.c | 4 +- + _dbus_bindings/types-internal.h | 7 ++ + 12 files changed, 129 insertions(+), 115 deletions(-) + +commit ca7a705663adbac2e781d10c13fc98a5444ef646 +Author: Barry Warsaw +Date: 2011-12-14 12:00:04 -0500 + + In preparation for Python 3 support, all reprs now return unicodes, which is + legal in Python 2 also. Use fancy REPR macro and the %V format code for + cross-Python compatibility. + + _dbus_bindings/abstract.c | 48 ++++++++++++------------ + _dbus_bindings/containers.c | 60 +++++++++++++++--------------- + _dbus_bindings/dbus_bindings-internal.h | 25 +++++++++++++ + _dbus_bindings/int.c | 14 ++++---- + _dbus_bindings/string.c | 12 +++--- + 5 files changed, 92 insertions(+), 67 deletions(-) + +commit 5ff1d938ee230b47dcab8b7703409067df35ed2f +Author: Barry Warsaw +Date: 2011-12-13 17:36:49 -0500 + + Modernize multiline imports in preparation for Python 3 support. + + dbus/__init__.py | 34 +++++++++++++++------------------- + dbus/_dbus.py | 12 +++++------- + dbus/bus.py | 27 ++++++++++----------------- + dbus/connection.py | 15 +++++++-------- + dbus/lowlevel.py | 14 +++++--------- + dbus/proxies.py | 10 ++++++---- + dbus/service.py | 10 +++++----- + dbus/types.py | 9 ++++----- + 8 files changed, 57 insertions(+), 74 deletions(-) + +commit dc7b07bc5921cd6263552bb1f3351416327fd67c +Author: Barry Warsaw +Date: 2011-12-13 17:26:15 -0500 + + Modernize `raise` syntax in preparation of Python 3 support. + + dbus/decorators.py | 8 ++++---- + 1 files changed, 4 insertions(+), 4 deletions(-) + +commit e033b0c8f22a67abfe2ba1b61365d0c2570b7429 +Author: Barry Warsaw +Date: 2011-12-13 17:22:22 -0500 + + Import threading instead of thread. The latter is gone in Python 3. + + dbus/_dbus.py | 5 ----- + dbus/connection.py | 7 ++----- + dbus/service.py | 7 ++----- + 3 files changed, 4 insertions(+), 15 deletions(-) + +commit 061e55e8edbfb457bf56194c52e7d7624855cf41 +Author: Barry Warsaw +Date: 2011-12-13 17:17:46 -0500 + + Fix an inconsequential typo. + + _dbus_bindings/signature.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 4477b6120240e186db8d86619f6da63faca296ba +Author: Barry Warsaw +Date: 2011-12-13 17:15:41 -0500 + + For pendantic correctness, and future Python 3 compatibility, explicitly + initialize the weaklist slots. + + _dbus_bindings/conn.c | 1 + + _dbus_bindings/server.c | 1 + + 2 files changed, 2 insertions(+), 0 deletions(-) + +commit 48abd4782f336de2d6dd228e58f86729778e26fb +Author: Barry Warsaw +Date: 2011-12-13 17:08:50 -0500 + + Don't leak the fast_seq object. + + _dbus_bindings/server.c | 5 ++++- + 1 files changed, 4 insertions(+), 1 deletions(-) + +commit 033a0f2890495053fd6474d6f52d4a6e9c32cca1 +Author: Barry Warsaw +Date: 2011-12-13 16:50:38 -0500 + + - Add a few missing Py_TYPE() changes for Python 3 compatibility. + - De-tabbify a few instances that "make check" complains about. + + _dbus_bindings/bytes.c | 2 +- + _dbus_bindings/containers.c | 8 ++++---- + _dbus_bindings/message-append.c | 2 +- + 3 files changed, 6 insertions(+), 6 deletions(-) + +commit 4a26dab362e8ddd7a765f1249649408f62eb96e7 +Author: Barry Warsaw +Date: 2011-12-13 16:21:04 -0500 + + Additional PyObject_HEAD_INIT -> PyVarObject_HEAD_INIT changes in preparation + for Python 3 support. + + _dbus_bindings/abstract.c | 12 ++++-------- + _dbus_bindings/conn.c | 3 +-- + _dbus_bindings/int.c | 3 +-- + _dbus_bindings/libdbusconn.c | 3 +-- + _dbus_bindings/message.c | 15 +++++---------- + _dbus_bindings/server.c | 3 +-- + 6 files changed, 13 insertions(+), 26 deletions(-) + +commit deccd695a43573d31183fe0e93316d306ce989f2 +Author: Alexandre Rostovtsev +Date: 2011-12-13 12:06:17 +0000 + + Fix rst2html build failure in non-unicode locales + + Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43735 + Signed-off-by: Simon McVittie + + NEWS | 2 ++ + configure.ac | 1 + + 2 files changed, 3 insertions(+), 0 deletions(-) + +commit 75f2aaaa06e57bc1fbdbaf0530e48dea02541b03 +Author: Simon McVittie +Date: 2011-12-13 12:04:25 +0000 + + Update NEWS + + NEWS | 9 +++++++++ + 1 files changed, 9 insertions(+), 0 deletions(-) + +commit cabcf23207a67cb9215e3efc25ae6e8d73823fd1 +Author: Simon McVittie +Date: 2011-12-13 12:04:19 +0000 + + Remove dbus_bindings, deprecated for nearly 5 years + + Makefile.am | 4 +--- + NEWS | 5 +++++ + dbus/__init__.py | 4 ---- + dbus/_dbus.py | 18 ------------------ + dbus/dbus_bindings.py | 37 ------------------------------------- + dbus_bindings.py | 1 - + 6 files changed, 6 insertions(+), 63 deletions(-) + +commit 14225c74b5bd75cf6c4cda3647341dc20214e6b8 +Author: Barry Warsaw +Date: 2011-12-13 11:55:44 +0000 + + Use Python 3 syntax to catch exceptions + + Signed-off-by: Simon McVittie + + dbus/_expat_introspect_parser.py | 2 +- + dbus/bus.py | 2 +- + dbus/connection.py | 6 +++--- + dbus/proxies.py | 2 +- + dbus/service.py | 6 +++--- + examples/example-client.py | 2 +- + test/cross-test-client.py | 8 ++++---- + test/test-client.py | 12 ++++++------ + test/test-service.py | 2 +- + 9 files changed, 21 insertions(+), 21 deletions(-) + +commit 959ce518a3b5b8794b9813bac82c64540c21fc31 +Author: Barry Warsaw +Date: 2011-12-13 11:51:17 +0000 + + Use PyVarObject_HEAD_INIT to initialize types + + Part of a patch for Python 3 compatibility. + + Signed-off-by: Simon McVittie + + _dbus_bindings/bytes.c | 6 ++---- + _dbus_bindings/containers.c | 9 +++------ + _dbus_bindings/float.c | 6 ++---- + _dbus_bindings/int.c | 18 ++++++------------ + _dbus_bindings/mainloop.c | 3 +-- + _dbus_bindings/pending-call.c | 3 +-- + _dbus_bindings/signature.c | 6 ++---- + _dbus_bindings/string.c | 9 +++------ + _dbus_bindings/unixfd.c | 3 +-- + 9 files changed, 21 insertions(+), 42 deletions(-) + +commit 380d1f383c65e767c49d8416dde041a59ba1343e +Author: Barry Warsaw +Date: 2011-12-13 11:46:17 +0000 + + Adjust debug messages + + Part of a patch for Python 3 compatibility. + + Signed-off-by: Simon McVittie + + _dbus_bindings/message-append.c | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +commit fc24dbaa43e1aea47945cc608640022fd8f94093 +Author: Simon McVittie +Date: 2011-12-13 11:39:32 +0000 + + Require Python 2.6, to make porting to Python 3 easier + + Signed-off-by: Simon McVittie + + NEWS | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit ebd44a420264da0031b715f7f08a0b347a81dd30 +Author: Simon McVittie +Date: 2011-12-13 11:38:48 +0000 + + Use Py_TYPE() rather than thing->ob_type, for Python 3 portability + + Based on part of a patch from Barry Warsaw. + + Signed-off-by: Simon McVittie + + _dbus_bindings/abstract.c | 16 ++++++++-------- + _dbus_bindings/bytes.c | 2 +- + _dbus_bindings/conn.c | 2 +- + _dbus_bindings/containers.c | 4 ++-- + _dbus_bindings/dbus_bindings-internal.h | 4 ++-- + _dbus_bindings/int.c | 4 ++-- + _dbus_bindings/libdbusconn.c | 2 +- + _dbus_bindings/message-append.c | 2 +- + _dbus_bindings/message-get-args.c | 2 +- + _dbus_bindings/message.c | 4 ++-- + _dbus_bindings/pending-call.c | 2 +- + _dbus_bindings/server.c | 2 +- + _dbus_bindings/string.c | 4 ++-- + 13 files changed, 25 insertions(+), 25 deletions(-) + +commit dc1c98f05d29c5b7464d7ac34ee900066f261a86 +Author: Simon McVittie +Date: 2011-12-13 11:30:54 +0000 + + _message_iter_get_pyobject: if UTF-8 from libdbus is invalid, don't crash + + Based on part of a patch from Barry Warsaw. + + Signed-off-by: Simon McVittie + + _dbus_bindings/message-get-args.c | 10 +++++++--- + 1 files changed, 7 insertions(+), 3 deletions(-) + +commit 876c668ecbc7b79aa04218b90e0f8b617d3997ed +Author: Simon McVittie +Date: 2011-12-13 11:26:31 +0000 + + Don't warn about unused parameters + + Signed-off-by: Simon McVittie + + configure.ac | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +commit d1b628e10626a51c306ac8f59bcfbaae2b6fbf2b +Author: Barry Warsaw +Date: 2011-12-13 11:25:01 +0000 + + Don't leak UTF-8 string if serializing a unicode object fails with OOM + + Signed-off-by: Simon McVittie + + _dbus_bindings/message-append.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +commit fb64313b8d37a7869c5489c8ee1bfad0c2c84c0f +Author: Simon McVittie +Date: 2011-12-13 11:22:28 +0000 + + Remove dbus_py_tp_richcompare_by_pointer, dbus_py_tp_hash_by_pointer + + These turn out not to be used for anything. Spotted by Barry Warsaw. + + Signed-off-by: Simon McVittie + + _dbus_bindings/dbus_bindings-internal.h | 4 ---- + _dbus_bindings/generic.c | 23 ----------------------- + 2 files changed, 0 insertions(+), 27 deletions(-) + +commit 3caf4241af3a0fbee5948a217172990bb3c5e0b7 +Author: Simon McVittie +Date: 2011-11-15 16:34:51 +0000 + + NEWS + + NEWS | 9 +++++++++ + 1 files changed, 9 insertions(+), 0 deletions(-) + +commit 092f60d1887a907434fb34e3a8841b067c21a01e +Author: Simon McVittie +Date: 2011-11-15 16:23:50 +0000 + + Remove support for Python < 2.5 + + _dbus_bindings/dbus_bindings-internal.h | 7 ------- + _dbus_bindings/module.c | 10 ---------- + configure.ac | 2 +- + 3 files changed, 1 insertions(+), 18 deletions(-) + +commit dfa62b24adde8666df4d9cf64569d3aa51063ac8 +Author: Simon McVittie +Date: 2011-11-15 13:33:27 +0000 + + Bump dbus dependency to 1.4 so we can make decent error handling mandatory + + _dbus_bindings/message-append.c | 4 ---- + configure.ac | 12 +----------- + 2 files changed, 1 insertions(+), 15 deletions(-) + +commit 9c26d255d7d94a6a9be961672ca666de601b561d +Author: Simon McVittie +Date: 2011-05-25 13:51:24 +0100 + + Nano version + + configure.ac | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 6bdb27482cace69935584d2d9b33bdfce50ef5ce +Author: Simon McVittie +Date: 2011-05-25 12:50:36 +0100 prepare 0.84 - NEWS | 11 ++++++++++- - 1 files changed, 10 insertions(+), 1 deletions(-) + NEWS | 11 ++++++++++- + configure.ac | 4 ++-- + 2 files changed, 12 insertions(+), 3 deletions(-) commit 5ee02bf8785167f042636ab3005105243bff533b Author: Simon McVittie @@ -2120,8 +2854,8 @@ Don't run the examples during "make check" - timing/startup issues cause intermittent failures - test/run-test.sh | 22 +++++++++++----------- - 1 files changed, 11 insertions(+), 11 deletions(-) + test/run-test.sh | 24 ++++++++++++------------ + 1 files changed, 12 insertions(+), 12 deletions(-) commit 32c4636888e03025b5f01167cea6530a8fb1ce53 Author: Simon McVittie @@ -2425,8 +3159,8 @@ dbus/_dbus.py | 7 +- dbus/bus.py | 76 ++++++++++-------------- dbus/connection.py | 139 ++++++++++++++++++++++++++++++++++++++++++++ - dbus/proxies.py | 163 +++++++++++++++++++++------------------------------- - 5 files changed, 242 insertions(+), 144 deletions(-) + dbus/proxies.py | 161 +++++++++++++++++++++------------------------------- + 5 files changed, 241 insertions(+), 143 deletions(-) commit e40ec8e4f29d104b66d78b183300e6bf134c2714 Author: Simon McVittie @@ -5589,8 +6323,8 @@ _dbus_bindings/module.c: PEP7-style whitespace - _dbus_bindings/module.c | 42 +++++++++++++++++++++--------------------- - 1 files changed, 21 insertions(+), 21 deletions(-) + _dbus_bindings/module.c | 44 ++++++++++++++++++++++---------------------- + 1 files changed, 22 insertions(+), 22 deletions(-) commit 888110c46b864b613a3281e3d0bf76ed85b04b01 Author: Simon McVittie @@ -7388,8 +8122,8 @@ * python/dbus_bindings.pyx.in (cunregister_function_handler, cmessage_function_handler): Patch from Anthony Baxter fixes threading problems by using the Py_GILState_Ensure/Release to synchronize with the python runtime. - python/dbus_bindings.pyx.in | 62 +++++++++++++++++++++++++----------------- - 1 files changed, 37 insertions(+), 25 deletions(-) + python/dbus_bindings.pyx.in | 60 +++++++++++++++++++++++++----------------- + 1 files changed, 36 insertions(+), 24 deletions(-) commit b9ef3eaf17a91f258af17c6e9ae8acb23eb7b411 Author: Colin Walters diff -Nru dbus-python-0.84.0/compile dbus-python-1.0.0/compile --- dbus-python-0.84.0/compile 2011-05-25 11:45:20.000000000 +0000 +++ dbus-python-1.0.0/compile 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2009-10-06.20; # UTC +scriptversion=2010-11-15.09; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010 Free Software # Foundation, Inc. # Written by Tom Tromey . # @@ -29,6 +29,171 @@ # bugs to or send patches to # . +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Win32 hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as `compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l*) + lib=${1#-l} + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + set x "$@" "$dir/$lib.dll.lib" + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + set x "$@" "$dir/$lib.lib" + break + fi + done + IFS=$save_IFS + + test "$found" != yes && set x "$@" "$lib.lib" + shift + ;; + -L*) + func_file_conv "${1#-L}" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 @@ -53,11 +218,13 @@ echo "compile $scriptversion" exit $? ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; esac ofile= cfile= -eat= for arg do diff -Nru dbus-python-0.84.0/config.h.in dbus-python-1.0.0/config.h.in --- dbus-python-0.84.0/config.h.in 2011-05-25 11:50:08.000000000 +0000 +++ dbus-python-1.0.0/config.h.in 2012-01-24 16:37:30.000000000 +0000 @@ -9,12 +9,6 @@ /* dbus-python minor version */ #undef DBUS_PYTHON_MINOR_VERSION -/* Define if libdbus-1 has dbus_message_iter_abandon_container */ -#undef HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER - -/* Define if libdbus-1 has dbus_watch_get_unix_fd */ -#undef HAVE_DBUS_WATCH_GET_UNIX_FD - /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff -Nru dbus-python-0.84.0/configure dbus-python-1.0.0/configure --- dbus-python-0.84.0/configure 2011-05-25 11:50:03.000000000 +0000 +++ dbus-python-1.0.0/configure 2012-01-24 16:37:29.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for dbus-python 0.84.0. +# Generated by GNU Autoconf 2.68 for dbus-python 1.0.0. # # Report bugs to . # @@ -571,8 +571,8 @@ # Identity of this package. PACKAGE_NAME='dbus-python' PACKAGE_TARNAME='dbus-python' -PACKAGE_VERSION='0.84.0' -PACKAGE_STRING='dbus-python 0.84.0' +PACKAGE_VERSION='1.0.0' +PACKAGE_STRING='dbus-python 1.0.0' PACKAGE_BUGREPORT='http://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=python' PACKAGE_URL='' @@ -667,6 +667,7 @@ am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE +am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE @@ -781,6 +782,7 @@ LIBS CPPFLAGS CPP +PYTHON PYTHON_INCLUDES PYTHON_LIBS PKG_CONFIG @@ -1332,7 +1334,7 @@ # 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 0.84.0 to adapt to many kinds of systems. +\`configure' configures dbus-python 1.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1402,7 +1404,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dbus-python 0.84.0:";; + short | recursive ) echo "Configuration of dbus-python 1.0.0:";; esac cat <<\_ACEOF @@ -1425,15 +1427,13 @@ and docutils) --disable-Werror compile without -Werror (normally enabled in development builds) - --enable-Werror Treat warnings as errors, if the compiler supports - it --enable-coding-style-checks check coding style using grep Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic try to use only PIC/non-PIC objects [default=use + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR @@ -1448,6 +1448,7 @@ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + PYTHON the Python interpreter PYTHON_INCLUDES CPPFLAGS for Python, overriding output of python2.x-config --includes, e.g. "-I/opt/misc/include/python2.7" @@ -1531,7 +1532,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dbus-python configure 0.84.0 +dbus-python configure 1.0.0 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1809,7 +1810,7 @@ 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 0.84.0, which was +It was created by dbus-python $as_me 1.0.0, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2172,14 +2173,14 @@ -$as_echo "#define DBUS_PYTHON_MAJOR_VERSION 0" >>confdefs.h +$as_echo "#define DBUS_PYTHON_MAJOR_VERSION 1" >>confdefs.h -DBUS_PYTHON_MAJOR_VERSION=0 +DBUS_PYTHON_MAJOR_VERSION=1 -$as_echo "#define DBUS_PYTHON_MINOR_VERSION 84" >>confdefs.h +$as_echo "#define DBUS_PYTHON_MINOR_VERSION 0" >>confdefs.h -DBUS_PYTHON_MINOR_VERSION=84 +DBUS_PYTHON_MINOR_VERSION=0 $as_echo "#define DBUS_PYTHON_MICRO_VERSION 0" >>confdefs.h @@ -2658,7 +2659,7 @@ # Define the identity of the package. PACKAGE='dbus-python' - VERSION='0.84.0' + VERSION='1.0.0' cat >>confdefs.h <<_ACEOF @@ -2813,8 +2814,8 @@ -macro_version='2.4' -macro_revision='1.3293' +macro_version='2.4.2' +macro_revision='1.3337' @@ -2951,6 +2952,7 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' + am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= @@ -3764,6 +3766,7 @@ # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -3823,7 +3826,7 @@ break fi ;; - msvisualcpp | msvcmsys) + msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. @@ -4567,6 +4570,11 @@ lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -4606,7 +4614,7 @@ # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -5035,7 +5043,7 @@ lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -5676,13 +5684,13 @@ if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -5829,6 +5837,7 @@ # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -6217,7 +6226,7 @@ CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 @@ -6228,7 +6237,20 @@ case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -6868,7 +6890,13 @@ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 @@ -6879,6 +6907,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : @@ -6911,6 +6940,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : @@ -6932,7 +6962,9 @@ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 @@ -7307,7 +7339,22 @@ # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : - withval=$with_pic; pic_mode="$withval" + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac else pic_mode=default fi @@ -7385,6 +7432,10 @@ + + + + test -z "$LN_S" && LN_S="ln -s" @@ -7844,7 +7895,9 @@ case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' - lt_prog_compiler_pic='-Xcompiler -fPIC' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi ;; esac else @@ -7935,18 +7988,33 @@ ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; esac ;; esac @@ -8308,7 +8376,6 @@ hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported @@ -8561,8 +8628,7 @@ xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld='-rpath $libdir' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ @@ -8942,6 +9008,7 @@ # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' @@ -8987,6 +9054,7 @@ hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + else whole_archive_flag_spec='' fi @@ -9015,10 +9083,6 @@ hardcode_shlibpath_var=no ;; - freebsd1*) - ld_shlibs=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -9031,7 +9095,7 @@ ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes @@ -9070,7 +9134,6 @@ fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes @@ -9694,11 +9757,6 @@ - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } @@ -9788,7 +9846,7 @@ case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -9797,7 +9855,7 @@ ;; aix[4-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -9862,7 +9920,7 @@ ;; bsdi[45]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -10001,7 +10059,7 @@ ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -10009,10 +10067,6 @@ shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -10020,7 +10074,7 @@ objformat=`/usr/bin/objformat` else case $host_os in - freebsd[123]*) objformat=aout ;; + freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -10038,7 +10092,7 @@ esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) @@ -10058,7 +10112,7 @@ ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' @@ -10069,7 +10123,7 @@ ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -10130,7 +10184,7 @@ ;; interix[3-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -10146,7 +10200,7 @@ nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -10183,9 +10237,9 @@ dynamic_linker=no ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -10279,7 +10333,7 @@ ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -10348,7 +10402,7 @@ ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -10373,7 +10427,7 @@ ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -10397,7 +10451,7 @@ sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -10428,7 +10482,7 @@ tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -10438,7 +10492,7 @@ ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -11220,6 +11274,8 @@ + + ac_config_commands="$ac_config_commands libtool" @@ -11359,15 +11415,17 @@ + + if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.4.0" >&5 -$as_echo_n "checking whether $PYTHON version >= 2.4.0... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.6" >&5 +$as_echo_n "checking whether $PYTHON version >= 2.6... " >&6; } prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x -minver = list(map(int, '2.4.0'.split('.'))) + [0, 0, 0] +minver = list(map(int, '2.6'.split('.'))) + [0, 0, 0] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i] @@ -11386,19 +11444,19 @@ else # Otherwise, try each interpreter until we find one that satisfies # VERSION. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.4.0" >&5 -$as_echo_n "checking for a Python interpreter with version >= 2.4.0... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.6" >&5 +$as_echo_n "checking for a Python interpreter with version >= 2.6... " >&6; } if ${am_cv_pathless_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else - for am_cv_pathless_PYTHON in python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do + for am_cv_pathless_PYTHON in python python2 python3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do test "$am_cv_pathless_PYTHON" = none && break prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x -minver = list(map(int, '2.4.0'.split('.'))) + [0, 0, 0] +minver = list(map(int, '2.6'.split('.'))) + [0, 0, 0] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i] @@ -11634,7 +11692,7 @@ CPPFLAGS="$save_CPPFLAGS" -PLATFORM=`$PYTHON -c "from distutils import util; print util.get_platform()"` +PLATFORM=`$PYTHON -c "from __future__ import print_function; from distutils import util; print(util.get_platform())"` @@ -11993,6 +12051,27 @@ fi ;; esac + +case " $RST2HTMLFLAGS " in +*[\ \ ]--input-encoding=UTF-8[\ \ ]*) + ;; +*) + save_RST2HTMLFLAGS="$RST2HTMLFLAGS" + RST2HTMLFLAGS="$RST2HTMLFLAGS --input-encoding=UTF-8" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $RST2HTML understands --input-encoding=UTF-8" >&5 +$as_echo_n "checking whether $RST2HTML understands --input-encoding=UTF-8... " >&6; } + if $RST2HTML --strict $RST2HTMLFLAGS /dev/null > /dev/null 2>/dev/null; then + dbuspy_has_option=yes + else + dbuspy_has_option=no + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dbuspy_has_option" >&5 +$as_echo "$dbuspy_has_option" >&6; } + if test $dbuspy_has_option = no; then + RST2HTMLFLAGS="$save_RST2HTMLFLAGS" + fi + ;; +esac fi fi @@ -12144,12 +12223,12 @@ pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.0") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1 >= 1.0" 2>/dev/null` + pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1 >= 1.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -12161,12 +12240,12 @@ pkg_cv_DBUS_LIBS="$DBUS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.0") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1 >= 1.0" 2>/dev/null` + pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1 >= 1.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -12187,14 +12266,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1 >= 1.0" 2>&1` + DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1 >= 1.4" 2>&1` else - DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1 >= 1.0" 2>&1` + DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1 >= 1.4" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$DBUS_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (dbus-1 >= 1.0) were not met: + as_fn_error $? "Package requirements (dbus-1 >= 1.4) were not met: $DBUS_PKG_ERRORS @@ -12318,95 +12397,6 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus_watch_get_unix_fd in -ldbus-1" >&5 -$as_echo_n "checking for dbus_watch_get_unix_fd in -ldbus-1... " >&6; } -if ${ac_cv_lib_dbus_1_dbus_watch_get_unix_fd+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldbus-1 $DBUS_LIBS $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dbus_watch_get_unix_fd (); -int -main () -{ -return dbus_watch_get_unix_fd (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dbus_1_dbus_watch_get_unix_fd=yes -else - ac_cv_lib_dbus_1_dbus_watch_get_unix_fd=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dbus_1_dbus_watch_get_unix_fd" >&5 -$as_echo "$ac_cv_lib_dbus_1_dbus_watch_get_unix_fd" >&6; } -if test "x$ac_cv_lib_dbus_1_dbus_watch_get_unix_fd" = xyes; then : - -$as_echo "#define HAVE_DBUS_WATCH_GET_UNIX_FD /**/" >>confdefs.h - -else - : -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus_message_iter_abandon_container in -ldbus-1" >&5 -$as_echo_n "checking for dbus_message_iter_abandon_container in -ldbus-1... " >&6; } -if ${ac_cv_lib_dbus_1_dbus_message_iter_abandon_container+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldbus-1 $DBUS_LIBS $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dbus_message_iter_abandon_container (); -int -main () -{ -return dbus_message_iter_abandon_container (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dbus_1_dbus_message_iter_abandon_container=yes -else - ac_cv_lib_dbus_1_dbus_message_iter_abandon_container=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dbus_1_dbus_message_iter_abandon_container" >&5 -$as_echo "$ac_cv_lib_dbus_1_dbus_message_iter_abandon_container" >&6; } -if test "x$ac_cv_lib_dbus_1_dbus_message_iter_abandon_container" = xyes; then : - -$as_echo "#define HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER /**/" >>confdefs.h - -else - : -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if compiler understands " >&5 $as_echo_n "checking to see if compiler understands ... " >&6; } @@ -12544,7 +12534,8 @@ $as_echo "$flag_ok" >&6; } - for tp_flag in missing-field-initializers; do + for tp_flag in missing-field-initializers \ + unused-parameter; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if compiler understands -Wno-$tp_flag" >&5 $as_echo_n "checking to see if compiler understands -Wno-$tp_flag... " >&6; } @@ -12708,49 +12699,6 @@ ;; esac -# Check whether --enable-Werror was given. -if test "${enable_Werror+set}" = set; then : - enableval=$enable_Werror; enable_Werror=$enableval -else - enable_Werror=no -fi - -if test "x$enable_Werror" = xyes; then - -case " $CFLAGS " in -*[\ \ ]-Werror[\ \ ]*) - ;; -*) - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -Werror" >&5 -$as_echo_n "checking whether $CC understands -Werror... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - jh_has_option=yes -else - jh_has_option=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jh_has_option" >&5 -$as_echo "$jh_has_option" >&6; } - if test $jh_has_option = no; then - CFLAGS="$save_CFLAGS" - fi - ;; -esac -fi - CFLAGS="$CFLAGS $CFLAGS_WARNINGS" # version x.y.z - disable coding style checks by default @@ -13307,7 +13255,7 @@ # 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 0.84.0, which was +This file was extended by dbus-python $as_me 1.0.0, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13373,7 +13321,7 @@ 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 0.84.0 +dbus-python config.status 1.0.0 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" @@ -13510,6 +13458,7 @@ enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' @@ -13592,7 +13541,6 @@ allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' @@ -13648,6 +13596,7 @@ # Quote evaled strings. for var in SHELL \ ECHO \ +PATH_SEPARATOR \ SED \ GREP \ EGREP \ @@ -13698,7 +13647,6 @@ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ @@ -14504,8 +14452,8 @@ # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -14559,6 +14507,9 @@ # An echo program that protects backslashes. ECHO=$lt_ECHO +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + # The host system. host_alias=$host_alias host=$host @@ -14860,10 +14811,6 @@ # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator diff -Nru dbus-python-0.84.0/configure.ac dbus-python-1.0.0/configure.ac --- dbus-python-0.84.0/configure.ac 2011-05-25 11:49:41.000000000 +0000 +++ dbus-python-1.0.0/configure.ac 2012-01-24 16:36:42.000000000 +0000 @@ -4,8 +4,8 @@ dnl If not 1, append datestamp to the version number m4_define(dbus_python_released, 1) dnl The dbus-python version number (must actually be numeric at the moment) -m4_define(dbus_python_major_version, 0) -m4_define(dbus_python_minor_version, 84) +m4_define(dbus_python_major_version, 1) +m4_define(dbus_python_minor_version, 0) m4_define(dbus_python_micro_version, 0) m4_define(dbus_python_maybe_datestamp, @@ -31,7 +31,7 @@ AC_CONFIG_SRCDIR([_dbus_bindings/module.c]) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE([1.9]) +AM_INIT_AUTOMAKE([1.9 -Wno-portability]) AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -46,11 +46,11 @@ AC_PROG_LIBTOOL AM_PROG_CC_C_O -AM_PATH_PYTHON(2.4.0) +AM_PATH_PYTHON([2.6]) AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) -PLATFORM=`$PYTHON -c "from distutils import util; print util.get_platform()"` +PLATFORM=`$PYTHON -c "from __future__ import print_function; from distutils import util; print(util.get_platform())"` AC_SUBST(PLATFORM) AC_ARG_VAR([PYTHON_LIBS], [LDFLAGS for Python, overriding output of python2.x-config --ldflags, e.g. "-L/opt/misc/lib -lpython2.7"]) @@ -140,6 +140,7 @@ DBUS_PY_ADD_RST2HTMLFLAG([--no-raw]) DBUS_PY_ADD_RST2HTMLFLAG([--no-file-insertion]) DBUS_PY_ADD_RST2HTMLFLAG([--cloak-email-addresses]) + DBUS_PY_ADD_RST2HTMLFLAG([--input-encoding=UTF-8]) fi fi AC_SUBST([RST2HTML]) @@ -148,19 +149,9 @@ 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.0]) +PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.4]) PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.70]) -dnl avoid deprecated stuff if possible -AC_CHECK_LIB([dbus-1], [dbus_watch_get_unix_fd], - [AC_DEFINE([HAVE_DBUS_WATCH_GET_UNIX_FD], [], - [Define if libdbus-1 has dbus_watch_get_unix_fd])], - [:], [$DBUS_LIBS]) -AC_CHECK_LIB([dbus-1], [dbus_message_iter_abandon_container], - [AC_DEFINE([HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER], [], - [Define if libdbus-1 has dbus_message_iter_abandon_container])], - [:], [$DBUS_LIBS]) - TP_COMPILER_WARNINGS([CFLAGS_WARNINGS], [test] dbus_python_released [= 0], [all \ extra \ @@ -175,19 +166,12 @@ pointer-arith \ format-security \ init-self], - [missing-field-initializers]) + [missing-field-initializers \ + unused-parameter]) JH_ADD_CFLAG([-std=c9x]) JH_ADD_CFLAG([-fno-strict-aliasing]) -AC_ARG_ENABLE(Werror, -AC_HELP_STRING([--enable-Werror], - [Treat warnings as errors, if the compiler supports it]), -enable_Werror=$enableval, enable_Werror=no) -if test "x$enable_Werror" = xyes; then - JH_ADD_CFLAG([-Werror]) -fi - CFLAGS="$CFLAGS $CFLAGS_WARNINGS" ifelse(dbus_python_released, 1, diff -Nru dbus-python-0.84.0/dbus/bus.py dbus-python-1.0.0/dbus/bus.py --- dbus-python-0.84.0/dbus/bus.py 2010-03-24 12:18:10.000000000 +0000 +++ dbus-python-1.0.0/dbus/bus.py 2012-01-24 15:55:44.000000000 +0000 @@ -26,26 +26,20 @@ import logging import weakref -from _dbus_bindings import validate_interface_name, validate_member_name,\ - validate_bus_name, validate_object_path,\ - validate_error_name,\ - BUS_SESSION, BUS_STARTER, BUS_SYSTEM, \ - DBUS_START_REPLY_SUCCESS, \ - DBUS_START_REPLY_ALREADY_RUNNING, \ - BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ - NAME_FLAG_ALLOW_REPLACEMENT, \ - NAME_FLAG_DO_NOT_QUEUE, \ - NAME_FLAG_REPLACE_EXISTING, \ - RELEASE_NAME_REPLY_NON_EXISTENT, \ - RELEASE_NAME_REPLY_NOT_OWNER, \ - RELEASE_NAME_REPLY_RELEASED, \ - REQUEST_NAME_REPLY_ALREADY_OWNER, \ - REQUEST_NAME_REPLY_EXISTS, \ - REQUEST_NAME_REPLY_IN_QUEUE, \ - REQUEST_NAME_REPLY_PRIMARY_OWNER +from _dbus_bindings import ( + BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION, + BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING, + DBUS_START_REPLY_SUCCESS, NAME_FLAG_ALLOW_REPLACEMENT, + NAME_FLAG_DO_NOT_QUEUE, NAME_FLAG_REPLACE_EXISTING, + RELEASE_NAME_REPLY_NON_EXISTENT, RELEASE_NAME_REPLY_NOT_OWNER, + RELEASE_NAME_REPLY_RELEASED, REQUEST_NAME_REPLY_ALREADY_OWNER, + REQUEST_NAME_REPLY_EXISTS, REQUEST_NAME_REPLY_IN_QUEUE, + REQUEST_NAME_REPLY_PRIMARY_OWNER, validate_bus_name, validate_error_name, + validate_interface_name, validate_member_name, validate_object_path) from dbus.connection import Connection from dbus.exceptions import DBusException from dbus.lowlevel import HANDLER_RESULT_NOT_YET_HANDLED +from dbus._compat import is_py2 _NAME_OWNER_CHANGE_MATCH = ("type='signal',sender='%s'," @@ -84,13 +78,16 @@ BUS_DAEMON_NAME, BUS_DAEMON_PATH, arg0=bus_name) + keywords = {} + if is_py2: + keywords['utf8_strings'] = True self._pending_call = bus_conn.call_async(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, 'GetNameOwner', 's', (bus_name,), callback, error_cb, - utf8_strings=True) + **keywords) def cancel(self): if self._match is not None: @@ -176,7 +173,7 @@ and bus_name != BUS_DAEMON_NAME): try: return self.get_name_owner(bus_name) - except DBusException, e: + except DBusException as e: if e.get_dbus_name() != _NAME_HAS_NO_OWNER: raise # else it doesn't exist: try to start it @@ -237,7 +234,7 @@ bus_name = named_service if kwargs: raise TypeError('get_object does not take these keyword ' - 'arguments: %s' % ', '.join(kwargs.iterkeys())) + 'arguments: %s' % ', '.join(kwargs.keys())) return self.ProxyObjectClass(self, bus_name, object_path, introspect=introspect, @@ -328,9 +325,12 @@ :Returns: a dbus.Array of dbus.UTF8String :Since: 0.81.0 """ + keywords = {} + if is_py2: + keywords['utf8_strings'] = True return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, 'ListNames', - '', (), utf8_strings=True) + '', (), **keywords) def list_activatable_names(self): """Return a list of all names that can be activated on the bus. @@ -338,9 +338,12 @@ :Returns: a dbus.Array of dbus.UTF8String :Since: 0.81.0 """ + keywords = {} + if is_py2: + keywords['utf8_strings'] = True return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, 'ListActivatableNames', - '', (), utf8_strings=True) + '', (), **keywords) def get_name_owner(self, bus_name): """Return the unique connection name of the primary owner of the @@ -349,10 +352,13 @@ :Raises `DBusException`: if the `bus_name` has no owner :Since: 0.81.0 """ + keywords = {} + if is_py2: + keywords['utf8_strings'] = True validate_bus_name(bus_name, allow_unique=False) return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, 'GetNameOwner', - 's', (bus_name,), utf8_strings=True) + 's', (bus_name,), **keywords) def watch_name_owner(self, bus_name, callback): """Watch the unique connection name of the primary owner of the diff -Nru dbus-python-0.84.0/dbus/_compat.py dbus-python-1.0.0/dbus/_compat.py --- dbus-python-0.84.0/dbus/_compat.py 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/dbus/_compat.py 2012-01-24 15:55:44.000000000 +0000 @@ -0,0 +1,8 @@ +# Python 2 / Python 3 compatibility helpers. + +import sys + +# In Python 2.6, sys.version_info is not a namedtuple, so we can't use +# sys.version_info.major. +is_py3 = (sys.version_info[0] == 3) +is_py2 = not is_py3 diff -Nru dbus-python-0.84.0/dbus/connection.py dbus-python-1.0.0/dbus/connection.py --- dbus-python-0.84.0/dbus/connection.py 2010-02-18 14:53:46.000000000 +0000 +++ dbus-python-1.0.0/dbus/connection.py 2012-01-24 15:55:44.000000000 +0000 @@ -24,22 +24,23 @@ __docformat__ = 'reStructuredText' import logging -try: - import thread -except ImportError: - import dummy_thread as thread +import threading import weakref -from _dbus_bindings import Connection as _Connection, \ - LOCAL_PATH, LOCAL_IFACE, \ - validate_interface_name, validate_member_name,\ - validate_bus_name, validate_object_path,\ - validate_error_name, \ - UTF8String +from _dbus_bindings import ( + Connection as _Connection, LOCAL_IFACE, LOCAL_PATH, validate_bus_name, + validate_interface_name, validate_member_name, validate_object_path) from dbus.exceptions import DBusException -from dbus.lowlevel import ErrorMessage, MethodCallMessage, SignalMessage, \ - MethodReturnMessage, HANDLER_RESULT_NOT_YET_HANDLED +from dbus.lowlevel import ( + ErrorMessage, HANDLER_RESULT_NOT_YET_HANDLED, MethodCallMessage, + MethodReturnMessage, SignalMessage) from dbus.proxies import ProxyObject +from dbus._compat import is_py2, is_py3 + +if is_py3: + from _dbus_bindings import String +else: + from _dbus_bindings import UTF8String _logger = logging.getLogger('dbus.connection') @@ -50,15 +51,19 @@ class SignalMatch(object): - __slots__ = ('_sender_name_owner', '_member', '_interface', '_sender', - '_path', '_handler', '_args_match', '_rule', - '_utf8_strings', '_byte_arrays', '_conn_weakref', - '_destination_keyword', '_interface_keyword', - '_message_keyword', '_member_keyword', - '_sender_keyword', '_path_keyword', '_int_args_match') + _slots = ['_sender_name_owner', '_member', '_interface', '_sender', + '_path', '_handler', '_args_match', '_rule', + '_byte_arrays', '_conn_weakref', + '_destination_keyword', '_interface_keyword', + '_message_keyword', '_member_keyword', + '_sender_keyword', '_path_keyword', '_int_args_match'] + if is_py2: + _slots.append('_utf8_strings') + + __slots__ = tuple(_slots) def __init__(self, conn, sender, object_path, dbus_interface, - member, handler, utf8_strings=False, byte_arrays=False, + member, handler, byte_arrays=False, sender_keyword=None, path_keyword=None, interface_keyword=None, member_keyword=None, message_keyword=None, destination_keyword=None, @@ -84,7 +89,11 @@ # this later self._sender_name_owner = sender - self._utf8_strings = utf8_strings + if is_py2: + self._utf8_strings = kwargs.pop('utf8_strings', False) + elif 'utf8_strings' in kwargs: + raise TypeError("unexpected keyword argument 'utf8_strings'") + self._byte_arrays = byte_arrays self._sender_keyword = sender_keyword self._path_keyword = path_keyword @@ -138,7 +147,7 @@ if self._member is not None: rule.append("member='%s'" % self._member) if self._int_args_match is not None: - for index, value in self._int_args_match.iteritems(): + for index, value in self._int_args_match.items(): rule.append("arg%d='%s'" % (index, value)) self._rule = ','.join(rule) @@ -176,10 +185,14 @@ return False if self._int_args_match is not None: # extracting args with utf8_strings and byte_arrays is less work - args = message.get_args_list(utf8_strings=True, byte_arrays=True) - for index, value in self._int_args_match.iteritems(): + kwargs = dict(byte_arrays=True) + arg_type = (String if is_py3 else UTF8String) + if is_py2: + kwargs['utf8_strings'] = True + args = message.get_args_list(**kwargs) + for index, value in self._int_args_match.items(): if (index >= len(args) - or not isinstance(args[index], UTF8String) + or not isinstance(args[index], arg_type) or args[index] != value): return False @@ -195,9 +208,12 @@ # minor optimization: if we already extracted the args with the # right calling convention to do the args match, don't bother # doing so again - if args is None or not self._utf8_strings or not self._byte_arrays: - args = message.get_args_list(utf8_strings=self._utf8_strings, - byte_arrays=self._byte_arrays) + utf8_strings = (is_py2 and self._utf8_strings) + if args is None or not utf8_strings or not self._byte_arrays: + kwargs = dict(byte_arrays=self._byte_arrays) + if is_py2: + kwargs['utf8_strings'] = self._utf8_strings + args = message.get_args_list(**kwargs) kwargs = {} if self._sender_keyword is not None: kwargs[self._sender_keyword] = message.get_sender() @@ -252,7 +268,7 @@ """Map from object path to dict mapping dbus_interface to dict mapping member to list of SignalMatch objects.""" - self._signals_lock = thread.allocate_lock() + self._signals_lock = threading.Lock() """Lock used to protect signal data structures""" self.add_message_filter(self.__class__._signal_func) @@ -305,7 +321,7 @@ bus_name = named_service if kwargs: raise TypeError('get_object does not take these keyword ' - 'arguments: %s' % ', '.join(kwargs.iterkeys())) + 'arguments: %s' % ', '.join(kwargs.keys())) return self.ProxyObjectClass(self, bus_name, object_path, introspect=introspect) @@ -425,8 +441,7 @@ member_keys = (None,) for path in path_keys: - by_interface = self._signal_recipients_by_object_path.get(path, - None) + by_interface = self._signal_recipients_by_object_path.get(path) if by_interface is None: continue for dbus_interface in interface_keys: @@ -525,7 +540,7 @@ for cb in self.__call_on_disconnection: try: cb(self) - except Exception, e: + except Exception: # basicConfig is a no-op if logging is already configured logging.basicConfig() _logger.error('Exception in handler for Disconnected ' @@ -535,8 +550,8 @@ def call_async(self, bus_name, object_path, dbus_interface, method, signature, args, reply_handler, error_handler, - timeout=-1.0, utf8_strings=False, byte_arrays=False, - require_main_loop=True): + timeout=-1.0, byte_arrays=False, + require_main_loop=True, **kwargs): """Call the given method, asynchronously. If the reply_handler is None, successful replies will be ignored. @@ -554,8 +569,11 @@ 'interface %s' % LOCAL_IFACE) # no need to validate other args - MethodCallMessage ctor will do - get_args_opts = {'utf8_strings': utf8_strings, - 'byte_arrays': byte_arrays} + get_args_opts = dict(byte_arrays=byte_arrays) + if is_py2: + get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False) + elif 'utf8_strings' in kwargs: + raise TypeError("unexpected keyword argument 'utf8_strings'") message = MethodCallMessage(destination=bus_name, path=object_path, @@ -564,7 +582,7 @@ # Add the arguments to the function try: message.append(signature=signature, *args) - except Exception, e: + except Exception as e: logging.basicConfig() _logger.error('Unable to set arguments %r according to ' 'signature %r: %s: %s', @@ -595,8 +613,8 @@ require_main_loop=require_main_loop) def call_blocking(self, bus_name, object_path, dbus_interface, method, - signature, args, timeout=-1.0, utf8_strings=False, - byte_arrays=False): + signature, args, timeout=-1.0, + byte_arrays=False, **kwargs): """Call the given method, synchronously. :Since: 0.81.0 """ @@ -608,8 +626,11 @@ 'interface %s' % LOCAL_IFACE) # no need to validate other args - MethodCallMessage ctor will do - get_args_opts = {'utf8_strings': utf8_strings, - 'byte_arrays': byte_arrays} + get_args_opts = dict(byte_arrays=byte_arrays) + if is_py2: + get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False) + elif 'utf8_strings' in kwargs: + raise TypeError("unexpected keyword argument 'utf8_strings'") message = MethodCallMessage(destination=bus_name, path=object_path, @@ -618,7 +639,7 @@ # Add the arguments to the function try: message.append(signature=signature, *args) - except Exception, e: + except Exception as e: logging.basicConfig() _logger.error('Unable to set arguments %r according to ' 'signature %r: %s: %s', diff -Nru dbus-python-0.84.0/dbus/dbus_bindings.py dbus-python-1.0.0/dbus/dbus_bindings.py --- dbus-python-0.84.0/dbus/dbus_bindings.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/dbus_bindings.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -# Backwards-compatibility with the old dbus_bindings. - -from warnings import warn as _warn - -_dbus_bindings_warning = DeprecationWarning("""\ -The dbus_bindings module is not public API and will go away soon. - -Most uses of dbus_bindings are applications catching the exception -dbus.dbus_bindings.DBusException. You should use dbus.DBusException -instead (this is compatible with all dbus-python versions since 0.40.2). - -If you need additional public API, please contact the maintainers via -. -""") - -_warn(_dbus_bindings_warning, DeprecationWarning, stacklevel=2) - -# Exceptions -from dbus.exceptions import DBusException -class ConnectionError(Exception): pass - -# Types -from dbus.types import * - -# Messages -from _dbus_bindings import Message, SignalMessage as Signal,\ - MethodCallMessage as MethodCall,\ - MethodReturnMessage as MethodReturn,\ - ErrorMessage as Error -# MessageIter has gone away, thankfully - -# Connection -from _dbus_bindings import Connection - -from dbus import Bus -bus_request_name = Bus.request_name -bus_release_name = Bus.release_name diff -Nru dbus-python-0.84.0/dbus/_dbus.py dbus-python-1.0.0/dbus/_dbus.py --- dbus-python-0.84.0/dbus/_dbus.py 2008-11-28 15:53:44.000000000 +0000 +++ dbus-python-1.0.0/dbus/_dbus.py 2012-01-24 15:55:44.000000000 +0000 @@ -30,26 +30,18 @@ __all__ = ('Bus', 'SystemBus', 'SessionBus', 'StarterBus') __docformat__ = 'reStructuredText' -import os -import sys -import weakref -from traceback import print_exc - from dbus.exceptions import DBusException -from _dbus_bindings import BUS_DAEMON_NAME, BUS_DAEMON_PATH,\ - BUS_DAEMON_IFACE, UTF8String,\ - validate_member_name, validate_interface_name,\ - validate_bus_name, validate_object_path,\ - BUS_SESSION, BUS_SYSTEM, BUS_STARTER,\ - DBUS_START_REPLY_SUCCESS, \ - DBUS_START_REPLY_ALREADY_RUNNING +from _dbus_bindings import ( + BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION, + BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING, + DBUS_START_REPLY_SUCCESS, validate_bus_name, + validate_interface_name, validate_member_name, validate_object_path) from dbus.bus import BusConnection from dbus.lowlevel import SignalMessage +from dbus._compat import is_py2 -try: - import thread -except ImportError: - import dummy_thread as thread +if is_py2: + from _dbus_bindings import UTF8String class Bus(BusConnection): @@ -236,21 +228,3 @@ """ return Bus.__new__(cls, Bus.TYPE_STARTER, private=private, mainloop=mainloop) - - -if 'DBUS_PYTHON_NO_DEPRECATED' not in os.environ: - - class _DBusBindingsEmulation: - """A partial emulation of the dbus_bindings module.""" - def __str__(self): - return '_DBusBindingsEmulation()' - def __repr__(self): - return '_DBusBindingsEmulation()' - def __getattr__(self, attr): - global dbus_bindings - import dbus.dbus_bindings as m - dbus_bindings = m - return getattr(m, attr) - - dbus_bindings = _DBusBindingsEmulation() - """Deprecated, don't use.""" diff -Nru dbus-python-0.84.0/dbus/decorators.py dbus-python-1.0.0/dbus/decorators.py --- dbus-python-0.84.0/dbus/decorators.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/decorators.py 2012-01-24 15:55:44.000000000 +0000 @@ -33,14 +33,15 @@ from dbus import validate_interface_name, Signature, validate_member_name from dbus.lowlevel import SignalMessage from dbus.exceptions import DBusException +from dbus._compat import is_py2 def method(dbus_interface, in_signature=None, out_signature=None, - async_callbacks=None, - sender_keyword=None, path_keyword=None, destination_keyword=None, - message_keyword=None, connection_keyword=None, - utf8_strings=False, byte_arrays=False, - rel_path_keyword=None): + async_callbacks=None, + sender_keyword=None, path_keyword=None, destination_keyword=None, + message_keyword=None, connection_keyword=None, + byte_arrays=False, + rel_path_keyword=None, **kwargs): """Factory for decorators used to mark methods of a `dbus.service.Object` to be exported on the D-Bus. @@ -182,9 +183,9 @@ in_sig = tuple(Signature(in_signature)) if len(in_sig) > len(args): - raise ValueError, 'input signature is longer than the number of arguments taken' + raise ValueError('input signature is longer than the number of arguments taken') elif len(in_sig) < len(args): - raise ValueError, 'input signature is shorter than the number of arguments taken' + raise ValueError('input signature is shorter than the number of arguments taken') func._dbus_is_method = True func._dbus_async_callbacks = async_callbacks @@ -198,8 +199,12 @@ func._dbus_message_keyword = message_keyword func._dbus_connection_keyword = connection_keyword func._dbus_args = args - func._dbus_get_args_options = {'byte_arrays': byte_arrays, - 'utf8_strings': utf8_strings} + func._dbus_get_args_options = dict(byte_arrays=byte_arrays) + if is_py2: + func._dbus_get_args_options['utf8_strings'] = kwargs.get( + 'utf8_strings', False) + elif 'utf8_strings' in kwargs: + raise TypeError("unexpected keyword argument 'utf8_strings'") return func return decorator @@ -325,9 +330,9 @@ sig = tuple(Signature(signature)) if len(sig) > len(args): - raise ValueError, 'signal signature is longer than the number of arguments provided' + raise ValueError('signal signature is longer than the number of arguments provided') elif len(sig) < len(args): - raise ValueError, 'signal signature is shorter than the number of arguments provided' + raise ValueError('signal signature is shorter than the number of arguments provided') emit_signal.__name__ = func.__name__ emit_signal.__doc__ = func.__doc__ diff -Nru dbus-python-0.84.0/dbus/exceptions.py dbus-python-1.0.0/dbus/exceptions.py --- dbus-python-0.84.0/dbus/exceptions.py 2008-11-28 15:53:44.000000000 +0000 +++ dbus-python-1.0.0/dbus/exceptions.py 2012-01-24 15:55:44.000000000 +0000 @@ -27,6 +27,7 @@ 'IntrospectionParserException', 'UnknownMethodException', 'NameExistsException') + class DBusException(Exception): include_traceback = False @@ -57,7 +58,9 @@ def get_dbus_message(self): s = Exception.__str__(self) - return s.decode('utf-8', 'replace') + if isinstance(s, bytes): + return s.decode('utf-8', 'replace') + return s def get_dbus_name(self): return self._dbus_error_name diff -Nru dbus-python-0.84.0/dbus/_expat_introspect_parser.py dbus-python-1.0.0/dbus/_expat_introspect_parser.py --- dbus-python-0.84.0/dbus/_expat_introspect_parser.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/_expat_introspect_parser.py 2012-01-24 15:55:44.000000000 +0000 @@ -23,7 +23,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from xml.parsers.expat import ExpatError, ParserCreate +from xml.parsers.expat import ParserCreate from dbus.exceptions import IntrospectionParserException class _Parser(object): @@ -81,5 +81,5 @@ """ try: return _Parser().parse(data) - except Exception, e: + except Exception as e: raise IntrospectionParserException('%s: %s' % (e.__class__, e)) diff -Nru dbus-python-0.84.0/dbus/glib.py dbus-python-1.0.0/dbus/glib.py --- dbus-python-0.84.0/dbus/glib.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/glib.py 2012-01-24 16:04:13.000000000 +0000 @@ -35,7 +35,17 @@ __docformat__ = 'restructuredtext' from dbus.mainloop.glib import DBusGMainLoop, threads_init +from warnings import warn as _warn init_threads = threads_init DBusGMainLoop(set_as_default=True) + +_warn(DeprecationWarning("""\ +Importing dbus.glib to use the GLib main loop with dbus-python is deprecated. +Instead, use this sequence: + + from dbus.mainloop.glib import DBusGMainLoop + + DBusGMainLoop(set_as_default=True) +"""), DeprecationWarning, stacklevel=2) diff -Nru dbus-python-0.84.0/dbus/gobject_service.py dbus-python-1.0.0/dbus/gobject_service.py --- dbus-python-0.84.0/dbus/gobject_service.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/gobject_service.py 2012-01-24 15:55:44.000000000 +0000 @@ -22,9 +22,21 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -import gobject +__all__ = ['ExportedGObject'] + +from gi.repository import GObject as gobject import dbus.service +# The odd syntax used here is required so that the code is compatible with +# both Python 2 and Python 3. It essentially creates a new class called +# ExportedGObject with a metaclass of ExportGObjectType and an __init__() +# function. +# +# Because GObject and `dbus.service.Object` both have custom metaclasses, the +# naive approach using simple multiple inheritance won't work. This class has +# `ExportedGObjectType` as its metaclass, which is sufficient to make it work +# correctly. + class ExportedGObjectType(gobject.GObjectMeta, dbus.service.InterfaceType): """A metaclass which inherits from both GObjectMeta and `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`. @@ -33,39 +45,39 @@ gobject.GObjectMeta.__init__(cls, name, bases, dct) dbus.service.InterfaceType.__init__(cls, name, bases, dct) -class ExportedGObject(gobject.GObject, dbus.service.Object): - """A GObject which is exported on the D-Bus. - - Because GObject and `dbus.service.Object` both have custom metaclasses, - the naive approach using simple multiple inheritance won't work. This - class has `ExportedGObjectType` as its metaclass, which is sufficient - to make it work correctly. - """ - __metaclass__ = ExportedGObjectType - def __init__(self, conn=None, object_path=None, **kwargs): - """Initialize an exported GObject. +def ExportedGObject__init__(self, conn=None, object_path=None, **kwargs): + """Initialize an exported GObject. - :Parameters: - `conn` : dbus.connection.Connection - The D-Bus connection or bus - `object_path` : str - The object path at which to register this object. - :Keywords: - `bus_name` : dbus.service.BusName - A bus name to be held on behalf of this object, or None. - `gobject_properties` : dict - GObject properties to be set on the constructed object. - - Any unrecognised keyword arguments will also be interpreted - as GObject properties. - """ - bus_name = kwargs.pop('bus_name', None) - gobject_properties = kwargs.pop('gobject_properties', None) - - if gobject_properties is not None: - kwargs.update(gobject_properties) - gobject.GObject.__init__(self, **kwargs) - dbus.service.Object.__init__(self, conn=conn, - object_path=object_path, - bus_name=bus_name) + :Parameters: + `conn` : dbus.connection.Connection + The D-Bus connection or bus + `object_path` : str + The object path at which to register this object. + :Keywords: + `bus_name` : dbus.service.BusName + A bus name to be held on behalf of this object, or None. + `gobject_properties` : dict + GObject properties to be set on the constructed object. + + Any unrecognised keyword arguments will also be interpreted + as GObject properties. + """ + bus_name = kwargs.pop('bus_name', None) + gobject_properties = kwargs.pop('gobject_properties', None) + + if gobject_properties is not None: + kwargs.update(gobject_properties) + gobject.GObject.__init__(self, **kwargs) + dbus.service.Object.__init__(self, conn=conn, + object_path=object_path, + bus_name=bus_name) + +ExportedGObject__doc__ = 'A GObject which is exported on the D-Bus.' + +ExportedGObject = ExportedGObjectType( + 'ExportedGObject', + (gobject.GObject, dbus.service.Object), + {'__init__': ExportedGObject__init__, + '__doc__': ExportedGObject__doc__, + }) diff -Nru dbus-python-0.84.0/dbus/__init__.py dbus-python-1.0.0/dbus/__init__.py --- dbus-python-0.84.0/dbus/__init__.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus/__init__.py 2012-01-24 16:03:27.000000000 +0000 @@ -34,9 +34,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -import os - -__all__ = ( +__all__ = [ # from _dbus 'Bus', 'SystemBus', 'SessionBus', 'StarterBus', @@ -56,7 +54,7 @@ 'ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', - 'Double', 'String', 'Array', 'Struct', 'Dictionary', 'UTF8String', + 'Double', 'String', 'Array', 'Struct', 'Dictionary', # from exceptions 'DBusException', @@ -66,7 +64,12 @@ # submodules 'service', 'mainloop', 'lowlevel' - ) + ] + +from dbus._compat import is_py2 +if is_py2: + __all__.append('UTF8String') + __docformat__ = 'restructuredtext' try: @@ -78,28 +81,24 @@ import dbus.exceptions as exceptions import dbus.types as types -from _dbus_bindings import get_default_main_loop, set_default_main_loop,\ - validate_interface_name, validate_member_name,\ - validate_bus_name, validate_object_path,\ - validate_error_name -from _dbus_bindings import BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ - LOCAL_PATH, LOCAL_IFACE, PEER_IFACE,\ - INTROSPECTABLE_IFACE, PROPERTIES_IFACE - -from dbus.exceptions import MissingErrorHandlerException, \ - MissingReplyHandlerException, \ - ValidationException, \ - IntrospectionParserException, \ - UnknownMethodException, \ - NameExistsException, \ - DBusException -from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte, Boolean,\ - Int16, UInt16, Int32, UInt32, Int64, UInt64,\ - Double, String, Array, Struct, Dictionary, \ - UTF8String -from dbus._dbus import Bus, SystemBus, SessionBus, StarterBus -from dbus.proxies import Interface +from _dbus_bindings import ( + get_default_main_loop, set_default_main_loop, validate_bus_name, + validate_error_name, validate_interface_name, validate_member_name, + validate_object_path) +from _dbus_bindings import ( + BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE, + LOCAL_IFACE, LOCAL_PATH, PEER_IFACE, PROPERTIES_IFACE) + +from dbus.exceptions import ( + DBusException, IntrospectionParserException, MissingErrorHandlerException, + MissingReplyHandlerException, NameExistsException, UnknownMethodException, + ValidationException) +from _dbus_bindings import ( + Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64, + ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64) +if is_py2: + from _dbus_bindings import UTF8String -if 'DBUS_PYTHON_NO_DEPRECATED' not in os.environ: - from dbus._dbus import dbus_bindings # for backwards compat +from dbus._dbus import Bus, SystemBus, SessionBus, StarterBus +from dbus.proxies import Interface diff -Nru dbus-python-0.84.0/dbus/lowlevel.py dbus-python-1.0.0/dbus/lowlevel.py --- dbus-python-0.84.0/dbus/lowlevel.py 2010-02-18 17:02:23.000000000 +0000 +++ dbus-python-1.0.0/dbus/lowlevel.py 2012-01-24 15:55:44.000000000 +0000 @@ -29,12 +29,8 @@ 'MESSAGE_TYPE_METHOD_RETURN', 'MESSAGE_TYPE_ERROR', 'MESSAGE_TYPE_SIGNAL') -from _dbus_bindings import PendingCall, Message, MethodCallMessage, \ - MethodReturnMessage, ErrorMessage, SignalMessage, \ - HANDLER_RESULT_HANDLED, \ - HANDLER_RESULT_NOT_YET_HANDLED, \ - MESSAGE_TYPE_INVALID, \ - MESSAGE_TYPE_METHOD_CALL, \ - MESSAGE_TYPE_METHOD_RETURN, \ - MESSAGE_TYPE_ERROR, \ - MESSAGE_TYPE_SIGNAL +from _dbus_bindings import ( + ErrorMessage, HANDLER_RESULT_HANDLED, HANDLER_RESULT_NOT_YET_HANDLED, + MESSAGE_TYPE_ERROR, MESSAGE_TYPE_INVALID, MESSAGE_TYPE_METHOD_CALL, + MESSAGE_TYPE_METHOD_RETURN, MESSAGE_TYPE_SIGNAL, Message, + MethodCallMessage, MethodReturnMessage, PendingCall, SignalMessage) diff -Nru dbus-python-0.84.0/dbus/proxies.py dbus-python-1.0.0/dbus/proxies.py --- dbus-python-0.84.0/dbus/proxies.py 2011-05-18 11:29:06.000000000 +0000 +++ dbus-python-1.0.0/dbus/proxies.py 2012-01-24 15:55:44.000000000 +0000 @@ -23,7 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -import sys import logging try: @@ -33,16 +32,19 @@ import _dbus_bindings from dbus._expat_introspect_parser import process_introspection_data -from dbus.exceptions import MissingReplyHandlerException, MissingErrorHandlerException, IntrospectionParserException, DBusException +from dbus.exceptions import ( + DBusException, IntrospectionParserException, MissingErrorHandlerException, + MissingReplyHandlerException) __docformat__ = 'restructuredtext' _logger = logging.getLogger('dbus.proxies') -from _dbus_bindings import LOCAL_PATH, \ - BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ - INTROSPECTABLE_IFACE +from _dbus_bindings import ( + BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE, + LOCAL_PATH) +from dbus._compat import is_py2 class _DeferredMethod: @@ -57,7 +59,7 @@ self._block = block def __call__(self, *args, **keywords): - if (keywords.has_key('reply_handler') or + if ('reply_handler' in keywords or keywords.get('ignore_reply', False)): # defer the async call til introspection finishes self._append(self._proxy_method, args, keywords) @@ -224,7 +226,7 @@ if kwargs: raise TypeError('ProxyObject.__init__ does not take these ' 'keyword arguments: %s' - % ', '.join(kwargs.iterkeys())) + % ', '.join(kwargs.keys())) if follow_name_owner_changes: # we don't get the signals unless the Bus has a main loop @@ -367,13 +369,15 @@ **keywords) def _Introspect(self): + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True return self._bus.call_async(self._named_service, self.__dbus_object_path__, INTROSPECTABLE_IFACE, 'Introspect', '', (), self._introspect_reply_handler, self._introspect_error_handler, - utf8_strings=True, - require_main_loop=False) + require_main_loop=False, **kwargs) def _introspect_execute_queue(self): # FIXME: potential to flood the bus @@ -388,7 +392,7 @@ try: try: self._introspect_method_map = process_introspection_data(data) - except IntrospectionParserException, e: + except IntrospectionParserException as e: self._introspect_error_handler(e) return diff -Nru dbus-python-0.84.0/dbus/service.py dbus-python-1.0.0/dbus/service.py --- dbus-python-0.84.0/dbus/service.py 2008-11-28 15:53:44.000000000 +0000 +++ dbus-python-1.0.0/dbus/service.py 2012-01-24 15:55:44.000000000 +0000 @@ -28,22 +28,20 @@ import sys import logging -import operator +import threading import traceback -try: - import thread -except ImportError: - import dummy_thread as thread +from collections import Sequence import _dbus_bindings -from dbus import SessionBus, Signature, Struct, validate_bus_name, \ - validate_object_path, INTROSPECTABLE_IFACE, ObjectPath +from dbus import ( + INTROSPECTABLE_IFACE, ObjectPath, SessionBus, Signature, Struct, + validate_bus_name, validate_object_path) from dbus.decorators import method, signal -from dbus.exceptions import DBusException, \ - NameExistsException, \ - UnknownMethodException +from dbus.exceptions import ( + DBusException, NameExistsException, UnknownMethodException) from dbus.lowlevel import ErrorMessage, MethodReturnMessage, MethodCallMessage from dbus.proxies import LOCAL_PATH +from dbus._compat import is_py2 _logger = logging.getLogger('dbus.service') @@ -59,10 +57,14 @@ """Return self.""" return self - def next(self): + def __next__(self): """Return 'v' whenever called.""" return 'v' + if is_py2: + next = __next__ + + class BusName(object): """A base class for exporting your own Named Services across the Bus. @@ -250,12 +252,12 @@ reply = MethodReturnMessage(message) try: reply.append(signature=signature, *retval) - except Exception, e: + except Exception as e: logging.basicConfig() if signature is None: try: signature = reply.guess_signature(retval) + ' (guessed)' - except Exception, e: + except Exception as e: _logger.error('Unable to guess signature for arguments %r: ' '%s: %s', retval, e.__class__, e) raise @@ -308,7 +310,7 @@ for b in bases: base_name = b.__module__ + '.' + b.__name__ if getattr(b, '_dbus_class_table', False): - for (interface, method_table) in class_table[base_name].iteritems(): + for (interface, method_table) in class_table[base_name].items(): our_method_table = interface_table.setdefault(interface, {}) our_method_table.update(method_table) @@ -368,8 +370,11 @@ return reflection_data -class Interface(object): - __metaclass__ = InterfaceType + +# Define Interface as an instance of the metaclass InterfaceType, in a way +# that is compatible across both Python 2 and Python 3. +Interface = InterfaceType('Interface', (object,), {}) + #: A unique object used as the value of Object._object_path and #: Object._connection if it's actually in more than one place @@ -466,7 +471,7 @@ #: is for future expansion (to support fallback paths) self._locations = [] #: Lock protecting `_locations`, `_connection` and `_object_path` - self._locations_lock = thread.allocate_lock() + self._locations_lock = threading.Lock() #: True if this is a fallback object handling a whole subtree. self._fallback = False @@ -722,8 +727,9 @@ elif len(signature_tuple) == 1: retval = (retval,) else: - if operator.isSequenceType(retval): - # multi-value signature, multi-value return... proceed unchanged + if isinstance(retval, Sequence): + # multi-value signature, multi-value return... proceed + # unchanged pass else: raise TypeError('%s has multiple output values in signature %s but did not return a sequence' % @@ -743,7 +749,7 @@ retval = (retval,) _method_reply_return(connection, message, method_name, signature, *retval) - except Exception, exception: + except Exception as exception: # send error reply _method_reply_error(connection, message, exception) @@ -757,7 +763,7 @@ reflection_data += '\n' % object_path interfaces = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__] - for (name, funcs) in interfaces.iteritems(): + for (name, funcs) in interfaces.items(): reflection_data += ' \n' % (name) for func in funcs.values(): diff -Nru dbus-python-0.84.0/dbus/types.py dbus-python-1.0.0/dbus/types.py --- dbus-python-0.84.0/dbus/types.py 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/dbus/types.py 2012-01-24 16:03:28.000000000 +0000 @@ -1,10 +1,14 @@ -__all__ = ('ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', +__all__ = ['ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Double', 'String', 'Array', 'Struct', 'Dictionary', - 'UTF8String', 'UnixFd') + 'UnixFd'] -from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte,\ - Int16, UInt16, Int32, UInt32,\ - Int64, UInt64, Dictionary, Array, \ - String, Boolean, Double, Struct, UTF8String, \ - UnixFd +from _dbus_bindings import ( + Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64, + ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64, + UnixFd) + +from dbus._compat import is_py2 +if is_py2: + from _dbus_bindings import UTF8String + __all__.append('UTF8String') diff -Nru dbus-python-0.84.0/dbus/_version.py dbus-python-1.0.0/dbus/_version.py --- dbus-python-0.84.0/dbus/_version.py 2011-05-25 11:50:08.000000000 +0000 +++ dbus-python-1.0.0/dbus/_version.py 2012-01-24 16:44:49.000000000 +0000 @@ -1,3 +1,3 @@ # dbus/_version.py. Generated from _version.py.in by configure. -version = (0, 84, 0) -__version__ = "0.84.0" +version = (1, 0, 0) +__version__ = "1.0.0" diff -Nru dbus-python-0.84.0/_dbus_bindings/abstract.c dbus-python-1.0.0/_dbus_bindings/abstract.c --- dbus-python-0.84.0/_dbus_bindings/abstract.c 2010-12-02 17:17:59.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/abstract.c 2012-01-24 15:55:44.000000000 +0000 @@ -44,17 +44,33 @@ { PyObject *vl_obj; PyObject *key = PyLong_FromVoidPtr(obj); + long variant_level; if (!key) { - return 0; + return -1; } vl_obj = PyDict_GetItem(_dbus_py_variant_levels, key); Py_CLEAR(key); - if (!vl_obj) + if (!vl_obj) { + /* PyDict_GetItem() does not set an exception when the key is missing. + * In our case, it just means that there was no entry in the variant + * dictionary for this object. Semantically, this is equivalent to a + * variant level of 0. + */ return 0; - return PyInt_AsLong(vl_obj); + } + variant_level = NATIVEINT_ASLONG(vl_obj); + if (variant_level == -1 && PyErr_Occurred()) { + /* variant_level < 0 can never be inserted into the dictionary; see + * dbus_py_variant_level_set() below. The semantics of setting + * variant_level < 0 is to delete it from the dictionary. + */ + return -1; + } + assert(variant_level >= 0); + return variant_level; } dbus_bool_t @@ -76,12 +92,12 @@ } } else { - PyObject *vl_obj = PyInt_FromLong(variant_level); + PyObject *vl_obj = NATIVEINT_FROMLONG(variant_level); if (!vl_obj) { Py_CLEAR(key); return FALSE; } - if (PyDict_SetItem (_dbus_py_variant_levels, key, vl_obj) < 0) { + if (PyDict_SetItem(_dbus_py_variant_levels, key, vl_obj) < 0) { Py_CLEAR(key); return FALSE; } @@ -95,7 +111,11 @@ { PyObject *key, *value; - if (PyString_Check(name)) { +#ifdef PY3 + if (PyUnicode_CompareWithASCIIString(name, "variant_level")) + return PyObject_GenericGetAttr(obj, name); +#else + if (PyBytes_Check(name)) { Py_INCREF(name); } else if (PyUnicode_Check(name)) { @@ -109,13 +129,14 @@ return NULL; } - if (strcmp(PyString_AS_STRING(name), "variant_level")) { + if (strcmp(PyBytes_AS_STRING(name), "variant_level")) { value = PyObject_GenericGetAttr(obj, name); Py_CLEAR(name); return value; } Py_CLEAR(name); +#endif /* PY3 */ key = PyLong_FromVoidPtr(obj); @@ -127,7 +148,7 @@ Py_CLEAR(key); if (!value) - return PyInt_FromLong(0); + return NATIVEINT_FROMLONG(0); Py_INCREF(value); return value; } @@ -148,6 +169,7 @@ PyErr_Restore(et, ev, etb); } +#ifndef PY3 /* Support code for int subclasses. ================================== */ PyDoc_STRVAR(DBusPythonInt_tp_doc,\ @@ -200,14 +222,14 @@ if (!parent_repr) return NULL; if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, - PyString_AS_STRING(parent_repr)); + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); } /* whether my_repr is NULL or not: */ Py_CLEAR(parent_repr); @@ -215,8 +237,7 @@ } PyTypeObject DBusPyIntBase_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._IntBase", sizeof(DBusPyIntBase), 0, @@ -256,6 +277,7 @@ DBusPythonInt_tp_new, /* tp_new */ PyObject_Del, /* tp_free */ }; +#endif /* !PY3 */ /* Support code for float subclasses. ================================ */ @@ -312,14 +334,14 @@ if (!parent_repr) return NULL; if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, - PyString_AS_STRING(parent_repr)); + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); } /* whether my_repr is NULL or not: */ Py_CLEAR(parent_repr); @@ -327,8 +349,7 @@ } PyTypeObject DBusPyFloatBase_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._FloatBase", sizeof(DBusPyFloatBase), 0, @@ -368,6 +389,131 @@ DBusPythonFloat_tp_new, /* tp_new */ }; +#ifdef PY3 +/* Support code for bytes subclasses ================================== */ + +PyDoc_STRVAR(DBusPythonBytes_tp_doc,\ +"Base class for bytes subclasses with a ``variant_level`` attribute.\n" +"Do not rely on the existence of this class outside dbus-python.\n" +); + +static PyObject * +DBusPythonBytes_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) +{ + PyObject *self; + long variantness = 0; + static char *argnames[] = {"variant_level", NULL}; + + if (PyTuple_Size(args) > 1) { + PyErr_SetString(PyExc_TypeError, + "__new__ takes at most one positional parameter"); + return NULL; + } + if (!PyArg_ParseTupleAndKeywords(dbus_py_empty_tuple, kwargs, + "|l:__new__", argnames, + &variantness)) + return NULL; + + if (variantness < 0) { + PyErr_SetString(PyExc_ValueError, + "variant_level must be non-negative"); + return NULL; + } + + self = (PyBytes_Type.tp_new)(cls, args, NULL); + if (self) { + if (!dbus_py_variant_level_set(self, variantness)) { + Py_CLEAR(self); + return NULL; + } + } + return self; +} + +static PyObject * +DBusPythonBytes_tp_repr(PyObject *self) +{ + PyObject *parent_repr = (PyBytes_Type.tp_repr)(self); + PyObject *vl_obj; + PyObject *my_repr; + long variant_level; + + if (!parent_repr) return NULL; + vl_obj = PyObject_GetAttr(self, dbus_py_variant_level_const); + if (!vl_obj) { + Py_CLEAR(parent_repr); + return NULL; + } + variant_level = NATIVEINT_ASLONG(vl_obj); + Py_CLEAR(vl_obj); + if (variant_level == -1 && PyErr_Occurred()) { + Py_CLEAR(parent_repr); + return NULL; + } + if (variant_level > 0) { + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + variant_level); + } + else { + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); + } + /* whether my_repr is NULL or not: */ + Py_CLEAR(parent_repr); + return my_repr; +} + +static void +DBusPyBytesBase_tp_dealloc(PyObject *self) +{ + dbus_py_variant_level_clear(self); + (PyBytes_Type.tp_dealloc)(self); +} + +PyTypeObject DBusPyBytesBase_Type = { + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) + "_dbus_bindings._BytesBase", + 0, + 0, + DBusPyBytesBase_tp_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + DBusPythonBytes_tp_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + dbus_py_variant_level_getattro, /* tp_getattro */ + dbus_py_immutable_setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + DBusPythonBytes_tp_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + DEFERRED_ADDRESS(&PyBytes_Type), /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + DBusPythonBytes_tp_new, /* tp_new */ +}; +#endif /* PY3 */ + /* Support code for str subclasses ================================== */ PyDoc_STRVAR(DBusPythonString_tp_doc,\ @@ -396,7 +542,7 @@ return NULL; } - self = (PyString_Type.tp_new)(cls, args, NULL); + self = (NATIVESTR_TYPE.tp_new)(cls, args, NULL); if (self) { if (!dbus_py_variant_level_set(self, variantness)) { Py_CLEAR(self); @@ -409,7 +555,7 @@ static PyObject * DBusPythonString_tp_repr(PyObject *self) { - PyObject *parent_repr = (PyString_Type.tp_repr)(self); + PyObject *parent_repr = (NATIVESTR_TYPE.tp_repr)(self); PyObject *vl_obj; PyObject *my_repr; long variant_level; @@ -420,17 +566,22 @@ Py_CLEAR(parent_repr); return NULL; } - variant_level = PyInt_AsLong(vl_obj); + variant_level = NATIVEINT_ASLONG(vl_obj); Py_CLEAR(vl_obj); + if (variant_level == -1 && PyErr_Occurred()) { + Py_CLEAR(parent_repr); + return NULL; + } + if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, - PyString_AS_STRING(parent_repr)); + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); } /* whether my_repr is NULL or not: */ Py_CLEAR(parent_repr); @@ -441,12 +592,11 @@ DBusPyStrBase_tp_dealloc(PyObject *self) { dbus_py_variant_level_clear(self); - (PyString_Type.tp_dealloc)(self); + (NATIVESTR_TYPE.tp_dealloc)(self); } PyTypeObject DBusPyStrBase_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._StrBase", 0, 0, @@ -476,7 +626,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&PyString_Type), /* tp_base */ + DEFERRED_ADDRESS(&NATIVESTR_TYPE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -538,17 +688,22 @@ Py_CLEAR(parent_repr); return NULL; } - variant_level = PyInt_AsLong(vl_obj); + variant_level = NATIVEINT_ASLONG(vl_obj); Py_CLEAR(vl_obj); + if (variant_level < 0 && PyErr_Occurred()) { + Py_CLEAR(parent_repr); + return NULL; + } + if (variant_level) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, - PyString_AS_STRING(parent_repr)); + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); } /* whether my_repr is NULL or not: */ Py_CLEAR(parent_repr); @@ -563,8 +718,7 @@ } PyTypeObject DBusPyLongBase_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._LongBase", 0, 0, @@ -608,26 +762,41 @@ PyObject *dbus_py_signature_const = NULL; PyObject *dbus_py__dbus_object_path__const = NULL; +#ifdef PY3 +#define INTERN (PyUnicode_InternFromString) +#else +/* Neither Python 2.6 nor 2.7 define the expected PyBytes_InternFromString + * alias in bytesobject.h. + */ +#define INTERN (PyString_InternFromString) +#endif + dbus_bool_t dbus_py_init_abstract(void) { _dbus_py_variant_levels = PyDict_New(); if (!_dbus_py_variant_levels) return 0; - dbus_py__dbus_object_path__const = PyString_InternFromString("__dbus_object_path__"); + dbus_py__dbus_object_path__const = INTERN("__dbus_object_path__"); if (!dbus_py__dbus_object_path__const) return 0; - dbus_py_variant_level_const = PyString_InternFromString("variant_level"); + dbus_py_variant_level_const = INTERN("variant_level"); if (!dbus_py_variant_level_const) return 0; - dbus_py_signature_const = PyString_InternFromString("signature"); + dbus_py_signature_const = INTERN("signature"); if (!dbus_py_signature_const) return 0; +#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; /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as desired */ DBusPyIntBase_Type.tp_print = NULL; +#endif DBusPyFloatBase_Type.tp_base = &PyFloat_Type; if (PyType_Ready(&DBusPyFloatBase_Type) < 0) return 0; @@ -637,7 +806,7 @@ if (PyType_Ready(&DBusPyLongBase_Type) < 0) return 0; DBusPyLongBase_Type.tp_print = NULL; - DBusPyStrBase_Type.tp_base = &PyString_Type; + DBusPyStrBase_Type.tp_base = &NATIVESTR_TYPE; if (PyType_Ready(&DBusPyStrBase_Type) < 0) return 0; DBusPyStrBase_Type.tp_print = NULL; @@ -648,12 +817,18 @@ dbus_py_insert_abstract_types(PyObject *this_module) { /* PyModule_AddObject steals a ref */ +#ifdef PY3 + Py_INCREF(&DBusPyBytesBase_Type); + if (PyModule_AddObject(this_module, "_BytesBase", + (PyObject *)&DBusPyBytesBase_Type) < 0) return 0; +#else Py_INCREF(&DBusPyIntBase_Type); + if (PyModule_AddObject(this_module, "_IntBase", + (PyObject *)&DBusPyIntBase_Type) < 0) return 0; +#endif Py_INCREF(&DBusPyLongBase_Type); Py_INCREF(&DBusPyStrBase_Type); Py_INCREF(&DBusPyFloatBase_Type); - if (PyModule_AddObject(this_module, "_IntBase", - (PyObject *)&DBusPyIntBase_Type) < 0) return 0; if (PyModule_AddObject(this_module, "_LongBase", (PyObject *)&DBusPyLongBase_Type) < 0) return 0; if (PyModule_AddObject(this_module, "_StrBase", diff -Nru dbus-python-0.84.0/_dbus_bindings/bus.c dbus-python-1.0.0/_dbus_bindings/bus.c --- dbus-python-0.84.0/_dbus_bindings/bus.c 2010-12-02 16:13:56.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/bus.c 2012-01-24 15:55:44.000000000 +0000 @@ -42,7 +42,14 @@ dbus_error_init(&error); - if (first && PyString_Check(first)) { + if (first && +#ifdef PY3 + PyUnicode_Check(first) +#else + PyBytes_Check(first) +#endif + ) + { dbus_bool_t ret; /* It's a custom address. First connect to it, then register. */ @@ -62,7 +69,8 @@ return (PyObject *)self; } - else if (!first || PyInt_Check(first)) { + else if (!first || INTORLONG_CHECK(first)) + { long type; PyObject *libdbusconn; PyObject *new_args; @@ -73,7 +81,10 @@ DBUS_BUS_SESSION. */ if (first) { - type = PyInt_AsLong(first); + /* on Python 2 this accepts either int or long */ + type = PyLong_AsLong(first); + if (type == -1 && PyErr_Occurred()) + return NULL; if (type != DBUS_BUS_SESSION && type != DBUS_BUS_SYSTEM && type != DBUS_BUS_STARTER) { @@ -142,7 +153,7 @@ return DBusPyException_SetString("This connection has no unique name " "yet"); } - return PyString_FromString(name); + return NATIVESTR_FROMSTR(name); } PyObject * diff -Nru dbus-python-0.84.0/_dbus_bindings/bytes.c dbus-python-1.0.0/_dbus_bindings/bytes.c --- dbus-python-0.84.0/_dbus_bindings/bytes.c 2010-12-02 17:17:54.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/bytes.c 2012-01-24 15:55:44.000000000 +0000 @@ -31,6 +31,12 @@ #include "dbus_bindings-internal.h" #include "types-internal.h" +#ifdef PY3 +#define DBUS_PY_BYTE_BASE (DBusPyLongBase_Type) +#else +#define DBUS_PY_BYTE_BASE (DBusPyIntBase_Type) +#endif + PyDoc_STRVAR(Byte_tp_doc, "An unsigned byte: a subtype of int, with range restricted to [0, 255].\n" "\n" @@ -76,21 +82,36 @@ return NULL; } - /* obj is only a borrowed ref for the moment */ + /* obj is a borrowed reference. It gets turned into an owned reference on + * the good-path of the if-statements below. + */ obj = PyTuple_GetItem(args, 0); - if (PyString_Check(obj)) { + if (PyBytes_Check(obj)) { /* string of length 1, we hope */ - if (PyString_GET_SIZE(obj) != 1) { + if (PyBytes_GET_SIZE(obj) != 1) { goto bad_arg; } - obj = PyInt_FromLong((unsigned char)(PyString_AS_STRING(obj)[0])); + obj = NATIVEINT_FROMLONG((unsigned char)(PyBytes_AS_STRING(obj)[0])); + if (!obj) + goto bad_arg; } - else if (PyInt_Check(obj)) { - long i = PyInt_AS_LONG(obj); + else if (INTORLONG_CHECK(obj)) { + /* on Python 2 this accepts either int or long */ + long i = PyLong_AsLong(obj); + long my_variant_level; + + if (i == -1 && PyErr_Occurred()) + goto bad_arg; - if (obj->ob_type == cls && - ((DBusPyIntBase *)obj)->variant_level == variantness) { +#ifdef PY3 + my_variant_level = dbus_py_variant_level_get(obj); + if (my_variant_level < 0) + return NULL; +#else + my_variant_level = ((DBusPyIntBase *)obj)->variant_level; +#endif + if (Py_TYPE(obj) == cls && my_variant_level == variantness) { Py_INCREF(obj); return obj; } @@ -102,16 +123,16 @@ goto bad_arg; } - tuple = Py_BuildValue("(O)", obj); + /* The tuple steals the reference to obj. */ + tuple = Py_BuildValue("(N)", obj); if (!tuple) return NULL; - Py_CLEAR(obj); - obj = DBusPyIntBase_Type.tp_new(cls, tuple, kwargs); + obj = DBUS_PY_BYTE_BASE.tp_new(cls, tuple, kwargs); Py_CLEAR(tuple); return obj; bad_arg: - PyErr_SetString(PyExc_TypeError, "Expected a string of length 1, " + PyErr_SetString(PyExc_TypeError, "Expected a bytes or str of length 1, " "or an int in the range 0-255"); return NULL; bad_range: @@ -122,13 +143,22 @@ static PyObject * Byte_tp_str(PyObject *self) { - unsigned char str[2] = { (unsigned char)PyInt_AS_LONG(self), 0 }; - return PyString_FromStringAndSize((char *)str, 1); + long i = NATIVEINT_ASLONG(self); + unsigned char str[2] = { 0, 0 }; + + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0 || i > 255) { + PyErr_SetString(PyExc_RuntimeError, "Integer outside range 0-255"); + return NULL; + } + + str[0] = (unsigned char)i; + return PyUnicode_FromStringAndSize((char *)str, 1); } PyTypeObject DBusPyByte_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Byte", 0, 0, @@ -158,7 +188,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&PyInt_Type), /* tp_base */ + DEFERRED_ADDRESS(&DBUS_PY_BYTE_BASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -168,6 +198,12 @@ Byte_new, /* tp_new */ }; +#ifdef PY3 +#define DBUS_PY_BYTEARRAY_BASE (DBusPyBytesBase_Type) +#else +#define DBUS_PY_BYTEARRAY_BASE (DBusPyStrBase_Type) +#endif + PyDoc_STRVAR(ByteArray_tp_doc, "ByteArray is a subtype of str which can be used when you want an\n" "efficient immutable representation of a D-Bus byte array (signature 'ay').\n" @@ -194,8 +230,7 @@ ); PyTypeObject DBusPyByteArray_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.ByteArray", 0, 0, @@ -225,7 +260,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyStrBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&DBUS_PY_BYTEARRAY_BASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -238,11 +273,11 @@ dbus_bool_t dbus_py_init_byte_types(void) { - DBusPyByte_Type.tp_base = &DBusPyIntBase_Type; + DBusPyByte_Type.tp_base = &DBUS_PY_BYTE_BASE; if (PyType_Ready(&DBusPyByte_Type) < 0) return 0; DBusPyByte_Type.tp_print = NULL; - DBusPyByteArray_Type.tp_base = &DBusPyStrBase_Type; + DBusPyByteArray_Type.tp_base = &DBUS_PY_BYTEARRAY_BASE; if (PyType_Ready(&DBusPyByteArray_Type) < 0) return 0; DBusPyByteArray_Type.tp_print = NULL; diff -Nru dbus-python-0.84.0/_dbus_bindings/conn.c dbus-python-1.0.0/_dbus_bindings/conn.c --- dbus-python-0.84.0/_dbus_bindings/conn.c 2010-12-02 17:18:23.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/conn.c 2012-01-24 15:55:44.000000000 +0000 @@ -99,7 +99,7 @@ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } else { - long i = PyInt_AsLong(obj); + long i = PyLong_AsLong(obj); DBG("%p: handler %p returned %ld", conn, callable, i); Py_CLEAR(obj); if (i == -1 && PyErr_Occurred()) { @@ -232,6 +232,7 @@ self->has_mainloop = (mainloop != Py_None); self->conn = NULL; self->filters = PyList_New(0); + self->weaklist = NULL; if (!self->filters) goto err; self->object_paths = PyDict_New(); if (!self->object_paths) goto err; @@ -298,7 +299,6 @@ Connection_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { DBusConnection *conn; - const char *address; PyObject *address_or_conn; DBusError error; PyObject *self, *mainloop = NULL; @@ -317,7 +317,30 @@ conn = dbus_connection_ref (wrapper->conn); } - else if ((address = PyString_AsString(address_or_conn)) != NULL) { + else if (PyBytes_Check(address_or_conn)) { + const char *address = PyBytes_AS_STRING(address_or_conn); + + dbus_error_init(&error); + + /* We always open a private connection (at the libdbus level). Sharing + * is done in Python, to keep things simple. */ + Py_BEGIN_ALLOW_THREADS + conn = dbus_connection_open_private(address, &error); + Py_END_ALLOW_THREADS + + if (!conn) { + DBusPyException_ConsumeError(&error); + return NULL; + } + } + else if (PyUnicode_Check(address_or_conn)) { + PyObject *address_as_bytes = PyUnicode_AsUTF8String(address_or_conn); + const char *address; + + if (!address_as_bytes) + return NULL; + address = PyBytes_AS_STRING(address_as_bytes); + dbus_error_init(&error); /* We always open a private connection (at the libdbus level). Sharing @@ -326,12 +349,14 @@ conn = dbus_connection_open_private(address, &error); Py_END_ALLOW_THREADS + Py_CLEAR(address_as_bytes); if (!conn) { DBusPyException_ConsumeError(&error); return NULL; } } else { + PyErr_SetString(PyExc_TypeError, "connection or str expected"); return NULL; } @@ -398,14 +423,13 @@ DBG("Connection at %p: freeing self", self); PyErr_Restore(et, ev, etb); - (self->ob_type->tp_free)((PyObject *)self); + (Py_TYPE(self)->tp_free)((PyObject *)self); } /* Connection type object =========================================== */ PyTypeObject DBusPyConnection_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_dbus_bindings.Connection", /*tp_name*/ sizeof(Connection), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -425,7 +449,11 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ +#ifdef PY3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +#else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_BASETYPE, +#endif Connection_tp_doc, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ diff -Nru dbus-python-0.84.0/_dbus_bindings/conn-methods.c dbus-python-1.0.0/_dbus_bindings/conn-methods.c --- dbus-python-0.84.0/_dbus_bindings/conn-methods.c 2011-05-17 17:06:05.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/conn-methods.c 2012-01-24 15:55:44.000000000 +0000 @@ -40,8 +40,9 @@ TRACE(conn_obj); DBG("Connection at %p unregistering object path %s", - conn_obj, PyString_AS_STRING((PyObject *)user_data)); - tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data); + conn_obj, PyBytes_AS_STRING((PyObject *)user_data)); + tuple = DBusPyConnection_GetObjectPathHandlers( + (PyObject *)conn_obj, (PyObject *)user_data); if (!tuple) goto out; if (tuple == Py_None) goto out; @@ -91,9 +92,10 @@ TRACE(conn_obj); DBG("Connection at %p messaging object path %s", - conn_obj, PyString_AS_STRING((PyObject *)user_data)); + conn_obj, PyBytes_AS_STRING((PyObject *)user_data)); DBG_DUMP_MESSAGE(message); - tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data); + tuple = DBusPyConnection_GetObjectPathHandlers( + (PyObject *)conn_obj, (PyObject *)user_data); if (!tuple || tuple == Py_None) { ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; goto out; @@ -562,7 +564,7 @@ ok = dbus_connection_get_unix_fd (self->conn, &fd); Py_END_ALLOW_THREADS if (!ok) Py_RETURN_NONE; - return PyInt_FromLong(fd); + return NATIVEINT_FROMLONG(fd); } PyDoc_STRVAR(Connection_get_peer_unix_user__doc__, @@ -702,6 +704,7 @@ { dbus_bool_t ok; int fallback = 0; + char *path_bytes; PyObject *callbacks, *path, *tuple, *on_message, *on_unregister = Py_None; static char *argnames[] = {"path", "on_message", "on_unregister", "fallback", NULL}; @@ -724,23 +727,25 @@ mad) to preserve the desirable property that the DBusConnection can never strongly reference the Connection, even indirectly. */ - if (PyString_CheckExact(path)) { + if (PyBytes_CheckExact(path)) { Py_INCREF(path); } else if (PyUnicode_Check(path)) { path = PyUnicode_AsUTF8String(path); if (!path) return NULL; } - else if (PyString_Check(path)) { - path = PyString_FromString(PyString_AS_STRING(path)); + else if (PyBytes_Check(path)) { + path = PyBytes_FromString(PyBytes_AS_STRING(path)); if (!path) return NULL; } else { - PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object"); + PyErr_SetString(PyExc_TypeError, + "path must be a str, bytes, or unicode object"); return NULL; } - if (!dbus_py_validate_object_path(PyString_AS_STRING(path))) { + path_bytes = PyBytes_AS_STRING(path); + if (!dbus_py_validate_object_path(path_bytes)) { Py_CLEAR(path); return NULL; } @@ -756,7 +761,7 @@ if (callbacks && callbacks != Py_None) { PyErr_Format(PyExc_KeyError, "Can't register the object-path " "handler for '%s': there is already a handler", - PyString_AS_STRING(path)); + path_bytes); Py_CLEAR(tuple); Py_CLEAR(path); return NULL; @@ -775,13 +780,13 @@ Py_BEGIN_ALLOW_THREADS if (fallback) { ok = dbus_connection_register_fallback(self->conn, - PyString_AS_STRING(path), + path_bytes, &_object_path_vtable, path); } else { ok = dbus_connection_register_object_path(self->conn, - PyString_AS_STRING(path), + path_bytes, &_object_path_vtable, path); } @@ -795,7 +800,7 @@ memory in libdbus, but tbh we should never get here anyway. */ Py_BEGIN_ALLOW_THREADS ok = dbus_connection_unregister_object_path(self->conn, - PyString_AS_STRING(path)); + path_bytes); Py_END_ALLOW_THREADS return NULL; } @@ -829,6 +834,7 @@ PyObject *kwargs) { dbus_bool_t ok; + char *path_bytes; PyObject *path; PyObject *callbacks; static char *argnames[] = {"path", NULL}; @@ -840,29 +846,32 @@ argnames, &path)) return NULL; /* Take a ref to the path. Same comments as for _register_object_path. */ - if (PyString_CheckExact(path)) { + if (PyBytes_CheckExact(path)) { Py_INCREF(path); } else if (PyUnicode_Check(path)) { path = PyUnicode_AsUTF8String(path); if (!path) return NULL; } - else if (PyString_Check(path)) { - path = PyString_FromString(PyString_AS_STRING(path)); + else if (PyBytes_Check(path)) { + path = PyBytes_FromString(PyBytes_AS_STRING(path)); if (!path) return NULL; } else { - PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object"); + PyErr_SetString(PyExc_TypeError, + "path must be a str, bytes, or unicode object"); return NULL; } + path_bytes = PyBytes_AS_STRING(path); + /* Guard against unregistering a handler that doesn't, in fact, exist, or whose unregistration is already in progress. */ callbacks = PyDict_GetItem(self->object_paths, path); if (!callbacks || callbacks == Py_None) { PyErr_Format(PyExc_KeyError, "Can't unregister the object-path " "handler for '%s': there is no such handler", - PyString_AS_STRING(path)); + path_bytes); Py_CLEAR(path); return NULL; } @@ -897,8 +906,7 @@ */ Py_BEGIN_ALLOW_THREADS - ok = dbus_connection_unregister_object_path(self->conn, - PyString_AS_STRING(path)); + ok = dbus_connection_unregister_object_path(self->conn, path_bytes); Py_END_ALLOW_THREADS if (ok) { @@ -968,7 +976,7 @@ return NULL; } for (kid_ptr = kids; *kid_ptr; kid_ptr++) { - PyObject *tmp = PyString_FromString(*kid_ptr); + PyObject *tmp = NATIVESTR_FROMSTR(*kid_ptr); if (!tmp) { Py_CLEAR(ret); @@ -988,7 +996,7 @@ } /* dbus_connection_get_object_path_data - not useful to Python, - * the object path data is just a PyString containing the path */ + * the object path data is just a PyBytes containing the path */ /* dbus_connection_list_registered could be useful, though */ /* dbus_connection_set_change_sigpipe - sets global state */ diff -Nru dbus-python-0.84.0/_dbus_bindings/containers.c dbus-python-1.0.0/_dbus_bindings/containers.c --- dbus-python-0.84.0/_dbus_bindings/containers.c 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/containers.c 2012-01-24 15:55:44.000000000 +0000 @@ -92,18 +92,18 @@ if (!parent_repr) goto finally; if (!sig_repr) goto finally; if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, signature=%s, " - "variant_level=%ld)", - self->super.ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " + "variant_level=%ld)", + Py_TYPE(&self->super)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s, signature=%s)", - self->super.ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr)); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", + Py_TYPE(&self->super)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr)); } finally: Py_CLEAR(parent_repr); @@ -127,11 +127,12 @@ variant_level = PyDict_GetItem(kwargs, dbus_py_variant_level_const); } if (variant_level) { - self->variant_level = PyInt_AsLong(variant_level); - if (PyErr_Occurred()) { + long new_variant_level = PyLong_AsLong(variant_level); + if (new_variant_level == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; } + self->variant_level = new_variant_level; } return (PyObject *)self; } @@ -166,15 +167,42 @@ } if (signature != Py_None) { - const char *c_str = PyString_AS_STRING(signature); + const char *c_str; + PyObject *signature_as_bytes; + + if ( +#ifdef PY3 + !PyUnicode_Check(signature) +#else + !PyBytes_Check(signature) +#endif + ) + { + PyErr_SetString(PyExc_TypeError, "str expected"); + Py_CLEAR(signature); + return -1; + } +#ifdef PY3 + if (!(signature_as_bytes = PyUnicode_AsUTF8String(signature))) { + Py_CLEAR(signature); + return -1; + } +#else + signature_as_bytes = signature; + Py_INCREF(signature_as_bytes); +#endif + + c_str = PyBytes_AS_STRING(signature_as_bytes); if (!dbus_signature_validate_single(c_str, NULL)) { Py_CLEAR(signature); + Py_CLEAR(signature_as_bytes); PyErr_SetString(PyExc_ValueError, "There must be exactly one complete type in " "an Array's signature parameter"); return -1; } + Py_CLEAR(signature_as_bytes); } tuple = Py_BuildValue("(O)", obj); @@ -195,8 +223,7 @@ } PyTypeObject DBusPyArray_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Array", sizeof(DBusPyArray), 0, @@ -300,18 +327,18 @@ if (!parent_repr) goto finally; if (!sig_repr) goto finally; if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, signature=%s, " - "variant_level=%ld)", - self->super.ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " + "variant_level=%ld)", + Py_TYPE(&self->super)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s, signature=%s)", - self->super.ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr)); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", + Py_TYPE(&self->super)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr)); } finally: Py_CLEAR(parent_repr); @@ -335,11 +362,13 @@ variant_level = PyDict_GetItem(kwargs, dbus_py_variant_level_const); } if (variant_level) { - self->variant_level = PyInt_AsLong(variant_level); - if (PyErr_Occurred()) { + long new_variant_level = PyLong_AsLong(variant_level); + + if (new_variant_level == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; } + self->variant_level = new_variant_level; } return (PyObject *)self; } @@ -373,8 +402,25 @@ } if (signature != Py_None) { - const char *c_str = PyString_AS_STRING(signature); + const char *c_str; + PyObject *signature_as_bytes; + if (!NATIVESTR_CHECK(signature)) { + PyErr_SetString(PyExc_TypeError, "str expected"); + Py_CLEAR(signature); + return -1; + } +#ifdef PY3 + if (!(signature_as_bytes = PyUnicode_AsUTF8String(signature))) { + Py_CLEAR(signature); + return -1; + } +#else + signature_as_bytes = signature; + Py_INCREF(signature_as_bytes); +#endif + + c_str = PyBytes_AS_STRING(signature_as_bytes); switch (c_str[0]) { case DBUS_TYPE_BYTE: case DBUS_TYPE_BOOLEAN: @@ -397,6 +443,7 @@ break; default: Py_CLEAR(signature); + Py_CLEAR(signature_as_bytes); PyErr_SetString(PyExc_ValueError, "The key type in a Dictionary's signature " "must be a primitive type"); @@ -405,11 +452,13 @@ if (!dbus_signature_validate_single(c_str + 1, NULL)) { Py_CLEAR(signature); + Py_CLEAR(signature_as_bytes); PyErr_SetString(PyExc_ValueError, "There must be exactly two complete types in " "a Dictionary's signature parameter"); return -1; } + Py_CLEAR(signature_as_bytes); } tuple = Py_BuildValue("(O)", obj); @@ -431,8 +480,7 @@ } PyTypeObject DBusPyDict_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Dictionary", sizeof(DBusPyDict), 0, @@ -521,20 +569,24 @@ if (!sig) sig = Py_None; sig_repr = PyObject_Repr(sig); if (!sig_repr) goto finally; + variant_level = dbus_py_variant_level_get(self); + if (variant_level < 0) + goto finally; + if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, signature=%s, " - "variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr), - variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " + "variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr), + variant_level); } else { - my_repr = PyString_FromFormat("%s(%s, signature=%s)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr)); + my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + REPRV(sig_repr)); } finally: @@ -648,7 +700,11 @@ { PyObject *key, *value; - if (PyString_Check(name)) { +#ifdef PY3 + if (PyUnicode_CompareWithASCIIString(name, "signature")) + return dbus_py_variant_level_getattro(obj, name); +#else + if (PyBytes_Check(name)) { Py_INCREF(name); } else if (PyUnicode_Check(name)) { @@ -662,13 +718,13 @@ return NULL; } - if (strcmp(PyString_AS_STRING(name), "signature")) { + if (strcmp(PyBytes_AS_STRING(name), "signature")) { value = dbus_py_variant_level_getattro(obj, name); Py_CLEAR(name); return value; } - Py_CLEAR(name); +#endif /* PY3 */ key = PyLong_FromVoidPtr(obj); @@ -686,8 +742,7 @@ } PyTypeObject DBusPyStruct_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Struct", 0, 0, diff -Nru dbus-python-0.84.0/_dbus_bindings/dbus_bindings-internal.h dbus-python-1.0.0/_dbus_bindings/dbus_bindings-internal.h --- dbus-python-0.84.0/_dbus_bindings/dbus_bindings-internal.h 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/dbus_bindings-internal.h 2012-01-24 15:55:44.000000000 +0000 @@ -30,13 +30,6 @@ #include -/* Python < 2.5 compat */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#endif - #define INSIDE_DBUS_PYTHON_BINDINGS #include "dbus-python.h" @@ -55,10 +48,57 @@ } \ static inline int type##_CheckExact (PyObject *o) \ { \ - return ((o)->ob_type == &type##_Type); \ + return (Py_TYPE(o) == &type##_Type); \ } +/* This is a clever little trick to make writing the various object reprs + * easier. It relies on Python's %V format option which consumes two + * arguments. The first is a unicode object which may be NULL, and the second + * is a char* which will be used if the first parameter is NULL. + * + * The issue is that we don't know whether the `parent_repr` at the call site + * is a unicode or a bytes (a.k.a. 8-bit string). Under Python 3, it will + * always be a unicode. Under Python 2 it will *probably* be a bytes/str, but + * could potentially be a unicode. So, we check the type, and if it's a + * unicode, we pass that as the first argument, leaving NULL as the second + * argument (since it will never be checked). However, if the object is not a + * unicode, it better be a bytes. In that case, we'll pass NULL as the first + * argument so that the second one gets used, and we'll dig the char* out of + * the bytes object for that purpose. + * + * You might think that this would crash if obj is neither a bytes/str or + * unicode, and you'd be right *except* that Python doesn't allow any other + * types to be returned in the reprs. Also, since obj will always be the repr + * of a built-in type, it will never be anything other than a bytes or a + * unicode in any version of Python. So in practice, this is safe. + */ +#define REPRV(obj) \ + (PyUnicode_Check(obj) ? (obj) : NULL), \ + (PyUnicode_Check(obj) ? NULL : PyBytes_AS_STRING(obj)) + +#ifdef PY3 +#define NATIVEINT_TYPE (PyLong_Type) +#define NATIVEINT_FROMLONG(x) (PyLong_FromLong(x)) +#define NATIVEINT_ASLONG(x) (PyLong_AsLong(x)) +#define INTORLONG_CHECK(obj) (PyLong_Check(obj)) +#define NATIVESTR_TYPE (PyUnicode_Type) +#define NATIVESTR_CHECK(obj) (PyUnicode_Check(obj)) +#define NATIVESTR_FROMSTR(obj) (PyUnicode_FromString(obj)) +#else +#define NATIVEINT_TYPE (PyInt_Type) +#define NATIVEINT_FROMLONG(x) (PyInt_FromLong(x)) +#define NATIVEINT_ASLONG(x) (PyInt_AsLong(x)) +#define INTORLONG_CHECK(obj) (PyLong_Check(obj) || PyInt_Check(obj)) +#define NATIVESTR_TYPE (PyBytes_Type) +#define NATIVESTR_CHECK(obj) (PyBytes_Check(obj)) +#define NATIVESTR_FROMSTR(obj) (PyBytes_FromString(obj)) +#endif + +#ifdef PY3 +PyMODINIT_FUNC PyInit__dbus_bindings(void); +#else PyMODINIT_FUNC init_dbus_bindings(void); +#endif /* conn.c */ extern PyTypeObject DBusPyConnection_Type; @@ -96,9 +136,12 @@ extern PyTypeObject DBusPyByte_Type, DBusPyByteArray_Type; DEFINE_CHECK(DBusPyByteArray) DEFINE_CHECK(DBusPyByte) -extern PyTypeObject DBusPyUTF8String_Type, DBusPyString_Type; -DEFINE_CHECK(DBusPyUTF8String) +extern PyTypeObject DBusPyString_Type; DEFINE_CHECK(DBusPyString) +#ifndef PY3 +extern PyTypeObject DBusPyUTF8String_Type; +DEFINE_CHECK(DBusPyUTF8String) +#endif extern PyTypeObject DBusPyDouble_Type; DEFINE_CHECK(DBusPyDouble) extern PyTypeObject DBusPyInt16_Type, DBusPyUInt16_Type; @@ -134,10 +177,6 @@ /* generic */ extern void dbus_py_take_gil_and_xdecref(PyObject *); extern int dbus_py_immutable_setattro(PyObject *, PyObject *, PyObject *); -extern PyObject *dbus_py_tp_richcompare_by_pointer(PyObject *, - PyObject *, - int); -extern long dbus_py_tp_hash_by_pointer(PyObject *self); extern PyObject *dbus_py_empty_tuple; extern dbus_bool_t dbus_py_init_generic(void); @@ -212,11 +251,13 @@ void _dbus_py_whereami(void); void _dbus_py_dbg_dump_message(DBusMessage *); -# define TRACE(self) do { fprintf(stderr, "TRACE: <%s at %p> in %s, " \ - "%d refs\n", \ - self->ob_type->tp_name, \ - self, __func__, \ - self->ob_refcnt); } while (0) +# define TRACE(self) do { \ + fprintf(stderr, "TRACE: <%s at %p> in %s, " \ + "%d refs\n", \ + self ? Py_TYPE(self)->tp_name : NULL, \ + self, __func__, \ + self ? (int)Py_REFCNT(self) : 0); \ + } while (0) # define DBG(format, ...) fprintf(stderr, "DEBUG: " format "\n",\ __VA_ARGS__) # define DBG_EXC(format, ...) do {DBG(format, __VA_ARGS__); \ diff -Nru dbus-python-0.84.0/_dbus_bindings/exceptions.c dbus-python-1.0.0/_dbus_bindings/exceptions.c --- dbus-python-0.84.0/_dbus_bindings/exceptions.c 2010-12-02 17:38:39.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/exceptions.c 2012-01-24 15:55:44.000000000 +0000 @@ -37,7 +37,7 @@ return TRUE; } - name = PyString_FromString("dbus.exceptions"); + name = NATIVESTR_FROMSTR("dbus.exceptions"); if (name == NULL) { return FALSE; } @@ -81,7 +81,7 @@ } if (error->name) { - PyObject *name = PyString_FromString(error->name); + PyObject *name = NATIVESTR_FROMSTR(error->name); int ret; if (!name) diff -Nru dbus-python-0.84.0/_dbus_bindings/float.c dbus-python-1.0.0/_dbus_bindings/float.c --- dbus-python-0.84.0/_dbus_bindings/float.c 2010-12-02 17:18:43.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/float.c 2012-01-11 12:26:09.000000000 +0000 @@ -40,8 +40,7 @@ #endif PyTypeObject DBusPyDouble_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Double", 0, 0, @@ -84,8 +83,7 @@ #ifdef WITH_DBUS_FLOAT32 PyTypeObject DBusPyFloat_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Float", 0, 0, diff -Nru dbus-python-0.84.0/_dbus_bindings/generic.c dbus-python-1.0.0/_dbus_bindings/generic.c --- dbus-python-0.84.0/_dbus_bindings/generic.c 2010-12-02 16:15:35.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/generic.c 2012-01-24 15:55:44.000000000 +0000 @@ -31,33 +31,10 @@ */ PyObject *dbus_py_empty_tuple = NULL; -PyObject * -dbus_py_tp_richcompare_by_pointer(PyObject *self, - PyObject *other, - int op) -{ - if (op == Py_EQ || op == Py_NE) { - if (self == other) { - return PyInt_FromLong(op == Py_EQ); - } - return PyInt_FromLong(op == Py_NE); - } - PyErr_SetString(PyExc_TypeError, - "Instances of this type are not ordered"); - return NULL; -} - -long -dbus_py_tp_hash_by_pointer(PyObject *self) -{ - long hash = (long)self; - return (hash == -1L ? -2L : hash); -} - int dbus_py_immutable_setattro(PyObject *obj UNUSED, - PyObject *name UNUSED, - PyObject *value UNUSED) + PyObject *name UNUSED, + PyObject *value UNUSED) { PyErr_SetString(PyExc_AttributeError, "Object is immutable"); return -1; diff -Nru dbus-python-0.84.0/_dbus_bindings/int.c dbus-python-1.0.0/_dbus_bindings/int.c --- dbus-python-0.84.0/_dbus_bindings/int.c 2010-12-02 17:18:49.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/int.c 2012-01-24 15:55:44.000000000 +0000 @@ -25,6 +25,12 @@ #include "types-internal.h" +#ifdef PY3 +#define INTBASE (DBusPyLongBase_Type) +#else +#define INTBASE (DBusPyIntBase_Type) +#endif + /* Specific types =================================================== */ /* Boolean, a subclass of DBusPythonInt ============================= */ @@ -65,29 +71,39 @@ } tuple = Py_BuildValue("(i)", PyObject_IsTrue(value) ? 1 : 0); if (!tuple) return NULL; - self = (DBusPyIntBase_Type.tp_new)(cls, tuple, kwargs); + self = (INTBASE.tp_new)(cls, tuple, kwargs); Py_CLEAR(tuple); return self; } static PyObject * -Boolean_tp_repr (PyObject *self) +Boolean_tp_repr(PyObject *self) { + int is_true = PyObject_IsTrue(self); +#ifdef PY3 + long variant_level = dbus_py_variant_level_get(self); + if (variant_level < 0) + return NULL; +#else long variant_level = ((DBusPyIntBase *)self)->variant_level; +#endif + + if (is_true == -1) + return NULL; + if (variant_level > 0) { - return PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyInt_AsLong(self) ? "True" : "False", - variant_level); - } - return PyString_FromFormat("%s(%s)", - self->ob_type->tp_name, - PyInt_AsLong(self) ? "True" : "False"); + return PyUnicode_FromFormat("%s(%s, variant_level=%ld)", + Py_TYPE(self)->tp_name, + is_true ? "True" : "False", + variant_level); + } + return PyUnicode_FromFormat("%s(%s)", + Py_TYPE(self)->tp_name, + is_true ? "True" : "False"); } PyTypeObject DBusPyBoolean_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Boolean", 0, 0, @@ -117,7 +133,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&INTBASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -153,20 +169,22 @@ dbus_int16_t dbus_py_int16_range_check(PyObject *obj) { - long i = PyInt_AsLong (obj); - if (i == -1 && PyErr_Occurred ()) return -1; + long i = PyLong_AsLong(obj); + if (i == -1 && PyErr_Occurred()) + return -1; + if (i < -0x8000 || i > 0x7fff) { PyErr_Format(PyExc_OverflowError, "Value %d out of range for Int16", (int)i); return -1; } - return i; + return (dbus_int16_t)i; } static PyObject * Int16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); + PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); if (self && dbus_py_int16_range_check(self) == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; @@ -175,8 +193,7 @@ } PyTypeObject DBusPyInt16_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Int16", 0, 0, @@ -206,7 +223,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&INTBASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -242,22 +259,25 @@ dbus_uint16_t dbus_py_uint16_range_check(PyObject *obj) { - long i = PyInt_AsLong(obj); - if (i == -1 && PyErr_Occurred()) return (dbus_uint16_t)(-1); + long i = PyLong_AsLong(obj); + if (i == -1 && PyErr_Occurred()) + return (dbus_uint16_t)(-1); + if (i < 0 || i > 0xffff) { PyErr_Format(PyExc_OverflowError, "Value %d out of range for UInt16", (int)i); return (dbus_uint16_t)(-1); } - return i; + return (dbus_uint16_t)i; } static PyObject * UInt16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); + PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); if (self && dbus_py_uint16_range_check(self) == (dbus_uint16_t)(-1) - && PyErr_Occurred()) { + && PyErr_Occurred()) + { Py_CLEAR (self); return NULL; } @@ -265,8 +285,7 @@ } PyTypeObject DBusPyUInt16_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.UInt16", 0, 0, @@ -296,7 +315,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&INTBASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -332,20 +351,22 @@ dbus_int32_t dbus_py_int32_range_check(PyObject *obj) { - long i = PyInt_AsLong(obj); - if (i == -1 && PyErr_Occurred()) return -1; + long i = PyLong_AsLong(obj); + if (i == -1 && PyErr_Occurred()) + return -1; + if (i < INT32_MIN || i > INT32_MAX) { PyErr_Format(PyExc_OverflowError, "Value %d out of range for Int32", (int)i); return -1; } - return i; + return (dbus_int32_t)i; } static PyObject * Int32_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); + PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); if (self && dbus_py_int32_range_check(self) == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; @@ -354,8 +375,7 @@ } PyTypeObject DBusPyInt32_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Int32", 0, 0, @@ -385,7 +405,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&INTBASE), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -456,8 +476,7 @@ } PyTypeObject DBusPyUInt32_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.UInt32", 0, 0, @@ -567,8 +586,7 @@ } PyTypeObject DBusPyInt64_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Int64", 0, 0, @@ -674,8 +692,7 @@ } PyTypeObject DBusPyUInt64_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.UInt64", 0, 0, @@ -718,17 +735,17 @@ dbus_bool_t dbus_py_init_int_types(void) { - DBusPyInt16_Type.tp_base = &DBusPyIntBase_Type; + DBusPyInt16_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyInt16_Type) < 0) return 0; /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as desired */ DBusPyInt16_Type.tp_print = NULL; - DBusPyUInt16_Type.tp_base = &DBusPyIntBase_Type; + DBusPyUInt16_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyUInt16_Type) < 0) return 0; DBusPyUInt16_Type.tp_print = NULL; - DBusPyInt32_Type.tp_base = &DBusPyIntBase_Type; + DBusPyInt32_Type.tp_base = &INTBASE; if (PyType_Ready(&DBusPyInt32_Type) < 0) return 0; DBusPyInt32_Type.tp_print = NULL; @@ -745,6 +762,11 @@ if (PyType_Ready(&DBusPyUInt64_Type) < 0) return 0; DBusPyUInt64_Type.tp_print = NULL; #endif + + DBusPyBoolean_Type.tp_base = &INTBASE; + if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; + DBusPyBoolean_Type.tp_print = NULL; + return 1; } diff -Nru dbus-python-0.84.0/_dbus_bindings/libdbusconn.c dbus-python-1.0.0/_dbus_bindings/libdbusconn.c --- dbus-python-0.84.0/_dbus_bindings/libdbusconn.c 2010-12-02 17:17:31.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/libdbusconn.c 2012-01-24 15:55:44.000000000 +0000 @@ -73,12 +73,11 @@ } PyErr_Restore(et, ev, etb); - (self->ob_type->tp_free)((PyObject *) self); + (Py_TYPE(self)->tp_free)((PyObject *) self); } PyTypeObject DBusPyLibDBusConnection_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_dbus_bindings._LibDBusConnection", sizeof(DBusPyLibDBusConnection), 0, /*tp_itemsize*/ diff -Nru dbus-python-0.84.0/_dbus_bindings/mainloop.c dbus-python-1.0.0/_dbus_bindings/mainloop.c --- dbus-python-0.84.0/_dbus_bindings/mainloop.c 2010-12-02 17:19:20.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/mainloop.c 2012-01-11 12:26:09.000000000 +0000 @@ -59,8 +59,7 @@ } static PyTypeObject NativeMainLoop_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.mainloop.NativeMainLoop", sizeof(NativeMainLoop), 0, diff -Nru dbus-python-0.84.0/_dbus_bindings/Makefile.am dbus-python-1.0.0/_dbus_bindings/Makefile.am --- dbus-python-0.84.0/_dbus_bindings/Makefile.am 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/Makefile.am 2012-01-24 15:55:44.000000000 +0000 @@ -1,7 +1,8 @@ pyexec_LTLIBRARIES = _dbus_bindings.la AM_CPPFLAGS = -I$(top_srcdir)/include $(DBUS_CFLAGS) $(PYTHON_INCLUDES) -AM_LDFLAGS = -module -avoid-version -export-symbols-regex init_dbus_bindings \ +AM_LDFLAGS = -module -avoid-version \ + -export-symbols-regex \(PyInit__\|init_\)dbus_bindings \ $(DBUS_LIBS) _dbus_bindings_la_SOURCES = \ abstract.c \ diff -Nru dbus-python-0.84.0/_dbus_bindings/Makefile.in dbus-python-1.0.0/_dbus_bindings/Makefile.in --- dbus-python-0.84.0/_dbus_bindings/Makefile.in 2011-05-25 11:50:03.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/Makefile.in 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -74,6 +74,12 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(pyexecdir)" LTLIBRARIES = $(pyexec_LTLIBRARIES) _dbus_bindings_la_LIBADD = @@ -258,7 +264,8 @@ top_srcdir = @top_srcdir@ pyexec_LTLIBRARIES = _dbus_bindings.la AM_CPPFLAGS = -I$(top_srcdir)/include $(DBUS_CFLAGS) $(PYTHON_INCLUDES) -AM_LDFLAGS = -module -avoid-version -export-symbols-regex init_dbus_bindings \ +AM_LDFLAGS = -module -avoid-version \ + -export-symbols-regex \(PyInit__\|init_\)dbus_bindings \ $(DBUS_LIBS) _dbus_bindings_la_SOURCES = \ @@ -392,26 +399,23 @@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -519,10 +523,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru dbus-python-0.84.0/_dbus_bindings/message-append.c dbus-python-1.0.0/_dbus_bindings/message-append.c --- dbus-python-0.84.0/_dbus_bindings/message-append.c 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/message-append.c 2012-01-24 15:55:44.000000000 +0000 @@ -38,9 +38,14 @@ static long get_variant_level(PyObject *obj) { - if (DBusPyIntBase_Check(obj)) { + if (DBusPyString_Check(obj)) { + return ((DBusPyString *)obj)->variant_level; + } +#ifndef PY3 + else if (DBusPyIntBase_Check(obj)) { return ((DBusPyIntBase *)obj)->variant_level; } +#endif else if (DBusPyFloatBase_Check(obj)) { return ((DBusPyFloatBase *)obj)->variant_level; } @@ -50,10 +55,10 @@ else if (DBusPyDict_Check(obj)) { return ((DBusPyDict *)obj)->variant_level; } - else if (DBusPyString_Check(obj)) { - return ((DBusPyString *)obj)->variant_level; - } else if (DBusPyLongBase_Check(obj) || +#ifdef PY3 + DBusPyBytesBase_Check(obj) || +#endif DBusPyStrBase_Check(obj) || DBusPyStruct_Check(obj)) { return dbus_py_variant_level_get(obj); @@ -143,7 +148,7 @@ PyObject *magic_attr = PyObject_GetAttr(obj, dbus_py__dbus_object_path__const); if (magic_attr) { - if (PyString_Check(magic_attr)) { + if (PyUnicode_Check(magic_attr) || PyBytes_Check(magic_attr)) { return magic_attr; } else { @@ -171,15 +176,19 @@ { PyObject *magic_attr; long variant_level = get_variant_level(obj); + + if (variant_level < 0) + return NULL; + if (variant_level_ptr) { *variant_level_ptr = variant_level; } else if (variant_level > 0) { - return PyString_FromString(DBUS_TYPE_VARIANT_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_VARIANT_AS_STRING); } if (obj == Py_True || obj == Py_False) { - return PyString_FromString(DBUS_TYPE_BOOLEAN_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); } magic_attr = get_object_path(obj); @@ -187,61 +196,84 @@ return NULL; if (magic_attr != Py_None) { Py_CLEAR(magic_attr); - return PyString_FromString(DBUS_TYPE_OBJECT_PATH_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_OBJECT_PATH_AS_STRING); } Py_CLEAR(magic_attr); /* Ordering is important: some of these are subclasses of each other. */ +#ifdef PY3 + if (PyLong_Check(obj)) { + if (DBusPyUInt64_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT64_AS_STRING); + else if (DBusPyInt64_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); + else if (DBusPyUInt32_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT32_AS_STRING); + else if (DBusPyInt32_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); + else if (DBusPyUInt16_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT16_AS_STRING); + else if (DBusPyInt16_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_INT16_AS_STRING); + else if (DBusPyByte_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_BYTE_AS_STRING); + else if (DBusPyBoolean_Check(obj)) + return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); + else + return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); + } +#else /* !PY3 */ if (PyInt_Check(obj)) { if (DBusPyInt16_Check(obj)) - return PyString_FromString(DBUS_TYPE_INT16_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_INT16_AS_STRING); else if (DBusPyInt32_Check(obj)) - return PyString_FromString(DBUS_TYPE_INT32_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); else if (DBusPyByte_Check(obj)) - return PyString_FromString(DBUS_TYPE_BYTE_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_BYTE_AS_STRING); else if (DBusPyUInt16_Check(obj)) - return PyString_FromString(DBUS_TYPE_UINT16_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT16_AS_STRING); else if (DBusPyBoolean_Check(obj)) - return PyString_FromString(DBUS_TYPE_BOOLEAN_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); else - return PyString_FromString(DBUS_TYPE_INT32_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); } else if (PyLong_Check(obj)) { if (DBusPyInt64_Check(obj)) - return PyString_FromString(DBUS_TYPE_INT64_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); else if (DBusPyUInt32_Check(obj)) - return PyString_FromString(DBUS_TYPE_UINT32_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT32_AS_STRING); else if (DBusPyUInt64_Check(obj)) - return PyString_FromString(DBUS_TYPE_UINT64_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_UINT64_AS_STRING); else - return PyString_FromString(DBUS_TYPE_INT64_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); } +#endif /* PY3 */ else if (PyUnicode_Check(obj)) - return PyString_FromString(DBUS_TYPE_STRING_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_STRING_AS_STRING); #if defined(DBUS_TYPE_UNIX_FD) else if (DBusPyUnixFd_Check(obj)) - return PyString_FromString(DBUS_TYPE_UNIX_FD_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_UNIX_FD_AS_STRING); #endif else if (PyFloat_Check(obj)) { #ifdef WITH_DBUS_FLOAT32 if (DBusPyDouble_Check(obj)) - return PyString_FromString(DBUS_TYPE_DOUBLE_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_DOUBLE_AS_STRING); else if (DBusPyFloat_Check(obj)) - return PyString_FromString(DBUS_TYPE_FLOAT_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_FLOAT_AS_STRING); else #endif - return PyString_FromString(DBUS_TYPE_DOUBLE_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_DOUBLE_AS_STRING); } - else if (PyString_Check(obj)) { + else if (PyBytes_Check(obj)) { if (DBusPyObjectPath_Check(obj)) - return PyString_FromString(DBUS_TYPE_OBJECT_PATH_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_OBJECT_PATH_AS_STRING); else if (DBusPySignature_Check(obj)) - return PyString_FromString(DBUS_TYPE_SIGNATURE_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_SIGNATURE_AS_STRING); else if (DBusPyByteArray_Check(obj)) - return PyString_FromString(DBUS_TYPE_ARRAY_AS_STRING - DBUS_TYPE_BYTE_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_ARRAY_AS_STRING + DBUS_TYPE_BYTE_AS_STRING); else - return PyString_FromString(DBUS_TYPE_STRING_AS_STRING); + return NATIVESTR_FROMSTR(DBUS_TYPE_STRING_AS_STRING); } else if (PyTuple_Check(obj)) { Py_ssize_t len = PyTuple_GET_SIZE(obj); @@ -258,12 +290,12 @@ return NULL; } /* Set the first and last elements of list to be the parentheses */ - item = PyString_FromString(DBUS_STRUCT_BEGIN_CHAR_AS_STRING); + item = NATIVESTR_FROMSTR(DBUS_STRUCT_BEGIN_CHAR_AS_STRING); if (PyList_SetItem(list, 0, item) < 0) { Py_CLEAR(list); return NULL; } - item = PyString_FromString(DBUS_STRUCT_END_CHAR_AS_STRING); + item = NATIVESTR_FROMSTR(DBUS_STRUCT_END_CHAR_AS_STRING); if (PyList_SetItem(list, len + 1, item) < 0) { Py_CLEAR(list); return NULL; @@ -291,7 +323,7 @@ } item = NULL; } - empty_str = PyString_FromString(""); + empty_str = NATIVESTR_FROMSTR(""); if (!empty_str) { /* really shouldn't happen */ Py_CLEAR(list); @@ -305,12 +337,25 @@ } else if (PyList_Check(obj)) { PyObject *tmp; - PyObject *ret = PyString_FromString(DBUS_TYPE_ARRAY_AS_STRING); + PyObject *ret = NATIVESTR_FROMSTR(DBUS_TYPE_ARRAY_AS_STRING); if (!ret) return NULL; - if (DBusPyArray_Check(obj) && PyString_Check(((DBusPyArray *)obj)->signature)) { - PyString_Concat(&ret, ((DBusPyArray *)obj)->signature); +#ifdef PY3 + if (DBusPyArray_Check(obj) && + PyUnicode_Check(((DBusPyArray *)obj)->signature)) + { + PyObject *concat = PyUnicode_Concat( + ret, ((DBusPyArray *)obj)->signature); + Py_CLEAR(ret); + return concat; + } +#else + if (DBusPyArray_Check(obj) && + PyBytes_Check(((DBusPyArray *)obj)->signature)) + { + PyBytes_Concat(&ret, ((DBusPyArray *)obj)->signature); return ret; } +#endif if (PyList_GET_SIZE(obj) == 0) { /* No items, so fail. Or should we guess "av"? */ PyErr_SetString(PyExc_ValueError, "Unable to guess signature " @@ -320,23 +365,46 @@ tmp = PyList_GetItem(obj, 0); tmp = _signature_string_from_pyobject(tmp, NULL); if (!tmp) return NULL; - PyString_ConcatAndDel(&ret, tmp); +#ifdef PY3 + { + PyObject *concat = PyUnicode_Concat(ret, tmp); + Py_CLEAR(ret); + Py_CLEAR(tmp); + return concat; + } +#else + PyBytes_ConcatAndDel(&ret, tmp); return ret; +#endif } else if (PyDict_Check(obj)) { PyObject *key, *value, *keysig, *valuesig; Py_ssize_t pos = 0; PyObject *ret = NULL; - if (DBusPyDict_Check(obj) && PyString_Check(((DBusPyDict *)obj)->signature)) { - const char *sig = PyString_AS_STRING(((DBusPyDict *)obj)->signature); +#ifdef PY3 + if (DBusPyDict_Check(obj) && + PyUnicode_Check(((DBusPyDict *)obj)->signature)) + { + return PyUnicode_FromFormat((DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + "%U" + DBUS_DICT_ENTRY_END_CHAR_AS_STRING), + ((DBusPyDict *)obj)->signature); + } +#else + if (DBusPyDict_Check(obj) && + PyBytes_Check(((DBusPyDict *)obj)->signature)) + { + const char *sig = PyBytes_AS_STRING(((DBusPyDict *)obj)->signature); - return PyString_FromFormat((DBUS_TYPE_ARRAY_AS_STRING - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - "%s" - DBUS_DICT_ENTRY_END_CHAR_AS_STRING), - sig); + return PyBytes_FromFormat((DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + "%s" + DBUS_DICT_ENTRY_END_CHAR_AS_STRING), + sig); } +#endif if (!PyDict_Next(obj, &pos, &key, &value)) { /* No items, so fail. Or should we guess "a{vv}"? */ PyErr_SetString(PyExc_ValueError, "Unable to guess signature " @@ -346,21 +414,29 @@ keysig = _signature_string_from_pyobject(key, NULL); valuesig = _signature_string_from_pyobject(value, NULL); if (keysig && valuesig) { - ret = PyString_FromFormat((DBUS_TYPE_ARRAY_AS_STRING - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - "%s%s" - DBUS_DICT_ENTRY_END_CHAR_AS_STRING), - PyString_AS_STRING(keysig), - PyString_AS_STRING(valuesig)); +#ifdef PY3 + ret = PyUnicode_FromFormat((DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + "%U%U" + DBUS_DICT_ENTRY_END_CHAR_AS_STRING), + keysig, valuesig); +#else + ret = PyBytes_FromFormat((DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + "%s%s" + DBUS_DICT_ENTRY_END_CHAR_AS_STRING), + PyBytes_AS_STRING(keysig), + PyBytes_AS_STRING(valuesig)); +#endif } Py_CLEAR(keysig); Py_CLEAR(valuesig); return ret; } else { - PyErr_Format(PyExc_TypeError, "Don't know how which D-Bus type " + PyErr_Format(PyExc_TypeError, "Don't know which D-Bus type " "to use to encode type \"%s\"", - obj->ob_type->tp_name); + Py_TYPE(obj)->tp_name); return NULL; } } @@ -403,7 +479,21 @@ DBG("%s", "Message_guess_signature: failed"); return NULL; } - if (!PyString_Check(tmp) || PyString_GET_SIZE(tmp) < 2) { + if (PyUnicode_Check(tmp)) { + PyObject *as_bytes = PyUnicode_AsUTF8String(tmp); + Py_CLEAR(tmp); + if (!as_bytes) + return NULL; + if (PyBytes_GET_SIZE(as_bytes) < 2) { + PyErr_SetString(PyExc_RuntimeError, "Internal error: " + "_signature_string_from_pyobject returned " + "a bad result"); + Py_CLEAR(as_bytes); + return NULL; + } + tmp = as_bytes; + } + if (!PyBytes_Check(tmp) || PyBytes_GET_SIZE(tmp) < 2) { PyErr_SetString(PyExc_RuntimeError, "Internal error: " "_signature_string_from_pyobject returned " "a bad result"); @@ -411,10 +501,8 @@ return NULL; } ret = PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s#)", - PyString_AS_STRING(tmp) + 1, - PyString_GET_SIZE(tmp) - 2); - DBG("Message_guess_signature: returning Signature at %p \"%s\"", ret, - ret ? PyString_AS_STRING(ret) : "(NULL)"); + PyBytes_AS_STRING(tmp) + 1, + PyBytes_GET_SIZE(tmp) - 2); Py_CLEAR(tmp); return ret; } @@ -450,13 +538,13 @@ } } - if (PyString_Check(obj)) { + if (PyBytes_Check(obj)) { PyObject *unicode; /* Raise TypeError if the string has embedded NULs */ - if (PyString_AsStringAndSize(obj, &s, NULL) < 0) return -1; + if (PyBytes_AsStringAndSize(obj, &s, NULL) < 0) return -1; /* Surely there's a faster stdlib way to validate UTF-8... */ - unicode = PyUnicode_DecodeUTF8(s, PyString_GET_SIZE(obj), NULL); + unicode = PyUnicode_DecodeUTF8(s, PyBytes_GET_SIZE(obj), NULL); if (!unicode) { PyErr_SetString(PyExc_UnicodeError, "String parameters " "to be sent over D-Bus must be valid UTF-8"); @@ -475,9 +563,10 @@ PyObject *utf8 = PyUnicode_AsUTF8String(obj); if (!utf8) return -1; /* Raise TypeError if the string has embedded NULs */ - if (PyString_AsStringAndSize(utf8, &s, NULL) < 0) return -1; + if (PyBytes_AsStringAndSize(utf8, &s, NULL) < 0) return -1; DBG("Performing actual append: string (from unicode) %s", s); if (!dbus_message_iter_append_basic(appender, sig_type, &s)) { + Py_CLEAR(utf8); PyErr_NoMemory(); return -1; } @@ -496,22 +585,24 @@ { unsigned char y; - if (PyString_Check(obj)) { - if (PyString_GET_SIZE(obj) != 1) { - PyErr_Format(PyExc_ValueError, "Expected a string of " - "length 1 byte, but found %d bytes", - (int) PyString_GET_SIZE(obj)); + if (PyBytes_Check(obj)) { + if (PyBytes_GET_SIZE(obj) != 1) { + PyErr_Format(PyExc_ValueError, + "Expected a length-1 bytes but found %d bytes", + (int)PyBytes_GET_SIZE(obj)); return -1; } - y = *(unsigned char *)PyString_AS_STRING(obj); + y = *(unsigned char *)PyBytes_AS_STRING(obj); } else { - long i = PyInt_AsLong(obj); + /* on Python 2 this accepts either int or long */ + long i = PyLong_AsLong(obj); if (i == -1 && PyErr_Occurred()) return -1; if (i < 0 || i > 0xff) { - PyErr_Format(PyExc_ValueError, "%d outside range for a " - "byte value", (int)i); + PyErr_Format(PyExc_ValueError, + "%d outside range for a byte value", + (int)i); return -1; } y = i; @@ -529,14 +620,10 @@ DBusMessageIter *sub, dbus_bool_t is_ok) { -#ifdef HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER if (!is_ok) { dbus_message_iter_abandon_container(iter, sub); return TRUE; } -#else - (void) is_ok; -#endif return dbus_message_iter_close_container(iter, sub); } @@ -545,12 +632,25 @@ _message_iter_append_unixfd(DBusMessageIter *appender, PyObject *obj) { int fd; + long original_fd; - if (PyInt_Check(obj)) { - fd = PyInt_AsLong(obj); - } else if (PyObject_IsInstance(obj, (PyObject*) &DBusPyUnixFd_Type)) { - fd = dbus_py_unix_fd_get_fd(obj); - } else { + if (INTORLONG_CHECK(obj)) + { + /* on Python 2 this accepts either int or long */ + original_fd = PyLong_AsLong(obj); + if (original_fd == -1 && PyErr_Occurred()) + return -1; + if (original_fd < INT_MIN || original_fd > INT_MAX) { + PyErr_Format(PyExc_ValueError, "out of int range: %ld", + original_fd); + return -1; + } + fd = (int)original_fd; + } + else if (PyObject_IsInstance(obj, (PyObject*) &DBusPyUnixFd_Type)) { + fd = dbus_py_unix_fd_get_fd(obj); + } + else { return -1; } @@ -671,7 +771,7 @@ } /* else leave sig set to NULL. */ - DBG("Opening %c container", container); + DBG("Opening '%c' container", container); if (!dbus_message_iter_open_container(appender, container, sig, &sub_appender)) { PyErr_NoMemory(); @@ -752,7 +852,7 @@ } /* This must be run as cleanup, even on failure. */ - DBG("Closing %c container", container); + DBG("Closing '%c' container", container); if (!dbuspy_message_iter_close_container(appender, &sub_appender, (ret == 0))) { PyErr_NoMemory(); ret = -1; @@ -769,19 +869,19 @@ PyObject *obj) { /* a bit of a faster path for byte arrays that are strings */ - Py_ssize_t len = PyString_GET_SIZE(obj); + Py_ssize_t len = PyBytes_GET_SIZE(obj); const char *s; DBusMessageIter sub; int ret; - s = PyString_AS_STRING(obj); + s = PyBytes_AS_STRING(obj); DBG("%s", "Opening ARRAY container"); if (!dbus_message_iter_open_container(appender, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) { PyErr_NoMemory(); return -1; } - DBG("Appending fixed array of %d bytes", len); + DBG("Appending fixed array of %d bytes", (int)len); if (dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &s, len)) { ret = 0; } @@ -813,8 +913,18 @@ obj_sig = _signature_string_from_pyobject(obj, &variant_level); if (!obj_sig) return -1; - obj_sig_str = PyString_AsString(obj_sig); - if (!obj_sig_str) return -1; + if (PyUnicode_Check(obj_sig)) { + PyObject *obj_sig_as_bytes = PyUnicode_AsUTF8String(obj_sig); + Py_CLEAR(obj_sig); + if (!obj_sig_as_bytes) + return -1; + obj_sig = obj_sig_as_bytes; + } + obj_sig_str = PyBytes_AsString(obj_sig); + if (!obj_sig_str) { + Py_CLEAR(obj_sig); + return -1; + } if (variant_level < 1) { variant_level = 1; @@ -1031,7 +1141,7 @@ if (sig_type == DBUS_TYPE_DICT_ENTRY) ret = _message_iter_append_multi(appender, sig_iter, DBUS_TYPE_DICT_ENTRY, obj); - else if (sig_type == DBUS_TYPE_BYTE && PyString_Check(obj)) + else if (sig_type == DBUS_TYPE_BYTE && PyBytes_Check(obj)) ret = _message_iter_append_string_as_byte_array(appender, obj); else ret = _message_iter_append_multi(appender, sig_iter, @@ -1108,7 +1218,18 @@ DBG("%s", "No signature for message, guessing..."); signature_obj = dbus_py_Message_guess_signature(NULL, args); if (!signature_obj) return NULL; - signature = PyString_AS_STRING(signature_obj); + if (PyUnicode_Check(signature_obj)) { + PyObject *signature_as_bytes; + signature_as_bytes = PyUnicode_AsUTF8String(signature_obj); + Py_CLEAR(signature_obj); + if (!signature_as_bytes) + return NULL; + signature_obj = signature_as_bytes; + } + else { + assert(PyBytes_Check(signature_obj)); + } + signature = PyBytes_AS_STRING(signature_obj); } /* from here onwards, you have to do a goto rather than returning NULL to make sure signature_obj gets freed */ diff -Nru dbus-python-0.84.0/_dbus_bindings/message.c dbus-python-1.0.0/_dbus_bindings/message.c --- dbus-python-0.84.0/_dbus_bindings/message.c 2010-12-02 17:20:03.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/message.c 2012-01-24 15:55:44.000000000 +0000 @@ -32,7 +32,7 @@ static inline int Message_Check(PyObject *o) { - return (o->ob_type == &MessageType) + return (Py_TYPE(o) == &MessageType) || PyObject_IsInstance(o, (PyObject *)&MessageType); } @@ -53,7 +53,7 @@ if (self->msg) { dbus_message_unref(self->msg); } - self->ob_type->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * @@ -69,6 +69,30 @@ return (PyObject *)self; } +static PyObject * +MethodCallMessage_tp_repr(PyObject *self) +{ + DBusMessage *msg = ((Message *)self)->msg; + const char *destination = dbus_message_get_destination(msg); + const char *path = dbus_message_get_path(msg); + const char *interface = dbus_message_get_interface(msg); + const char *member = dbus_message_get_member(msg); + + if (!path) + path = "n/a"; + if (!interface) + interface = "n/a"; + if (!member) + member = "n/a"; + if (!destination) + destination = "n/a"; + + return PyUnicode_FromFormat( + "<%s path: %s, iface: %s, member: %s dest: %s>", + Py_TYPE(self)->tp_name, + path, interface, member, destination); +} + PyDoc_STRVAR(MethodCallMessage_tp_doc, "A method-call message.\n" "\n" "Constructor::\n" @@ -169,6 +193,29 @@ return 0; } +static PyObject * +SignalMessage_tp_repr(PyObject *self) +{ + DBusMessage *msg = ((Message *)self)->msg; + const char *path = dbus_message_get_path(msg); + const char *interface = dbus_message_get_interface(msg); + const char *member = dbus_message_get_member(msg); + const char *destination = dbus_message_get_destination(msg); + + if (!path) + path = "n/a"; + if (!interface) + interface = "n/a"; + if (!member) + member = "n/a"; + if (!destination) + destination = "(broadcast)"; + + return PyUnicode_FromFormat("<%s path: %s, iface: %s, member: %s, dest: %s>", + Py_TYPE(self)->tp_name, + path, interface, member, destination); +} + PyDoc_STRVAR(ErrorMessage_tp_doc, "An error message.\n\n" "Constructor::\n\n" " dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n" @@ -341,7 +388,7 @@ Message_get_type(Message *self, PyObject *unused UNUSED) { if (!self->msg) return DBusPy_RaiseUnusableMessage(); - return PyInt_FromLong(dbus_message_get_type(self->msg)); + return NATIVEINT_FROMLONG(dbus_message_get_type(self->msg)); } PyDoc_STRVAR(Message_get_serial__doc__, @@ -415,7 +462,7 @@ if (!c_str) { Py_RETURN_NONE; } - return PyString_FromString(c_str); + return NATIVESTR_FROMSTR(c_str); } PyDoc_STRVAR(Message_has_member__doc__, @@ -490,7 +537,7 @@ Py_RETURN_NONE; } for (ptr = paths; *ptr; ptr++) { - PyObject *str = PyString_FromString(*ptr); + PyObject *str = NATIVESTR_FROMSTR(*ptr); if (!str) { Py_CLEAR(ret); @@ -576,7 +623,7 @@ if (!c_str) { Py_RETURN_NONE; } - return PyString_FromString(c_str); + return NATIVESTR_FROMSTR(c_str); } PyDoc_STRVAR(Message_has_sender__doc__, @@ -622,7 +669,7 @@ if (!c_str) { Py_RETURN_NONE; } - return PyString_FromString(c_str); + return NATIVESTR_FROMSTR(c_str); } PyDoc_STRVAR(Message_has_destination__doc__, @@ -667,7 +714,7 @@ if (!c_str) { Py_RETURN_NONE; } - return PyString_FromString(c_str); + return NATIVESTR_FROMSTR(c_str); } PyDoc_STRVAR(Message_has_interface__doc__, @@ -712,7 +759,7 @@ if (!c_str) { Py_RETURN_NONE; } - return PyString_FromString(c_str); + return NATIVESTR_FROMSTR(c_str); } PyDoc_STRVAR(Message_set_error_name__doc__, @@ -808,8 +855,7 @@ }; static PyTypeObject MessageType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dbus.lowlevel.Message", /*tp_name*/ sizeof(Message), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -850,8 +896,7 @@ }; static PyTypeObject MethodCallMessageType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dbus.lowlevel.MethodCallMessage", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -860,7 +905,7 @@ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ - 0, /*tp_repr*/ + MethodCallMessage_tp_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -892,8 +937,7 @@ }; static PyTypeObject MethodReturnMessageType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dbus.lowlevel.MethodReturnMessage", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -934,8 +978,7 @@ }; static PyTypeObject SignalMessageType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dbus.lowlevel.SignalMessage", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -944,7 +987,7 @@ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ - 0, /*tp_repr*/ + SignalMessage_tp_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -976,8 +1019,7 @@ }; static PyTypeObject ErrorMessageType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dbus.lowlevel.ErrorMessage", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ diff -Nru dbus-python-0.84.0/_dbus_bindings/message-get-args.c dbus-python-1.0.0/_dbus_bindings/message-get-args.c --- dbus-python-0.84.0/_dbus_bindings/message-get-args.c 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/message-get-args.c 2012-01-24 15:55:44.000000000 +0000 @@ -42,9 +42,11 @@ " it's off by default for consistency.\n" "\n" " If false (default), convert them into a dbus.Array of Bytes.\n" +#ifndef PY3 " `utf8_strings` : bool\n" " If true, return D-Bus strings as Python 8-bit strings (of UTF-8).\n" " If false (default), return D-Bus strings as Python unicode objects.\n" +#endif "\n" "Most of the type mappings should be fairly obvious:\n" "\n" @@ -70,7 +72,9 @@ typedef struct { int byte_arrays; +#ifndef PY3 int utf8_strings; +#endif } Message_get_args_options; static PyObject *_message_iter_get_pyobject(DBusMessageIter *iter, @@ -94,7 +98,7 @@ #ifdef USING_DBG fprintf(stderr, "DBG/%ld: appending to list: %p == ", (long)getpid(), item); PyObject_Print(item, stderr, 0); - fprintf(stderr, " of type %p\n", item->ob_type); + fprintf(stderr, " of type %p\n", Py_TYPE(item)); #endif ret = PyList_Append(list, item); Py_CLEAR(item); @@ -213,7 +217,7 @@ if (variant_level > 0 && type != DBUS_TYPE_VARIANT) { PyObject *variant_level_int; - variant_level_int = PyInt_FromLong(variant_level); + variant_level_int = NATIVEINT_FROMLONG(variant_level); if (!variant_level_int) { return NULL; } @@ -235,9 +239,12 @@ */ switch (type) { + PyObject *unicode; + case DBUS_TYPE_STRING: DBG("%s", "found a string"); dbus_message_iter_get_basic(iter, &u.s); +#ifndef PY3 if (opts->utf8_strings) { args = Py_BuildValue("(s)", u.s); if (!args) break; @@ -245,15 +252,20 @@ args, kwargs); } else { - args = Py_BuildValue("(N)", PyUnicode_DecodeUTF8(u.s, - strlen(u.s), - NULL)); +#endif + unicode = PyUnicode_DecodeUTF8(u.s, strlen(u.s), NULL); + if (!unicode) { + break; + } + args = Py_BuildValue("(N)", unicode); if (!args) { break; } ret = PyObject_Call((PyObject *)&DBusPyString_Type, args, kwargs); +#ifndef PY3 } +#endif break; case DBUS_TYPE_SIGNATURE: @@ -408,7 +420,11 @@ * for an empty byte-blob... */ u.s = ""; } +#ifdef PY3 + args = Py_BuildValue("(y#)", u.s, (Py_ssize_t)n); +#else args = Py_BuildValue("(s#)", u.s, (Py_ssize_t)n); +#endif if (!args) break; ret = PyObject_Call((PyObject *)&DBusPyByteArray_Type, args, kwargs); @@ -492,8 +508,13 @@ PyObject * dbus_py_Message_get_args_list(Message *self, PyObject *args, PyObject *kwargs) { +#ifdef PY3 + Message_get_args_options opts = { 0 }; + static char *argnames[] = { "byte_arrays", NULL }; +#else Message_get_args_options opts = { 0, 0 }; static char *argnames[] = { "byte_arrays", "utf8_strings", NULL }; +#endif PyObject *list; DBusMessageIter iter; @@ -513,10 +534,16 @@ "arguments"); return NULL; } +#ifdef PY3 + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:get_args_list", + argnames, + &(opts.byte_arrays))) return NULL; +#else if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii:get_args_list", argnames, &(opts.byte_arrays), &(opts.utf8_strings))) return NULL; +#endif if (!self->msg) return DBusPy_RaiseUnusableMessage(); list = PyList_New(0); diff -Nru dbus-python-0.84.0/_dbus_bindings/module.c dbus-python-1.0.0/_dbus_bindings/module.c --- dbus-python-0.84.0/_dbus_bindings/module.c 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/module.c 2012-01-24 15:55:44.000000000 +0000 @@ -234,90 +234,108 @@ }; PyMODINIT_FUNC +#ifdef PY3 +PyInit__dbus_bindings(void) +#else init_dbus_bindings(void) +#endif { - PyObject *this_module, *c_api; + PyObject *this_module = NULL, *c_api; static const int API_count = DBUS_BINDINGS_API_COUNT; static _dbus_py_func_ptr dbus_bindings_API[DBUS_BINDINGS_API_COUNT]; +#ifdef PY3 + static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "_dbus_bindings", /* m_name */ + module_doc, /* m_doc */ + -1, /* m_size */ + module_functions, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ + }; +#endif + dbus_bindings_API[0] = (_dbus_py_func_ptr)&API_count; dbus_bindings_API[1] = (_dbus_py_func_ptr)DBusPyConnection_BorrowDBusConnection; dbus_bindings_API[2] = (_dbus_py_func_ptr)DBusPyNativeMainLoop_New4; default_main_loop = NULL; - /* I'd rather not initialize threads if we can help it - dbus-python and - pygobject both release and re-obtain the GIL on a regular basis, which is - much simpler (basically free) before threads are initialized. - - However, on Python < 2.4.2c1 you aren't allowed to call - PyGILState_Release without initializing threads first. */ - if (strcmp(Py_GetVersion(), "2.4.2c1") < 0) { - PyEval_InitThreads(); - } + if (!dbus_py_init_generic()) goto init_error; + if (!dbus_py_init_abstract()) goto init_error; + if (!dbus_py_init_signature()) goto init_error; + if (!dbus_py_init_int_types()) goto init_error; + if (!dbus_py_init_unixfd_type()) goto init_error; + if (!dbus_py_init_string_types()) goto init_error; + if (!dbus_py_init_float_types()) goto init_error; + if (!dbus_py_init_container_types()) goto init_error; + if (!dbus_py_init_byte_types()) goto init_error; + if (!dbus_py_init_message_types()) goto init_error; + if (!dbus_py_init_pending_call()) goto init_error; + if (!dbus_py_init_mainloop()) goto init_error; + if (!dbus_py_init_libdbus_conn_types()) goto init_error; + if (!dbus_py_init_conn_types()) goto init_error; + if (!dbus_py_init_server_types()) goto init_error; + +#ifdef PY3 + this_module = PyModule_Create(&moduledef); +#else + this_module = Py_InitModule3("_dbus_bindings", + module_functions, module_doc); +#endif + if (!this_module) goto init_error; - if (!dbus_py_init_generic()) return; - if (!dbus_py_init_abstract()) return; - if (!dbus_py_init_signature()) return; - if (!dbus_py_init_int_types()) return; - if (!dbus_py_init_unixfd_type()) return; - if (!dbus_py_init_string_types()) return; - if (!dbus_py_init_float_types()) return; - if (!dbus_py_init_container_types()) return; - if (!dbus_py_init_byte_types()) return; - if (!dbus_py_init_message_types()) return; - if (!dbus_py_init_pending_call()) return; - if (!dbus_py_init_mainloop()) return; - if (!dbus_py_init_libdbus_conn_types()) return; - if (!dbus_py_init_conn_types()) return; - if (!dbus_py_init_server_types()) return; - - this_module = Py_InitModule3("_dbus_bindings", module_functions, module_doc); - if (!this_module) return; - - if (!dbus_py_insert_abstract_types(this_module)) return; - if (!dbus_py_insert_signature(this_module)) return; - if (!dbus_py_insert_int_types(this_module)) return; - if (!dbus_py_insert_unixfd_type(this_module)) return; - if (!dbus_py_insert_string_types(this_module)) return; - if (!dbus_py_insert_float_types(this_module)) return; - if (!dbus_py_insert_container_types(this_module)) return; - if (!dbus_py_insert_byte_types(this_module)) return; - if (!dbus_py_insert_message_types(this_module)) return; - if (!dbus_py_insert_pending_call(this_module)) return; - if (!dbus_py_insert_mainloop_types(this_module)) return; - if (!dbus_py_insert_libdbus_conn_types(this_module)) return; - if (!dbus_py_insert_conn_types(this_module)) return; - if (!dbus_py_insert_server_types(this_module)) return; + if (!dbus_py_insert_abstract_types(this_module)) goto init_error; + if (!dbus_py_insert_signature(this_module)) goto init_error; + if (!dbus_py_insert_int_types(this_module)) goto init_error; + if (!dbus_py_insert_unixfd_type(this_module)) goto init_error; + if (!dbus_py_insert_string_types(this_module)) goto init_error; + if (!dbus_py_insert_float_types(this_module)) goto init_error; + if (!dbus_py_insert_container_types(this_module)) goto init_error; + if (!dbus_py_insert_byte_types(this_module)) goto init_error; + if (!dbus_py_insert_message_types(this_module)) goto init_error; + if (!dbus_py_insert_pending_call(this_module)) goto init_error; + if (!dbus_py_insert_mainloop_types(this_module)) goto init_error; + if (!dbus_py_insert_libdbus_conn_types(this_module)) goto init_error; + if (!dbus_py_insert_conn_types(this_module)) goto init_error; + if (!dbus_py_insert_server_types(this_module)) goto init_error; if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_NAME", - DBUS_SERVICE_DBUS) < 0) return; + DBUS_SERVICE_DBUS) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_PATH", - DBUS_PATH_DBUS) < 0) return; + DBUS_PATH_DBUS) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_IFACE", - DBUS_INTERFACE_DBUS) < 0) return; + DBUS_INTERFACE_DBUS) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "LOCAL_PATH", - DBUS_PATH_LOCAL) < 0) return; + DBUS_PATH_LOCAL) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "LOCAL_IFACE", - DBUS_INTERFACE_LOCAL) < 0) return; + DBUS_INTERFACE_LOCAL) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "INTROSPECTABLE_IFACE", - DBUS_INTERFACE_INTROSPECTABLE) < 0) return; + DBUS_INTERFACE_INTROSPECTABLE) < 0) + goto init_error; if (PyModule_AddStringConstant(this_module, "PEER_IFACE", - DBUS_INTERFACE_PEER) < 0) return; + DBUS_INTERFACE_PEER) < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "PROPERTIES_IFACE", - DBUS_INTERFACE_PROPERTIES) < 0) return; + DBUS_INTERFACE_PROPERTIES) < 0) + goto init_error; if (PyModule_AddStringConstant(this_module, "DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER", - DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER) < 0) return; + DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER) < 0) + goto init_error; if (PyModule_AddStringConstant(this_module, "DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER", - DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER) < 0) return; + DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER) < 0) + goto init_error; if (PyModule_AddStringConstant(this_module, "DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE", - DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE) < 0) return; + DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE) < 0) + goto init_error; #define ADD_CONST_VAL(x, v) \ - if (PyModule_AddIntConstant(this_module, x, v) < 0) return; + if (PyModule_AddIntConstant(this_module, x, v) < 0) goto init_error; #define ADD_CONST_PREFIXED(x) ADD_CONST_VAL(#x, DBUS_##x) #define ADD_CONST(x) ADD_CONST_VAL(#x, x) @@ -382,19 +400,34 @@ ADD_CONST_PREFIXED(WATCH_ERROR) if (PyModule_AddStringConstant(this_module, "__docformat__", - "restructuredtext") < 0) return; + "restructuredtext") < 0) goto init_error; if (PyModule_AddStringConstant(this_module, "__version__", - PACKAGE_VERSION) < 0) return; + PACKAGE_VERSION) < 0) goto init_error; if (PyModule_AddIntConstant(this_module, "_python_version", - PY_VERSION_HEX) < 0) return; + PY_VERSION_HEX) < 0) goto init_error; +#ifdef PY3 + c_api = PyCapsule_New((void *)dbus_bindings_API, + PYDBUS_CAPSULE_NAME, NULL); +#else c_api = PyCObject_FromVoidPtr ((void *)dbus_bindings_API, NULL); +#endif if (!c_api) { - return; + goto init_error; } PyModule_AddObject(this_module, "_C_API", c_api); + +#ifdef PY3 + return this_module; + init_error: + Py_CLEAR(this_module); + return NULL; +#else + init_error: + return; +#endif } /* vim:set ft=c cino< sw=4 sts=4 et: */ diff -Nru dbus-python-0.84.0/_dbus_bindings/pending-call.c dbus-python-1.0.0/_dbus_bindings/pending-call.c --- dbus-python-0.84.0/_dbus_bindings/pending-call.c 2010-12-02 17:22:33.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/pending-call.c 2012-01-11 12:26:09.000000000 +0000 @@ -34,7 +34,7 @@ static inline int PendingCall_Check (PyObject *o) { - return (o->ob_type == &PendingCallType) + return (Py_TYPE(o) == &PendingCallType) || PyObject_IsInstance(o, (PyObject *)&PendingCallType); } @@ -233,8 +233,7 @@ }; static PyTypeObject PendingCallType = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.lowlevel.PendingCall", sizeof(PendingCall), 0, diff -Nru dbus-python-0.84.0/_dbus_bindings/server.c dbus-python-1.0.0/_dbus_bindings/server.c --- dbus-python-0.84.0/_dbus_bindings/server.c 2010-12-02 17:23:06.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/server.c 2012-01-24 15:55:44.000000000 +0000 @@ -85,7 +85,7 @@ DBusPyServer_set_auth_mechanisms(Server *self, PyObject *auth_mechanisms) { - PyObject *fast_seq; + PyObject *fast_seq = NULL, *references = NULL; Py_ssize_t length; Py_ssize_t i; @@ -101,16 +101,29 @@ { const char *list[length + 1]; + if (!(references = PyTuple_New(length))) + goto error; + for (i = 0; i < length; ++i) { - PyObject *am; + PyObject *am, *am_as_bytes; am = PySequence_Fast_GET_ITEM(auth_mechanisms, i); - /* this supports either str or unicode, raising TypeError - * on failure */ - list[i] = PyString_AsString(am); + if (!am) goto error; + if (PyUnicode_Check(am)) { + am_as_bytes = PyUnicode_AsUTF8String(am); + if (!am_as_bytes) + goto error; + } + else { + am_as_bytes = am; + Py_INCREF(am_as_bytes); + } + list[i] = PyBytes_AsString(am_as_bytes); if (!list[i]) - return FALSE; + goto error; + + PyTuple_SET_ITEM(references, i, am_as_bytes); } list[length] = NULL; @@ -120,7 +133,13 @@ Py_END_ALLOW_THREADS } + Py_CLEAR(fast_seq); + Py_CLEAR(references); return TRUE; + error: + Py_CLEAR(fast_seq); + Py_CLEAR(references); + return FALSE; } /* Return a new reference to a Python Server or subclass corresponding @@ -385,6 +404,7 @@ self = DBusPyServer_NewConsumingDBusServer(cls, server, conn_class, mainloop, auth_mechanisms); + ((Server *)self)->weaklist = NULL; TRACE(self); return self; @@ -429,7 +449,7 @@ DBG("Server at %p: freeing self", self); PyErr_Restore(et, ev, etb); - (self->ob_type->tp_free)((PyObject *)self); + (Py_TYPE(self)->tp_free)((PyObject *)self); } PyDoc_STRVAR(Server_disconnect__doc__, @@ -462,7 +482,7 @@ address = dbus_server_get_address(self->server); Py_END_ALLOW_THREADS - return PyString_FromString(address); + return NATIVESTR_FROMSTR(address); } PyDoc_STRVAR(Server_get_id__doc__, @@ -479,7 +499,7 @@ id = dbus_server_get_id(self->server); Py_END_ALLOW_THREADS - return PyString_FromString(id); + return NATIVESTR_FROMSTR(id); } PyDoc_STRVAR(Server_get_is_connected__doc__, @@ -511,8 +531,7 @@ }; PyTypeObject DBusPyServer_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_dbus_bindings._Server",/*tp_name*/ sizeof(Server), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -532,7 +551,11 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ +#ifdef PY3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +#else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_BASETYPE, +#endif Server_tp_doc, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ diff -Nru dbus-python-0.84.0/_dbus_bindings/signature.c dbus-python-1.0.0/_dbus_bindings/signature.c --- dbus-python-0.84.0/_dbus_bindings/signature.c 2010-12-02 17:21:22.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/signature.c 2012-01-24 15:55:44.000000000 +0000 @@ -55,14 +55,14 @@ typedef struct { PyObject_HEAD - PyObject *string; + PyObject *bytes; DBusSignatureIter iter; } SignatureIter; static void SignatureIter_tp_dealloc (SignatureIter *self) { - Py_CLEAR(self->string); + Py_CLEAR(self->bytes); PyObject_Del(self); } @@ -73,7 +73,7 @@ PyObject *obj; /* Stop immediately if finished or not correctly initialized */ - if (!self->string) return NULL; + if (!self->bytes) return NULL; sig = dbus_signature_iter_get_signature(&(self->iter)); if (!sig) return PyErr_NoMemory(); @@ -83,7 +83,7 @@ if (!dbus_signature_iter_next(&(self->iter))) { /* mark object as having been finished with */ - Py_CLEAR(self->string); + Py_CLEAR(self->bytes); } return obj; @@ -97,8 +97,7 @@ } static PyTypeObject SignatureIterType = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._SignatureIter", sizeof(SignatureIter), 0, @@ -141,19 +140,33 @@ }; static PyObject * -Signature_tp_iter (PyObject *self) +Signature_tp_iter(PyObject *self) { SignatureIter *iter = PyObject_New(SignatureIter, &SignatureIterType); + PyObject *self_as_bytes; + if (!iter) return NULL; - if (PyString_AS_STRING (self)[0]) { - Py_INCREF(self); - iter->string = self; - dbus_signature_iter_init(&(iter->iter), PyString_AS_STRING(self)); +#ifdef PY3 + self_as_bytes = PyUnicode_AsUTF8String(self); + if (!self_as_bytes) { + Py_CLEAR(iter); + return NULL; + } +#else + self_as_bytes = self; + Py_INCREF(self_as_bytes); +#endif + + if (PyBytes_GET_SIZE(self_as_bytes) > 0) { + iter->bytes = self_as_bytes; + dbus_signature_iter_init(&(iter->iter), + PyBytes_AS_STRING(self_as_bytes)); } else { /* this is a null string, make a null iterator */ - iter->string = NULL; + iter->bytes = NULL; + Py_CLEAR(self_as_bytes); } return (PyObject *)iter; } @@ -175,8 +188,7 @@ } PyTypeObject DBusPySignature_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.Signature", 0, 0, @@ -206,7 +218,7 @@ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPythonStringType), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyStrBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ diff -Nru dbus-python-0.84.0/_dbus_bindings/string.c dbus-python-1.0.0/_dbus_bindings/string.c --- dbus-python-0.84.0/_dbus_bindings/string.c 2010-12-02 17:21:29.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/string.c 2012-01-24 15:55:44.000000000 +0000 @@ -26,6 +26,7 @@ #include "types-internal.h" #include +#ifndef PY3 /* UTF-8 string representation ====================================== */ PyDoc_STRVAR(UTF8String_tp_doc, @@ -82,8 +83,7 @@ } PyTypeObject DBusPyUTF8String_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.UTF8String", 0, 0, @@ -122,6 +122,7 @@ 0, /* tp_alloc */ UTF8String_tp_new, /* tp_new */ }; +#endif /* !PY3 */ /* Object path ====================================================== */ @@ -161,8 +162,7 @@ } PyTypeObject DBusPyObjectPath_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.ObjectPath", 0, 0, @@ -275,14 +275,14 @@ return NULL; } if (((DBusPyString *)self)->variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", - self->ob_type->tp_name, - PyString_AS_STRING(parent_repr), - ((DBusPyString *)self)->variant_level); + my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", + Py_TYPE(self)->tp_name, + REPRV(parent_repr), + ((DBusPyString *)self)->variant_level); } else { - my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, - PyString_AS_STRING(parent_repr)); + my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, + REPRV(parent_repr)); } /* whether my_repr is NULL or not: */ Py_CLEAR(parent_repr); @@ -290,8 +290,7 @@ } PyTypeObject DBusPyString_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "dbus.String", sizeof(DBusPyString), 0, @@ -346,18 +345,16 @@ if (PyType_Ready(&DBusPyString_Type) < 0) return 0; DBusPyString_Type.tp_print = NULL; +#ifndef PY3 DBusPyUTF8String_Type.tp_base = &DBusPyStrBase_Type; if (PyType_Ready(&DBusPyUTF8String_Type) < 0) return 0; DBusPyUTF8String_Type.tp_print = NULL; +#endif DBusPyObjectPath_Type.tp_base = &DBusPyStrBase_Type; if (PyType_Ready(&DBusPyObjectPath_Type) < 0) return 0; DBusPyObjectPath_Type.tp_print = NULL; - DBusPyBoolean_Type.tp_base = &DBusPyIntBase_Type; - if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; - DBusPyBoolean_Type.tp_print = NULL; - return 1; } @@ -366,15 +363,18 @@ { /* PyModule_AddObject steals a ref */ Py_INCREF(&DBusPyObjectPath_Type); - Py_INCREF(&DBusPyUTF8String_Type); Py_INCREF(&DBusPyString_Type); if (PyModule_AddObject(this_module, "ObjectPath", (PyObject *)&DBusPyObjectPath_Type) < 0) return 0; - if (PyModule_AddObject(this_module, "UTF8String", - (PyObject *)&DBusPyUTF8String_Type) < 0) return 0; if (PyModule_AddObject(this_module, "String", (PyObject *)&DBusPyString_Type) < 0) return 0; +#ifndef PY3 + Py_INCREF(&DBusPyUTF8String_Type); + if (PyModule_AddObject(this_module, "UTF8String", + (PyObject *)&DBusPyUTF8String_Type) < 0) return 0; +#endif + return 1; } diff -Nru dbus-python-0.84.0/_dbus_bindings/types-internal.h dbus-python-1.0.0/_dbus_bindings/types-internal.h --- dbus-python-0.84.0/_dbus_bindings/types-internal.h 2011-05-18 10:10:41.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/types-internal.h 2012-01-24 15:55:44.000000000 +0000 @@ -26,11 +26,23 @@ #include #include +/* In Python2 >= 2.6 this aliases PyString to PyBytes. There is no PyString + * in Python 3, so this allows the C extension to be compilable in both Python + * versions. + */ +#include + +/* In Python 2.x, we need this to define the type of PyLongObject */ +#ifndef PY3 +#include +#endif + #include "dbus_bindings-internal.h" #ifndef DBUS_BINDINGS_TYPES_INTERNAL_H #define DBUS_BINDINGS_TYPES_INTERNAL_H +#ifndef PY3 extern PyTypeObject DBusPyIntBase_Type; DEFINE_CHECK(DBusPyIntBase) @@ -38,6 +50,7 @@ PyIntObject base; long variant_level; } DBusPyIntBase; +#endif extern PyTypeObject DBusPyLongBase_Type; DEFINE_CHECK(DBusPyLongBase) @@ -58,6 +71,11 @@ extern PyTypeObject DBusPyStrBase_Type; DEFINE_CHECK(DBusPyStrBase) +#ifdef PY3 +extern PyTypeObject DBusPyBytesBase_Type; +DEFINE_CHECK(DBusPyBytesBase) +#endif + dbus_int16_t dbus_py_int16_range_check(PyObject *); dbus_uint16_t dbus_py_uint16_range_check(PyObject *); dbus_int32_t dbus_py_int32_range_check(PyObject *); diff -Nru dbus-python-0.84.0/_dbus_bindings/unixfd.c dbus-python-1.0.0/_dbus_bindings/unixfd.c --- dbus-python-0.84.0/_dbus_bindings/unixfd.c 2011-05-24 15:39:14.000000000 +0000 +++ dbus-python-1.0.0/_dbus_bindings/unixfd.c 2012-01-24 15:55:44.000000000 +0000 @@ -55,49 +55,83 @@ int fd; } UnixFdObject; +/* Return values: + * -2 - the long value overflows an int + * -1 - Python failed producing a long (or in Python 2 an int) + * 0 - success + * 1 - arg is not a long (or in Python 2 an int) + * + * Or to summarize: + * status < 0 - an error occurred, and a Python exception is set. + * status == 0 - all is okay, output argument *fd is set. + * status > 0 - try something else + */ +static int +make_fd(PyObject *arg, int *fd) +{ + long fd_arg; + + if (INTORLONG_CHECK(arg)) + { + /* on Python 2 this accepts either int or long */ + fd_arg = PyLong_AsLong(arg); + if (fd_arg == -1 && PyErr_Occurred()) { + return -1; + } + } + else { + return 1; + } + /* Check for int overflow. */ + if (fd_arg < INT_MIN || fd_arg > INT_MAX) { + PyErr_Format(PyExc_ValueError, "int is outside fd range"); + return -2; + } + *fd = (int)fd_arg; + return 0; +} + static PyObject * UnixFd_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs UNUSED) { UnixFdObject *self = NULL; PyObject *arg; - PyObject *fdnumber; - int fd_original, fd; + int status, fd, fd_original = -1; - if (! PyArg_ParseTuple(args, "O", &arg, NULL)) { + if (!PyArg_ParseTuple(args, "O", &arg, NULL)) { return NULL; } - if (PyInt_Check(arg)) { - fd_original = PyInt_AsLong(arg); - fd = dup(fd_original); - if (fd < 0) { - PyErr_Format(PyExc_ValueError, "Invalid file descriptor"); - return NULL; - } + status = make_fd(arg, &fd_original); + if (status < 0) + return NULL; - } else if (PyObject_HasAttrString(arg, "fileno")) { - fdnumber = PyObject_CallMethod(arg, "fileno", NULL); - if (! fdnumber) { - PyErr_Format(PyExc_ValueError, "Argument's fileno() method " - "is not callable"); - return NULL; - } - if (! PyInt_Check(fdnumber)) { - PyErr_Format(PyExc_ValueError, "Argument's fileno() method " - "returned a non-int value"); - return NULL; + if (status > 0) { + if (PyObject_HasAttrString(arg, "fileno")) { + PyObject *fd_number = PyObject_CallMethod(arg, "fileno", NULL); + if (!fd_number) + return NULL; + status = make_fd(fd_number, &fd_original); + Py_CLEAR(fd_number); + if (status < 0) + return NULL; + if (status > 0) { + PyErr_Format(PyExc_ValueError, "Argument's fileno() method " + "returned a non-int value"); + return NULL; + } + /* fd_original is all good. */ } - fd_original = PyInt_AsLong(fdnumber); - Py_DECREF(fdnumber); - fd = dup(fd_original); - if (fd < 0) { - PyErr_Format(PyExc_ValueError, "Invalid file descriptor from fileno()"); + else { + PyErr_Format(PyExc_ValueError, "Argument is not int and does not " + "implement fileno() method"); return NULL; } - - } else { - PyErr_Format(PyExc_ValueError, "Argument is not int and does not " - "implement fileno() method"); + } + assert(fd_original >= 0); + fd = dup(fd_original); + if (fd < 0) { + PyErr_Format(PyExc_ValueError, "Invalid file descriptor"); return NULL; } @@ -106,8 +140,7 @@ return NULL; self->fd = fd; - - return (PyObject *) self; + return (PyObject *)self; } static void @@ -159,8 +192,7 @@ }; PyTypeObject DBusPyUnixFd_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "dbus.UnixFd", sizeof(UnixFdObject), 0, diff -Nru dbus-python-0.84.0/dbus_bindings.py dbus-python-1.0.0/dbus_bindings.py --- dbus-python-0.84.0/dbus_bindings.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/dbus_bindings.py 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -from dbus.dbus_bindings import * diff -Nru dbus-python-0.84.0/_dbus_glib_bindings/Makefile.am dbus-python-1.0.0/_dbus_glib_bindings/Makefile.am --- dbus-python-0.84.0/_dbus_glib_bindings/Makefile.am 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/_dbus_glib_bindings/Makefile.am 2012-01-24 15:55:44.000000000 +0000 @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include $(DBUS_CFLAGS) $(DBUS_GLIB_CFLAGS) \ $(PYTHON_INCLUDES) AM_LDFLAGS = -module -avoid-version \ - -export-symbols-regex init_dbus_glib_bindings \ + -export-symbols-regex \(PyInit__\|init_\)dbus_glib_bindings \ $(DBUS_LIBS) $(DBUS_GLIB_LIBS) _dbus_glib_bindings_la_SOURCES = module.c diff -Nru dbus-python-0.84.0/_dbus_glib_bindings/Makefile.in dbus-python-1.0.0/_dbus_glib_bindings/Makefile.in --- dbus-python-0.84.0/_dbus_glib_bindings/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/_dbus_glib_bindings/Makefile.in 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -73,6 +73,12 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(pyexecdir)" LTLIBRARIES = $(pyexec_LTLIBRARIES) _dbus_glib_bindings_la_LIBADD = @@ -256,7 +262,7 @@ $(PYTHON_INCLUDES) AM_LDFLAGS = -module -avoid-version \ - -export-symbols-regex init_dbus_glib_bindings \ + -export-symbols-regex \(PyInit__\|init_\)dbus_glib_bindings \ $(DBUS_LIBS) $(DBUS_GLIB_LIBS) _dbus_glib_bindings_la_SOURCES = module.c @@ -339,26 +345,23 @@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -465,10 +468,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru dbus-python-0.84.0/_dbus_glib_bindings/module.c dbus-python-1.0.0/_dbus_glib_bindings/module.c --- dbus-python-0.84.0/_dbus_glib_bindings/module.c 2010-12-02 16:17:49.000000000 +0000 +++ dbus-python-1.0.0/_dbus_glib_bindings/module.c 2012-01-24 15:55:44.000000000 +0000 @@ -28,7 +28,11 @@ #include #include +#ifdef PY3 +PyMODINIT_FUNC PyInit__dbus_glib_bindings(void); +#else PyMODINIT_FUNC init_dbus_glib_bindings(void); +#endif #if defined(__GNUC__) # if __GNUC__ >= 3 @@ -170,6 +174,33 @@ {NULL, NULL, 0, NULL} }; +#ifdef PY3 +PyMODINIT_FUNC +PyInit__dbus_glib_bindings(void) +{ + PyObject *this_module; + + static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "_dbus_glib_bindings", /* m_name */ + module_doc, /* m_doc */ + -1, /* m_size */ + module_functions, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ + }; + + if (import_dbus_bindings("_dbus_glib_bindings") < 0) + return NULL; + + if (!(this_module = PyModule_Create(&moduledef))) { + return NULL; + } + return this_module; +} +#else PyMODINIT_FUNC init_dbus_glib_bindings(void) { @@ -180,5 +211,6 @@ module_doc); if (!this_module) return; } +#endif /* vim:set ft=c cino< sw=4 sts=4 et: */ diff -Nru dbus-python-0.84.0/debian/changelog dbus-python-1.0.0/debian/changelog --- dbus-python-0.84.0/debian/changelog 2012-01-17 15:40:20.000000000 +0000 +++ dbus-python-1.0.0/debian/changelog 2012-01-24 20:52:48.000000000 +0000 @@ -1,35 +1,25 @@ -dbus-python (0.84.0-2ubuntu3) precise; urgency=low +dbus-python (1.0.0-1) UNRELEASED; urgency=low - * Drop the python-gi and python-gobject/python-gtk Recommends to - Suggests to avoid pulling these packages in on KDE. After analysis of - archive by Scott Kitterman and myself, this is a safe change as - nothing we can determine uses dbus/gobject_service.py (the only - non-build time reference). + * New upstream version 1.0.0 + - increase Python requirement to 2.6 + - build for Python 3 too + - split python-dbus-dev into a separate package to be shared between + versions + - make python-dbus depend on python-dbus-dev for now, to preserve + historical functionality (but packages which use it, like PyQt, should + switch to depending on it explicitly) + + -- Simon McVittie Tue, 24 Jan 2012 19:07:26 +0000 + +dbus-python (0.84.0-3) unstable; urgency=low + + * Drop obsolete recommendation of python-gtk, which hasn't provided the + GLib main loop since before squeeze. Allow python-gi (also GLib main loop) + or python-qt4-dbus (Qt main loop) to satisfy the dependency instead + (Closes: #656230) + * Move to debhelper 9 compat and use dh - -- Barry Warsaw Tue, 17 Jan 2012 10:36:46 -0500 - -dbus-python (0.84.0-2ubuntu2) precise; urgency=low - - * Fix various lintian warnings on the resulting .debs. - - -- Barry Warsaw Mon, 16 Jan 2012 15:46:48 -0500 - -dbus-python (0.84.0-2ubuntu1) precise; urgency=low - - * debian/patches: - - since-0.84.0.patch: Upstream unreleased changes from git tag - dbus-python-0.84.0 to HEAD. This is a precursor to the following. - - python3-support.patch: Upstream unreleased changes from git - `python3` branch for supporting Python 3. (LP: #893091) - * debian/rules: Enable the test suite. - - -- Barry Warsaw Thu, 12 Jan 2012 14:47:33 +0100 - -dbus-python (0.84.0-2build1) precise; urgency=low - - * Rebuild to drop python2.6 dependencies. - - -- Matthias Klose Sat, 31 Dec 2011 02:02:09 +0000 + -- Simon McVittie Tue, 24 Jan 2012 20:38:03 +0000 dbus-python (0.84.0-2) unstable; urgency=low diff -Nru dbus-python-0.84.0/debian/compat dbus-python-1.0.0/debian/compat --- dbus-python-0.84.0/debian/compat 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/compat 2012-01-24 20:52:48.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru dbus-python-0.84.0/debian/control dbus-python-1.0.0/debian/control --- dbus-python-0.84.0/debian/control 2012-01-17 15:37:45.000000000 +0000 +++ dbus-python-1.0.0/debian/control 2012-01-24 20:52:48.000000000 +0000 @@ -1,33 +1,27 @@ Source: dbus-python Section: devel Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Utopia Maintenance Team +Maintainer: Utopia Maintenance Team Uploaders: Sjoerd Simons , Sebastian Dröge , Simon McVittie , Loic Minier -Build-Depends: debhelper (>= 8), - xmlto, +Build-Depends: autoconf, + automake, + debhelper (>= 9), + dh-autoreconf, python-all-dbg (>= 2.6.6-3~), python-all-dev (>= 2.6.6-3~), python3-all-dbg, python3-all-dev, - python-gobject, - python-gobject-dbg, - python3-gobject, - python3-gobject-dbg, libdbus-1-dev (>= 1.4), libdbus-glib-1-dev (>= 0.71), - dh-autoreconf, - autotools-dev, - dbus-x11 + xmlto Build-Depends-Indep: python-docutils, python-epydoc (>= 3.0~beta1) Standards-Version: 3.9.2 X-Python-Version: >= 2.6 X-Python3-Version: >= 3.2 -XS-Dm-Upload-Allowed: yes Homepage: http://www.freedesktop.org/wiki/Software/DBusBindings#Python Vcs-Git: git://anonscm.debian.org/git/pkg-utopia/dbus-python.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-utopia/dbus-python.git @@ -35,12 +29,14 @@ Package: python-dbus Section: python Architecture: any -Depends: python-dbus-common, +# Depends on python-dbus-dev for backwards compatibility, until packages +# are fixed to depend on that directly +Depends: ${misc:Depends}, + ${python:Depends}, ${shlibs:Depends}, - ${misc:Depends}, - ${python:Depends} -Suggests: python-dbus-doc, python-dbus-dbg, - python-gobject | python-gtk (<< 2.10) + python-dbus-dev +Recommends: python-gi | python-gobject-2 | python-qt4-dbus +Suggests: python-dbus-doc, python-dbus-dbg Replaces: python2.4-dbus Conflicts: python2.4-dbus Breaks: gnome-osd (<< 0.12.0), @@ -56,63 +52,76 @@ . See the dbus description for more information about D-Bus in general. -Package: python-dbus-common -Section: python -Priority: extra -Architecture: any -Depends: ${shlibs:Depends}, - ${misc:Depends}, - ${python:Depends} -Breaks: python-dbus (<< 0.84.0-2ubuntu1) -Replaces: python-dbus (<< 0.84.0-2ubuntu1) -Description: Common files for dbus-python. - This contains the files which are common between the Python 2 and Python 3 - versions of the package. - -Package: python-dbus-dbg -Section: debug -Priority: extra -Architecture: any -Depends: python-dbus (= ${binary:Version}), python-dbg, ${shlibs:Depends}, ${misc:Depends} -Description: Debug build of the D-Bus Python interface - This package provides a version of the python-dbus package built for - debugging versions of Python. - -Package: python-dbus-doc -Section: doc -Architecture: all -Depends: ${misc:Depends} -Suggests: python-dbus -Description: Documentation for the D-Bus Python interface - This package provides text and HTML documentation, and examples, for the - python-dbus package. - Package: python3-dbus Section: python Architecture: any -Depends: python-dbus-common, - ${misc:Depends}, - ${python:Depends}, +# Does not have Depends: python-dbus-dev because as a new package, it cannot +# have backwards compatibility concerns +Depends: ${misc:Depends}, + ${python3:Depends}, ${shlibs:Depends} -Suggests: python-dbus-dbg, python-dbus-doc, python-gi -Provides: ${python:Provides} -Description: simple interprocess messaging system (Python interface) +Recommends: python3-gi | python3-qt4-dbus +Suggests: python-dbus-doc, python3-dbus-dbg +Provides: ${python3:Provides} +Description: simple interprocess messaging system (Python 3 interface) D-Bus is a message bus, used for sending messages between applications. Conceptually, it fits somewhere in between raw sockets and CORBA in terms of complexity. . - This package provides a Python interface to D-Bus. + This package provides a Python 3 interface to D-Bus. . See the dbus description for more information about D-Bus in general. +Package: python-dbus-dev +Section: python +Priority: optional +Architecture: all +Depends: ${misc:Depends} +Breaks: python-dbus (<< 1.0), + python-dbus-common (<< 1.0) +Replaces: python-dbus (<< 1.0), + python-dbus-common (<< 1.0) +Description: main loop integration development files for python-dbus + D-Bus is a message bus, used for sending messages between applications. + Conceptually, it fits somewhere in between raw sockets and CORBA in + terms of complexity. + . + This package provides development files required to compile main-loop + integration modules for python-dbus, such as dbus.mainloop.qt provided + by PyQt. It is Python-version-independent: you must also depend on either + python-dbus or python3-dbus, if required. + +Package: python-dbus-dbg +Section: debug +Priority: extra +Architecture: any +Depends: python-dbg, + python-dbus (= ${binary:Version}), + ${shlibs:Depends}, + ${misc:Depends}, + ${python:Depends} +Description: debug build of the D-Bus Python 2 interface + This package provides a version of the python-dbus package built for + debugging versions of Python 2, and debug symbols for python-dbus. + Package: python3-dbus-dbg Section: debug Priority: extra Architecture: any Depends: python3-dbg, python3-dbus (= ${binary:Version}), + ${shlibs:Depends}, ${misc:Depends}, - ${shlibs:Depends} -Description: Debug build of the D-Bus Python interface - This package provides a version of the python-dbus package built for - debugging versions of Python. + ${python:Depends} +Description: debug build of the D-Bus Python 3 interface + This package provides a version of the python3-dbus package built for + debugging versions of Python 3, and debug symbols for python3-dbus. + +Package: python-dbus-doc +Section: doc +Architecture: all +Depends: ${misc:Depends} +Suggests: python-dbus | python3-dbus +Description: Documentation for the D-Bus Python interface + This package provides text and HTML documentation, and examples, for the + python-dbus and python3-dbus packages. diff -Nru dbus-python-0.84.0/debian/patches/python3-support.patch dbus-python-1.0.0/debian/patches/python3-support.patch --- dbus-python-0.84.0/debian/patches/python3-support.patch 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/patches/python3-support.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,6101 +0,0 @@ -Description: Upstream patch applied to git python branch, as yet unmerged. - This enables Python 3 support. -Author: Barry Warsaw -Bug-Ubuntu: https://bugs.launchpad.net/bugs/893091 -Bug: https://bugs.freedesktop.org/show_bug.cgi?id=26420 -Forwarded: not-needed - ---- a/NEWS -+++ b/NEWS -@@ -5,13 +5,26 @@ - - * libdbus 1.4 or later is now required. - --* Python 2.6 or later is now required. -+* Python 2.6 or later is now required. If Python 3 is used, it must be -+ version 3.2 or later. - - API changes: - - * dbus_bindings, which was never meant to be public API and has been - deprecated for nearly 5 years, has finally been removed. - -+* The repr() of every dbus-python object is now unicode. -+ -+* The Python 3 API is not the same as the Python 2 API; see PY3PORT.rst -+ for details. -+ -+Enhancements: -+ -+* Python 3 compatibility (fd.o #26420, Barry Warsaw) -+ -+* MethodCallMessage and SignalMessage now have a more useful repr() -+ (Barry Warsaw) -+ - Fixes: - - * OOM while appending a unicode object to a message no longer leaks a string -@@ -21,8 +34,6 @@ - - * Fix rst2html failure in non-UTF-8 locales (Alexandre Rostovtsev) - --* Start to port to Python 3 compatibility (Barry Warsaw) -- - D-Bus Python Bindings 0.84.0 (2011-05-25) - ========================================= - ---- /dev/null -+++ b/PY3PORT.rst -@@ -0,0 +1,224 @@ -+=============================== -+Porting python-dbus to Python 3 -+=============================== -+ -+This is an experimental port to Python 3.x where x >= 2. There are lots of -+great sources for porting C extensions to Python 3, including: -+ -+ * http://python3porting.com/toc.html -+ * http://docs.python.org/howto/cporting.html -+ * http://docs.python.org/py3k/c-api/index.html -+ -+I also consulted an early take on this port by John Palmieri and David Malcolm -+in the context of Fedora: -+ -+ * https://bugs.freedesktop.org/show_bug.cgi?id=26420 -+ -+although I have made some different choices. The patches in that tracker -+issue also don't cover porting the Python bits (e.g. the test suite), nor the -+pygtk -> pygi porting, both which I've also attempted to do in this branch. -+ -+This document outlines my notes and strategies for doing this port. Please -+feel free to contact me with any bugs, issues, disagreements, suggestions, -+kudos, and curses. -+ -+Barry Warsaw -+barry@python.org -+2011-11-11 -+ -+ -+User visible changes -+==================== -+ -+You've got some dbus-python code that works great in Python 2. This branch -+should generally allow your existing Python 2 code to continue to work -+unchanged. There are a few changes you'll notice in Python 2 though: -+ -+ - The minimum supported Python 2 version is 2.6. -+ - All object reprs are unicodes. This change was made because it greatly -+ simplifies the implementation and cross-compatibility with Python 3. -+ - Some exception strings have changed. -+ - `MethodCallMessage` and `SignalMessage` objects have better reprs now. -+ -+What do you need to do to port that to Python 3? Here are the user visible -+changes you should be aware of, relative to Python 2. Python 3.2 is the -+minimal required version: -+ -+ - `ByteArray` objects must be initialized with bytes objects, not unicodes. -+ Use `b''` literals in the constructor. This also works in Python 2, where -+ bytes objects are aliases for 8-bit strings. -+ - `Byte` objects must be initialized with either a length-1 bytes object -+ (again, use `b''` literals to be compatible with either Python 2 or 3) -+ or an integer. -+ - byte signatures (i.e. `y` type codes) must be passed either a length-1 -+ bytes object or an integer. unicodes (str in Python 3) are not allowed. -+ - `ByteArray` is now a subclass of `bytes`, where in Python 2 it is a -+ subclass of `str`. -+ - `dbus.UTF8String` is gone, use `dbus.String`. Also `utf8_string` arguments -+ are no longer allowed. -+ - All longs are now ints, since Python 3 has only a single int type. This -+ also means that the class hierarchy for the dbus numeric types has changed -+ (all derive from int in Python 3). -+ -+ -+Bytes vs. Strings -+================= -+ -+All strings in dbus are defined as UTF-8: -+ -+http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures -+ -+However, the dbus C API accepts `char*` which must be UTF-8 strings NUL -+terminated and no other NUL bytes. -+ -+This page describes the mapping between Python types and dbus types: -+ -+ http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#basic-types -+ -+Notice that it maps dbus `string` (`'s'`) to `dbus.String` (unicode) or -+`dbus.UTF8String` (str). Also notice that there is no direct dbus equivalent -+of Python's bytes type (although dbus does have byte arrays), so I am mapping -+dbus strings to unicodes in all cases, and getting rid of `dbus.UTF8String` in -+Python 3. I've also added a `dbus._BytesBase` type which is unused in Python -+2, but which forms the base class for `dbus.ByteArray` in Python 3. This is -+an implementation detail and not part of the public API. -+ -+In Python 3, object paths (`'o'` or `dbus.ObjectPath`), signatures (`'g'` or -+`dbus.Signature`), bus names, interfaces, and methods are all strings. A -+previous aborted effort was made to use bytes for these, which at first blush -+may makes some sense, but on deeper consideration does not. This approach -+also tended to impose too many changes on user code, and caused lots of -+difficult to track down problems. -+ -+In Python 3, all such objects are subclasses of `str` (i.e. `unicode`). -+ -+(As an example, dbus-python's callback dispatching pretty much assumes all -+these things are strings. When they are bytes, the fact that `'foo' != b'foo'` -+causes dispatch matching to fail in difficult to debug ways. Even bus names -+are not immune, since they do things like `bus_name[:1] == ':'` which fails in -+multiple ways when `bus_name` is a bytes. For sanity purposes, these are all -+unicode strings now, and we just eat the complexity at the C level.) -+ -+I am using `#include `, which exposes the PyBytes API to Python -+2.6 and 2.7, and I have converted all internal PyString calls to PyBytes -+calls. Where this is inappropriate, we'll use PyUnicode calls explicitly. -+E.g. all repr() implementations now return unicodes. Most of these changes -+shouldn't be noticed, even in existing Python 2 code. -+ -+Generally, I've left the descriptions and docstrings saying "str" instead of -+"unicode" since there's no distinction in Python 3. -+ -+APIs which previously returned PyStrings will usually return PyUnicodes, not -+PyBytes. -+ -+ -+Ints vs. Longs -+============== -+ -+Python 3 only has PyLong types; PyInts are gone. For that reason, I've -+switched all PyInt calls to use PyLong in both Python 2 and Python 3. Python -+3.0 had a nice `` header that aliased PyInt to PyLong, but that's -+gone as of Python 3.1, and the minimal required Python 3 version is 3.2. -+ -+In the above page mapping basic types, you'll notice that the Python int type -+is mapped to 32-bit signed integers ('i') and the Python long type is mapped -+to 64-bit signed integers ('x'). Python 3 doesn't have this distinction, so -+ints map to 'i' even though ints can be larger in Python 3. Use the -+dbus-specific integer types if you must have more exact mappings. -+ -+APIs which accepted ints in Python 2 will still do so, but they'll also now -+accept longs. These APIs obviously only accept longs in Python 3. -+ -+Long literals in Python code are an interesting thing to have to port. Don't -+use them if you want your code to work in both Python versions. -+ -+`dbus._IntBase` is removed in Python 3, you only have `dbus._LongBase`, which -+inherits from a Python 3 int (i.e. a PyLong). Again, this is an -+implementation detail that users should never care about. -+ -+ -+Macros -+====== -+ -+In types-internal.h, I define `PY3K` when `PY_MAJOR_VERSION` >= 3, so you'll -+see ifdefs on the former symbol within the C code. -+ -+Python 3 really could use a PY_REFCNT() wrapper for ob_refcnt access. -+ -+ -+PyCapsule vs. PyCObject -+======================= -+ -+`_dbus_bindings._C_API` is an attribute exposed to Python in the module. In -+Python 2, this is a PyCObject, but these do not exist in Python >= 3.2, so it -+is replaced with a PyCapsules for Python 3. However, since PyCapsules were -+only introduced in Python 2.7, and I want to support Python 2.6, PyCObjects -+are still used when this module is compiled for Python 2. -+ -+ -+Python level compatibility -+========================== -+ -+`from dbus import _is_py3` gives you a flag to check if you must do something -+different in Python 3. In general I use this flag to support both versions in -+one set of sources, which seems better than trying to use 2to3. It's not part -+of the dbus-python public API, so you must not use it in third-party projects. -+ -+ -+Miscellaneous -+============= -+ -+The PyDoc_STRVAR() documentation is probably out of date. Once the API -+choices have been green-lighted upstream, I'll make a pass through the code to -+update them. It might be tricky based on any differences between Python 2 and -+Python 3. -+ -+There were a few places where I noticed what might be considered bugs, -+unchecked exception conditions, or possible reference count leaks. In these -+cases, I've just fixed what I can and hopefully haven't made the situation -+worse. -+ -+`dbus_py_variant_level_get()` did not check possible error conditions, nor did -+their callers. When `dbus_py_variant_level_get()` encounters an error, it now -+returns -1, and callers check this. -+ -+As much as possible, I've refrained from general code cleanups (e.g. 80 -+columns), unless it just bugged me too much or I touched the code for reasons -+related to the port. I've also tried to stick to existing C code style, -+e.g. through the use of pervasive `Py_CLEAR()` calls, comparison against NULL -+usually with `!foo`, and such. As Bart Simpson might write on his classroom -+blackboard:: -+ -+ This is not a rewrite -+ This is not a rewrite -+ This is not a rewrite -+ This is not a rewrite -+ ... -+ -+and so on. Well, mostly ;). -+ -+I think I fixed a reference leak in `DBusPyServer_set_auth_mechanisms()`. -+`PySequence_Fast()` returns a new reference, which wasn't getting decref'd in -+any return path. -+ -+ - Instantiation of metaclasses uses different, incompatible syntax in Python -+ 2 and 3. You have to use direct calling of the metaclass to work across -+ versions, i.e. `Interface = InterfaceType('Interface', (object,), {})` -+ - `iteritems()` and friends are gone. I dropped the "iter" prefixes. -+ - `xrange() is gone. I changed them to use `range()`. -+ - `isSequenceType()` is gone in Python 3, so I use a different idiom there. -+ - `__next__()` vs. `next()` -+ - `PyUnicode_FromFormat()` `%V` flag is a clever hack! -+ - `sys.version_info` is a tuple in Python 2.6, not a namedtuple. i.e. there -+ is no `sys.version_info.major` -+ - `PyArg_Parse()`: No 'y' code in Python 2; in Python 3, no equivalent of 'z' -+ for bytes objects. -+ -+ -+Open issues -+=========== -+ -+Here are a few things that still need to be done, or for which there may be -+open questions:: -+ -+ - Update all C extension docstrings for accuracy. ---- a/_dbus_bindings/Makefile.am -+++ b/_dbus_bindings/Makefile.am -@@ -1,7 +1,8 @@ - pyexec_LTLIBRARIES = _dbus_bindings.la - - AM_CPPFLAGS = -I$(top_srcdir)/include $(DBUS_CFLAGS) $(PYTHON_INCLUDES) --AM_LDFLAGS = -module -avoid-version -export-symbols-regex init_dbus_bindings \ -+AM_LDFLAGS = -module -avoid-version \ -+ -export-symbols-regex \(PyInit__\|init_\)dbus_bindings \ - $(DBUS_LIBS) - _dbus_bindings_la_SOURCES = \ - abstract.c \ ---- a/_dbus_bindings/abstract.c -+++ b/_dbus_bindings/abstract.c -@@ -44,17 +44,33 @@ - { - PyObject *vl_obj; - PyObject *key = PyLong_FromVoidPtr(obj); -+ long variant_level; - - if (!key) { -- return 0; -+ return -1; - } - - vl_obj = PyDict_GetItem(_dbus_py_variant_levels, key); - Py_CLEAR(key); - -- if (!vl_obj) -+ if (!vl_obj) { -+ /* PyDict_GetItem() does not set an exception when the key is missing. -+ * In our case, it just means that there was no entry in the variant -+ * dictionary for this object. Semantically, this is equivalent to a -+ * variant level of 0. -+ */ - return 0; -- return PyInt_AsLong(vl_obj); -+ } -+ variant_level = NATIVEINT_ASLONG(vl_obj); -+ if (variant_level == -1 && PyErr_Occurred()) { -+ /* variant_level < 0 can never be inserted into the dictionary; see -+ * dbus_py_variant_level_set() below. The semantics of setting -+ * variant_level < 0 is to delete it from the dictionary. -+ */ -+ return -1; -+ } -+ assert(variant_level >= 0); -+ return variant_level; - } - - dbus_bool_t -@@ -76,12 +92,12 @@ - } - } - else { -- PyObject *vl_obj = PyInt_FromLong(variant_level); -+ PyObject *vl_obj = NATIVEINT_FROMLONG(variant_level); - if (!vl_obj) { - Py_CLEAR(key); - return FALSE; - } -- if (PyDict_SetItem (_dbus_py_variant_levels, key, vl_obj) < 0) { -+ if (PyDict_SetItem(_dbus_py_variant_levels, key, vl_obj) < 0) { - Py_CLEAR(key); - return FALSE; - } -@@ -95,7 +111,11 @@ - { - PyObject *key, *value; - -- if (PyString_Check(name)) { -+#ifdef PY3 -+ if (PyUnicode_CompareWithASCIIString(name, "variant_level")) -+ return PyObject_GenericGetAttr(obj, name); -+#else -+ if (PyBytes_Check(name)) { - Py_INCREF(name); - } - else if (PyUnicode_Check(name)) { -@@ -109,13 +129,14 @@ - return NULL; - } - -- if (strcmp(PyString_AS_STRING(name), "variant_level")) { -+ if (strcmp(PyBytes_AS_STRING(name), "variant_level")) { - value = PyObject_GenericGetAttr(obj, name); - Py_CLEAR(name); - return value; - } - - Py_CLEAR(name); -+#endif /* PY3 */ - - key = PyLong_FromVoidPtr(obj); - -@@ -127,7 +148,7 @@ - Py_CLEAR(key); - - if (!value) -- return PyInt_FromLong(0); -+ return NATIVEINT_FROMLONG(0); - Py_INCREF(value); - return value; - } -@@ -148,6 +169,7 @@ - PyErr_Restore(et, ev, etb); - } - -+#ifndef PY3 - /* Support code for int subclasses. ================================== */ - - PyDoc_STRVAR(DBusPythonInt_tp_doc,\ -@@ -200,14 +222,14 @@ - - if (!parent_repr) return NULL; - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); - } - /* whether my_repr is NULL or not: */ - Py_CLEAR(parent_repr); -@@ -215,8 +237,7 @@ - } - - PyTypeObject DBusPyIntBase_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "_dbus_bindings._IntBase", - sizeof(DBusPyIntBase), - 0, -@@ -256,6 +277,7 @@ - DBusPythonInt_tp_new, /* tp_new */ - PyObject_Del, /* tp_free */ - }; -+#endif /* !PY3 */ - - /* Support code for float subclasses. ================================ */ - -@@ -312,14 +334,14 @@ - - if (!parent_repr) return NULL; - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); - } - /* whether my_repr is NULL or not: */ - Py_CLEAR(parent_repr); -@@ -327,8 +349,7 @@ - } - - PyTypeObject DBusPyFloatBase_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "_dbus_bindings._FloatBase", - sizeof(DBusPyFloatBase), - 0, -@@ -368,6 +389,131 @@ - DBusPythonFloat_tp_new, /* tp_new */ - }; - -+#ifdef PY3 -+/* Support code for bytes subclasses ================================== */ -+ -+PyDoc_STRVAR(DBusPythonBytes_tp_doc,\ -+"Base class for bytes subclasses with a ``variant_level`` attribute.\n" -+"Do not rely on the existence of this class outside dbus-python.\n" -+); -+ -+static PyObject * -+DBusPythonBytes_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) -+{ -+ PyObject *self; -+ long variantness = 0; -+ static char *argnames[] = {"variant_level", NULL}; -+ -+ if (PyTuple_Size(args) > 1) { -+ PyErr_SetString(PyExc_TypeError, -+ "__new__ takes at most one positional parameter"); -+ return NULL; -+ } -+ if (!PyArg_ParseTupleAndKeywords(dbus_py_empty_tuple, kwargs, -+ "|l:__new__", argnames, -+ &variantness)) -+ return NULL; -+ -+ if (variantness < 0) { -+ PyErr_SetString(PyExc_ValueError, -+ "variant_level must be non-negative"); -+ return NULL; -+ } -+ -+ self = (PyBytes_Type.tp_new)(cls, args, NULL); -+ if (self) { -+ if (!dbus_py_variant_level_set(self, variantness)) { -+ Py_CLEAR(self); -+ return NULL; -+ } -+ } -+ return self; -+} -+ -+static PyObject * -+DBusPythonBytes_tp_repr(PyObject *self) -+{ -+ PyObject *parent_repr = (PyBytes_Type.tp_repr)(self); -+ PyObject *vl_obj; -+ PyObject *my_repr; -+ long variant_level; -+ -+ if (!parent_repr) return NULL; -+ vl_obj = PyObject_GetAttr(self, dbus_py_variant_level_const); -+ if (!vl_obj) { -+ Py_CLEAR(parent_repr); -+ return NULL; -+ } -+ variant_level = NATIVEINT_ASLONG(vl_obj); -+ Py_CLEAR(vl_obj); -+ if (variant_level == -1 && PyErr_Occurred()) { -+ Py_CLEAR(parent_repr); -+ return NULL; -+ } -+ if (variant_level > 0) { -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ variant_level); -+ } -+ else { -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); -+ } -+ /* whether my_repr is NULL or not: */ -+ Py_CLEAR(parent_repr); -+ return my_repr; -+} -+ -+static void -+DBusPyBytesBase_tp_dealloc(PyObject *self) -+{ -+ dbus_py_variant_level_clear(self); -+ (PyBytes_Type.tp_dealloc)(self); -+} -+ -+PyTypeObject DBusPyBytesBase_Type = { -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) -+ "_dbus_bindings._BytesBase", -+ 0, -+ 0, -+ DBusPyBytesBase_tp_dealloc, /* tp_dealloc */ -+ 0, /* tp_print */ -+ 0, /* tp_getattr */ -+ 0, /* tp_setattr */ -+ 0, /* tp_compare */ -+ DBusPythonBytes_tp_repr, /* tp_repr */ -+ 0, /* tp_as_number */ -+ 0, /* tp_as_sequence */ -+ 0, /* tp_as_mapping */ -+ 0, /* tp_hash */ -+ 0, /* tp_call */ -+ 0, /* tp_str */ -+ dbus_py_variant_level_getattro, /* tp_getattro */ -+ dbus_py_immutable_setattro, /* tp_setattro */ -+ 0, /* tp_as_buffer */ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ -+ DBusPythonBytes_tp_doc, /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ 0, /* tp_getset */ -+ DEFERRED_ADDRESS(&PyBytes_Type), /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ 0, /* tp_init */ -+ 0, /* tp_alloc */ -+ DBusPythonBytes_tp_new, /* tp_new */ -+}; -+#endif /* PY3 */ -+ - /* Support code for str subclasses ================================== */ - - PyDoc_STRVAR(DBusPythonString_tp_doc,\ -@@ -396,7 +542,7 @@ - return NULL; - } - -- self = (PyString_Type.tp_new)(cls, args, NULL); -+ self = (NATIVESTR_TYPE.tp_new)(cls, args, NULL); - if (self) { - if (!dbus_py_variant_level_set(self, variantness)) { - Py_CLEAR(self); -@@ -409,7 +555,7 @@ - static PyObject * - DBusPythonString_tp_repr(PyObject *self) - { -- PyObject *parent_repr = (PyString_Type.tp_repr)(self); -+ PyObject *parent_repr = (NATIVESTR_TYPE.tp_repr)(self); - PyObject *vl_obj; - PyObject *my_repr; - long variant_level; -@@ -420,17 +566,22 @@ - Py_CLEAR(parent_repr); - return NULL; - } -- variant_level = PyInt_AsLong(vl_obj); -+ variant_level = NATIVEINT_ASLONG(vl_obj); - Py_CLEAR(vl_obj); -+ if (variant_level == -1 && PyErr_Occurred()) { -+ Py_CLEAR(parent_repr); -+ return NULL; -+ } -+ - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); - } - /* whether my_repr is NULL or not: */ - Py_CLEAR(parent_repr); -@@ -441,12 +592,11 @@ - DBusPyStrBase_tp_dealloc(PyObject *self) - { - dbus_py_variant_level_clear(self); -- (PyString_Type.tp_dealloc)(self); -+ (NATIVESTR_TYPE.tp_dealloc)(self); - } - - PyTypeObject DBusPyStrBase_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "_dbus_bindings._StrBase", - 0, - 0, -@@ -476,7 +626,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&PyString_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&NATIVESTR_TYPE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -538,17 +688,22 @@ - Py_CLEAR(parent_repr); - return NULL; - } -- variant_level = PyInt_AsLong(vl_obj); -+ variant_level = NATIVEINT_ASLONG(vl_obj); - Py_CLEAR(vl_obj); -+ if (variant_level < 0 && PyErr_Occurred()) { -+ Py_CLEAR(parent_repr); -+ return NULL; -+ } -+ - if (variant_level) { -- my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); - } - /* whether my_repr is NULL or not: */ - Py_CLEAR(parent_repr); -@@ -563,8 +718,7 @@ - } - - PyTypeObject DBusPyLongBase_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "_dbus_bindings._LongBase", - 0, - 0, -@@ -608,26 +762,41 @@ - PyObject *dbus_py_signature_const = NULL; - PyObject *dbus_py__dbus_object_path__const = NULL; - -+#ifdef PY3 -+#define INTERN (PyUnicode_InternFromString) -+#else -+/* Neither Python 2.6 nor 2.7 define the expected PyBytes_InternFromString -+ * alias in bytesobject.h. -+ */ -+#define INTERN (PyString_InternFromString) -+#endif -+ - dbus_bool_t - dbus_py_init_abstract(void) - { - _dbus_py_variant_levels = PyDict_New(); - if (!_dbus_py_variant_levels) return 0; - -- dbus_py__dbus_object_path__const = PyString_InternFromString("__dbus_object_path__"); -+ dbus_py__dbus_object_path__const = INTERN("__dbus_object_path__"); - if (!dbus_py__dbus_object_path__const) return 0; - -- dbus_py_variant_level_const = PyString_InternFromString("variant_level"); -+ dbus_py_variant_level_const = INTERN("variant_level"); - if (!dbus_py_variant_level_const) return 0; - -- dbus_py_signature_const = PyString_InternFromString("signature"); -+ dbus_py_signature_const = INTERN("signature"); - if (!dbus_py_signature_const) return 0; - -+#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; - /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as - desired */ - DBusPyIntBase_Type.tp_print = NULL; -+#endif - - DBusPyFloatBase_Type.tp_base = &PyFloat_Type; - if (PyType_Ready(&DBusPyFloatBase_Type) < 0) return 0; -@@ -637,7 +806,7 @@ - if (PyType_Ready(&DBusPyLongBase_Type) < 0) return 0; - DBusPyLongBase_Type.tp_print = NULL; - -- DBusPyStrBase_Type.tp_base = &PyString_Type; -+ DBusPyStrBase_Type.tp_base = &NATIVESTR_TYPE; - if (PyType_Ready(&DBusPyStrBase_Type) < 0) return 0; - DBusPyStrBase_Type.tp_print = NULL; - -@@ -648,12 +817,18 @@ - dbus_py_insert_abstract_types(PyObject *this_module) - { - /* PyModule_AddObject steals a ref */ -+#ifdef PY3 -+ Py_INCREF(&DBusPyBytesBase_Type); -+ if (PyModule_AddObject(this_module, "_BytesBase", -+ (PyObject *)&DBusPyBytesBase_Type) < 0) return 0; -+#else - Py_INCREF(&DBusPyIntBase_Type); -+ if (PyModule_AddObject(this_module, "_IntBase", -+ (PyObject *)&DBusPyIntBase_Type) < 0) return 0; -+#endif - Py_INCREF(&DBusPyLongBase_Type); - Py_INCREF(&DBusPyStrBase_Type); - Py_INCREF(&DBusPyFloatBase_Type); -- if (PyModule_AddObject(this_module, "_IntBase", -- (PyObject *)&DBusPyIntBase_Type) < 0) return 0; - if (PyModule_AddObject(this_module, "_LongBase", - (PyObject *)&DBusPyLongBase_Type) < 0) return 0; - if (PyModule_AddObject(this_module, "_StrBase", ---- a/_dbus_bindings/bus.c -+++ b/_dbus_bindings/bus.c -@@ -42,7 +42,14 @@ - - dbus_error_init(&error); - -- if (first && PyString_Check(first)) { -+ if (first && -+#ifdef PY3 -+ PyUnicode_Check(first) -+#else -+ PyBytes_Check(first) -+#endif -+ ) -+ { - dbus_bool_t ret; - - /* It's a custom address. First connect to it, then register. */ -@@ -62,7 +69,8 @@ - - return (PyObject *)self; - } -- else if (!first || PyInt_Check(first)) { -+ else if (!first || INTORLONG_CHECK(first)) -+ { - long type; - PyObject *libdbusconn; - PyObject *new_args; -@@ -73,7 +81,10 @@ - DBUS_BUS_SESSION. */ - - if (first) { -- type = PyInt_AsLong(first); -+ /* on Python 2 this accepts either int or long */ -+ type = PyLong_AsLong(first); -+ if (type == -1 && PyErr_Occurred()) -+ return NULL; - - if (type != DBUS_BUS_SESSION && type != DBUS_BUS_SYSTEM - && type != DBUS_BUS_STARTER) { -@@ -142,7 +153,7 @@ - return DBusPyException_SetString("This connection has no unique name " - "yet"); - } -- return PyString_FromString(name); -+ return NATIVESTR_FROMSTR(name); - } - - PyObject * ---- a/_dbus_bindings/bytes.c -+++ b/_dbus_bindings/bytes.c -@@ -31,6 +31,12 @@ - #include "dbus_bindings-internal.h" - #include "types-internal.h" - -+#ifdef PY3 -+#define DBUS_PY_BYTE_BASE (DBusPyLongBase_Type) -+#else -+#define DBUS_PY_BYTE_BASE (DBusPyIntBase_Type) -+#endif -+ - PyDoc_STRVAR(Byte_tp_doc, - "An unsigned byte: a subtype of int, with range restricted to [0, 255].\n" - "\n" -@@ -76,21 +82,36 @@ - return NULL; - } - -- /* obj is only a borrowed ref for the moment */ -+ /* obj is a borrowed reference. It gets turned into an owned reference on -+ * the good-path of the if-statements below. -+ */ - obj = PyTuple_GetItem(args, 0); - -- if (PyString_Check(obj)) { -+ if (PyBytes_Check(obj)) { - /* string of length 1, we hope */ -- if (PyString_GET_SIZE(obj) != 1) { -+ if (PyBytes_GET_SIZE(obj) != 1) { - goto bad_arg; - } -- obj = PyInt_FromLong((unsigned char)(PyString_AS_STRING(obj)[0])); -+ obj = NATIVEINT_FROMLONG((unsigned char)(PyBytes_AS_STRING(obj)[0])); -+ if (!obj) -+ goto bad_arg; - } -- else if (PyInt_Check(obj)) { -- long i = PyInt_AS_LONG(obj); -+ else if (INTORLONG_CHECK(obj)) { -+ /* on Python 2 this accepts either int or long */ -+ long i = PyLong_AsLong(obj); -+ long my_variant_level; -+ -+ if (i == -1 && PyErr_Occurred()) -+ goto bad_arg; - -- if (Py_TYPE(obj) == cls && -- ((DBusPyIntBase *)obj)->variant_level == variantness) { -+#ifdef PY3 -+ my_variant_level = dbus_py_variant_level_get(obj); -+ if (my_variant_level < 0) -+ return NULL; -+#else -+ my_variant_level = ((DBusPyIntBase *)obj)->variant_level; -+#endif -+ if (Py_TYPE(obj) == cls && my_variant_level == variantness) { - Py_INCREF(obj); - return obj; - } -@@ -102,16 +123,16 @@ - goto bad_arg; - } - -- tuple = Py_BuildValue("(O)", obj); -+ /* The tuple steals the reference to obj. */ -+ tuple = Py_BuildValue("(N)", obj); - if (!tuple) return NULL; -- Py_CLEAR(obj); - -- obj = DBusPyIntBase_Type.tp_new(cls, tuple, kwargs); -+ obj = DBUS_PY_BYTE_BASE.tp_new(cls, tuple, kwargs); - Py_CLEAR(tuple); - return obj; - - bad_arg: -- PyErr_SetString(PyExc_TypeError, "Expected a string of length 1, " -+ PyErr_SetString(PyExc_TypeError, "Expected a bytes or str of length 1, " - "or an int in the range 0-255"); - return NULL; - bad_range: -@@ -122,12 +143,22 @@ - static PyObject * - Byte_tp_str(PyObject *self) - { -- unsigned char str[2] = { (unsigned char)PyInt_AS_LONG(self), 0 }; -- return PyString_FromStringAndSize((char *)str, 1); -+ long i = NATIVEINT_ASLONG(self); -+ unsigned char str[2] = { 0, 0 }; -+ -+ if (i == -1 && PyErr_Occurred()) -+ return NULL; -+ if (i < 0 || i > 255) { -+ PyErr_SetString(PyExc_RuntimeError, "Integer outside range 0-255"); -+ return NULL; -+ } -+ -+ str[0] = (unsigned char)i; -+ return PyUnicode_FromStringAndSize((char *)str, 1); - } - - PyTypeObject DBusPyByte_Type = { -- PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Byte", - 0, - 0, -@@ -157,7 +188,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&PyInt_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&DBUS_PY_BYTE_BASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -167,6 +198,12 @@ - Byte_new, /* tp_new */ - }; - -+#ifdef PY3 -+#define DBUS_PY_BYTEARRAY_BASE (DBusPyBytesBase_Type) -+#else -+#define DBUS_PY_BYTEARRAY_BASE (DBusPyStrBase_Type) -+#endif -+ - PyDoc_STRVAR(ByteArray_tp_doc, - "ByteArray is a subtype of str which can be used when you want an\n" - "efficient immutable representation of a D-Bus byte array (signature 'ay').\n" -@@ -223,7 +260,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPyStrBase_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&DBUS_PY_BYTEARRAY_BASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -236,11 +273,11 @@ - dbus_bool_t - dbus_py_init_byte_types(void) - { -- DBusPyByte_Type.tp_base = &DBusPyIntBase_Type; -+ DBusPyByte_Type.tp_base = &DBUS_PY_BYTE_BASE; - if (PyType_Ready(&DBusPyByte_Type) < 0) return 0; - DBusPyByte_Type.tp_print = NULL; - -- DBusPyByteArray_Type.tp_base = &DBusPyStrBase_Type; -+ DBusPyByteArray_Type.tp_base = &DBUS_PY_BYTEARRAY_BASE; - if (PyType_Ready(&DBusPyByteArray_Type) < 0) return 0; - DBusPyByteArray_Type.tp_print = NULL; - ---- a/_dbus_bindings/conn-methods.c -+++ b/_dbus_bindings/conn-methods.c -@@ -40,8 +40,9 @@ - TRACE(conn_obj); - - DBG("Connection at %p unregistering object path %s", -- conn_obj, PyString_AS_STRING((PyObject *)user_data)); -- tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data); -+ conn_obj, PyBytes_AS_STRING((PyObject *)user_data)); -+ tuple = DBusPyConnection_GetObjectPathHandlers( -+ (PyObject *)conn_obj, (PyObject *)user_data); - if (!tuple) goto out; - if (tuple == Py_None) goto out; - -@@ -91,9 +92,10 @@ - TRACE(conn_obj); - - DBG("Connection at %p messaging object path %s", -- conn_obj, PyString_AS_STRING((PyObject *)user_data)); -+ conn_obj, PyBytes_AS_STRING((PyObject *)user_data)); - DBG_DUMP_MESSAGE(message); -- tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data); -+ tuple = DBusPyConnection_GetObjectPathHandlers( -+ (PyObject *)conn_obj, (PyObject *)user_data); - if (!tuple || tuple == Py_None) { - ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - goto out; -@@ -562,7 +564,7 @@ - ok = dbus_connection_get_unix_fd (self->conn, &fd); - Py_END_ALLOW_THREADS - if (!ok) Py_RETURN_NONE; -- return PyInt_FromLong(fd); -+ return NATIVEINT_FROMLONG(fd); - } - - PyDoc_STRVAR(Connection_get_peer_unix_user__doc__, -@@ -702,6 +704,7 @@ - { - dbus_bool_t ok; - int fallback = 0; -+ char *path_bytes; - PyObject *callbacks, *path, *tuple, *on_message, *on_unregister = Py_None; - static char *argnames[] = {"path", "on_message", "on_unregister", - "fallback", NULL}; -@@ -724,23 +727,25 @@ - mad) to preserve the desirable property that the DBusConnection can - never strongly reference the Connection, even indirectly. - */ -- if (PyString_CheckExact(path)) { -+ if (PyBytes_CheckExact(path)) { - Py_INCREF(path); - } - else if (PyUnicode_Check(path)) { - path = PyUnicode_AsUTF8String(path); - if (!path) return NULL; - } -- else if (PyString_Check(path)) { -- path = PyString_FromString(PyString_AS_STRING(path)); -+ else if (PyBytes_Check(path)) { -+ path = PyBytes_FromString(PyBytes_AS_STRING(path)); - if (!path) return NULL; - } - else { -- PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object"); -+ PyErr_SetString(PyExc_TypeError, -+ "path must be a str, bytes, or unicode object"); - return NULL; - } - -- if (!dbus_py_validate_object_path(PyString_AS_STRING(path))) { -+ path_bytes = PyBytes_AS_STRING(path); -+ if (!dbus_py_validate_object_path(path_bytes)) { - Py_CLEAR(path); - return NULL; - } -@@ -756,7 +761,7 @@ - if (callbacks && callbacks != Py_None) { - PyErr_Format(PyExc_KeyError, "Can't register the object-path " - "handler for '%s': there is already a handler", -- PyString_AS_STRING(path)); -+ path_bytes); - Py_CLEAR(tuple); - Py_CLEAR(path); - return NULL; -@@ -775,13 +780,13 @@ - Py_BEGIN_ALLOW_THREADS - if (fallback) { - ok = dbus_connection_register_fallback(self->conn, -- PyString_AS_STRING(path), -+ path_bytes, - &_object_path_vtable, - path); - } - else { - ok = dbus_connection_register_object_path(self->conn, -- PyString_AS_STRING(path), -+ path_bytes, - &_object_path_vtable, - path); - } -@@ -795,7 +800,7 @@ - memory in libdbus, but tbh we should never get here anyway. */ - Py_BEGIN_ALLOW_THREADS - ok = dbus_connection_unregister_object_path(self->conn, -- PyString_AS_STRING(path)); -+ path_bytes); - Py_END_ALLOW_THREADS - return NULL; - } -@@ -829,6 +834,7 @@ - PyObject *kwargs) - { - dbus_bool_t ok; -+ char *path_bytes; - PyObject *path; - PyObject *callbacks; - static char *argnames[] = {"path", NULL}; -@@ -840,29 +846,32 @@ - argnames, &path)) return NULL; - - /* Take a ref to the path. Same comments as for _register_object_path. */ -- if (PyString_CheckExact(path)) { -+ if (PyBytes_CheckExact(path)) { - Py_INCREF(path); - } - else if (PyUnicode_Check(path)) { - path = PyUnicode_AsUTF8String(path); - if (!path) return NULL; - } -- else if (PyString_Check(path)) { -- path = PyString_FromString(PyString_AS_STRING(path)); -+ else if (PyBytes_Check(path)) { -+ path = PyBytes_FromString(PyBytes_AS_STRING(path)); - if (!path) return NULL; - } - else { -- PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object"); -+ PyErr_SetString(PyExc_TypeError, -+ "path must be a str, bytes, or unicode object"); - return NULL; - } - -+ path_bytes = PyBytes_AS_STRING(path); -+ - /* Guard against unregistering a handler that doesn't, in fact, exist, - or whose unregistration is already in progress. */ - callbacks = PyDict_GetItem(self->object_paths, path); - if (!callbacks || callbacks == Py_None) { - PyErr_Format(PyExc_KeyError, "Can't unregister the object-path " - "handler for '%s': there is no such handler", -- PyString_AS_STRING(path)); -+ path_bytes); - Py_CLEAR(path); - return NULL; - } -@@ -897,8 +906,7 @@ - */ - - Py_BEGIN_ALLOW_THREADS -- ok = dbus_connection_unregister_object_path(self->conn, -- PyString_AS_STRING(path)); -+ ok = dbus_connection_unregister_object_path(self->conn, path_bytes); - Py_END_ALLOW_THREADS - - if (ok) { -@@ -968,7 +976,7 @@ - return NULL; - } - for (kid_ptr = kids; *kid_ptr; kid_ptr++) { -- PyObject *tmp = PyString_FromString(*kid_ptr); -+ PyObject *tmp = NATIVESTR_FROMSTR(*kid_ptr); - - if (!tmp) { - Py_CLEAR(ret); -@@ -988,7 +996,7 @@ - } - - /* dbus_connection_get_object_path_data - not useful to Python, -- * the object path data is just a PyString containing the path */ -+ * the object path data is just a PyBytes containing the path */ - /* dbus_connection_list_registered could be useful, though */ - - /* dbus_connection_set_change_sigpipe - sets global state */ ---- a/_dbus_bindings/conn.c -+++ b/_dbus_bindings/conn.c -@@ -99,7 +99,7 @@ - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - else { -- long i = PyInt_AsLong(obj); -+ long i = PyLong_AsLong(obj); - DBG("%p: handler %p returned %ld", conn, callable, i); - Py_CLEAR(obj); - if (i == -1 && PyErr_Occurred()) { -@@ -232,6 +232,7 @@ - self->has_mainloop = (mainloop != Py_None); - self->conn = NULL; - self->filters = PyList_New(0); -+ self->weaklist = NULL; - if (!self->filters) goto err; - self->object_paths = PyDict_New(); - if (!self->object_paths) goto err; -@@ -298,7 +299,6 @@ - Connection_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - { - DBusConnection *conn; -- const char *address; - PyObject *address_or_conn; - DBusError error; - PyObject *self, *mainloop = NULL; -@@ -317,7 +317,30 @@ - - conn = dbus_connection_ref (wrapper->conn); - } -- else if ((address = PyString_AsString(address_or_conn)) != NULL) { -+ else if (PyBytes_Check(address_or_conn)) { -+ const char *address = PyBytes_AS_STRING(address_or_conn); -+ -+ dbus_error_init(&error); -+ -+ /* We always open a private connection (at the libdbus level). Sharing -+ * is done in Python, to keep things simple. */ -+ Py_BEGIN_ALLOW_THREADS -+ conn = dbus_connection_open_private(address, &error); -+ Py_END_ALLOW_THREADS -+ -+ if (!conn) { -+ DBusPyException_ConsumeError(&error); -+ return NULL; -+ } -+ } -+ else if (PyUnicode_Check(address_or_conn)) { -+ PyObject *address_as_bytes = PyUnicode_AsUTF8String(address_or_conn); -+ const char *address; -+ -+ if (!address_as_bytes) -+ return NULL; -+ address = PyBytes_AS_STRING(address_as_bytes); -+ - dbus_error_init(&error); - - /* We always open a private connection (at the libdbus level). Sharing -@@ -326,12 +349,14 @@ - conn = dbus_connection_open_private(address, &error); - Py_END_ALLOW_THREADS - -+ Py_CLEAR(address_as_bytes); - if (!conn) { - DBusPyException_ConsumeError(&error); - return NULL; - } - } - else { -+ PyErr_SetString(PyExc_TypeError, "connection or str expected"); - return NULL; - } - -@@ -404,8 +429,7 @@ - /* Connection type object =========================================== */ - - PyTypeObject DBusPyConnection_Type = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "_dbus_bindings.Connection", /*tp_name*/ - sizeof(Connection), /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -425,7 +449,11 @@ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ -+#ifdef PY3 -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, -+#else - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_BASETYPE, -+#endif - Connection_tp_doc, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ ---- a/_dbus_bindings/containers.c -+++ b/_dbus_bindings/containers.c -@@ -92,18 +92,18 @@ - if (!parent_repr) goto finally; - if (!sig_repr) goto finally; - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, signature=%s, " -- "variant_level=%ld)", -- self->super.ob_type->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " -+ "variant_level=%ld)", -+ Py_TYPE(&self->super)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s, signature=%s)", -- self->super.ob_type->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", -+ Py_TYPE(&self->super)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr)); - } - finally: - Py_CLEAR(parent_repr); -@@ -127,11 +127,12 @@ - variant_level = PyDict_GetItem(kwargs, dbus_py_variant_level_const); - } - if (variant_level) { -- self->variant_level = PyInt_AsLong(variant_level); -- if (PyErr_Occurred()) { -+ long new_variant_level = PyLong_AsLong(variant_level); -+ if (new_variant_level == -1 && PyErr_Occurred()) { - Py_CLEAR(self); - return NULL; - } -+ self->variant_level = new_variant_level; - } - return (PyObject *)self; - } -@@ -166,15 +167,42 @@ - } - - if (signature != Py_None) { -- const char *c_str = PyString_AS_STRING(signature); -+ const char *c_str; -+ PyObject *signature_as_bytes; -+ -+ if ( -+#ifdef PY3 -+ !PyUnicode_Check(signature) -+#else -+ !PyBytes_Check(signature) -+#endif -+ ) -+ { -+ PyErr_SetString(PyExc_TypeError, "str expected"); -+ Py_CLEAR(signature); -+ return -1; -+ } -+#ifdef PY3 -+ if (!(signature_as_bytes = PyUnicode_AsUTF8String(signature))) { -+ Py_CLEAR(signature); -+ return -1; -+ } -+#else -+ signature_as_bytes = signature; -+ Py_INCREF(signature_as_bytes); -+#endif -+ -+ c_str = PyBytes_AS_STRING(signature_as_bytes); - - if (!dbus_signature_validate_single(c_str, NULL)) { - Py_CLEAR(signature); -+ Py_CLEAR(signature_as_bytes); - PyErr_SetString(PyExc_ValueError, - "There must be exactly one complete type in " - "an Array's signature parameter"); - return -1; - } -+ Py_CLEAR(signature_as_bytes); - } - - tuple = Py_BuildValue("(O)", obj); -@@ -299,18 +327,18 @@ - if (!parent_repr) goto finally; - if (!sig_repr) goto finally; - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, signature=%s, " -- "variant_level=%ld)", -- self->super.ob_type->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " -+ "variant_level=%ld)", -+ Py_TYPE(&self->super)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s, signature=%s)", -- self->super.ob_type->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", -+ Py_TYPE(&self->super)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr)); - } - finally: - Py_CLEAR(parent_repr); -@@ -334,11 +362,13 @@ - variant_level = PyDict_GetItem(kwargs, dbus_py_variant_level_const); - } - if (variant_level) { -- self->variant_level = PyInt_AsLong(variant_level); -- if (PyErr_Occurred()) { -+ long new_variant_level = PyLong_AsLong(variant_level); -+ -+ if (new_variant_level == -1 && PyErr_Occurred()) { - Py_CLEAR(self); - return NULL; - } -+ self->variant_level = new_variant_level; - } - return (PyObject *)self; - } -@@ -372,8 +402,25 @@ - } - - if (signature != Py_None) { -- const char *c_str = PyString_AS_STRING(signature); -+ const char *c_str; -+ PyObject *signature_as_bytes; - -+ if (!NATIVESTR_CHECK(signature)) { -+ PyErr_SetString(PyExc_TypeError, "str expected"); -+ Py_CLEAR(signature); -+ return -1; -+ } -+#ifdef PY3 -+ if (!(signature_as_bytes = PyUnicode_AsUTF8String(signature))) { -+ Py_CLEAR(signature); -+ return -1; -+ } -+#else -+ signature_as_bytes = signature; -+ Py_INCREF(signature_as_bytes); -+#endif -+ -+ c_str = PyBytes_AS_STRING(signature_as_bytes); - switch (c_str[0]) { - case DBUS_TYPE_BYTE: - case DBUS_TYPE_BOOLEAN: -@@ -396,6 +443,7 @@ - break; - default: - Py_CLEAR(signature); -+ Py_CLEAR(signature_as_bytes); - PyErr_SetString(PyExc_ValueError, - "The key type in a Dictionary's signature " - "must be a primitive type"); -@@ -404,11 +452,13 @@ - - if (!dbus_signature_validate_single(c_str + 1, NULL)) { - Py_CLEAR(signature); -+ Py_CLEAR(signature_as_bytes); - PyErr_SetString(PyExc_ValueError, - "There must be exactly two complete types in " - "a Dictionary's signature parameter"); - return -1; - } -+ Py_CLEAR(signature_as_bytes); - } - - tuple = Py_BuildValue("(O)", obj); -@@ -519,20 +569,24 @@ - if (!sig) sig = Py_None; - sig_repr = PyObject_Repr(sig); - if (!sig_repr) goto finally; -+ - variant_level = dbus_py_variant_level_get(self); -+ if (variant_level < 0) -+ goto finally; -+ - if (variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, signature=%s, " -- "variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr), -- variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, " -+ "variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr), -+ variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s, signature=%s)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- PyString_AS_STRING(sig_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ REPRV(sig_repr)); - } - - finally: -@@ -646,7 +700,11 @@ - { - PyObject *key, *value; - -- if (PyString_Check(name)) { -+#ifdef PY3 -+ if (PyUnicode_CompareWithASCIIString(name, "signature")) -+ return dbus_py_variant_level_getattro(obj, name); -+#else -+ if (PyBytes_Check(name)) { - Py_INCREF(name); - } - else if (PyUnicode_Check(name)) { -@@ -660,13 +718,13 @@ - return NULL; - } - -- if (strcmp(PyString_AS_STRING(name), "signature")) { -+ if (strcmp(PyBytes_AS_STRING(name), "signature")) { - value = dbus_py_variant_level_getattro(obj, name); - Py_CLEAR(name); - return value; - } -- - Py_CLEAR(name); -+#endif /* PY3 */ - - key = PyLong_FromVoidPtr(obj); - ---- a/_dbus_bindings/dbus_bindings-internal.h -+++ b/_dbus_bindings/dbus_bindings-internal.h -@@ -51,7 +51,54 @@ - return (Py_TYPE(o) == &type##_Type); \ - } - -+/* This is a clever little trick to make writing the various object reprs -+ * easier. It relies on Python's %V format option which consumes two -+ * arguments. The first is a unicode object which may be NULL, and the second -+ * is a char* which will be used if the first parameter is NULL. -+ * -+ * The issue is that we don't know whether the `parent_repr` at the call site -+ * is a unicode or a bytes (a.k.a. 8-bit string). Under Python 3, it will -+ * always be a unicode. Under Python 2 it will *probably* be a bytes/str, but -+ * could potentially be a unicode. So, we check the type, and if it's a -+ * unicode, we pass that as the first argument, leaving NULL as the second -+ * argument (since it will never be checked). However, if the object is not a -+ * unicode, it better be a bytes. In that case, we'll pass NULL as the first -+ * argument so that the second one gets used, and we'll dig the char* out of -+ * the bytes object for that purpose. -+ * -+ * You might think that this would crash if obj is neither a bytes/str or -+ * unicode, and you'd be right *except* that Python doesn't allow any other -+ * types to be returned in the reprs. Also, since obj will always be the repr -+ * of a built-in type, it will never be anything other than a bytes or a -+ * unicode in any version of Python. So in practice, this is safe. -+ */ -+#define REPRV(obj) \ -+ (PyUnicode_Check(obj) ? (obj) : NULL), \ -+ (PyUnicode_Check(obj) ? NULL : PyBytes_AS_STRING(obj)) -+ -+#ifdef PY3 -+#define NATIVEINT_TYPE (PyLong_Type) -+#define NATIVEINT_FROMLONG(x) (PyLong_FromLong(x)) -+#define NATIVEINT_ASLONG(x) (PyLong_AsLong(x)) -+#define INTORLONG_CHECK(obj) (PyLong_Check(obj)) -+#define NATIVESTR_TYPE (PyUnicode_Type) -+#define NATIVESTR_CHECK(obj) (PyUnicode_Check(obj)) -+#define NATIVESTR_FROMSTR(obj) (PyUnicode_FromString(obj)) -+#else -+#define NATIVEINT_TYPE (PyInt_Type) -+#define NATIVEINT_FROMLONG(x) (PyInt_FromLong(x)) -+#define NATIVEINT_ASLONG(x) (PyInt_AsLong(x)) -+#define INTORLONG_CHECK(obj) (PyLong_Check(obj) || PyInt_Check(obj)) -+#define NATIVESTR_TYPE (PyBytes_Type) -+#define NATIVESTR_CHECK(obj) (PyBytes_Check(obj)) -+#define NATIVESTR_FROMSTR(obj) (PyBytes_FromString(obj)) -+#endif -+ -+#ifdef PY3 -+PyMODINIT_FUNC PyInit__dbus_bindings(void); -+#else - PyMODINIT_FUNC init_dbus_bindings(void); -+#endif - - /* conn.c */ - extern PyTypeObject DBusPyConnection_Type; -@@ -89,9 +136,12 @@ - extern PyTypeObject DBusPyByte_Type, DBusPyByteArray_Type; - DEFINE_CHECK(DBusPyByteArray) - DEFINE_CHECK(DBusPyByte) --extern PyTypeObject DBusPyUTF8String_Type, DBusPyString_Type; --DEFINE_CHECK(DBusPyUTF8String) -+extern PyTypeObject DBusPyString_Type; - DEFINE_CHECK(DBusPyString) -+#ifndef PY3 -+extern PyTypeObject DBusPyUTF8String_Type; -+DEFINE_CHECK(DBusPyUTF8String) -+#endif - extern PyTypeObject DBusPyDouble_Type; - DEFINE_CHECK(DBusPyDouble) - extern PyTypeObject DBusPyInt16_Type, DBusPyUInt16_Type; -@@ -201,11 +251,13 @@ - void _dbus_py_whereami(void); - void _dbus_py_dbg_dump_message(DBusMessage *); - --# define TRACE(self) do { fprintf(stderr, "TRACE: <%s at %p> in %s, " \ -- "%d refs\n", \ -- Py_TYPE(self)->tp_name, \ -- self, __func__, \ -- self->ob_refcnt); } while (0) -+# define TRACE(self) do { \ -+ fprintf(stderr, "TRACE: <%s at %p> in %s, " \ -+ "%d refs\n", \ -+ self ? Py_TYPE(self)->tp_name : NULL, \ -+ self, __func__, \ -+ self ? (int)Py_REFCNT(self) : 0); \ -+ } while (0) - # define DBG(format, ...) fprintf(stderr, "DEBUG: " format "\n",\ - __VA_ARGS__) - # define DBG_EXC(format, ...) do {DBG(format, __VA_ARGS__); \ ---- a/_dbus_bindings/exceptions.c -+++ b/_dbus_bindings/exceptions.c -@@ -37,7 +37,7 @@ - return TRUE; - } - -- name = PyString_FromString("dbus.exceptions"); -+ name = NATIVESTR_FROMSTR("dbus.exceptions"); - if (name == NULL) { - return FALSE; - } -@@ -81,7 +81,7 @@ - } - - if (error->name) { -- PyObject *name = PyString_FromString(error->name); -+ PyObject *name = NATIVESTR_FROMSTR(error->name); - int ret; - - if (!name) ---- a/_dbus_bindings/generic.c -+++ b/_dbus_bindings/generic.c -@@ -33,8 +33,8 @@ - - int - dbus_py_immutable_setattro(PyObject *obj UNUSED, -- PyObject *name UNUSED, -- PyObject *value UNUSED) -+ PyObject *name UNUSED, -+ PyObject *value UNUSED) - { - PyErr_SetString(PyExc_AttributeError, "Object is immutable"); - return -1; ---- a/_dbus_bindings/int.c -+++ b/_dbus_bindings/int.c -@@ -25,6 +25,12 @@ - - #include "types-internal.h" - -+#ifdef PY3 -+#define INTBASE (DBusPyLongBase_Type) -+#else -+#define INTBASE (DBusPyIntBase_Type) -+#endif -+ - /* Specific types =================================================== */ - - /* Boolean, a subclass of DBusPythonInt ============================= */ -@@ -65,29 +71,39 @@ - } - tuple = Py_BuildValue("(i)", PyObject_IsTrue(value) ? 1 : 0); - if (!tuple) return NULL; -- self = (DBusPyIntBase_Type.tp_new)(cls, tuple, kwargs); -+ self = (INTBASE.tp_new)(cls, tuple, kwargs); - Py_CLEAR(tuple); - return self; - } - - static PyObject * --Boolean_tp_repr (PyObject *self) -+Boolean_tp_repr(PyObject *self) - { -+ int is_true = PyObject_IsTrue(self); -+#ifdef PY3 -+ long variant_level = dbus_py_variant_level_get(self); -+ if (variant_level < 0) -+ return NULL; -+#else - long variant_level = ((DBusPyIntBase *)self)->variant_level; -+#endif -+ -+ if (is_true == -1) -+ return NULL; -+ - if (variant_level > 0) { -- return PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyInt_AsLong(self) ? "True" : "False", -- variant_level); -- } -- return PyString_FromFormat("%s(%s)", -- Py_TYPE(self)->tp_name, -- PyInt_AsLong(self) ? "True" : "False"); -+ return PyUnicode_FromFormat("%s(%s, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ is_true ? "True" : "False", -+ variant_level); -+ } -+ return PyUnicode_FromFormat("%s(%s)", -+ Py_TYPE(self)->tp_name, -+ is_true ? "True" : "False"); - } - - PyTypeObject DBusPyBoolean_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Boolean", - 0, - 0, -@@ -117,7 +133,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&INTBASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -153,20 +169,22 @@ - dbus_int16_t - dbus_py_int16_range_check(PyObject *obj) - { -- long i = PyInt_AsLong (obj); -- if (i == -1 && PyErr_Occurred ()) return -1; -+ long i = PyLong_AsLong(obj); -+ if (i == -1 && PyErr_Occurred()) -+ return -1; -+ - if (i < -0x8000 || i > 0x7fff) { - PyErr_Format(PyExc_OverflowError, "Value %d out of range for Int16", - (int)i); - return -1; - } -- return i; -+ return (dbus_int16_t)i; - } - - static PyObject * - Int16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - { -- PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); -+ PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); - if (self && dbus_py_int16_range_check(self) == -1 && PyErr_Occurred()) { - Py_CLEAR(self); - return NULL; -@@ -205,7 +223,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&INTBASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -241,22 +259,25 @@ - dbus_uint16_t - dbus_py_uint16_range_check(PyObject *obj) - { -- long i = PyInt_AsLong(obj); -- if (i == -1 && PyErr_Occurred()) return (dbus_uint16_t)(-1); -+ long i = PyLong_AsLong(obj); -+ if (i == -1 && PyErr_Occurred()) -+ return (dbus_uint16_t)(-1); -+ - if (i < 0 || i > 0xffff) { - PyErr_Format(PyExc_OverflowError, "Value %d out of range for UInt16", - (int)i); - return (dbus_uint16_t)(-1); - } -- return i; -+ return (dbus_uint16_t)i; - } - - static PyObject * - UInt16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - { -- PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); -+ PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); - if (self && dbus_py_uint16_range_check(self) == (dbus_uint16_t)(-1) -- && PyErr_Occurred()) { -+ && PyErr_Occurred()) -+ { - Py_CLEAR (self); - return NULL; - } -@@ -294,7 +315,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&INTBASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -330,20 +351,22 @@ - dbus_int32_t - dbus_py_int32_range_check(PyObject *obj) - { -- long i = PyInt_AsLong(obj); -- if (i == -1 && PyErr_Occurred()) return -1; -+ long i = PyLong_AsLong(obj); -+ if (i == -1 && PyErr_Occurred()) -+ return -1; -+ - if (i < INT32_MIN || i > INT32_MAX) { - PyErr_Format(PyExc_OverflowError, "Value %d out of range for Int32", - (int)i); - return -1; - } -- return i; -+ return (dbus_int32_t)i; - } - - static PyObject * - Int32_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - { -- PyObject *self = (DBusPyIntBase_Type.tp_new)(cls, args, kwargs); -+ PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); - if (self && dbus_py_int32_range_check(self) == -1 && PyErr_Occurred()) { - Py_CLEAR(self); - return NULL; -@@ -382,7 +405,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPyIntBase_Type), /* tp_base */ -+ DEFERRED_ADDRESS(&INTBASE), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -@@ -712,17 +735,17 @@ - dbus_bool_t - dbus_py_init_int_types(void) - { -- DBusPyInt16_Type.tp_base = &DBusPyIntBase_Type; -+ DBusPyInt16_Type.tp_base = &INTBASE; - if (PyType_Ready(&DBusPyInt16_Type) < 0) return 0; - /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as - desired */ - DBusPyInt16_Type.tp_print = NULL; - -- DBusPyUInt16_Type.tp_base = &DBusPyIntBase_Type; -+ DBusPyUInt16_Type.tp_base = &INTBASE; - if (PyType_Ready(&DBusPyUInt16_Type) < 0) return 0; - DBusPyUInt16_Type.tp_print = NULL; - -- DBusPyInt32_Type.tp_base = &DBusPyIntBase_Type; -+ DBusPyInt32_Type.tp_base = &INTBASE; - if (PyType_Ready(&DBusPyInt32_Type) < 0) return 0; - DBusPyInt32_Type.tp_print = NULL; - -@@ -739,6 +762,11 @@ - if (PyType_Ready(&DBusPyUInt64_Type) < 0) return 0; - DBusPyUInt64_Type.tp_print = NULL; - #endif -+ -+ DBusPyBoolean_Type.tp_base = &INTBASE; -+ if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; -+ DBusPyBoolean_Type.tp_print = NULL; -+ - return 1; - } - ---- a/_dbus_bindings/libdbusconn.c -+++ b/_dbus_bindings/libdbusconn.c -@@ -77,8 +77,7 @@ - } - - PyTypeObject DBusPyLibDBusConnection_Type = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "_dbus_bindings._LibDBusConnection", - sizeof(DBusPyLibDBusConnection), - 0, /*tp_itemsize*/ ---- a/_dbus_bindings/message-append.c -+++ b/_dbus_bindings/message-append.c -@@ -38,9 +38,14 @@ - static long - get_variant_level(PyObject *obj) - { -- if (DBusPyIntBase_Check(obj)) { -+ if (DBusPyString_Check(obj)) { -+ return ((DBusPyString *)obj)->variant_level; -+ } -+#ifndef PY3 -+ else if (DBusPyIntBase_Check(obj)) { - return ((DBusPyIntBase *)obj)->variant_level; - } -+#endif - else if (DBusPyFloatBase_Check(obj)) { - return ((DBusPyFloatBase *)obj)->variant_level; - } -@@ -50,10 +55,10 @@ - else if (DBusPyDict_Check(obj)) { - return ((DBusPyDict *)obj)->variant_level; - } -- else if (DBusPyString_Check(obj)) { -- return ((DBusPyString *)obj)->variant_level; -- } - else if (DBusPyLongBase_Check(obj) || -+#ifdef PY3 -+ DBusPyBytesBase_Check(obj) || -+#endif - DBusPyStrBase_Check(obj) || - DBusPyStruct_Check(obj)) { - return dbus_py_variant_level_get(obj); -@@ -143,7 +148,7 @@ - PyObject *magic_attr = PyObject_GetAttr(obj, dbus_py__dbus_object_path__const); - - if (magic_attr) { -- if (PyString_Check(magic_attr)) { -+ if (PyUnicode_Check(magic_attr) || PyBytes_Check(magic_attr)) { - return magic_attr; - } - else { -@@ -171,15 +176,19 @@ - { - PyObject *magic_attr; - long variant_level = get_variant_level(obj); -+ -+ if (variant_level < 0) -+ return NULL; -+ - if (variant_level_ptr) { - *variant_level_ptr = variant_level; - } - else if (variant_level > 0) { -- return PyString_FromString(DBUS_TYPE_VARIANT_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_VARIANT_AS_STRING); - } - - if (obj == Py_True || obj == Py_False) { -- return PyString_FromString(DBUS_TYPE_BOOLEAN_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); - } - - magic_attr = get_object_path(obj); -@@ -187,61 +196,84 @@ - return NULL; - if (magic_attr != Py_None) { - Py_CLEAR(magic_attr); -- return PyString_FromString(DBUS_TYPE_OBJECT_PATH_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_OBJECT_PATH_AS_STRING); - } - Py_CLEAR(magic_attr); - - /* Ordering is important: some of these are subclasses of each other. */ -+#ifdef PY3 -+ if (PyLong_Check(obj)) { -+ if (DBusPyUInt64_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT64_AS_STRING); -+ else if (DBusPyInt64_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); -+ else if (DBusPyUInt32_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT32_AS_STRING); -+ else if (DBusPyInt32_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); -+ else if (DBusPyUInt16_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT16_AS_STRING); -+ else if (DBusPyInt16_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT16_AS_STRING); -+ else if (DBusPyByte_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_BYTE_AS_STRING); -+ else if (DBusPyBoolean_Check(obj)) -+ return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); -+ else -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); -+ } -+#else /* !PY3 */ - if (PyInt_Check(obj)) { - if (DBusPyInt16_Check(obj)) -- return PyString_FromString(DBUS_TYPE_INT16_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT16_AS_STRING); - else if (DBusPyInt32_Check(obj)) -- return PyString_FromString(DBUS_TYPE_INT32_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); - else if (DBusPyByte_Check(obj)) -- return PyString_FromString(DBUS_TYPE_BYTE_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_BYTE_AS_STRING); - else if (DBusPyUInt16_Check(obj)) -- return PyString_FromString(DBUS_TYPE_UINT16_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT16_AS_STRING); - else if (DBusPyBoolean_Check(obj)) -- return PyString_FromString(DBUS_TYPE_BOOLEAN_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_BOOLEAN_AS_STRING); - else -- return PyString_FromString(DBUS_TYPE_INT32_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT32_AS_STRING); - } - else if (PyLong_Check(obj)) { - if (DBusPyInt64_Check(obj)) -- return PyString_FromString(DBUS_TYPE_INT64_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); - else if (DBusPyUInt32_Check(obj)) -- return PyString_FromString(DBUS_TYPE_UINT32_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT32_AS_STRING); - else if (DBusPyUInt64_Check(obj)) -- return PyString_FromString(DBUS_TYPE_UINT64_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UINT64_AS_STRING); - else -- return PyString_FromString(DBUS_TYPE_INT64_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_INT64_AS_STRING); - } -+#endif /* PY3 */ - else if (PyUnicode_Check(obj)) -- return PyString_FromString(DBUS_TYPE_STRING_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_STRING_AS_STRING); - #if defined(DBUS_TYPE_UNIX_FD) - else if (DBusPyUnixFd_Check(obj)) -- return PyString_FromString(DBUS_TYPE_UNIX_FD_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_UNIX_FD_AS_STRING); - #endif - else if (PyFloat_Check(obj)) { - #ifdef WITH_DBUS_FLOAT32 - if (DBusPyDouble_Check(obj)) -- return PyString_FromString(DBUS_TYPE_DOUBLE_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_DOUBLE_AS_STRING); - else if (DBusPyFloat_Check(obj)) -- return PyString_FromString(DBUS_TYPE_FLOAT_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_FLOAT_AS_STRING); - else - #endif -- return PyString_FromString(DBUS_TYPE_DOUBLE_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_DOUBLE_AS_STRING); - } -- else if (PyString_Check(obj)) { -+ else if (PyBytes_Check(obj)) { - if (DBusPyObjectPath_Check(obj)) -- return PyString_FromString(DBUS_TYPE_OBJECT_PATH_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_OBJECT_PATH_AS_STRING); - else if (DBusPySignature_Check(obj)) -- return PyString_FromString(DBUS_TYPE_SIGNATURE_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_SIGNATURE_AS_STRING); - else if (DBusPyByteArray_Check(obj)) -- return PyString_FromString(DBUS_TYPE_ARRAY_AS_STRING -- DBUS_TYPE_BYTE_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_ARRAY_AS_STRING -+ DBUS_TYPE_BYTE_AS_STRING); - else -- return PyString_FromString(DBUS_TYPE_STRING_AS_STRING); -+ return NATIVESTR_FROMSTR(DBUS_TYPE_STRING_AS_STRING); - } - else if (PyTuple_Check(obj)) { - Py_ssize_t len = PyTuple_GET_SIZE(obj); -@@ -258,12 +290,12 @@ - return NULL; - } - /* Set the first and last elements of list to be the parentheses */ -- item = PyString_FromString(DBUS_STRUCT_BEGIN_CHAR_AS_STRING); -+ item = NATIVESTR_FROMSTR(DBUS_STRUCT_BEGIN_CHAR_AS_STRING); - if (PyList_SetItem(list, 0, item) < 0) { - Py_CLEAR(list); - return NULL; - } -- item = PyString_FromString(DBUS_STRUCT_END_CHAR_AS_STRING); -+ item = NATIVESTR_FROMSTR(DBUS_STRUCT_END_CHAR_AS_STRING); - if (PyList_SetItem(list, len + 1, item) < 0) { - Py_CLEAR(list); - return NULL; -@@ -291,7 +323,7 @@ - } - item = NULL; - } -- empty_str = PyString_FromString(""); -+ empty_str = NATIVESTR_FROMSTR(""); - if (!empty_str) { - /* really shouldn't happen */ - Py_CLEAR(list); -@@ -305,12 +337,25 @@ - } - else if (PyList_Check(obj)) { - PyObject *tmp; -- PyObject *ret = PyString_FromString(DBUS_TYPE_ARRAY_AS_STRING); -+ PyObject *ret = NATIVESTR_FROMSTR(DBUS_TYPE_ARRAY_AS_STRING); - if (!ret) return NULL; -- if (DBusPyArray_Check(obj) && PyString_Check(((DBusPyArray *)obj)->signature)) { -- PyString_Concat(&ret, ((DBusPyArray *)obj)->signature); -+#ifdef PY3 -+ if (DBusPyArray_Check(obj) && -+ PyUnicode_Check(((DBusPyArray *)obj)->signature)) -+ { -+ PyObject *concat = PyUnicode_Concat( -+ ret, ((DBusPyArray *)obj)->signature); -+ Py_CLEAR(ret); -+ return concat; -+ } -+#else -+ if (DBusPyArray_Check(obj) && -+ PyBytes_Check(((DBusPyArray *)obj)->signature)) -+ { -+ PyBytes_Concat(&ret, ((DBusPyArray *)obj)->signature); - return ret; - } -+#endif - if (PyList_GET_SIZE(obj) == 0) { - /* No items, so fail. Or should we guess "av"? */ - PyErr_SetString(PyExc_ValueError, "Unable to guess signature " -@@ -320,23 +365,46 @@ - tmp = PyList_GetItem(obj, 0); - tmp = _signature_string_from_pyobject(tmp, NULL); - if (!tmp) return NULL; -- PyString_ConcatAndDel(&ret, tmp); -+#ifdef PY3 -+ { -+ PyObject *concat = PyUnicode_Concat(ret, tmp); -+ Py_CLEAR(ret); -+ Py_CLEAR(tmp); -+ return concat; -+ } -+#else -+ PyBytes_ConcatAndDel(&ret, tmp); - return ret; -+#endif - } - else if (PyDict_Check(obj)) { - PyObject *key, *value, *keysig, *valuesig; - Py_ssize_t pos = 0; - PyObject *ret = NULL; - -- if (DBusPyDict_Check(obj) && PyString_Check(((DBusPyDict *)obj)->signature)) { -- const char *sig = PyString_AS_STRING(((DBusPyDict *)obj)->signature); -+#ifdef PY3 -+ if (DBusPyDict_Check(obj) && -+ PyUnicode_Check(((DBusPyDict *)obj)->signature)) -+ { -+ return PyUnicode_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -+ "%U" -+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -+ ((DBusPyDict *)obj)->signature); -+ } -+#else -+ if (DBusPyDict_Check(obj) && -+ PyBytes_Check(((DBusPyDict *)obj)->signature)) -+ { -+ const char *sig = PyBytes_AS_STRING(((DBusPyDict *)obj)->signature); - -- return PyString_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -- "%s" -- DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -- sig); -+ return PyBytes_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -+ "%s" -+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -+ sig); - } -+#endif - if (!PyDict_Next(obj, &pos, &key, &value)) { - /* No items, so fail. Or should we guess "a{vv}"? */ - PyErr_SetString(PyExc_ValueError, "Unable to guess signature " -@@ -346,19 +414,27 @@ - keysig = _signature_string_from_pyobject(key, NULL); - valuesig = _signature_string_from_pyobject(value, NULL); - if (keysig && valuesig) { -- ret = PyString_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -- "%s%s" -- DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -- PyString_AS_STRING(keysig), -- PyString_AS_STRING(valuesig)); -+#ifdef PY3 -+ ret = PyUnicode_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -+ "%U%U" -+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -+ keysig, valuesig); -+#else -+ ret = PyBytes_FromFormat((DBUS_TYPE_ARRAY_AS_STRING -+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING -+ "%s%s" -+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING), -+ PyBytes_AS_STRING(keysig), -+ PyBytes_AS_STRING(valuesig)); -+#endif - } - Py_CLEAR(keysig); - Py_CLEAR(valuesig); - return ret; - } - else { -- PyErr_Format(PyExc_TypeError, "Don't know how which D-Bus type " -+ PyErr_Format(PyExc_TypeError, "Don't know which D-Bus type " - "to use to encode type \"%s\"", - Py_TYPE(obj)->tp_name); - return NULL; -@@ -403,7 +479,21 @@ - DBG("%s", "Message_guess_signature: failed"); - return NULL; - } -- if (!PyString_Check(tmp) || PyString_GET_SIZE(tmp) < 2) { -+ if (PyUnicode_Check(tmp)) { -+ PyObject *as_bytes = PyUnicode_AsUTF8String(tmp); -+ Py_CLEAR(tmp); -+ if (!as_bytes) -+ return NULL; -+ if (PyBytes_GET_SIZE(as_bytes) < 2) { -+ PyErr_SetString(PyExc_RuntimeError, "Internal error: " -+ "_signature_string_from_pyobject returned " -+ "a bad result"); -+ Py_CLEAR(as_bytes); -+ return NULL; -+ } -+ tmp = as_bytes; -+ } -+ if (!PyBytes_Check(tmp) || PyBytes_GET_SIZE(tmp) < 2) { - PyErr_SetString(PyExc_RuntimeError, "Internal error: " - "_signature_string_from_pyobject returned " - "a bad result"); -@@ -411,10 +501,8 @@ - return NULL; - } - ret = PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s#)", -- PyString_AS_STRING(tmp) + 1, -- PyString_GET_SIZE(tmp) - 2); -- DBG("Message_guess_signature: returning Signature at %p \"%s\"", ret, -- ret ? PyString_AS_STRING(ret) : "(NULL)"); -+ PyBytes_AS_STRING(tmp) + 1, -+ PyBytes_GET_SIZE(tmp) - 2); - Py_CLEAR(tmp); - return ret; - } -@@ -450,13 +538,13 @@ - } - } - -- if (PyString_Check(obj)) { -+ if (PyBytes_Check(obj)) { - PyObject *unicode; - - /* Raise TypeError if the string has embedded NULs */ -- if (PyString_AsStringAndSize(obj, &s, NULL) < 0) return -1; -+ if (PyBytes_AsStringAndSize(obj, &s, NULL) < 0) return -1; - /* Surely there's a faster stdlib way to validate UTF-8... */ -- unicode = PyUnicode_DecodeUTF8(s, PyString_GET_SIZE(obj), NULL); -+ unicode = PyUnicode_DecodeUTF8(s, PyBytes_GET_SIZE(obj), NULL); - if (!unicode) { - PyErr_SetString(PyExc_UnicodeError, "String parameters " - "to be sent over D-Bus must be valid UTF-8"); -@@ -475,7 +563,7 @@ - PyObject *utf8 = PyUnicode_AsUTF8String(obj); - if (!utf8) return -1; - /* Raise TypeError if the string has embedded NULs */ -- if (PyString_AsStringAndSize(utf8, &s, NULL) < 0) return -1; -+ if (PyBytes_AsStringAndSize(utf8, &s, NULL) < 0) return -1; - DBG("Performing actual append: string (from unicode) %s", s); - if (!dbus_message_iter_append_basic(appender, sig_type, &s)) { - Py_CLEAR(utf8); -@@ -497,22 +585,24 @@ - { - unsigned char y; - -- if (PyString_Check(obj)) { -- if (PyString_GET_SIZE(obj) != 1) { -- PyErr_Format(PyExc_ValueError, "Expected a string of " -- "length 1 byte, but found %d bytes", -- (int) PyString_GET_SIZE(obj)); -+ if (PyBytes_Check(obj)) { -+ if (PyBytes_GET_SIZE(obj) != 1) { -+ PyErr_Format(PyExc_ValueError, -+ "Expected a length-1 bytes but found %d bytes", -+ (int)PyBytes_GET_SIZE(obj)); - return -1; - } -- y = *(unsigned char *)PyString_AS_STRING(obj); -+ y = *(unsigned char *)PyBytes_AS_STRING(obj); - } - else { -- long i = PyInt_AsLong(obj); -+ /* on Python 2 this accepts either int or long */ -+ long i = PyLong_AsLong(obj); - - if (i == -1 && PyErr_Occurred()) return -1; - if (i < 0 || i > 0xff) { -- PyErr_Format(PyExc_ValueError, "%d outside range for a " -- "byte value", (int)i); -+ PyErr_Format(PyExc_ValueError, -+ "%d outside range for a byte value", -+ (int)i); - return -1; - } - y = i; -@@ -542,12 +632,25 @@ - _message_iter_append_unixfd(DBusMessageIter *appender, PyObject *obj) - { - int fd; -+ long original_fd; - -- if (PyInt_Check(obj)) { -- fd = PyInt_AsLong(obj); -- } else if (PyObject_IsInstance(obj, (PyObject*) &DBusPyUnixFd_Type)) { -- fd = dbus_py_unix_fd_get_fd(obj); -- } else { -+ if (INTORLONG_CHECK(obj)) -+ { -+ /* on Python 2 this accepts either int or long */ -+ original_fd = PyLong_AsLong(obj); -+ if (original_fd == -1 && PyErr_Occurred()) -+ return -1; -+ if (original_fd < INT_MIN || original_fd > INT_MAX) { -+ PyErr_Format(PyExc_ValueError, "out of int range: %ld", -+ original_fd); -+ return -1; -+ } -+ fd = (int)original_fd; -+ } -+ else if (PyObject_IsInstance(obj, (PyObject*) &DBusPyUnixFd_Type)) { -+ fd = dbus_py_unix_fd_get_fd(obj); -+ } -+ else { - return -1; - } - -@@ -766,12 +869,12 @@ - PyObject *obj) - { - /* a bit of a faster path for byte arrays that are strings */ -- Py_ssize_t len = PyString_GET_SIZE(obj); -+ Py_ssize_t len = PyBytes_GET_SIZE(obj); - const char *s; - DBusMessageIter sub; - int ret; - -- s = PyString_AS_STRING(obj); -+ s = PyBytes_AS_STRING(obj); - DBG("%s", "Opening ARRAY container"); - if (!dbus_message_iter_open_container(appender, DBUS_TYPE_ARRAY, - DBUS_TYPE_BYTE_AS_STRING, &sub)) { -@@ -810,8 +913,18 @@ - obj_sig = _signature_string_from_pyobject(obj, &variant_level); - if (!obj_sig) return -1; - -- obj_sig_str = PyString_AsString(obj_sig); -- if (!obj_sig_str) return -1; -+ if (PyUnicode_Check(obj_sig)) { -+ PyObject *obj_sig_as_bytes = PyUnicode_AsUTF8String(obj_sig); -+ Py_CLEAR(obj_sig); -+ if (!obj_sig_as_bytes) -+ return -1; -+ obj_sig = obj_sig_as_bytes; -+ } -+ obj_sig_str = PyBytes_AsString(obj_sig); -+ if (!obj_sig_str) { -+ Py_CLEAR(obj_sig); -+ return -1; -+ } - - if (variant_level < 1) { - variant_level = 1; -@@ -1028,7 +1141,7 @@ - if (sig_type == DBUS_TYPE_DICT_ENTRY) - ret = _message_iter_append_multi(appender, sig_iter, - DBUS_TYPE_DICT_ENTRY, obj); -- else if (sig_type == DBUS_TYPE_BYTE && PyString_Check(obj)) -+ else if (sig_type == DBUS_TYPE_BYTE && PyBytes_Check(obj)) - ret = _message_iter_append_string_as_byte_array(appender, obj); - else - ret = _message_iter_append_multi(appender, sig_iter, -@@ -1105,7 +1218,18 @@ - DBG("%s", "No signature for message, guessing..."); - signature_obj = dbus_py_Message_guess_signature(NULL, args); - if (!signature_obj) return NULL; -- signature = PyString_AS_STRING(signature_obj); -+ if (PyUnicode_Check(signature_obj)) { -+ PyObject *signature_as_bytes; -+ signature_as_bytes = PyUnicode_AsUTF8String(signature_obj); -+ Py_CLEAR(signature_obj); -+ if (!signature_as_bytes) -+ return NULL; -+ signature_obj = signature_as_bytes; -+ } -+ else { -+ assert(PyBytes_Check(signature_obj)); -+ } -+ signature = PyBytes_AS_STRING(signature_obj); - } - /* from here onwards, you have to do a goto rather than returning NULL - to make sure signature_obj gets freed */ ---- a/_dbus_bindings/message-get-args.c -+++ b/_dbus_bindings/message-get-args.c -@@ -42,9 +42,11 @@ - " it's off by default for consistency.\n" - "\n" - " If false (default), convert them into a dbus.Array of Bytes.\n" -+#ifndef PY3 - " `utf8_strings` : bool\n" - " If true, return D-Bus strings as Python 8-bit strings (of UTF-8).\n" - " If false (default), return D-Bus strings as Python unicode objects.\n" -+#endif - "\n" - "Most of the type mappings should be fairly obvious:\n" - "\n" -@@ -70,7 +72,9 @@ - - typedef struct { - int byte_arrays; -+#ifndef PY3 - int utf8_strings; -+#endif - } Message_get_args_options; - - static PyObject *_message_iter_get_pyobject(DBusMessageIter *iter, -@@ -213,7 +217,7 @@ - if (variant_level > 0 && type != DBUS_TYPE_VARIANT) { - PyObject *variant_level_int; - -- variant_level_int = PyInt_FromLong(variant_level); -+ variant_level_int = NATIVEINT_FROMLONG(variant_level); - if (!variant_level_int) { - return NULL; - } -@@ -235,9 +239,12 @@ - */ - - switch (type) { -+ PyObject *unicode; -+ - case DBUS_TYPE_STRING: - DBG("%s", "found a string"); - dbus_message_iter_get_basic(iter, &u.s); -+#ifndef PY3 - if (opts->utf8_strings) { - args = Py_BuildValue("(s)", u.s); - if (!args) break; -@@ -245,8 +252,7 @@ - args, kwargs); - } - else { -- PyObject *unicode; -- -+#endif - unicode = PyUnicode_DecodeUTF8(u.s, strlen(u.s), NULL); - if (!unicode) { - break; -@@ -257,7 +263,9 @@ - } - ret = PyObject_Call((PyObject *)&DBusPyString_Type, - args, kwargs); -+#ifndef PY3 - } -+#endif - break; - - case DBUS_TYPE_SIGNATURE: -@@ -412,7 +420,11 @@ - * for an empty byte-blob... */ - u.s = ""; - } -+#ifdef PY3 -+ args = Py_BuildValue("(y#)", u.s, (Py_ssize_t)n); -+#else - args = Py_BuildValue("(s#)", u.s, (Py_ssize_t)n); -+#endif - if (!args) break; - ret = PyObject_Call((PyObject *)&DBusPyByteArray_Type, - args, kwargs); -@@ -496,8 +508,13 @@ - PyObject * - dbus_py_Message_get_args_list(Message *self, PyObject *args, PyObject *kwargs) - { -+#ifdef PY3 -+ Message_get_args_options opts = { 0 }; -+ static char *argnames[] = { "byte_arrays", NULL }; -+#else - Message_get_args_options opts = { 0, 0 }; - static char *argnames[] = { "byte_arrays", "utf8_strings", NULL }; -+#endif - PyObject *list; - DBusMessageIter iter; - -@@ -517,10 +534,16 @@ - "arguments"); - return NULL; - } -+#ifdef PY3 -+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:get_args_list", -+ argnames, -+ &(opts.byte_arrays))) return NULL; -+#else - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii:get_args_list", - argnames, - &(opts.byte_arrays), - &(opts.utf8_strings))) return NULL; -+#endif - if (!self->msg) return DBusPy_RaiseUnusableMessage(); - - list = PyList_New(0); ---- a/_dbus_bindings/message.c -+++ b/_dbus_bindings/message.c -@@ -69,6 +69,30 @@ - return (PyObject *)self; - } - -+static PyObject * -+MethodCallMessage_tp_repr(PyObject *self) -+{ -+ DBusMessage *msg = ((Message *)self)->msg; -+ const char *destination = dbus_message_get_destination(msg); -+ const char *path = dbus_message_get_path(msg); -+ const char *interface = dbus_message_get_interface(msg); -+ const char *member = dbus_message_get_member(msg); -+ -+ if (!path) -+ path = "n/a"; -+ if (!interface) -+ interface = "n/a"; -+ if (!member) -+ member = "n/a"; -+ if (!destination) -+ destination = "n/a"; -+ -+ return PyUnicode_FromFormat( -+ "<%s path: %s, iface: %s, member: %s dest: %s>", -+ Py_TYPE(self)->tp_name, -+ path, interface, member, destination); -+} -+ - PyDoc_STRVAR(MethodCallMessage_tp_doc, "A method-call message.\n" - "\n" - "Constructor::\n" -@@ -169,6 +193,29 @@ - return 0; - } - -+static PyObject * -+SignalMessage_tp_repr(PyObject *self) -+{ -+ DBusMessage *msg = ((Message *)self)->msg; -+ const char *path = dbus_message_get_path(msg); -+ const char *interface = dbus_message_get_interface(msg); -+ const char *member = dbus_message_get_member(msg); -+ const char *destination = dbus_message_get_destination(msg); -+ -+ if (!path) -+ path = "n/a"; -+ if (!interface) -+ interface = "n/a"; -+ if (!member) -+ member = "n/a"; -+ if (!destination) -+ destination = "(broadcast)"; -+ -+ return PyUnicode_FromFormat("<%s path: %s, iface: %s, member: %s, dest: %s>", -+ Py_TYPE(self)->tp_name, -+ path, interface, member, destination); -+} -+ - PyDoc_STRVAR(ErrorMessage_tp_doc, "An error message.\n\n" - "Constructor::\n\n" - " dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n" -@@ -341,7 +388,7 @@ - Message_get_type(Message *self, PyObject *unused UNUSED) - { - if (!self->msg) return DBusPy_RaiseUnusableMessage(); -- return PyInt_FromLong(dbus_message_get_type(self->msg)); -+ return NATIVEINT_FROMLONG(dbus_message_get_type(self->msg)); - } - - PyDoc_STRVAR(Message_get_serial__doc__, -@@ -415,7 +462,7 @@ - if (!c_str) { - Py_RETURN_NONE; - } -- return PyString_FromString(c_str); -+ return NATIVESTR_FROMSTR(c_str); - } - - PyDoc_STRVAR(Message_has_member__doc__, -@@ -490,7 +537,7 @@ - Py_RETURN_NONE; - } - for (ptr = paths; *ptr; ptr++) { -- PyObject *str = PyString_FromString(*ptr); -+ PyObject *str = NATIVESTR_FROMSTR(*ptr); - - if (!str) { - Py_CLEAR(ret); -@@ -576,7 +623,7 @@ - if (!c_str) { - Py_RETURN_NONE; - } -- return PyString_FromString(c_str); -+ return NATIVESTR_FROMSTR(c_str); - } - - PyDoc_STRVAR(Message_has_sender__doc__, -@@ -622,7 +669,7 @@ - if (!c_str) { - Py_RETURN_NONE; - } -- return PyString_FromString(c_str); -+ return NATIVESTR_FROMSTR(c_str); - } - - PyDoc_STRVAR(Message_has_destination__doc__, -@@ -667,7 +714,7 @@ - if (!c_str) { - Py_RETURN_NONE; - } -- return PyString_FromString(c_str); -+ return NATIVESTR_FROMSTR(c_str); - } - - PyDoc_STRVAR(Message_has_interface__doc__, -@@ -712,7 +759,7 @@ - if (!c_str) { - Py_RETURN_NONE; - } -- return PyString_FromString(c_str); -+ return NATIVESTR_FROMSTR(c_str); - } - - PyDoc_STRVAR(Message_set_error_name__doc__, -@@ -808,8 +855,7 @@ - }; - - static PyTypeObject MessageType = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.lowlevel.Message", /*tp_name*/ - sizeof(Message), /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -850,8 +896,7 @@ - }; - - static PyTypeObject MethodCallMessageType = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.lowlevel.MethodCallMessage", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -860,7 +905,7 @@ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ -- 0, /*tp_repr*/ -+ MethodCallMessage_tp_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ -@@ -892,8 +937,7 @@ - }; - - static PyTypeObject MethodReturnMessageType = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.lowlevel.MethodReturnMessage", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -934,8 +978,7 @@ - }; - - static PyTypeObject SignalMessageType = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.lowlevel.SignalMessage", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -944,7 +987,7 @@ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ -- 0, /*tp_repr*/ -+ SignalMessage_tp_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ -@@ -976,8 +1019,7 @@ - }; - - static PyTypeObject ErrorMessageType = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.lowlevel.ErrorMessage", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ ---- a/_dbus_bindings/module.c -+++ b/_dbus_bindings/module.c -@@ -234,80 +234,108 @@ - }; - - PyMODINIT_FUNC -+#ifdef PY3 -+PyInit__dbus_bindings(void) -+#else - init_dbus_bindings(void) -+#endif - { -- PyObject *this_module, *c_api; -+ PyObject *this_module = NULL, *c_api; - static const int API_count = DBUS_BINDINGS_API_COUNT; - static _dbus_py_func_ptr dbus_bindings_API[DBUS_BINDINGS_API_COUNT]; - -+#ifdef PY3 -+ static struct PyModuleDef moduledef = { -+ PyModuleDef_HEAD_INIT, -+ "_dbus_bindings", /* m_name */ -+ module_doc, /* m_doc */ -+ -1, /* m_size */ -+ module_functions, /* m_methods */ -+ NULL, /* m_reload */ -+ NULL, /* m_traverse */ -+ NULL, /* m_clear */ -+ NULL /* m_free */ -+ }; -+#endif -+ - dbus_bindings_API[0] = (_dbus_py_func_ptr)&API_count; - dbus_bindings_API[1] = (_dbus_py_func_ptr)DBusPyConnection_BorrowDBusConnection; - dbus_bindings_API[2] = (_dbus_py_func_ptr)DBusPyNativeMainLoop_New4; - - default_main_loop = NULL; - -- if (!dbus_py_init_generic()) return; -- if (!dbus_py_init_abstract()) return; -- if (!dbus_py_init_signature()) return; -- if (!dbus_py_init_int_types()) return; -- if (!dbus_py_init_unixfd_type()) return; -- if (!dbus_py_init_string_types()) return; -- if (!dbus_py_init_float_types()) return; -- if (!dbus_py_init_container_types()) return; -- if (!dbus_py_init_byte_types()) return; -- if (!dbus_py_init_message_types()) return; -- if (!dbus_py_init_pending_call()) return; -- if (!dbus_py_init_mainloop()) return; -- if (!dbus_py_init_libdbus_conn_types()) return; -- if (!dbus_py_init_conn_types()) return; -- if (!dbus_py_init_server_types()) return; -- -- this_module = Py_InitModule3("_dbus_bindings", module_functions, module_doc); -- if (!this_module) return; -- -- if (!dbus_py_insert_abstract_types(this_module)) return; -- if (!dbus_py_insert_signature(this_module)) return; -- if (!dbus_py_insert_int_types(this_module)) return; -- if (!dbus_py_insert_unixfd_type(this_module)) return; -- if (!dbus_py_insert_string_types(this_module)) return; -- if (!dbus_py_insert_float_types(this_module)) return; -- if (!dbus_py_insert_container_types(this_module)) return; -- if (!dbus_py_insert_byte_types(this_module)) return; -- if (!dbus_py_insert_message_types(this_module)) return; -- if (!dbus_py_insert_pending_call(this_module)) return; -- if (!dbus_py_insert_mainloop_types(this_module)) return; -- if (!dbus_py_insert_libdbus_conn_types(this_module)) return; -- if (!dbus_py_insert_conn_types(this_module)) return; -- if (!dbus_py_insert_server_types(this_module)) return; -+ if (!dbus_py_init_generic()) goto init_error; -+ if (!dbus_py_init_abstract()) goto init_error; -+ if (!dbus_py_init_signature()) goto init_error; -+ if (!dbus_py_init_int_types()) goto init_error; -+ if (!dbus_py_init_unixfd_type()) goto init_error; -+ if (!dbus_py_init_string_types()) goto init_error; -+ if (!dbus_py_init_float_types()) goto init_error; -+ if (!dbus_py_init_container_types()) goto init_error; -+ if (!dbus_py_init_byte_types()) goto init_error; -+ if (!dbus_py_init_message_types()) goto init_error; -+ if (!dbus_py_init_pending_call()) goto init_error; -+ if (!dbus_py_init_mainloop()) goto init_error; -+ if (!dbus_py_init_libdbus_conn_types()) goto init_error; -+ if (!dbus_py_init_conn_types()) goto init_error; -+ if (!dbus_py_init_server_types()) goto init_error; -+ -+#ifdef PY3 -+ this_module = PyModule_Create(&moduledef); -+#else -+ this_module = Py_InitModule3("_dbus_bindings", -+ module_functions, module_doc); -+#endif -+ if (!this_module) goto init_error; -+ -+ if (!dbus_py_insert_abstract_types(this_module)) goto init_error; -+ if (!dbus_py_insert_signature(this_module)) goto init_error; -+ if (!dbus_py_insert_int_types(this_module)) goto init_error; -+ if (!dbus_py_insert_unixfd_type(this_module)) goto init_error; -+ if (!dbus_py_insert_string_types(this_module)) goto init_error; -+ if (!dbus_py_insert_float_types(this_module)) goto init_error; -+ if (!dbus_py_insert_container_types(this_module)) goto init_error; -+ if (!dbus_py_insert_byte_types(this_module)) goto init_error; -+ if (!dbus_py_insert_message_types(this_module)) goto init_error; -+ if (!dbus_py_insert_pending_call(this_module)) goto init_error; -+ if (!dbus_py_insert_mainloop_types(this_module)) goto init_error; -+ if (!dbus_py_insert_libdbus_conn_types(this_module)) goto init_error; -+ if (!dbus_py_insert_conn_types(this_module)) goto init_error; -+ if (!dbus_py_insert_server_types(this_module)) goto init_error; - - if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_NAME", -- DBUS_SERVICE_DBUS) < 0) return; -+ DBUS_SERVICE_DBUS) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_PATH", -- DBUS_PATH_DBUS) < 0) return; -+ DBUS_PATH_DBUS) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_IFACE", -- DBUS_INTERFACE_DBUS) < 0) return; -+ DBUS_INTERFACE_DBUS) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "LOCAL_PATH", -- DBUS_PATH_LOCAL) < 0) return; -+ DBUS_PATH_LOCAL) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "LOCAL_IFACE", -- DBUS_INTERFACE_LOCAL) < 0) return; -+ DBUS_INTERFACE_LOCAL) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "INTROSPECTABLE_IFACE", -- DBUS_INTERFACE_INTROSPECTABLE) < 0) return; -+ DBUS_INTERFACE_INTROSPECTABLE) < 0) -+ goto init_error; - if (PyModule_AddStringConstant(this_module, "PEER_IFACE", -- DBUS_INTERFACE_PEER) < 0) return; -+ DBUS_INTERFACE_PEER) < 0) goto init_error; - if (PyModule_AddStringConstant(this_module, "PROPERTIES_IFACE", -- DBUS_INTERFACE_PROPERTIES) < 0) return; -+ DBUS_INTERFACE_PROPERTIES) < 0) -+ goto init_error; - if (PyModule_AddStringConstant(this_module, - "DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER", -- DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER) < 0) return; -+ DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER) < 0) -+ goto init_error; - if (PyModule_AddStringConstant(this_module, - "DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER", -- DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER) < 0) return; -+ DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER) < 0) -+ goto init_error; - if (PyModule_AddStringConstant(this_module, - "DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE", -- DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE) < 0) return; -+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE) < 0) -+ goto init_error; - - #define ADD_CONST_VAL(x, v) \ -- if (PyModule_AddIntConstant(this_module, x, v) < 0) return; -+ if (PyModule_AddIntConstant(this_module, x, v) < 0) goto init_error; - #define ADD_CONST_PREFIXED(x) ADD_CONST_VAL(#x, DBUS_##x) - #define ADD_CONST(x) ADD_CONST_VAL(#x, x) - -@@ -372,19 +400,34 @@ - ADD_CONST_PREFIXED(WATCH_ERROR) - - if (PyModule_AddStringConstant(this_module, "__docformat__", -- "restructuredtext") < 0) return; -+ "restructuredtext") < 0) goto init_error; - - if (PyModule_AddStringConstant(this_module, "__version__", -- PACKAGE_VERSION) < 0) return; -+ PACKAGE_VERSION) < 0) goto init_error; - - if (PyModule_AddIntConstant(this_module, "_python_version", -- PY_VERSION_HEX) < 0) return; -+ PY_VERSION_HEX) < 0) goto init_error; - -+#ifdef PY3 -+ c_api = PyCapsule_New((void *)dbus_bindings_API, -+ PYDBUS_CAPSULE_NAME, NULL); -+#else - c_api = PyCObject_FromVoidPtr ((void *)dbus_bindings_API, NULL); -+#endif - if (!c_api) { -- return; -+ goto init_error; - } - PyModule_AddObject(this_module, "_C_API", c_api); -+ -+#ifdef PY3 -+ return this_module; -+ init_error: -+ Py_CLEAR(this_module); -+ return NULL; -+#else -+ init_error: -+ return; -+#endif - } - - /* vim:set ft=c cino< sw=4 sts=4 et: */ ---- a/_dbus_bindings/server.c -+++ b/_dbus_bindings/server.c -@@ -85,7 +85,7 @@ - DBusPyServer_set_auth_mechanisms(Server *self, - PyObject *auth_mechanisms) - { -- PyObject *fast_seq; -+ PyObject *fast_seq = NULL, *references = NULL; - Py_ssize_t length; - Py_ssize_t i; - -@@ -101,16 +101,29 @@ - { - const char *list[length + 1]; - -+ if (!(references = PyTuple_New(length))) -+ goto error; -+ - for (i = 0; i < length; ++i) { -- PyObject *am; -+ PyObject *am, *am_as_bytes; - - am = PySequence_Fast_GET_ITEM(auth_mechanisms, i); -- /* this supports either str or unicode, raising TypeError -- * on failure */ -- list[i] = PyString_AsString(am); -+ if (!am) goto error; - -+ if (PyUnicode_Check(am)) { -+ am_as_bytes = PyUnicode_AsUTF8String(am); -+ if (!am_as_bytes) -+ goto error; -+ } -+ else { -+ am_as_bytes = am; -+ Py_INCREF(am_as_bytes); -+ } -+ list[i] = PyBytes_AsString(am_as_bytes); - if (!list[i]) -- return FALSE; -+ goto error; -+ -+ PyTuple_SET_ITEM(references, i, am_as_bytes); - } - - list[length] = NULL; -@@ -120,7 +133,13 @@ - Py_END_ALLOW_THREADS - } - -+ Py_CLEAR(fast_seq); -+ Py_CLEAR(references); - return TRUE; -+ error: -+ Py_CLEAR(fast_seq); -+ Py_CLEAR(references); -+ return FALSE; - } - - /* Return a new reference to a Python Server or subclass corresponding -@@ -385,6 +404,7 @@ - - self = DBusPyServer_NewConsumingDBusServer(cls, server, conn_class, - mainloop, auth_mechanisms); -+ ((Server *)self)->weaklist = NULL; - TRACE(self); - - return self; -@@ -462,7 +482,7 @@ - address = dbus_server_get_address(self->server); - Py_END_ALLOW_THREADS - -- return PyString_FromString(address); -+ return NATIVESTR_FROMSTR(address); - } - - PyDoc_STRVAR(Server_get_id__doc__, -@@ -479,7 +499,7 @@ - id = dbus_server_get_id(self->server); - Py_END_ALLOW_THREADS - -- return PyString_FromString(id); -+ return NATIVESTR_FROMSTR(id); - } - - PyDoc_STRVAR(Server_get_is_connected__doc__, -@@ -511,8 +531,7 @@ - }; - - PyTypeObject DBusPyServer_Type = { -- PyObject_HEAD_INIT(NULL) -- 0, /*ob_size*/ -+ PyVarObject_HEAD_INIT(NULL, 0) - "_dbus_bindings._Server",/*tp_name*/ - sizeof(Server), /*tp_basicsize*/ - 0, /*tp_itemsize*/ -@@ -532,7 +551,11 @@ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ -+#ifdef PY3 -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, -+#else - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_BASETYPE, -+#endif - Server_tp_doc, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ ---- a/_dbus_bindings/signature.c -+++ b/_dbus_bindings/signature.c -@@ -55,14 +55,14 @@ - - typedef struct { - PyObject_HEAD -- PyObject *string; -+ PyObject *bytes; - DBusSignatureIter iter; - } SignatureIter; - - static void - SignatureIter_tp_dealloc (SignatureIter *self) - { -- Py_CLEAR(self->string); -+ Py_CLEAR(self->bytes); - PyObject_Del(self); - } - -@@ -73,7 +73,7 @@ - PyObject *obj; - - /* Stop immediately if finished or not correctly initialized */ -- if (!self->string) return NULL; -+ if (!self->bytes) return NULL; - - sig = dbus_signature_iter_get_signature(&(self->iter)); - if (!sig) return PyErr_NoMemory(); -@@ -83,7 +83,7 @@ - - if (!dbus_signature_iter_next(&(self->iter))) { - /* mark object as having been finished with */ -- Py_CLEAR(self->string); -+ Py_CLEAR(self->bytes); - } - - return obj; -@@ -140,19 +140,33 @@ - }; - - static PyObject * --Signature_tp_iter (PyObject *self) -+Signature_tp_iter(PyObject *self) - { - SignatureIter *iter = PyObject_New(SignatureIter, &SignatureIterType); -+ PyObject *self_as_bytes; -+ - if (!iter) return NULL; - -- if (PyString_AS_STRING (self)[0]) { -- Py_INCREF(self); -- iter->string = self; -- dbus_signature_iter_init(&(iter->iter), PyString_AS_STRING(self)); -+#ifdef PY3 -+ self_as_bytes = PyUnicode_AsUTF8String(self); -+ if (!self_as_bytes) { -+ Py_CLEAR(iter); -+ return NULL; -+ } -+#else -+ self_as_bytes = self; -+ Py_INCREF(self_as_bytes); -+#endif -+ -+ if (PyBytes_GET_SIZE(self_as_bytes) > 0) { -+ iter->bytes = self_as_bytes; -+ dbus_signature_iter_init(&(iter->iter), -+ PyBytes_AS_STRING(self_as_bytes)); - } - else { - /* this is a null string, make a null iterator */ -- iter->string = NULL; -+ iter->bytes = NULL; -+ Py_CLEAR(self_as_bytes); - } - return (PyObject *)iter; - } -@@ -204,7 +218,7 @@ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -- DEFERRED_ADDRESS(&DBusPythonStringType), /* tp_base */ -+ DEFERRED_ADDRESS(&DBusPyStrBase_Type), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ ---- a/_dbus_bindings/string.c -+++ b/_dbus_bindings/string.c -@@ -26,6 +26,7 @@ - #include "types-internal.h" - #include - -+#ifndef PY3 - /* UTF-8 string representation ====================================== */ - - PyDoc_STRVAR(UTF8String_tp_doc, -@@ -121,6 +122,7 @@ - 0, /* tp_alloc */ - UTF8String_tp_new, /* tp_new */ - }; -+#endif /* !PY3 */ - - /* Object path ====================================================== */ - -@@ -273,14 +275,14 @@ - return NULL; - } - if (((DBusPyString *)self)->variant_level > 0) { -- my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr), -- ((DBusPyString *)self)->variant_level); -+ my_repr = PyUnicode_FromFormat("%s(%V, variant_level=%ld)", -+ Py_TYPE(self)->tp_name, -+ REPRV(parent_repr), -+ ((DBusPyString *)self)->variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, -- PyString_AS_STRING(parent_repr)); -+ my_repr = PyUnicode_FromFormat("%s(%V)", Py_TYPE(self)->tp_name, -+ REPRV(parent_repr)); - } - /* whether my_repr is NULL or not: */ - Py_CLEAR(parent_repr); -@@ -343,18 +345,16 @@ - if (PyType_Ready(&DBusPyString_Type) < 0) return 0; - DBusPyString_Type.tp_print = NULL; - -+#ifndef PY3 - DBusPyUTF8String_Type.tp_base = &DBusPyStrBase_Type; - if (PyType_Ready(&DBusPyUTF8String_Type) < 0) return 0; - DBusPyUTF8String_Type.tp_print = NULL; -+#endif - - DBusPyObjectPath_Type.tp_base = &DBusPyStrBase_Type; - if (PyType_Ready(&DBusPyObjectPath_Type) < 0) return 0; - DBusPyObjectPath_Type.tp_print = NULL; - -- DBusPyBoolean_Type.tp_base = &DBusPyIntBase_Type; -- if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; -- DBusPyBoolean_Type.tp_print = NULL; -- - return 1; - } - -@@ -363,15 +363,18 @@ - { - /* PyModule_AddObject steals a ref */ - Py_INCREF(&DBusPyObjectPath_Type); -- Py_INCREF(&DBusPyUTF8String_Type); - Py_INCREF(&DBusPyString_Type); - if (PyModule_AddObject(this_module, "ObjectPath", - (PyObject *)&DBusPyObjectPath_Type) < 0) return 0; -- if (PyModule_AddObject(this_module, "UTF8String", -- (PyObject *)&DBusPyUTF8String_Type) < 0) return 0; - if (PyModule_AddObject(this_module, "String", - (PyObject *)&DBusPyString_Type) < 0) return 0; - -+#ifndef PY3 -+ Py_INCREF(&DBusPyUTF8String_Type); -+ if (PyModule_AddObject(this_module, "UTF8String", -+ (PyObject *)&DBusPyUTF8String_Type) < 0) return 0; -+#endif -+ - return 1; - } - ---- a/_dbus_bindings/types-internal.h -+++ b/_dbus_bindings/types-internal.h -@@ -26,11 +26,23 @@ - #include - #include - -+/* In Python2 >= 2.6 this aliases PyString to PyBytes. There is no PyString -+ * in Python 3, so this allows the C extension to be compilable in both Python -+ * versions. -+ */ -+#include -+ -+/* In Python 2.x, we need this to define the type of PyLongObject */ -+#ifndef PY3 -+#include -+#endif -+ - #include "dbus_bindings-internal.h" - - #ifndef DBUS_BINDINGS_TYPES_INTERNAL_H - #define DBUS_BINDINGS_TYPES_INTERNAL_H - -+#ifndef PY3 - extern PyTypeObject DBusPyIntBase_Type; - DEFINE_CHECK(DBusPyIntBase) - -@@ -38,6 +50,7 @@ - PyIntObject base; - long variant_level; - } DBusPyIntBase; -+#endif - - extern PyTypeObject DBusPyLongBase_Type; - DEFINE_CHECK(DBusPyLongBase) -@@ -58,6 +71,11 @@ - extern PyTypeObject DBusPyStrBase_Type; - DEFINE_CHECK(DBusPyStrBase) - -+#ifdef PY3 -+extern PyTypeObject DBusPyBytesBase_Type; -+DEFINE_CHECK(DBusPyBytesBase) -+#endif -+ - dbus_int16_t dbus_py_int16_range_check(PyObject *); - dbus_uint16_t dbus_py_uint16_range_check(PyObject *); - dbus_int32_t dbus_py_int32_range_check(PyObject *); ---- a/_dbus_bindings/unixfd.c -+++ b/_dbus_bindings/unixfd.c -@@ -55,49 +55,83 @@ - int fd; - } UnixFdObject; - -+/* Return values: -+ * -2 - the long value overflows an int -+ * -1 - Python failed producing a long (or in Python 2 an int) -+ * 0 - success -+ * 1 - arg is not a long (or in Python 2 an int) -+ * -+ * Or to summarize: -+ * status < 0 - an error occurred, and a Python exception is set. -+ * status == 0 - all is okay, output argument *fd is set. -+ * status > 0 - try something else -+ */ -+static int -+make_fd(PyObject *arg, int *fd) -+{ -+ long fd_arg; -+ -+ if (INTORLONG_CHECK(arg)) -+ { -+ /* on Python 2 this accepts either int or long */ -+ fd_arg = PyLong_AsLong(arg); -+ if (fd_arg == -1 && PyErr_Occurred()) { -+ return -1; -+ } -+ } -+ else { -+ return 1; -+ } -+ /* Check for int overflow. */ -+ if (fd_arg < INT_MIN || fd_arg > INT_MAX) { -+ PyErr_Format(PyExc_ValueError, "int is outside fd range"); -+ return -2; -+ } -+ *fd = (int)fd_arg; -+ return 0; -+} -+ - static PyObject * - UnixFd_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs UNUSED) - { - UnixFdObject *self = NULL; - PyObject *arg; -- PyObject *fdnumber; -- int fd_original, fd; -+ int status, fd, fd_original = -1; - -- if (! PyArg_ParseTuple(args, "O", &arg, NULL)) { -+ if (!PyArg_ParseTuple(args, "O", &arg, NULL)) { - return NULL; - } - -- if (PyInt_Check(arg)) { -- fd_original = PyInt_AsLong(arg); -- fd = dup(fd_original); -- if (fd < 0) { -- PyErr_Format(PyExc_ValueError, "Invalid file descriptor"); -- return NULL; -- } -+ status = make_fd(arg, &fd_original); -+ if (status < 0) -+ return NULL; - -- } else if (PyObject_HasAttrString(arg, "fileno")) { -- fdnumber = PyObject_CallMethod(arg, "fileno", NULL); -- if (! fdnumber) { -- PyErr_Format(PyExc_ValueError, "Argument's fileno() method " -- "is not callable"); -- return NULL; -- } -- if (! PyInt_Check(fdnumber)) { -- PyErr_Format(PyExc_ValueError, "Argument's fileno() method " -- "returned a non-int value"); -- return NULL; -+ if (status > 0) { -+ if (PyObject_HasAttrString(arg, "fileno")) { -+ PyObject *fd_number = PyObject_CallMethod(arg, "fileno", NULL); -+ if (!fd_number) -+ return NULL; -+ status = make_fd(fd_number, &fd_original); -+ Py_CLEAR(fd_number); -+ if (status < 0) -+ return NULL; -+ if (status > 0) { -+ PyErr_Format(PyExc_ValueError, "Argument's fileno() method " -+ "returned a non-int value"); -+ return NULL; -+ } -+ /* fd_original is all good. */ - } -- fd_original = PyInt_AsLong(fdnumber); -- Py_DECREF(fdnumber); -- fd = dup(fd_original); -- if (fd < 0) { -- PyErr_Format(PyExc_ValueError, "Invalid file descriptor from fileno()"); -+ else { -+ PyErr_Format(PyExc_ValueError, "Argument is not int and does not " -+ "implement fileno() method"); - return NULL; - } -- -- } else { -- PyErr_Format(PyExc_ValueError, "Argument is not int and does not " -- "implement fileno() method"); -+ } -+ assert(fd_original >= 0); -+ fd = dup(fd_original); -+ if (fd < 0) { -+ PyErr_Format(PyExc_ValueError, "Invalid file descriptor"); - return NULL; - } - -@@ -106,8 +140,7 @@ - return NULL; - - self->fd = fd; -- -- return (PyObject *) self; -+ return (PyObject *)self; - } - - static void ---- a/_dbus_glib_bindings/Makefile.am -+++ b/_dbus_glib_bindings/Makefile.am -@@ -3,7 +3,7 @@ - AM_CPPFLAGS = -I$(top_srcdir)/include $(DBUS_CFLAGS) $(DBUS_GLIB_CFLAGS) \ - $(PYTHON_INCLUDES) - AM_LDFLAGS = -module -avoid-version \ -- -export-symbols-regex init_dbus_glib_bindings \ -+ -export-symbols-regex \(PyInit__\|init_\)dbus_glib_bindings \ - $(DBUS_LIBS) $(DBUS_GLIB_LIBS) - - _dbus_glib_bindings_la_SOURCES = module.c ---- a/_dbus_glib_bindings/module.c -+++ b/_dbus_glib_bindings/module.c -@@ -28,7 +28,11 @@ - #include - #include - -+#ifdef PY3 -+PyMODINIT_FUNC PyInit__dbus_glib_bindings(void); -+#else - PyMODINIT_FUNC init_dbus_glib_bindings(void); -+#endif - - #if defined(__GNUC__) - # if __GNUC__ >= 3 -@@ -170,6 +174,33 @@ - {NULL, NULL, 0, NULL} - }; - -+#ifdef PY3 -+PyMODINIT_FUNC -+PyInit__dbus_glib_bindings(void) -+{ -+ PyObject *this_module; -+ -+ static struct PyModuleDef moduledef = { -+ PyModuleDef_HEAD_INIT, -+ "_dbus_glib_bindings", /* m_name */ -+ module_doc, /* m_doc */ -+ -1, /* m_size */ -+ module_functions, /* m_methods */ -+ NULL, /* m_reload */ -+ NULL, /* m_traverse */ -+ NULL, /* m_clear */ -+ NULL /* m_free */ -+ }; -+ -+ if (import_dbus_bindings("_dbus_glib_bindings") < 0) -+ return NULL; -+ -+ if (!(this_module = PyModule_Create(&moduledef))) { -+ return NULL; -+ } -+ return this_module; -+} -+#else - PyMODINIT_FUNC - init_dbus_glib_bindings(void) - { -@@ -180,5 +211,6 @@ - module_doc); - if (!this_module) return; - } -+#endif - - /* vim:set ft=c cino< sw=4 sts=4 et: */ ---- a/configure.ac -+++ b/configure.ac -@@ -50,7 +50,7 @@ - - AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) - --PLATFORM=`$PYTHON -c "from distutils import util; print util.get_platform()"` -+PLATFORM=`$PYTHON -c "from __future__ import print_function; from distutils import util; print(util.get_platform())"` - AC_SUBST(PLATFORM) - - AC_ARG_VAR([PYTHON_LIBS], [LDFLAGS for Python, overriding output of python2.x-config --ldflags, e.g. "-L/opt/misc/lib -lpython2.7"]) ---- a/dbus/__init__.py -+++ b/dbus/__init__.py -@@ -34,9 +34,7 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --import os -- --__all__ = ( -+__all__ = [ - # from _dbus - 'Bus', 'SystemBus', 'SessionBus', 'StarterBus', - -@@ -56,7 +54,7 @@ - - 'ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', - 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', -- 'Double', 'String', 'Array', 'Struct', 'Dictionary', 'UTF8String', -+ 'Double', 'String', 'Array', 'Struct', 'Dictionary', - - # from exceptions - 'DBusException', -@@ -66,7 +64,12 @@ - - # submodules - 'service', 'mainloop', 'lowlevel' -- ) -+ ] -+ -+from dbus._compat import is_py2 -+if is_py2: -+ __all__.append('UTF8String') -+ - __docformat__ = 'restructuredtext' - - try: -@@ -78,24 +81,24 @@ - import dbus.exceptions as exceptions - import dbus.types as types - --from _dbus_bindings import get_default_main_loop, set_default_main_loop,\ -- validate_interface_name, validate_member_name,\ -- validate_bus_name, validate_object_path,\ -- validate_error_name --from _dbus_bindings import BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ -- LOCAL_PATH, LOCAL_IFACE, PEER_IFACE,\ -- INTROSPECTABLE_IFACE, PROPERTIES_IFACE -- --from dbus.exceptions import MissingErrorHandlerException, \ -- MissingReplyHandlerException, \ -- ValidationException, \ -- IntrospectionParserException, \ -- UnknownMethodException, \ -- NameExistsException, \ -- DBusException --from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte, Boolean,\ -- Int16, UInt16, Int32, UInt32, Int64, UInt64,\ -- Double, String, Array, Struct, Dictionary, \ -- UTF8String -+from _dbus_bindings import ( -+ get_default_main_loop, set_default_main_loop, validate_bus_name, -+ validate_error_name, validate_interface_name, validate_member_name, -+ validate_object_path) -+from _dbus_bindings import ( -+ BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE, -+ LOCAL_IFACE, LOCAL_PATH, PEER_IFACE, PROPERTIES_IFACE) -+ -+from dbus.exceptions import ( -+ DBusException, IntrospectionParserException, MissingErrorHandlerException, -+ MissingReplyHandlerException, NameExistsException, UnknownMethodException, -+ ValidationException) -+from _dbus_bindings import ( -+ Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64, -+ ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64) -+ -+if is_py2: -+ from _dbus_bindings import UTF8String -+ - from dbus._dbus import Bus, SystemBus, SessionBus, StarterBus - from dbus.proxies import Interface ---- /dev/null -+++ b/dbus/_compat.py -@@ -0,0 +1,8 @@ -+# Python 2 / Python 3 compatibility helpers. -+ -+import sys -+ -+# In Python 2.6, sys.version_info is not a namedtuple, so we can't use -+# sys.version_info.major. -+is_py3 = (sys.version_info[0] == 3) -+is_py2 = not is_py3 ---- a/dbus/_dbus.py -+++ b/dbus/_dbus.py -@@ -30,26 +30,18 @@ - __all__ = ('Bus', 'SystemBus', 'SessionBus', 'StarterBus') - __docformat__ = 'reStructuredText' - --import os --import sys --import weakref --from traceback import print_exc -- - from dbus.exceptions import DBusException --from _dbus_bindings import BUS_DAEMON_NAME, BUS_DAEMON_PATH,\ -- BUS_DAEMON_IFACE, UTF8String,\ -- validate_member_name, validate_interface_name,\ -- validate_bus_name, validate_object_path,\ -- BUS_SESSION, BUS_SYSTEM, BUS_STARTER,\ -- DBUS_START_REPLY_SUCCESS, \ -- DBUS_START_REPLY_ALREADY_RUNNING -+from _dbus_bindings import ( -+ BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION, -+ BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING, -+ DBUS_START_REPLY_SUCCESS, validate_bus_name, -+ validate_interface_name, validate_member_name, validate_object_path) - from dbus.bus import BusConnection - from dbus.lowlevel import SignalMessage -+from dbus._compat import is_py2 - --try: -- import thread --except ImportError: -- import dummy_thread as thread -+if is_py2: -+ from _dbus_bindings import UTF8String - - - class Bus(BusConnection): ---- a/dbus/_expat_introspect_parser.py -+++ b/dbus/_expat_introspect_parser.py -@@ -23,7 +23,7 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --from xml.parsers.expat import ExpatError, ParserCreate -+from xml.parsers.expat import ParserCreate - from dbus.exceptions import IntrospectionParserException - - class _Parser(object): ---- a/dbus/bus.py -+++ b/dbus/bus.py -@@ -26,26 +26,20 @@ - import logging - import weakref - --from _dbus_bindings import validate_interface_name, validate_member_name,\ -- validate_bus_name, validate_object_path,\ -- validate_error_name,\ -- BUS_SESSION, BUS_STARTER, BUS_SYSTEM, \ -- DBUS_START_REPLY_SUCCESS, \ -- DBUS_START_REPLY_ALREADY_RUNNING, \ -- BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ -- NAME_FLAG_ALLOW_REPLACEMENT, \ -- NAME_FLAG_DO_NOT_QUEUE, \ -- NAME_FLAG_REPLACE_EXISTING, \ -- RELEASE_NAME_REPLY_NON_EXISTENT, \ -- RELEASE_NAME_REPLY_NOT_OWNER, \ -- RELEASE_NAME_REPLY_RELEASED, \ -- REQUEST_NAME_REPLY_ALREADY_OWNER, \ -- REQUEST_NAME_REPLY_EXISTS, \ -- REQUEST_NAME_REPLY_IN_QUEUE, \ -- REQUEST_NAME_REPLY_PRIMARY_OWNER -+from _dbus_bindings import ( -+ BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION, -+ BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING, -+ DBUS_START_REPLY_SUCCESS, NAME_FLAG_ALLOW_REPLACEMENT, -+ NAME_FLAG_DO_NOT_QUEUE, NAME_FLAG_REPLACE_EXISTING, -+ RELEASE_NAME_REPLY_NON_EXISTENT, RELEASE_NAME_REPLY_NOT_OWNER, -+ RELEASE_NAME_REPLY_RELEASED, REQUEST_NAME_REPLY_ALREADY_OWNER, -+ REQUEST_NAME_REPLY_EXISTS, REQUEST_NAME_REPLY_IN_QUEUE, -+ REQUEST_NAME_REPLY_PRIMARY_OWNER, validate_bus_name, validate_error_name, -+ validate_interface_name, validate_member_name, validate_object_path) - from dbus.connection import Connection - from dbus.exceptions import DBusException - from dbus.lowlevel import HANDLER_RESULT_NOT_YET_HANDLED -+from dbus._compat import is_py2 - - - _NAME_OWNER_CHANGE_MATCH = ("type='signal',sender='%s'," -@@ -84,13 +78,16 @@ - BUS_DAEMON_NAME, - BUS_DAEMON_PATH, - arg0=bus_name) -+ keywords = {} -+ if is_py2: -+ keywords['utf8_strings'] = True - self._pending_call = bus_conn.call_async(BUS_DAEMON_NAME, - BUS_DAEMON_PATH, - BUS_DAEMON_IFACE, - 'GetNameOwner', - 's', (bus_name,), - callback, error_cb, -- utf8_strings=True) -+ **keywords) - - def cancel(self): - if self._match is not None: -@@ -237,7 +234,7 @@ - bus_name = named_service - if kwargs: - raise TypeError('get_object does not take these keyword ' -- 'arguments: %s' % ', '.join(kwargs.iterkeys())) -+ 'arguments: %s' % ', '.join(kwargs.keys())) - - return self.ProxyObjectClass(self, bus_name, object_path, - introspect=introspect, -@@ -328,9 +325,12 @@ - :Returns: a dbus.Array of dbus.UTF8String - :Since: 0.81.0 - """ -+ keywords = {} -+ if is_py2: -+ keywords['utf8_strings'] = True - return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, - BUS_DAEMON_IFACE, 'ListNames', -- '', (), utf8_strings=True) -+ '', (), **keywords) - - def list_activatable_names(self): - """Return a list of all names that can be activated on the bus. -@@ -338,9 +338,12 @@ - :Returns: a dbus.Array of dbus.UTF8String - :Since: 0.81.0 - """ -+ keywords = {} -+ if is_py2: -+ keywords['utf8_strings'] = True - return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, - BUS_DAEMON_IFACE, 'ListActivatableNames', -- '', (), utf8_strings=True) -+ '', (), **keywords) - - def get_name_owner(self, bus_name): - """Return the unique connection name of the primary owner of the -@@ -349,10 +352,13 @@ - :Raises `DBusException`: if the `bus_name` has no owner - :Since: 0.81.0 - """ -+ keywords = {} -+ if is_py2: -+ keywords['utf8_strings'] = True - validate_bus_name(bus_name, allow_unique=False) - return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, - BUS_DAEMON_IFACE, 'GetNameOwner', -- 's', (bus_name,), utf8_strings=True) -+ 's', (bus_name,), **keywords) - - def watch_name_owner(self, bus_name, callback): - """Watch the unique connection name of the primary owner of the ---- a/dbus/connection.py -+++ b/dbus/connection.py -@@ -24,22 +24,23 @@ - __docformat__ = 'reStructuredText' - - import logging --try: -- import thread --except ImportError: -- import dummy_thread as thread -+import threading - import weakref - --from _dbus_bindings import Connection as _Connection, \ -- LOCAL_PATH, LOCAL_IFACE, \ -- validate_interface_name, validate_member_name,\ -- validate_bus_name, validate_object_path,\ -- validate_error_name, \ -- UTF8String -+from _dbus_bindings import ( -+ Connection as _Connection, LOCAL_IFACE, LOCAL_PATH, validate_bus_name, -+ validate_interface_name, validate_member_name, validate_object_path) - from dbus.exceptions import DBusException --from dbus.lowlevel import ErrorMessage, MethodCallMessage, SignalMessage, \ -- MethodReturnMessage, HANDLER_RESULT_NOT_YET_HANDLED -+from dbus.lowlevel import ( -+ ErrorMessage, HANDLER_RESULT_NOT_YET_HANDLED, MethodCallMessage, -+ MethodReturnMessage, SignalMessage) - from dbus.proxies import ProxyObject -+from dbus._compat import is_py2, is_py3 -+ -+if is_py3: -+ from _dbus_bindings import String -+else: -+ from _dbus_bindings import UTF8String - - - _logger = logging.getLogger('dbus.connection') -@@ -50,15 +51,19 @@ - - - class SignalMatch(object): -- __slots__ = ('_sender_name_owner', '_member', '_interface', '_sender', -- '_path', '_handler', '_args_match', '_rule', -- '_utf8_strings', '_byte_arrays', '_conn_weakref', -- '_destination_keyword', '_interface_keyword', -- '_message_keyword', '_member_keyword', -- '_sender_keyword', '_path_keyword', '_int_args_match') -+ _slots = ['_sender_name_owner', '_member', '_interface', '_sender', -+ '_path', '_handler', '_args_match', '_rule', -+ '_byte_arrays', '_conn_weakref', -+ '_destination_keyword', '_interface_keyword', -+ '_message_keyword', '_member_keyword', -+ '_sender_keyword', '_path_keyword', '_int_args_match'] -+ if is_py2: -+ _slots.append('_utf8_strings') -+ -+ __slots__ = tuple(_slots) - - def __init__(self, conn, sender, object_path, dbus_interface, -- member, handler, utf8_strings=False, byte_arrays=False, -+ member, handler, byte_arrays=False, - sender_keyword=None, path_keyword=None, - interface_keyword=None, member_keyword=None, - message_keyword=None, destination_keyword=None, -@@ -84,7 +89,11 @@ - # this later - self._sender_name_owner = sender - -- self._utf8_strings = utf8_strings -+ if is_py2: -+ self._utf8_strings = kwargs.pop('utf8_strings', False) -+ elif 'utf8_strings' in kwargs: -+ raise TypeError("unexpected keyword argument 'utf8_strings'") -+ - self._byte_arrays = byte_arrays - self._sender_keyword = sender_keyword - self._path_keyword = path_keyword -@@ -138,7 +147,7 @@ - if self._member is not None: - rule.append("member='%s'" % self._member) - if self._int_args_match is not None: -- for index, value in self._int_args_match.iteritems(): -+ for index, value in self._int_args_match.items(): - rule.append("arg%d='%s'" % (index, value)) - - self._rule = ','.join(rule) -@@ -176,10 +185,14 @@ - return False - if self._int_args_match is not None: - # extracting args with utf8_strings and byte_arrays is less work -- args = message.get_args_list(utf8_strings=True, byte_arrays=True) -- for index, value in self._int_args_match.iteritems(): -+ kwargs = dict(byte_arrays=True) -+ arg_type = (String if is_py3 else UTF8String) -+ if is_py2: -+ kwargs['utf8_strings'] = True -+ args = message.get_args_list(**kwargs) -+ for index, value in self._int_args_match.items(): - if (index >= len(args) -- or not isinstance(args[index], UTF8String) -+ or not isinstance(args[index], arg_type) - or args[index] != value): - return False - -@@ -195,9 +208,12 @@ - # minor optimization: if we already extracted the args with the - # right calling convention to do the args match, don't bother - # doing so again -- if args is None or not self._utf8_strings or not self._byte_arrays: -- args = message.get_args_list(utf8_strings=self._utf8_strings, -- byte_arrays=self._byte_arrays) -+ utf8_strings = (is_py2 and self._utf8_strings) -+ if args is None or not utf8_strings or not self._byte_arrays: -+ kwargs = dict(byte_arrays=self._byte_arrays) -+ if is_py2: -+ kwargs['utf8_strings'] = self._utf8_strings -+ args = message.get_args_list(**kwargs) - kwargs = {} - if self._sender_keyword is not None: - kwargs[self._sender_keyword] = message.get_sender() -@@ -252,7 +268,7 @@ - """Map from object path to dict mapping dbus_interface to dict - mapping member to list of SignalMatch objects.""" - -- self._signals_lock = thread.allocate_lock() -+ self._signals_lock = threading.Lock() - """Lock used to protect signal data structures""" - - self.add_message_filter(self.__class__._signal_func) -@@ -305,7 +321,7 @@ - bus_name = named_service - if kwargs: - raise TypeError('get_object does not take these keyword ' -- 'arguments: %s' % ', '.join(kwargs.iterkeys())) -+ 'arguments: %s' % ', '.join(kwargs.keys())) - - return self.ProxyObjectClass(self, bus_name, object_path, - introspect=introspect) -@@ -425,8 +441,7 @@ - member_keys = (None,) - - for path in path_keys: -- by_interface = self._signal_recipients_by_object_path.get(path, -- None) -+ by_interface = self._signal_recipients_by_object_path.get(path) - if by_interface is None: - continue - for dbus_interface in interface_keys: -@@ -525,7 +540,7 @@ - for cb in self.__call_on_disconnection: - try: - cb(self) -- except Exception as e: -+ except Exception: - # basicConfig is a no-op if logging is already configured - logging.basicConfig() - _logger.error('Exception in handler for Disconnected ' -@@ -535,8 +550,8 @@ - - def call_async(self, bus_name, object_path, dbus_interface, method, - signature, args, reply_handler, error_handler, -- timeout=-1.0, utf8_strings=False, byte_arrays=False, -- require_main_loop=True): -+ timeout=-1.0, byte_arrays=False, -+ require_main_loop=True, **kwargs): - """Call the given method, asynchronously. - - If the reply_handler is None, successful replies will be ignored. -@@ -554,8 +569,11 @@ - 'interface %s' % LOCAL_IFACE) - # no need to validate other args - MethodCallMessage ctor will do - -- get_args_opts = {'utf8_strings': utf8_strings, -- 'byte_arrays': byte_arrays} -+ get_args_opts = dict(byte_arrays=byte_arrays) -+ if is_py2: -+ get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False) -+ elif 'utf8_strings' in kwargs: -+ raise TypeError("unexpected keyword argument 'utf8_strings'") - - message = MethodCallMessage(destination=bus_name, - path=object_path, -@@ -595,8 +613,8 @@ - require_main_loop=require_main_loop) - - def call_blocking(self, bus_name, object_path, dbus_interface, method, -- signature, args, timeout=-1.0, utf8_strings=False, -- byte_arrays=False): -+ signature, args, timeout=-1.0, -+ byte_arrays=False, **kwargs): - """Call the given method, synchronously. - :Since: 0.81.0 - """ -@@ -608,8 +626,11 @@ - 'interface %s' % LOCAL_IFACE) - # no need to validate other args - MethodCallMessage ctor will do - -- get_args_opts = {'utf8_strings': utf8_strings, -- 'byte_arrays': byte_arrays} -+ get_args_opts = dict(byte_arrays=byte_arrays) -+ if is_py2: -+ get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False) -+ elif 'utf8_strings' in kwargs: -+ raise TypeError("unexpected keyword argument 'utf8_strings'") - - message = MethodCallMessage(destination=bus_name, - path=object_path, ---- a/dbus/decorators.py -+++ b/dbus/decorators.py -@@ -33,14 +33,15 @@ - from dbus import validate_interface_name, Signature, validate_member_name - from dbus.lowlevel import SignalMessage - from dbus.exceptions import DBusException -+from dbus._compat import is_py2 - - - def method(dbus_interface, in_signature=None, out_signature=None, -- async_callbacks=None, -- sender_keyword=None, path_keyword=None, destination_keyword=None, -- message_keyword=None, connection_keyword=None, -- utf8_strings=False, byte_arrays=False, -- rel_path_keyword=None): -+ async_callbacks=None, -+ sender_keyword=None, path_keyword=None, destination_keyword=None, -+ message_keyword=None, connection_keyword=None, -+ byte_arrays=False, -+ rel_path_keyword=None, **kwargs): - """Factory for decorators used to mark methods of a `dbus.service.Object` - to be exported on the D-Bus. - -@@ -182,9 +183,9 @@ - in_sig = tuple(Signature(in_signature)) - - if len(in_sig) > len(args): -- raise ValueError, 'input signature is longer than the number of arguments taken' -+ raise ValueError('input signature is longer than the number of arguments taken') - elif len(in_sig) < len(args): -- raise ValueError, 'input signature is shorter than the number of arguments taken' -+ raise ValueError('input signature is shorter than the number of arguments taken') - - func._dbus_is_method = True - func._dbus_async_callbacks = async_callbacks -@@ -198,8 +199,12 @@ - func._dbus_message_keyword = message_keyword - func._dbus_connection_keyword = connection_keyword - func._dbus_args = args -- func._dbus_get_args_options = {'byte_arrays': byte_arrays, -- 'utf8_strings': utf8_strings} -+ func._dbus_get_args_options = dict(byte_arrays=byte_arrays) -+ if is_py2: -+ func._dbus_get_args_options['utf8_strings'] = kwargs.get( -+ 'utf8_strings', False) -+ elif 'utf8_strings' in kwargs: -+ raise TypeError("unexpected keyword argument 'utf8_strings'") - return func - - return decorator -@@ -325,9 +330,9 @@ - sig = tuple(Signature(signature)) - - if len(sig) > len(args): -- raise ValueError, 'signal signature is longer than the number of arguments provided' -+ raise ValueError('signal signature is longer than the number of arguments provided') - elif len(sig) < len(args): -- raise ValueError, 'signal signature is shorter than the number of arguments provided' -+ raise ValueError('signal signature is shorter than the number of arguments provided') - - emit_signal.__name__ = func.__name__ - emit_signal.__doc__ = func.__doc__ ---- a/dbus/exceptions.py -+++ b/dbus/exceptions.py -@@ -27,6 +27,7 @@ - 'IntrospectionParserException', 'UnknownMethodException', - 'NameExistsException') - -+ - class DBusException(Exception): - - include_traceback = False -@@ -57,7 +58,9 @@ - - def get_dbus_message(self): - s = Exception.__str__(self) -- return s.decode('utf-8', 'replace') -+ if isinstance(s, bytes): -+ return s.decode('utf-8', 'replace') -+ return s - - def get_dbus_name(self): - return self._dbus_error_name ---- a/dbus/gobject_service.py -+++ b/dbus/gobject_service.py -@@ -22,9 +22,21 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --import gobject -+__all__ = ['ExportedGObject'] -+ -+from gi.repository import GObject as gobject - import dbus.service - -+# The odd syntax used here is required so that the code is compatible with -+# both Python 2 and Python 3. It essentially creates a new class called -+# ExportedGObject with a metaclass of ExportGObjectType and an __init__() -+# function. -+# -+# Because GObject and `dbus.service.Object` both have custom metaclasses, the -+# naive approach using simple multiple inheritance won't work. This class has -+# `ExportedGObjectType` as its metaclass, which is sufficient to make it work -+# correctly. -+ - class ExportedGObjectType(gobject.GObjectMeta, dbus.service.InterfaceType): - """A metaclass which inherits from both GObjectMeta and - `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`. -@@ -33,39 +45,39 @@ - gobject.GObjectMeta.__init__(cls, name, bases, dct) - dbus.service.InterfaceType.__init__(cls, name, bases, dct) - --class ExportedGObject(gobject.GObject, dbus.service.Object): -- """A GObject which is exported on the D-Bus. -- -- Because GObject and `dbus.service.Object` both have custom metaclasses, -- the naive approach using simple multiple inheritance won't work. This -- class has `ExportedGObjectType` as its metaclass, which is sufficient -- to make it work correctly. -- """ -- __metaclass__ = ExportedGObjectType - -- def __init__(self, conn=None, object_path=None, **kwargs): -- """Initialize an exported GObject. -+def ExportedGObject__init__(self, conn=None, object_path=None, **kwargs): -+ """Initialize an exported GObject. - -- :Parameters: -- `conn` : dbus.connection.Connection -- The D-Bus connection or bus -- `object_path` : str -- The object path at which to register this object. -- :Keywords: -- `bus_name` : dbus.service.BusName -- A bus name to be held on behalf of this object, or None. -- `gobject_properties` : dict -- GObject properties to be set on the constructed object. -- -- Any unrecognised keyword arguments will also be interpreted -- as GObject properties. -- """ -- bus_name = kwargs.pop('bus_name', None) -- gobject_properties = kwargs.pop('gobject_properties', None) -- -- if gobject_properties is not None: -- kwargs.update(gobject_properties) -- gobject.GObject.__init__(self, **kwargs) -- dbus.service.Object.__init__(self, conn=conn, -- object_path=object_path, -- bus_name=bus_name) -+ :Parameters: -+ `conn` : dbus.connection.Connection -+ The D-Bus connection or bus -+ `object_path` : str -+ The object path at which to register this object. -+ :Keywords: -+ `bus_name` : dbus.service.BusName -+ A bus name to be held on behalf of this object, or None. -+ `gobject_properties` : dict -+ GObject properties to be set on the constructed object. -+ -+ Any unrecognised keyword arguments will also be interpreted -+ as GObject properties. -+ """ -+ bus_name = kwargs.pop('bus_name', None) -+ gobject_properties = kwargs.pop('gobject_properties', None) -+ -+ if gobject_properties is not None: -+ kwargs.update(gobject_properties) -+ gobject.GObject.__init__(self, **kwargs) -+ dbus.service.Object.__init__(self, conn=conn, -+ object_path=object_path, -+ bus_name=bus_name) -+ -+ExportedGObject__doc__ = 'A GObject which is exported on the D-Bus.' -+ -+ExportedGObject = ExportedGObjectType( -+ 'ExportedGObject', -+ (gobject.GObject, dbus.service.Object), -+ {'__init__': ExportedGObject__init__, -+ '__doc__': ExportedGObject__doc__, -+ }) ---- a/dbus/lowlevel.py -+++ b/dbus/lowlevel.py -@@ -29,12 +29,8 @@ - 'MESSAGE_TYPE_METHOD_RETURN', 'MESSAGE_TYPE_ERROR', - 'MESSAGE_TYPE_SIGNAL') - --from _dbus_bindings import PendingCall, Message, MethodCallMessage, \ -- MethodReturnMessage, ErrorMessage, SignalMessage, \ -- HANDLER_RESULT_HANDLED, \ -- HANDLER_RESULT_NOT_YET_HANDLED, \ -- MESSAGE_TYPE_INVALID, \ -- MESSAGE_TYPE_METHOD_CALL, \ -- MESSAGE_TYPE_METHOD_RETURN, \ -- MESSAGE_TYPE_ERROR, \ -- MESSAGE_TYPE_SIGNAL -+from _dbus_bindings import ( -+ ErrorMessage, HANDLER_RESULT_HANDLED, HANDLER_RESULT_NOT_YET_HANDLED, -+ MESSAGE_TYPE_ERROR, MESSAGE_TYPE_INVALID, MESSAGE_TYPE_METHOD_CALL, -+ MESSAGE_TYPE_METHOD_RETURN, MESSAGE_TYPE_SIGNAL, Message, -+ MethodCallMessage, MethodReturnMessage, PendingCall, SignalMessage) ---- a/dbus/proxies.py -+++ b/dbus/proxies.py -@@ -23,7 +23,6 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --import sys - import logging - - try: -@@ -33,16 +32,19 @@ - - import _dbus_bindings - from dbus._expat_introspect_parser import process_introspection_data --from dbus.exceptions import MissingReplyHandlerException, MissingErrorHandlerException, IntrospectionParserException, DBusException -+from dbus.exceptions import ( -+ DBusException, IntrospectionParserException, MissingErrorHandlerException, -+ MissingReplyHandlerException) - - __docformat__ = 'restructuredtext' - - - _logger = logging.getLogger('dbus.proxies') - --from _dbus_bindings import LOCAL_PATH, \ -- BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,\ -- INTROSPECTABLE_IFACE -+from _dbus_bindings import ( -+ BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE, -+ LOCAL_PATH) -+from dbus._compat import is_py2 - - - class _DeferredMethod: -@@ -57,7 +59,7 @@ - self._block = block - - def __call__(self, *args, **keywords): -- if (keywords.has_key('reply_handler') or -+ if ('reply_handler' in keywords or - keywords.get('ignore_reply', False)): - # defer the async call til introspection finishes - self._append(self._proxy_method, args, keywords) -@@ -224,7 +226,7 @@ - if kwargs: - raise TypeError('ProxyObject.__init__ does not take these ' - 'keyword arguments: %s' -- % ', '.join(kwargs.iterkeys())) -+ % ', '.join(kwargs.keys())) - - if follow_name_owner_changes: - # we don't get the signals unless the Bus has a main loop -@@ -367,13 +369,15 @@ - **keywords) - - def _Introspect(self): -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True - return self._bus.call_async(self._named_service, - self.__dbus_object_path__, - INTROSPECTABLE_IFACE, 'Introspect', '', (), - self._introspect_reply_handler, - self._introspect_error_handler, -- utf8_strings=True, -- require_main_loop=False) -+ require_main_loop=False, **kwargs) - - def _introspect_execute_queue(self): - # FIXME: potential to flood the bus ---- a/dbus/service.py -+++ b/dbus/service.py -@@ -28,22 +28,20 @@ - - import sys - import logging --import operator -+import threading - import traceback --try: -- import thread --except ImportError: -- import dummy_thread as thread -+from collections import Sequence - - import _dbus_bindings --from dbus import SessionBus, Signature, Struct, validate_bus_name, \ -- validate_object_path, INTROSPECTABLE_IFACE, ObjectPath -+from dbus import ( -+ INTROSPECTABLE_IFACE, ObjectPath, SessionBus, Signature, Struct, -+ validate_bus_name, validate_object_path) - from dbus.decorators import method, signal --from dbus.exceptions import DBusException, \ -- NameExistsException, \ -- UnknownMethodException -+from dbus.exceptions import ( -+ DBusException, NameExistsException, UnknownMethodException) - from dbus.lowlevel import ErrorMessage, MethodReturnMessage, MethodCallMessage - from dbus.proxies import LOCAL_PATH -+from dbus._compat import is_py2 - - - _logger = logging.getLogger('dbus.service') -@@ -59,10 +57,14 @@ - """Return self.""" - return self - -- def next(self): -+ def __next__(self): - """Return 'v' whenever called.""" - return 'v' - -+ if is_py2: -+ next = __next__ -+ -+ - class BusName(object): - """A base class for exporting your own Named Services across the Bus. - -@@ -308,7 +310,7 @@ - for b in bases: - base_name = b.__module__ + '.' + b.__name__ - if getattr(b, '_dbus_class_table', False): -- for (interface, method_table) in class_table[base_name].iteritems(): -+ for (interface, method_table) in class_table[base_name].items(): - our_method_table = interface_table.setdefault(interface, {}) - our_method_table.update(method_table) - -@@ -368,8 +370,11 @@ - - return reflection_data - --class Interface(object): -- __metaclass__ = InterfaceType -+ -+# Define Interface as an instance of the metaclass InterfaceType, in a way -+# that is compatible across both Python 2 and Python 3. -+Interface = InterfaceType('Interface', (object,), {}) -+ - - #: A unique object used as the value of Object._object_path and - #: Object._connection if it's actually in more than one place -@@ -466,7 +471,7 @@ - #: is for future expansion (to support fallback paths) - self._locations = [] - #: Lock protecting `_locations`, `_connection` and `_object_path` -- self._locations_lock = thread.allocate_lock() -+ self._locations_lock = threading.Lock() - - #: True if this is a fallback object handling a whole subtree. - self._fallback = False -@@ -722,8 +727,9 @@ - elif len(signature_tuple) == 1: - retval = (retval,) - else: -- if operator.isSequenceType(retval): -- # multi-value signature, multi-value return... proceed unchanged -+ if isinstance(retval, Sequence): -+ # multi-value signature, multi-value return... proceed -+ # unchanged - pass - else: - raise TypeError('%s has multiple output values in signature %s but did not return a sequence' % -@@ -757,7 +763,7 @@ - reflection_data += '\n' % object_path - - interfaces = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__] -- for (name, funcs) in interfaces.iteritems(): -+ for (name, funcs) in interfaces.items(): - reflection_data += ' \n' % (name) - - for func in funcs.values(): ---- a/dbus/types.py -+++ b/dbus/types.py -@@ -1,10 +1,14 @@ --__all__ = ('ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', -+__all__ = ['ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean', - 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', - 'Double', 'String', 'Array', 'Struct', 'Dictionary', -- 'UTF8String', 'UnixFd') -+ 'UnixFd'] - --from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte,\ -- Int16, UInt16, Int32, UInt32,\ -- Int64, UInt64, Dictionary, Array, \ -- String, Boolean, Double, Struct, UTF8String, \ -- UnixFd -+from _dbus_bindings import ( -+ Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64, -+ ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64, -+ UnixFd) -+ -+from dbus._compat import is_py2 -+if is_py2: -+ from _dbus_bindings import UTF8String -+ __all__.append('UTF8String') ---- a/include/dbus-python.h -+++ b/include/dbus-python.h -@@ -32,6 +32,11 @@ - #include - #include - -+#if PY_MAJOR_VERSION >= 3 -+#define PY3 -+#define PYDBUS_CAPSULE_NAME "_dbus_bindings._C_API" -+#endif -+ - DBUS_BEGIN_DECLS - - typedef void (*_dbus_py_func_ptr)(void); -@@ -73,6 +78,18 @@ - } - c_api = PyObject_GetAttrString(_dbus_bindings_module, "_C_API"); - if (c_api == NULL) return -1; -+#ifdef PY3 -+ dbus_bindings_API = NULL; -+ if (PyCapsule_IsValid(c_api, PYDBUS_CAPSULE_NAME)) { -+ dbus_bindings_API = (_dbus_py_func_ptr *)PyCapsule_GetPointer( -+ c_api, PYDBUS_CAPSULE_NAME); -+ } -+ Py_CLEAR(c_api); -+ if (!dbus_bindings_API) { -+ PyErr_SetString(PyExc_RuntimeError, "C API is not a PyCapsule"); -+ return -1; -+ } -+#else - if (PyCObject_Check(c_api)) { - dbus_bindings_API = (_dbus_py_func_ptr *)PyCObject_AsVoidPtr(c_api); - } -@@ -82,6 +99,7 @@ - return -1; - } - Py_DECREF (c_api); -+#endif - count = *(int *)dbus_bindings_API[0]; - if (count < DBUS_BINDINGS_API_COUNT) { - PyErr_Format(PyExc_RuntimeError, ---- a/test/cross-test-client.py -+++ b/test/cross-test-client.py -@@ -20,19 +20,31 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --from time import sleep -+from __future__ import print_function, unicode_literals - import logging - --import gobject -+from gi.repository import GObject as gobject - --from dbus import SessionBus, Interface, Array, Byte, Double, Boolean, ByteArray, Int16, Int32, Int64, UInt16, UInt32, UInt64, String, UTF8String, Struct, Dictionary --from dbus.service import BusName -+from dbus import ( -+ Array, Boolean, Byte, ByteArray, Double, Int16, Int32, Int64, -+ Interface, SessionBus, String, UInt16, UInt32, UInt64) -+from dbus._compat import is_py2, is_py3 - import dbus.glib - --from crosstest import CROSS_TEST_PATH, CROSS_TEST_BUS_NAME,\ -- INTERFACE_SINGLE_TESTS, INTERFACE_TESTS,\ -- INTERFACE_SIGNAL_TESTS, INTERFACE_CALLBACK_TESTS,\ -- SignalTestsImpl -+if is_py2: -+ from dbus import UTF8String -+ -+from crosstest import ( -+ CROSS_TEST_BUS_NAME, CROSS_TEST_PATH, INTERFACE_CALLBACK_TESTS, -+ INTERFACE_SIGNAL_TESTS, INTERFACE_SINGLE_TESTS, INTERFACE_TESTS, -+ SignalTestsImpl) -+ -+if is_py3: -+ def make_long(n): -+ return n -+else: -+ def make_long(n): -+ return long(n) - - - logging.basicConfig() -@@ -47,9 +59,9 @@ - def quit(self): - for x in self.expected: - self.fail_id += 1 -- print "%s fail %d" % (x, self.fail_id) -+ print("%s fail %d" % (x, self.fail_id)) - s = "report %d: reply to %s didn't arrive" % (self.fail_id, x) -- print s -+ print(s) - logger.error(s) - logger.info("asking server to Exit") - Interface(self.obj, INTERFACE_TESTS).Exit(reply_handler=self.quit_reply_handler, error_handler=self.quit_error_handler) -@@ -72,26 +84,28 @@ - self.expected.discard('%s.Trigger' % INTERFACE_SIGNAL_TESTS) - if (input1, input2) != (42, 23): - self.fail_id += 1 -- print "%s.Trigger fail %d" % (INTERFACE_SIGNAL_TESTS, self.fail_id) -+ print("%s.Trigger fail %d" % -+ (INTERFACE_SIGNAL_TESTS, self.fail_id)) - s = ("report %d: expected (42,23), got %r" - % (self.fail_id, (input1, input2))) - logger.error(s) -- print s -+ print(s) - else: -- print "%s.Trigger pass" % INTERFACE_SIGNAL_TESTS -+ print("%s.Trigger pass" % INTERFACE_SIGNAL_TESTS) - self.quit() - -- def assert_method_matches(self, interface, check_fn, check_arg, member, *args): -+ def assert_method_matches(self, interface, check_fn, check_arg, member, -+ *args): - if_obj = Interface(self.obj, interface) - method = getattr(if_obj, member) - try: - real_ret = method(*args) - except Exception as e: - self.fail_id += 1 -- print "%s.%s fail %d" % (interface, member, self.fail_id) -+ print("%s.%s fail %d" % (interface, member, self.fail_id)) - s = ("report %d: %s.%s%r: raised %r \"%s\"" - % (self.fail_id, interface, member, args, e, e)) -- print s -+ print(s) - logger.error(s) - __import__('traceback').print_exc() - return -@@ -99,13 +113,13 @@ - check_fn(real_ret, check_arg) - except Exception as e: - self.fail_id += 1 -- print "%s.%s fail %d" % (interface, member, self.fail_id) -+ print("%s.%s fail %d" % (interface, member, self.fail_id)) - s = ("report %d: %s.%s%r: %s" - % (self.fail_id, interface, member, args, e)) -- print s -+ print(s) - logger.error(s) - return -- print "%s.%s pass" % (interface, member) -+ print("%s.%s pass" % (interface, member)) - - def assert_method_eq(self, interface, ret, member, *args): - def equals(real_ret, exp): -@@ -119,7 +133,7 @@ - % (getattr(exp, 'variant_level', 0), real_ret, - real_ret.variant_level)) - if isinstance(exp, list) or isinstance(exp, tuple): -- for i in xrange(len(exp)): -+ for i in range(len(exp)): - try: - equals(real_ret[i], exp[i]) - except AssertionError as e: -@@ -161,20 +175,20 @@ - self.expected.discard('%s.Trigger' % INTERFACE_TESTS) - if sender_path != '/Where/Ever': - self.fail_id += 1 -- print "%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id) -+ print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id)) - s = ("report %d: expected signal from /Where/Ever, got %r" - % (self.fail_id, sender_path)) -- print s -+ print(s) - logger.error(s) - elif param != 42: - self.fail_id += 1 -- print "%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id) -+ print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id)) - s = ("report %d: expected signal param 42, got %r" -- % (self.fail_id, parameter)) -- print s -+ % (self.fail_id, param)) -+ print(s) - logger.error(s) - else: -- print "%s.Trigger pass" % INTERFACE_TESTS -+ print("%s.Trigger pass" % INTERFACE_TESTS) - - def trigger_returned_cb(self): - logger.info('method/signal: Trigger() returned') -@@ -202,7 +216,10 @@ - path_keyword='sender_path') - logger.info("method/signal: Triggering signal") - self.expected.add('%s.Trigger' % INTERFACE_TESTS) -- Interface(obj, INTERFACE_TESTS).Trigger(u'/Where/Ever', dbus.UInt64(42), reply_handler=self.trigger_returned_cb, error_handler=self.trigger_error_handler) -+ Interface(obj, INTERFACE_TESTS).Trigger( -+ '/Where/Ever', dbus.UInt64(42), -+ reply_handler=self.trigger_returned_cb, -+ error_handler=self.trigger_error_handler) - - def trigger_error_handler(self, e): - logger.error("method/signal: %s %s", e.__class__, e) -@@ -217,20 +234,22 @@ - # "Single tests" - if have_signatures: - self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [1, 2, 3]) -- self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ['\x01', '\x02', '\x03']) -+ self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', -+ [b'\x01', b'\x02', b'\x03']) - self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [Byte(1), Byte(2), Byte(3)]) -- self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ByteArray('\x01\x02\x03')) -+ self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ByteArray(b'\x01\x02\x03')) - - # Main tests -- self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', String('foo')) -- self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', UTF8String('foo')) -+ self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', String('foo')) -+ if is_py2: -+ self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', UTF8String('foo')) - self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42)) - self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=23), 'Identity', Byte(42, variant_level=23)) - self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', 42.5) - self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5) - - if have_signatures: -- self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', 'foo') -+ self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', 'foo') - self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42)) - self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', Double(42.5)) - self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5) -@@ -246,9 +265,12 @@ - self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt16', UInt16(i)) - for i in (-0x7fffffff-1, 0, 42, 0x7fffffff): - self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt32', Int32(i)) -- for i in (0L, 42L, 0xffffffffL): -+ for i in (0, 42, 0xffffffff): -+ i = make_long(i) - self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt32', UInt32(i)) -- MANY = 0x8000L * 0x10000L * 0x10000L * 0x10000L -+ MANY = 1 -+ for n in (0x8000, 0x10000, 0x10000, 0x10000): -+ MANY *= make_long(n) - for i in (-MANY, 0, 42, MANY-1): - self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt64', Int64(i)) - for i in (0, 42, 2*MANY - 1): -@@ -257,11 +279,12 @@ - self.assert_method_eq(INTERFACE_TESTS, 42.3, 'IdentityDouble', 42.3) - for i in ('', 'foo'): - self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityString', i) -- for i in (u'\xa9', '\xc2\xa9'): -- self.assert_method_eq(INTERFACE_TESTS, u'\xa9', 'IdentityString', i) -+ for i in ('\xa9', b'\xc2\xa9'): -+ self.assert_method_eq(INTERFACE_TESTS, '\xa9', 'IdentityString', i) - - if have_signatures: -- self.assert_method_eq(INTERFACE_TESTS, Byte(0x42), 'IdentityByte', '\x42') -+ self.assert_method_eq(INTERFACE_TESTS, Byte(0x42), -+ 'IdentityByte', b'\x42') - self.assert_method_eq(INTERFACE_TESTS, True, 'IdentityBool', 42) - self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityInt16', 42) - self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt16', 42) -@@ -271,13 +294,13 @@ - self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt64', 42) - self.assert_method_eq(INTERFACE_TESTS, 42.0, 'IdentityDouble', 42) - -- self.assert_method_eq(INTERFACE_TESTS, [Byte('\x01', variant_level=1), -- Byte('\x02', variant_level=1), -- Byte('\x03', variant_level=1)], -+ self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1), -+ Byte(b'\x02', variant_level=1), -+ Byte(b'\x03', variant_level=1)], - 'IdentityArray', -- Array([Byte('\x01'), -- Byte('\x02'), -- Byte('\x03')], -+ Array([Byte(b'\x01'), -+ Byte(b'\x02'), -+ Byte(b'\x03')], - signature='v')) - - self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1), -@@ -288,9 +311,9 @@ - Int32(2), - Int32(3)], - signature='v')) -- self.assert_method_eq(INTERFACE_TESTS, [String(u'a', variant_level=1), -- String(u'b', variant_level=1), -- String(u'c', variant_level=1)], -+ self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1), -+ String('b', variant_level=1), -+ String('c', variant_level=1)], - 'IdentityArray', - Array([String('a'), - String('b'), -@@ -298,11 +321,11 @@ - signature='v')) - - if have_signatures: -- self.assert_method_eq(INTERFACE_TESTS, [Byte('\x01', variant_level=1), -- Byte('\x02', variant_level=1), -- Byte('\x03', variant_level=1)], -+ self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1), -+ Byte(b'\x02', variant_level=1), -+ Byte(b'\x03', variant_level=1)], - 'IdentityArray', -- ByteArray('\x01\x02\x03')) -+ ByteArray(b'\x01\x02\x03')) - self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1), - Int32(2, variant_level=1), - Int32(3, variant_level=1)], -@@ -310,18 +333,20 @@ - [Int32(1), - Int32(2), - Int32(3)]) -- self.assert_method_eq(INTERFACE_TESTS, [String(u'a', variant_level=1), -- String(u'b', variant_level=1), -- String(u'c', variant_level=1)], -+ self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1), -+ String('b', variant_level=1), -+ String('c', variant_level=1)], - 'IdentityArray', - ['a','b','c']) - - self.assert_method_eq(INTERFACE_TESTS, - [Byte(1), Byte(2), Byte(3)], - 'IdentityByteArray', -- ByteArray('\x01\x02\x03')) -+ ByteArray(b'\x01\x02\x03')) - if have_signatures: -- self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityByteArray', ['\x01', '\x02', '\x03']) -+ self.assert_method_eq(INTERFACE_TESTS, [1,2,3], -+ 'IdentityByteArray', -+ [b'\x01', b'\x02', b'\x03']) - self.assert_method_eq(INTERFACE_TESTS, [False,True], 'IdentityBoolArray', [False,True]) - if have_signatures: - self.assert_method_eq(INTERFACE_TESTS, [False,True,True], 'IdentityBoolArray', [0,1,2]) ---- a/test/cross-test-server.py -+++ b/test/cross-test-server.py -@@ -20,18 +20,20 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - -+from __future__ import print_function - import logging - --import gobject -+from gi.repository import GObject as gobject - - import dbus.glib - from dbus import SessionBus - from dbus.service import BusName -+from dbus._compat import is_py2 - --from crosstest import CROSS_TEST_PATH, CROSS_TEST_BUS_NAME, \ -- INTERFACE_SINGLE_TESTS, INTERFACE_TESTS,\ -- INTERFACE_CALLBACK_TESTS, INTERFACE_SIGNAL_TESTS,\ -- SignalTestsImpl -+from crosstest import ( -+ CROSS_TEST_BUS_NAME, CROSS_TEST_PATH, INTERFACE_CALLBACK_TESTS, -+ INTERFACE_SIGNAL_TESTS, INTERFACE_SINGLE_TESTS, INTERFACE_TESTS, -+ SignalTestsImpl) - - - logging.basicConfig() -@@ -41,7 +43,7 @@ - - class VerboseSet(set): - def add(self, thing): -- print '%s ok' % thing -+ print('%s ok' % thing) - set.add(self, thing) - - -@@ -218,11 +220,15 @@ - return x - - -- @dbus.service.method(INTERFACE_TESTS, 'a{ss}', 'a{sas}', utf8_strings=True) -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True -+ -+ @dbus.service.method(INTERFACE_TESTS, 'a{ss}', 'a{sas}', **kwargs) - def InvertMapping(self, input): - tested_things.add(INTERFACE_TESTS + '.InvertMapping') - output = dbus.Dictionary({}) -- for k, v in input.iteritems(): -+ for k, v in input.items(): - output.setdefault(v, []).append(k) - return output - -@@ -261,8 +267,9 @@ - tested_things.add(INTERFACE_TESTS + '.Invert') - return not input - -- @dbus.service.method(INTERFACE_TESTS, 'st', '', utf8_strings=True, -- connection_keyword='conn') -+ @dbus.service.method(INTERFACE_TESTS, 'st', '', -+ connection_keyword='conn', -+ **kwargs) - def Trigger(self, object, parameter, conn=None): - assert isinstance(object, str) - logger.info('method/signal: client wants me to emit Triggered(%r) from %r', parameter, object) -@@ -286,7 +293,7 @@ - tested_things.add(INTERFACE_TESTS + '.Exit') - for x in testable_things: - if x not in tested_things: -- print '%s untested' % x -+ print('%s untested' % x) - logger.info('will quit when idle') - gobject.idle_add(self._exit_fn) - -@@ -309,6 +316,9 @@ - loop = gobject.MainLoop() - obj = Server(bus_name, CROSS_TEST_PATH, loop.quit) - objects[CROSS_TEST_PATH] = obj -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True - bus.add_signal_receiver(obj.triggered_by_client, - signal_name='Trigger', - dbus_interface=INTERFACE_SIGNAL_TESTS, -@@ -316,7 +326,7 @@ - path=None, - sender_keyword='sender', - path_keyword='sender_path', -- utf8_strings=True) -+ **kwargs) - - logger.info("running...") - loop.run() ---- a/test/dbus_py_test.c -+++ b/test/dbus_py_test.c -@@ -26,7 +26,11 @@ - #include - #include "dbus-python.h" - -+#ifdef PY3 -+PyMODINIT_FUNC PyInit_dbus_py_test(void); -+#else - PyMODINIT_FUNC initdbus_py_test(void); -+#endif - - #if defined(__GNUC__) - # if __GNUC__ >= 3 -@@ -113,6 +117,27 @@ - {NULL, NULL, 0, NULL} - }; - -+#ifdef PY3 -+PyMODINIT_FUNC -+PyInit_dbus_py_test(void) -+{ -+ static struct PyModuleDef moduledef = { -+ PyModuleDef_HEAD_INIT, -+ "dbus_py_test", /* m_name */ -+ NULL, /* m_doc */ -+ -1, /* m_size */ -+ module_functions, /* m_methods */ -+ NULL, /* m_reload */ -+ NULL, /* m_traverse */ -+ NULL, /* m_clear */ -+ NULL /* m_free */ -+ }; -+ if (import_dbus_bindings("dbus_py_test") < 0) -+ return NULL; -+ -+ return PyModule_Create(&moduledef); -+} -+#else - PyMODINIT_FUNC - initdbus_py_test(void) - { -@@ -122,5 +147,6 @@ - this_module = Py_InitModule3 ("dbus_py_test", module_functions, ""); - if (!this_module) return; - } -+#endif - - /* vim:set ft=c cino< sw=4 sts=4 et: */ ---- a/test/run-test.sh -+++ b/test/run-test.sh -@@ -62,6 +62,11 @@ - - dbus-monitor > "$DBUS_TOP_BUILDDIR"/test/monitor.log & - -+echo "DBUS_TOP_SRCDIR=$DBUS_TOP_SRCDIR" -+echo "DBUS_TOP_BUILDDIR=$DBUS_TOP_BUILDDIR" -+echo "PYTHONPATH=$PYTHONPATH" -+echo "PYTHON=$PYTHON" -+ - echo "running test-standalone.py" - $PYTHON "$DBUS_TOP_SRCDIR"/test/test-standalone.py || die "test-standalone.py failed" - ---- a/test/test-client.py -+++ b/test/test-client.py -@@ -23,7 +23,7 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --import sys -+from __future__ import print_function - import os - import unittest - import time -@@ -35,10 +35,12 @@ - - import dbus - import _dbus_bindings --import gobject - import dbus.glib - import dbus.service - -+from dbus._compat import is_py2, is_py3 -+from gi.repository import GObject as gobject -+ - - logging.basicConfig() - -@@ -52,8 +54,8 @@ - - test_types_vals = [1, 12323231, 3.14159265, 99999999.99, - "dude", "123", "What is all the fuss about?", "gob@gob.com", -- u'\\u310c\\u310e\\u3114', u'\\u0413\\u0414\\u0415', -- u'\\u2200software \\u2203crack', u'\\xf4\\xe5\\xe8', -+ '\\u310c\\u310e\\u3114', '\\u0413\\u0414\\u0415', -+ '\\u2200software \\u2203crack', '\\xf4\\xe5\\xe8', - [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"], - (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2), - {1:"a", 2:"b"}, {"a":1, "b":2}, #{"a":(1,"B")}, -@@ -76,50 +78,59 @@ - self.iface = dbus.Interface(self.remote_object, IFACE) - - def testGObject(self): -- print "Testing ExportedGObject... ", -+ print("Testing ExportedGObject... ", end='') - remote_gobject = self.bus.get_object(NAME, OBJECT + '/GObject') - iface = dbus.Interface(remote_gobject, IFACE) -- print "introspection, ", -+ print("introspection, ", end='') - remote_gobject.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE) -- print "method call, ", -- self.assertEquals(iface.Echo('123'), '123') -- print "... OK" -+ print("method call, ", end='') -+ self.assertEqual(iface.Echo('123'), '123') -+ print("... OK") - - def testWeakRefs(self): - # regression test for Sugar crash caused by smcv getting weak refs - # wrong - pre-bugfix, this would segfault - bus = dbus.SessionBus(private=True) - ref = weakref.ref(bus) -- self.assert_(ref() is bus) -+ self.assertTrue(ref() is bus) - del bus -- self.assert_(ref() is None) -+ self.assertTrue(ref() is None) - - def testInterfaceKeyword(self): - #test dbus_interface parameter -- print self.remote_object.Echo("dbus_interface on Proxy test Passed", dbus_interface = IFACE) -- print self.iface.Echo("dbus_interface on Interface test Passed", dbus_interface = IFACE) -- self.assert_(True) -+ print(self.remote_object.Echo("dbus_interface on Proxy test Passed", -+ dbus_interface = IFACE)) -+ print(self.iface.Echo("dbus_interface on Interface test Passed", -+ dbus_interface = IFACE)) -+ self.assertTrue(True) - - def testGetDBusMethod(self): -- self.assertEquals(self.iface.get_dbus_method('AcceptListOfByte')('\1\2\3'), [1,2,3]) -- self.assertEquals(self.remote_object.get_dbus_method('AcceptListOfByte', dbus_interface=IFACE)('\1\2\3'), [1,2,3]) -+ self.assertEqual(self.iface.get_dbus_method('AcceptListOfByte')(b'\1\2\3'), [1,2,3]) -+ self.assertEqual(self.remote_object.get_dbus_method('AcceptListOfByte', dbus_interface=IFACE)(b'\1\2\3'), [1,2,3]) - - def testCallingConventionOptions(self): -- self.assertEquals(self.iface.AcceptListOfByte('\1\2\3'), [1,2,3]) -- self.assertEquals(self.iface.AcceptListOfByte('\1\2\3', byte_arrays=True), '\1\2\3') -- self.assertEquals(self.iface.AcceptByteArray('\1\2\3'), [1,2,3]) -- self.assertEquals(self.iface.AcceptByteArray('\1\2\3', byte_arrays=True), '\1\2\3') -- self.assert_(isinstance(self.iface.AcceptUTF8String('abc'), unicode)) -- self.assert_(isinstance(self.iface.AcceptUTF8String('abc', utf8_strings=True), str)) -- self.assert_(isinstance(self.iface.AcceptUnicodeString('abc'), unicode)) -- self.assert_(isinstance(self.iface.AcceptUnicodeString('abc', utf8_strings=True), str)) -+ self.assertEqual(self.iface.AcceptListOfByte(b'\1\2\3'), [1,2,3]) -+ self.assertEqual(self.iface.AcceptListOfByte(b'\1\2\3', byte_arrays=True), b'\1\2\3') -+ self.assertEqual(self.iface.AcceptByteArray(b'\1\2\3'), [1,2,3]) -+ self.assertEqual(self.iface.AcceptByteArray(b'\1\2\3', byte_arrays=True), b'\1\2\3') -+ if is_py2: -+ self.assertTrue(isinstance(self.iface.AcceptUTF8String('abc'), unicode)) -+ self.assertTrue(isinstance(self.iface.AcceptUTF8String('abc', utf8_strings=True), str)) -+ unicode_type = (str if is_py3 else unicode) -+ self.assertTrue(isinstance(self.iface.AcceptUnicodeString('abc'), -+ unicode_type)) -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True -+ self.assertTrue(isinstance(self.iface.AcceptUnicodeString('abc', **kwargs), str)) - - def testIntrospection(self): - #test introspection -- print "\n********* Introspection Test ************" -- print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") -- print "Introspection test passed" -- self.assert_(True) -+ print("\n********* Introspection Test ************") -+ print(self.remote_object.Introspect( -+ dbus_interface="org.freedesktop.DBus.Introspectable")) -+ print("Introspection test passed") -+ self.assertTrue(True) - - def testMultiPathIntrospection(self): - # test introspection on an object exported in multiple places -@@ -130,80 +141,86 @@ - remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") - remote_object = self.bus.get_object(NAME, OBJECT + '/Multi2/3') - remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") -- self.assert_(True) -+ self.assertTrue(True) - - def testPythonTypes(self): - #test sending python types and getting them back -- print "\n********* Testing Python Types ***********" -+ print("\n********* Testing Python Types ***********") - - for send_val in test_types_vals: -- print "Testing %s"% str(send_val) -+ print("Testing %s"% str(send_val)) - recv_val = self.iface.Echo(send_val) -- self.assertEquals(send_val, recv_val) -- self.assertEquals(recv_val.variant_level, 1) -+ self.assertEqual(send_val, recv_val) -+ self.assertEqual(recv_val.variant_level, 1) - - def testMethodExtraInfoKeywords(self): -- print "Testing MethodExtraInfoKeywords..." -+ print("Testing MethodExtraInfoKeywords...") - sender, path, destination, message_cls = self.iface.MethodExtraInfoKeywords() -- self.assert_(sender.startswith(':')) -- self.assertEquals(path, '/org/freedesktop/DBus/TestSuitePythonObject') -+ self.assertTrue(sender.startswith(':')) -+ self.assertEqual(path, '/org/freedesktop/DBus/TestSuitePythonObject') - # we're using the "early binding" form of get_object (without - # follow_name_owner_changes), so the destination we actually sent it - # to will be the unique name -- self.assert_(destination.startswith(':')) -- self.assertEquals(message_cls, 'dbus.lowlevel.MethodCallMessage') -+ self.assertTrue(destination.startswith(':')) -+ self.assertEqual(message_cls, 'dbus.lowlevel.MethodCallMessage') - - def testUtf8StringsSync(self): -- send_val = u'foo' -+ if is_py3: -+ return -+ send_val = 'foo' - recv_val = self.iface.Echo(send_val, utf8_strings=True) -- self.assert_(isinstance(recv_val, str)) -- self.assert_(isinstance(recv_val, dbus.UTF8String)) -+ self.assertTrue(isinstance(recv_val, str)) -+ self.assertTrue(isinstance(recv_val, dbus.UTF8String)) - recv_val = self.iface.Echo(send_val, utf8_strings=False) -- self.assert_(isinstance(recv_val, unicode)) -- self.assert_(isinstance(recv_val, dbus.String)) -+ self.assertTrue(isinstance(recv_val, unicode)) -+ self.assertTrue(isinstance(recv_val, dbus.String)) - - def testBenchmarkIntrospect(self): -- print "\n********* Benchmark Introspect ************" -+ print("\n********* Benchmark Introspect ************") - a = time.time() -- print a -- print self.iface.GetComplexArray() -+ print(a) -+ print(self.iface.GetComplexArray()) - b = time.time() -- print b -- print "Delta: %f" % (b - a) -- self.assert_(True) -+ print(b) -+ print("Delta: %f" % (b - a)) -+ self.assertTrue(True) - - def testAsyncCalls(self): - #test sending python types and getting them back async -- print "\n********* Testing Async Calls ***********" -+ print("\n********* Testing Async Calls ***********") - - failures = [] - main_loop = gobject.MainLoop() - - class async_check: -- def __init__(self, test_controler, expected_result, do_exit, utf8): -+ def __init__(self, test_controler, expected_result, do_exit, **kwargs): - self.expected_result = expected_result - self.do_exit = do_exit -- self.utf8 = utf8 - self.test_controler = test_controler -+ if is_py2: -+ self.utf8 = kwargs['utf8'] -+ elif 'utf8' in kwargs: -+ raise TypeError("unexpected keyword argument 'utf8'") - - def callback(self, val): - try: - if self.do_exit: - main_loop.quit() - -- self.test_controler.assertEquals(val, self.expected_result) -- self.test_controler.assertEquals(val.variant_level, 1) -- if self.utf8 and not isinstance(val, dbus.UTF8String): -- failures.append('%r should have been utf8 but was not' % val) -- return -- elif not self.utf8 and isinstance(val, dbus.UTF8String): -- failures.append('%r should not have been utf8' % val) -- return -+ self.test_controler.assertEqual(val, self.expected_result) -+ self.test_controler.assertEqual(val.variant_level, 1) -+ if is_py2: -+ if self.utf8 and not isinstance(val, dbus.UTF8String): -+ failures.append('%r should have been utf8 but was not' % val) -+ return -+ elif not self.utf8 and isinstance(val, dbus.UTF8String): -+ failures.append('%r should not have been utf8' % val) -+ return - except Exception as e: - failures.append("%s:\n%s" % (e.__class__, e)) - - def error_handler(self, error): -- print error -+ print(error) - if self.do_exit: - main_loop.quit() - -@@ -211,20 +228,24 @@ - - last_type = test_types_vals[-1] - for send_val in test_types_vals: -- print "Testing %s" % str(send_val) -- utf8 = (send_val == 'gob@gob.com') -+ print("Testing %s" % str(send_val)) -+ kwargs = {} -+ if is_py2: -+ utf8 = (send_val == 'gob@gob.com') -+ kwargs['utf8'] = utf8 -+ kwargs['utf8_strings'] = utf8 - check = async_check(self, send_val, last_type == send_val, -- utf8) -+ **kwargs) - recv_val = self.iface.Echo(send_val, - reply_handler=check.callback, - error_handler=check.error_handler, -- utf8_strings=utf8) -+ **kwargs) - main_loop.run() - if failures: -- self.assert_(False, failures) -+ self.assertTrue(False, failures) - - def testStrictMarshalling(self): -- print "\n********* Testing strict return & signal marshalling ***********" -+ print("\n********* Testing strict return & signal marshalling ***********") - - # these values are the same as in the server, and the - # methods should only succeed when they are called with -@@ -233,82 +254,95 @@ - # with a different number - values = ["", ("",""), ("","",""), [], {}, ["",""], ["","",""]] - methods = [ -- (self.iface.ReturnOneString, 'SignalOneString', set([0]), set([0])), -- (self.iface.ReturnTwoStrings, 'SignalTwoStrings', set([1, 5]), set([1])), -- (self.iface.ReturnStruct, 'SignalStruct', set([1, 5]), set([1])), -- # all of our test values are sequences so will marshall correctly into an array :P -- (self.iface.ReturnArray, 'SignalArray', set(range(len(values))), set([3, 5, 6])), -- (self.iface.ReturnDict, 'SignalDict', set([0, 3, 4]), set([4])) -- ] -+ (self.iface.ReturnOneString, 'SignalOneString', set([0]), set([0])), -+ (self.iface.ReturnTwoStrings, 'SignalTwoStrings', set([1, 5]), set([1])), -+ (self.iface.ReturnStruct, 'SignalStruct', set([1, 5]), set([1])), -+ # all of our test values are sequences so will marshall correctly -+ # into an array :P -+ (self.iface.ReturnArray, 'SignalArray', set(range(len(values))), set([3, 5, 6])), -+ (self.iface.ReturnDict, 'SignalDict', set([0, 3, 4]), set([4])) -+ ] - - for (method, signal, success_values, return_values) in methods: -- print "\nTrying correct behaviour of", method._method_name -+ print("\nTrying correct behaviour of", method._method_name) - for value in range(len(values)): - try: - ret = method(value) -- except Exception, e: -- print "%s(%r) raised %s: %s" % (method._method_name, values[value], e.__class__, e) -+ except Exception as e: -+ print("%s(%r) raised %s: %s" % -+ (method._method_name, values[value], e.__class__, e)) - - # should fail if it tried to marshal the wrong type -- self.assert_(value not in success_values, "%s should succeed when we ask it to return %r\n%s\n%s" % (method._method_name, values[value], e.__class__, e)) -+ self.assertTrue(value not in success_values, -+ "%s should succeed when we ask it to " -+ "return %r\n%s\n%s" % ( -+ method._method_name, values[value], -+ e.__class__, e)) - else: -- print "%s(%r) returned %r" % (method._method_name, values[value], ret) -+ print("%s(%r) returned %r" % ( -+ method._method_name, values[value], ret)) - - # should only succeed if it's the right return type -- self.assert_(value in success_values, "%s should fail when we ask it to return %r" % (method._method_name, values[value])) -+ self.assertTrue(value in success_values, -+ "%s should fail when we ask it to " -+ "return %r" % ( -+ method._method_name, values[value])) - - # check the value is right too :D - returns = map(lambda n: values[n], return_values) -- self.assert_(ret in returns, "%s should return one of %r but it returned %r instead" % (method._method_name, returns, ret)) -+ self.assertTrue(ret in returns, -+ "%s should return one of %r but it " -+ "returned %r instead" % ( -+ method._method_name, returns, ret)) - -- print "\nTrying correct emission of", signal -+ print("\nTrying correct emission of", signal) - for value in range(len(values)): - try: - self.iface.EmitSignal(signal, value) -- except Exception, e: -- print "EmitSignal(%s, %r) raised %s" % (signal, values[value], e.__class__) -+ except Exception as e: -+ print("EmitSignal(%s, %r) raised %s" % (signal, values[value], e.__class__)) - - # should fail if it tried to marshal the wrong type -- self.assert_(value not in success_values, "EmitSignal(%s) should succeed when we ask it to return %r\n%s\n%s" % (signal, values[value], e.__class__, e)) -+ self.assertTrue(value not in success_values, "EmitSignal(%s) should succeed when we ask it to return %r\n%s\n%s" % (signal, values[value], e.__class__, e)) - else: -- print "EmitSignal(%s, %r) appeared to succeed" % (signal, values[value]) -+ print("EmitSignal(%s, %r) appeared to succeed" % (signal, values[value])) - - # should only succeed if it's the right return type -- self.assert_(value in success_values, "EmitSignal(%s) should fail when we ask it to return %r" % (signal, values[value])) -+ self.assertTrue(value in success_values, "EmitSignal(%s) should fail when we ask it to return %r" % (signal, values[value])) - - # FIXME: wait for the signal here - -- print -+ print() - - def testInheritance(self): -- print "\n********* Testing inheritance from dbus.method.Interface ***********" -+ print("\n********* Testing inheritance from dbus.method.Interface ***********") - ret = self.iface.CheckInheritance() -- print "CheckInheritance returned %s" % ret -- self.assert_(ret, "overriding CheckInheritance from TestInterface failed") -+ print("CheckInheritance returned %s" % ret) -+ self.assertTrue(ret, "overriding CheckInheritance from TestInterface failed") - - def testAsyncMethods(self): -- print "\n********* Testing asynchronous method implementation *******" -+ print("\n********* Testing asynchronous method implementation *******") - for async in (True, False): - for fail in (True, False): - try: - val = ('a', 1, False, [1,2], {1:2}) -- print "calling AsynchronousMethod with %s %s %s" % (async, fail, val) -+ print("calling AsynchronousMethod with %s %s %s" % (async, fail, val)) - ret = self.iface.AsynchronousMethod(async, fail, val) -- except Exception, e: -- self.assert_(fail, '%s: %s' % (e.__class__, e)) -- print "Expected failure: %s: %s" % (e.__class__, e) -+ except Exception as e: -+ self.assertTrue(fail, '%s: %s' % (e.__class__, e)) -+ print("Expected failure: %s: %s" % (e.__class__, e)) - else: -- self.assert_(not fail, 'Expected failure but succeeded?!') -- self.assertEquals(val, ret) -- self.assertEquals(1, ret.variant_level) -+ self.assertTrue(not fail, 'Expected failure but succeeded?!') -+ self.assertEqual(val, ret) -+ self.assertEqual(1, ret.variant_level) - - def testBusInstanceCaching(self): -- print "\n********* Testing dbus.Bus instance sharing *********" -+ print("\n********* Testing dbus.Bus instance sharing *********") - - # unfortunately we can't test the system bus here - # but the codepaths are the same - for (cls, type, func) in ((dbus.SessionBus, dbus.Bus.TYPE_SESSION, dbus.Bus.get_session), (dbus.StarterBus, dbus.Bus.TYPE_STARTER, dbus.Bus.get_starter)): -- print "\nTesting %s:" % cls.__name__ -+ print("\nTesting %s:" % cls.__name__) - - share_cls = cls() - share_type = dbus.Bus(bus_type=type) -@@ -318,43 +352,43 @@ - private_type = dbus.Bus(bus_type=type, private=True) - private_func = func(private=True) - -- print " - checking shared instances are the same..." -- self.assert_(share_cls == share_type, '%s should equal %s' % (share_cls, share_type)) -- self.assert_(share_type == share_func, '%s should equal %s' % (share_type, share_func)) -- -- print " - checking private instances are distinct from the shared instance..." -- self.assert_(share_cls != private_cls, '%s should not equal %s' % (share_cls, private_cls)) -- self.assert_(share_type != private_type, '%s should not equal %s' % (share_type, private_type)) -- self.assert_(share_func != private_func, '%s should not equal %s' % (share_func, private_func)) -- -- print " - checking private instances are distinct from each other..." -- self.assert_(private_cls != private_type, '%s should not equal %s' % (private_cls, private_type)) -- self.assert_(private_type != private_func, '%s should not equal %s' % (private_type, private_func)) -- self.assert_(private_func != private_cls, '%s should not equal %s' % (private_func, private_cls)) -+ print(" - checking shared instances are the same...") -+ self.assertTrue(share_cls == share_type, '%s should equal %s' % (share_cls, share_type)) -+ self.assertTrue(share_type == share_func, '%s should equal %s' % (share_type, share_func)) -+ -+ print(" - checking private instances are distinct from the shared instance...") -+ self.assertTrue(share_cls != private_cls, '%s should not equal %s' % (share_cls, private_cls)) -+ self.assertTrue(share_type != private_type, '%s should not equal %s' % (share_type, private_type)) -+ self.assertTrue(share_func != private_func, '%s should not equal %s' % (share_func, private_func)) -+ -+ print(" - checking private instances are distinct from each other...") -+ self.assertTrue(private_cls != private_type, '%s should not equal %s' % (private_cls, private_type)) -+ self.assertTrue(private_type != private_func, '%s should not equal %s' % (private_type, private_func)) -+ self.assertTrue(private_func != private_cls, '%s should not equal %s' % (private_func, private_cls)) - - def testSenderName(self): -- print '\n******** Testing sender name keyword ********' -+ print('\n******** Testing sender name keyword ********') - myself = self.iface.WhoAmI() -- print "I am", myself -+ print("I am", myself) - - def testBusGetNameOwner(self): - ret = self.bus.get_name_owner(NAME) -- self.assert_(ret.startswith(':'), ret) -+ self.assertTrue(ret.startswith(':'), ret) - - def testBusListNames(self): - ret = self.bus.list_names() -- self.assert_(NAME in ret, ret) -+ self.assertTrue(NAME in ret, ret) - - def testBusListActivatableNames(self): - ret = self.bus.list_activatable_names() -- self.assert_(NAME in ret, ret) -+ self.assertTrue(NAME in ret, ret) - - def testBusNameHasOwner(self): -- self.assert_(self.bus.name_has_owner(NAME)) -- self.assert_(not self.bus.name_has_owner('badger.mushroom.snake')) -+ self.assertTrue(self.bus.name_has_owner(NAME)) -+ self.assertTrue(not self.bus.name_has_owner('badger.mushroom.snake')) - - def testBusNameCreation(self): -- print '\n******** Testing BusName creation ********' -+ print('\n******** Testing BusName creation ********') - test = [('org.freedesktop.DBus.Python.TestName', True), - ('org.freedesktop.DBus.Python.TestName', True), - ('org.freedesktop.DBus.Python.InvalidName&^*%$', False)] -@@ -369,92 +403,92 @@ - names = {} - for (name, succeed) in test: - try: -- print "requesting %s" % name -+ print("requesting %s" % name) - busname = dbus.service.BusName(name, dbus.SessionBus()) - except Exception as e: -- print "%s:\n%s" % (e.__class__, e) -- self.assert_(not succeed, 'did not expect registering bus name %s to fail' % name) -+ print("%s:\n%s" % (e.__class__, e)) -+ self.assertTrue(not succeed, 'did not expect registering bus name %s to fail' % name) - else: -- print busname -- self.assert_(succeed, 'expected registering bus name %s to fail'% name) -+ print(busname) -+ self.assertTrue(succeed, 'expected registering bus name %s to fail'% name) - if name in names: -- self.assert_(names[name] == busname, 'got a new instance for same name %s' % name) -- print "instance of %s re-used, good!" % name -+ self.assertTrue(names[name] == busname, 'got a new instance for same name %s' % name) -+ print("instance of %s re-used, good!" % name) - else: - names[name] = busname - - del busname - -- print -+ print() - - del names - - bus = dbus.Bus() - ret = bus.name_has_owner('org.freedesktop.DBus.Python.TestName') -- self.assert_(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName') -+ self.assertTrue(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName') - - def testMultipleReturnWithoutSignature(self): - # https://bugs.freedesktop.org/show_bug.cgi?id=10174 - ret = self.iface.MultipleReturnWithoutSignature() -- self.assert_(not isinstance(ret, dbus.Struct), repr(ret)) -- self.assertEquals(ret, ('abc', 123)) -+ self.assertTrue(not isinstance(ret, dbus.Struct), repr(ret)) -+ self.assertEqual(ret, ('abc', 123)) - - def testListExportedChildObjects(self): -- self.assert_(self.iface.TestListExportedChildObjects()) -+ self.assertTrue(self.iface.TestListExportedChildObjects()) - - def testRemoveFromConnection(self): - # https://bugs.freedesktop.org/show_bug.cgi?id=10457 -- self.assert_(not self.iface.HasRemovableObject()) -- self.assert_(self.iface.AddRemovableObject()) -- self.assert_(self.iface.HasRemovableObject()) -+ self.assertTrue(not self.iface.HasRemovableObject()) -+ self.assertTrue(self.iface.AddRemovableObject()) -+ self.assertTrue(self.iface.HasRemovableObject()) - - removable = self.bus.get_object(NAME, OBJECT + '/RemovableObject') - iface = dbus.Interface(removable, IFACE) -- self.assert_(iface.IsThere()) -- self.assert_(iface.RemoveSelf()) -+ self.assertTrue(iface.IsThere()) -+ self.assertTrue(iface.RemoveSelf()) - -- self.assert_(not self.iface.HasRemovableObject()) -+ self.assertTrue(not self.iface.HasRemovableObject()) - - # and again... -- self.assert_(self.iface.AddRemovableObject()) -- self.assert_(self.iface.HasRemovableObject()) -- self.assert_(iface.IsThere()) -- self.assert_(iface.RemoveSelf()) -- self.assert_(not self.iface.HasRemovableObject()) -+ self.assertTrue(self.iface.AddRemovableObject()) -+ self.assertTrue(self.iface.HasRemovableObject()) -+ self.assertTrue(iface.IsThere()) -+ self.assertTrue(iface.RemoveSelf()) -+ self.assertTrue(not self.iface.HasRemovableObject()) - - def testFallbackObjectTrivial(self): - obj = self.bus.get_object(NAME, OBJECT + '/Fallback') - iface = dbus.Interface(obj, IFACE) - path, rel, unique_name = iface.TestPathAndConnKeywords() -- self.assertEquals(path, OBJECT + '/Fallback') -- self.assertEquals(rel, '/') -- self.assertEquals(unique_name, obj.bus_name) -+ self.assertEqual(path, OBJECT + '/Fallback') -+ self.assertEqual(rel, '/') -+ self.assertEqual(unique_name, obj.bus_name) - - def testFallbackObjectNested(self): - obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Nested') - iface = dbus.Interface(obj, IFACE) - path, rel, unique_name = iface.TestPathAndConnKeywords() -- self.assertEquals(path, OBJECT + '/Fallback/Nested') -- self.assertEquals(rel, '/') -- self.assertEquals(unique_name, obj.bus_name) -+ self.assertEqual(path, OBJECT + '/Fallback/Nested') -+ self.assertEqual(rel, '/') -+ self.assertEqual(unique_name, obj.bus_name) - - obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Nested/Badger/Mushroom') - iface = dbus.Interface(obj, IFACE) - path, rel, unique_name = iface.TestPathAndConnKeywords() -- self.assertEquals(path, OBJECT + '/Fallback/Nested/Badger/Mushroom') -- self.assertEquals(rel, '/Badger/Mushroom') -- self.assertEquals(unique_name, obj.bus_name) -+ self.assertEqual(path, OBJECT + '/Fallback/Nested/Badger/Mushroom') -+ self.assertEqual(rel, '/Badger/Mushroom') -+ self.assertEqual(unique_name, obj.bus_name) - - def testFallbackObject(self): - obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Badger/Mushroom') - iface = dbus.Interface(obj, IFACE) - path, rel, unique_name = iface.TestPathAndConnKeywords() -- self.assertEquals(path, OBJECT + '/Fallback/Badger/Mushroom') -- self.assertEquals(rel, '/Badger/Mushroom') -- self.assertEquals(unique_name, obj.bus_name) -+ self.assertEqual(path, OBJECT + '/Fallback/Badger/Mushroom') -+ self.assertEqual(rel, '/Badger/Mushroom') -+ self.assertEqual(unique_name, obj.bus_name) - - def testTimeoutSync(self): -- self.assert_(self.iface.BlockFor500ms(timeout=1.0) is None) -+ self.assertTrue(self.iface.BlockFor500ms(timeout=1.0) is None) - self.assertRaises(dbus.DBusException, - lambda: self.iface.BlockFor500ms(timeout=0.25)) - -@@ -463,11 +497,11 @@ - try: - self.iface.AsyncRaise() - except dbus.DBusException as e: -- self.assert_(e.get_dbus_name() == -+ self.assertTrue(e.get_dbus_name() == - 'org.freedesktop.bugzilla.bug12403', - e.get_dbus_name()) - else: -- self.assert_(False) -+ self.assertTrue(False) - - def testClosePrivateBus(self): - # fd.o #12096 -@@ -500,11 +534,11 @@ - reply_handler=incorrectly_returned, - error_handler=correctly_failed) - loop.run() -- self.assertEquals(passes, ['250', '1000']) -- self.assertEquals(fails, []) -+ self.assertEqual(passes, ['250', '1000']) -+ self.assertEqual(fails, []) - - def testTimeoutAsyncService(self): -- self.assert_(self.iface.AsyncWait500ms(timeout=1.0) is None) -+ self.assertTrue(self.iface.AsyncWait500ms(timeout=1.0) is None) - self.assertRaises(dbus.DBusException, - lambda: self.iface.AsyncWait500ms(timeout=0.25)) - -@@ -519,8 +553,8 @@ - try: - self.iface.RaiseValueError() - except Exception as e: -- self.assert_(isinstance(e, dbus.DBusException), e.__class__) -- self.assert_('.ValueError: Traceback ' in str(e), -+ self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) -+ self.assertTrue('.ValueError: Traceback ' in str(e), - 'Wanted a traceback but got:\n"""%s"""' % str(e)) - else: - raise AssertionError('Wanted an exception') -@@ -528,8 +562,8 @@ - try: - self.iface.RaiseDBusExceptionNoTraceback() - except Exception as e: -- self.assert_(isinstance(e, dbus.DBusException), e.__class__) -- self.assertEquals(str(e), -+ self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) -+ self.assertEqual(str(e), - 'com.example.Networking.ServerError: ' - 'Server not responding') - else: -@@ -538,8 +572,8 @@ - try: - self.iface.RaiseDBusExceptionWithTraceback() - except Exception as e: -- self.assert_(isinstance(e, dbus.DBusException), e.__class__) -- self.assert_(str(e).startswith('com.example.Misc.RealityFailure: ' -+ self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) -+ self.assertTrue(str(e).startswith('com.example.Misc.RealityFailure: ' - 'Traceback '), - 'Wanted a traceback but got:\n%s' % str(e)) - else: -@@ -557,20 +591,20 @@ - print "\n********* Introspection Test ************" - print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") - print "Introspection test passed" -- self.assert_(True) -+ self.assertTrue(True) - - def testCalls(self): - print "\n********* Call Test ************" - result = self.iface.ManyArgs(1000, 'Hello GLib', 2) - print result -- self.assert_(result == [2002.0, 'HELLO GLIB']) -+ self.assertTrue(result == [2002.0, 'HELLO GLIB']) - - arg0 = {"Dude": 1, "john": "palmieri", "python": 2.4} - result = self.iface.ManyStringify(arg0) - print result - - print "Call test passed" -- self.assert_(True) -+ self.assertTrue(True) - - def testPythonTypes(self): - print "\n********* Testing Python Types ***********" -@@ -578,7 +612,7 @@ - for send_val in test_types_vals: - print "Testing %s"% str(send_val) - recv_val = self.iface.EchoVariant(send_val) -- self.assertEquals(send_val, recv_val.object) -+ self.assertEqual(send_val, recv_val.object) - """ - if __name__ == '__main__': - gobject.threads_init() ---- a/test/test-p2p.py -+++ b/test/test-p2p.py -@@ -24,22 +24,20 @@ - # DEALINGS IN THE SOFTWARE. - - --import sys - import os - import unittest --import time - import logging --import weakref - - builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) - pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - - import dbus --import _dbus_bindings --import gobject - import dbus.glib - import dbus.service - -+from dbus._compat import is_py2 -+from gi.repository import GObject as gobject -+ - - logging.basicConfig() - logging.getLogger().setLevel(1) -@@ -58,33 +56,40 @@ - # using dbus.bus.BusConnection! - conn = dbus.connection.Connection( - os.environ['DBUS_SESSION_BUS_ADDRESS']) -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True - unique = conn.call_blocking('org.freedesktop.DBus', - '/org/freedesktop/DBus', - 'org.freedesktop.DBus', 'Hello', -- '', (), utf8_strings=True) -- self.assert_(unique.__class__ == dbus.UTF8String, repr(unique)) -- self.assert_(unique.startswith(':'), unique) -+ '', (), **kwargs) -+ if is_py2: -+ self.assertTrue(unique.__class__ == dbus.UTF8String, repr(unique)) -+ self.assertTrue(unique.startswith(':'), unique) - conn.set_unique_name(unique) - return conn, unique - - def testCall(self): - conn, unique = self.get_conn_and_unique() - ret = conn.call_blocking(NAME, OBJECT, IFACE, 'Echo', 'v', ('V',)) -- self.assertEquals(ret, 'V') -+ self.assertEqual(ret, 'V') - - def testCallThroughProxy(self): - conn, unique = self.get_conn_and_unique() - proxy = conn.get_object(NAME, OBJECT) - iface = dbus.Interface(proxy, IFACE) - ret = iface.Echo('V') -- self.assertEquals(ret, 'V') -+ self.assertEqual(ret, 'V') - - def testSetUniqueName(self): - conn, unique = self.get_conn_and_unique() -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True - ret = conn.call_blocking(NAME, OBJECT, IFACE, - 'MethodExtraInfoKeywords', '', (), -- utf8_strings=True) -- self.assertEquals(ret, (unique, OBJECT, NAME, -+ **kwargs) -+ self.assertEqual(ret, (unique, OBJECT, NAME, - 'dbus.lowlevel.MethodCallMessage')) - - ---- a/test/test-service.py -+++ b/test/test-service.py -@@ -23,7 +23,6 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - --import sys - import os - import logging - from time import sleep -@@ -38,17 +37,17 @@ - - import dbus.service - import dbus.glib --import gobject - import random - - from dbus.gobject_service import ExportedGObject -+from gi.repository import GObject as gobject -+from dbus._compat import is_py2, is_py3 - - --logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='w') -+logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='a') - logging.getLogger().setLevel(1) - logger = logging.getLogger('test-service') - -- - NAME = "org.freedesktop.DBus.TestSuitePythonService" - IFACE = "org.freedesktop.DBus.TestSuiteInterface" - OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject" -@@ -137,10 +136,14 @@ - - @dbus.service.method(IFACE, in_signature='s', out_signature='s') - def AcceptUnicodeString(self, foo): -- assert isinstance(foo, unicode), (foo, foo.__class__.__mro__) -+ unicode_type = (str if is_py3 else unicode) -+ assert isinstance(foo, unicode_type), (foo, foo.__class__.__mro__) - return foo - -- @dbus.service.method(IFACE, in_signature='s', out_signature='s', utf8_strings=True) -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True -+ @dbus.service.method(IFACE, in_signature='s', out_signature='s', **kwargs) - def AcceptUTF8String(self, foo): - assert isinstance(foo, str), (foo, foo.__class__.__mro__) - return foo -@@ -158,9 +161,10 @@ - assert isinstance(foo, list), (foo, foo.__class__.__mro__) - return foo - -- @dbus.service.method(IFACE, in_signature='ay', out_signature='ay', byte_arrays=True) -+ @dbus.service.method(IFACE, in_signature='ay', out_signature='ay', -+ byte_arrays=True) - def AcceptByteArray(self, foo): -- assert isinstance(foo, str), (foo, foo.__class__.__mro__) -+ assert isinstance(foo, bytes), (foo, foo.__class__.__mro__) - return foo - - @dbus.service.method(IFACE) -@@ -254,11 +258,13 @@ - assert objs_org == ['freedesktop'], objs_org - return True - -- @dbus.service.method(IFACE, in_signature='bbv', out_signature='v', async_callbacks=('return_cb', 'error_cb')) -+ @dbus.service.method(IFACE, in_signature='bbv', out_signature='v', -+ async_callbacks=('return_cb', 'error_cb')) - def AsynchronousMethod(self, async, fail, variant, return_cb, error_cb): - try: - if async: -- gobject.timeout_add(500, self.AsynchronousMethod, False, fail, variant, return_cb, error_cb) -+ gobject.timeout_add(500, self.AsynchronousMethod, False, fail, -+ variant, return_cb, error_cb) - return - else: - if fail: -@@ -270,7 +276,8 @@ - except Exception as e: - error_cb(e) - -- @dbus.service.method(IFACE, in_signature='', out_signature='s', sender_keyword='sender') -+ @dbus.service.method(IFACE, in_signature='', out_signature='s', -+ sender_keyword='sender') - def WhoAmI(self, sender): - return sender - -@@ -335,10 +342,31 @@ - - raise_cb(Fdo12403Error()) - --session_bus = dbus.SessionBus() --global_name = dbus.service.BusName(NAME, bus=session_bus) --object = TestObject(global_name) --g_object = TestGObject(global_name) --fallback_object = Fallback(session_bus) --loop = gobject.MainLoop() --loop.run() -+ -+def main(): -+ global session_bus -+ logger.info('getting session bus') -+ session_bus = dbus.SessionBus() -+ logger.info('getting bus name %s', NAME) -+ global_name = dbus.service.BusName(NAME, bus=session_bus) -+ logger.info('making TestObject') -+ object = TestObject(global_name) -+ logger.info('making TestGObject') -+ g_object = TestGObject(global_name) -+ logger.info('making Fallback') -+ fallback_object = Fallback(session_bus) -+ logger.info('creating mainloop') -+ loop = gobject.MainLoop() -+ logger.info('running') -+ loop.run() -+ logger.info('done') -+ -+ -+if __name__ == '__main__': -+ session_bus = None -+ try: -+ logger.info('entering main') -+ main() -+ except: -+ logger.exception('test-service main failure') -+ raise ---- a/test/test-signals.py -+++ b/test/test-signals.py -@@ -34,9 +34,9 @@ - - import dbus - import _dbus_bindings --import gobject - import dbus.glib - import dbus.service -+from gi.repository import GObject as gobject - - - logging.basicConfig() ---- a/test/test-standalone.py -+++ b/test/test-standalone.py -@@ -26,18 +26,28 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - -+from __future__ import unicode_literals -+ - import sys - import os - import unittest --import time --from traceback import print_exc - - builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) - pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) - - import _dbus_bindings - import dbus -+import dbus.lowlevel as lowlevel - import dbus.types as types -+from dbus._compat import is_py2, is_py3 -+ -+if is_py3: -+ def make_long(n): -+ return n -+else: -+ def make_long(n): -+ return long(n) -+ - - # Check that we're using the right versions - if not dbus.__file__.startswith(pydir): -@@ -57,87 +67,161 @@ - class TestTypes(unittest.TestCase): - - def test_Dictionary(self): -- self.assertEquals(types.Dictionary({'foo':'bar'}), {'foo':'bar'}) -- self.assertEquals(types.Dictionary({}, variant_level=2), {}) -- self.assertEquals(types.Dictionary({}, variant_level=2).variant_level, 2) -+ self.assertEqual(types.Dictionary({'foo':'bar'}), {'foo':'bar'}) -+ self.assertEqual(types.Dictionary({}, variant_level=2), {}) -+ self.assertEqual(types.Dictionary({}, variant_level=2).variant_level, 2) - - def test_Array(self): -- self.assertEquals(types.Array(['foo','bar']), ['foo','bar']) -- self.assertEquals(types.Array([], variant_level=2), []) -- self.assertEquals(types.Array([], variant_level=2).variant_level, 2) -+ self.assertEqual(types.Array(['foo','bar']), ['foo','bar']) -+ self.assertEqual(types.Array([], variant_level=2), []) -+ self.assertEqual(types.Array([], variant_level=2).variant_level, 2) - - def test_Double(self): -- self.assertEquals(types.Double(0.0), 0.0) -- self.assertEquals(types.Double(0.125, variant_level=2), 0.125) -- self.assertEquals(types.Double(0.125, variant_level=2).variant_level, 2) -+ 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) - - def test_Struct(self): - x = types.Struct(('',)) -- self.assertEquals(x.variant_level, 0) -- self.assertEquals(x, ('',)) -+ self.assertEqual(x.variant_level, 0) -+ self.assertEqual(x, ('',)) - x = types.Struct('abc', variant_level=42) -- self.assertEquals(x.variant_level, 42) -- self.assertEquals(x, ('a','b','c')) -+ self.assertEqual(x.variant_level, 42) -+ self.assertEqual(x, ('a','b','c')) - - def test_Byte(self): -- self.assertEquals(types.Byte('x', variant_level=2), types.Byte(ord('x'))) -+ self.assertEqual(types.Byte(b'x', variant_level=2), -+ types.Byte(ord('x'))) -+ self.assertEqual(types.Byte(1), 1) -+ self.assertEqual(types.Byte(make_long(1)), 1) -+ self.assertRaises(Exception, lambda: types.Byte(b'ab')) -+ self.assertRaises(TypeError, types.Byte, '\x12xxxxxxxxxxxxx') -+ -+ # Byte from a unicode object: what would that even mean? -+ self.assertRaises(Exception, -+ lambda: types.Byte(b'a'.decode('latin-1'))) - - def test_ByteArray(self): -- self.assertEquals(types.ByteArray(''), '') -+ self.assertEqual(types.ByteArray(b''), b'') - - def test_object_path_attr(self): - class MyObject(object): - __dbus_object_path__ = '/foo' - from _dbus_bindings import SignalMessage -- self.assertEquals(SignalMessage.guess_signature(MyObject()), 'o') -+ self.assertEqual(SignalMessage.guess_signature(MyObject()), 'o') - - def test_integers(self): -+ subclasses = [int] -+ if is_py2: -+ subclasses.append(long) -+ subclasses = tuple(subclasses) - # This is an API guarantee. Note that exactly which of these types - # are ints and which of them are longs is *not* guaranteed. - for cls in (types.Int16, types.UInt16, types.Int32, types.UInt32, - types.Int64, types.UInt64): -- self.assert_(issubclass(cls, (int, long))) -- self.assert_(isinstance(cls(0), (int, long))) -- self.assertEquals(cls(0), 0) -- self.assertEquals(cls(23, variant_level=1), 23) -- self.assertEquals(cls(23, variant_level=1).variant_level, 1) -+ self.assertTrue(issubclass(cls, subclasses)) -+ self.assertTrue(isinstance(cls(0), subclasses)) -+ self.assertEqual(cls(0), 0) -+ self.assertEqual(cls(23, variant_level=1), 23) -+ self.assertEqual(cls(23, variant_level=1).variant_level, 1) - - def test_integer_limits_16(self): -- self.assertEquals(types.Int16(0x7fff), 0x7fff) -- self.assertEquals(types.Int16(-0x8000), -0x8000) -- self.assertEquals(types.UInt16(0xffff), 0xffff) -+ self.assertEqual(types.Int16(0x7fff), 0x7fff) -+ self.assertEqual(types.Int16(-0x8000), -0x8000) -+ self.assertEqual(types.UInt16(0xffff), 0xffff) - self.assertRaises(Exception, types.Int16, 0x8000) - self.assertRaises(Exception, types.Int16, -0x8001) - self.assertRaises(Exception, types.UInt16, 0x10000) - - def test_integer_limits_32(self): -- self.assertEquals(types.Int32(0x7fffffff), 0x7fffffff) -- self.assertEquals(types.Int32(-0x80000000L), -0x80000000L) -- self.assertEquals(types.UInt32(0xffffffffL), 0xffffffffL) -- self.assertRaises(Exception, types.Int32, 0x80000000L) -- self.assertRaises(Exception, types.Int32, -0x80000001L) -- self.assertRaises(Exception, types.UInt32, 0x100000000L) -+ self.assertEqual(types.Int32(0x7fffffff), 0x7fffffff) -+ self.assertEqual(types.Int32(make_long(-0x80000000)), -+ make_long(-0x80000000)) -+ self.assertEqual(types.UInt32(make_long(0xffffffff)), -+ make_long(0xffffffff)) -+ self.assertRaises(Exception, types.Int32, make_long(0x80000000)) -+ self.assertRaises(Exception, types.Int32, make_long(-0x80000001)) -+ self.assertRaises(Exception, types.UInt32, make_long(0x100000000)) - - def test_integer_limits_64(self): -- self.assertEquals(types.Int64(0x7fffffffffffffffL), 0x7fffffffffffffffL) -- self.assertEquals(types.Int64(-0x8000000000000000L), -0x8000000000000000L) -- self.assertEquals(types.UInt64(0xffffffffffffffffL), 0xffffffffffffffffL) -- self.assertRaises(Exception, types.Int16, 0x8000000000000000L) -- self.assertRaises(Exception, types.Int16, -0x8000000000000001L) -- self.assertRaises(Exception, types.UInt16, 0x10000000000000000L) -+ self.assertEqual(types.Int64(make_long(0x7fffffffffffffff)), -+ make_long(0x7fffffffffffffff)) -+ self.assertEqual(types.Int64(make_long(-0x8000000000000000)), -+ make_long(-0x8000000000000000)) -+ self.assertEqual(types.UInt64(make_long(0xffffffffffffffff)), -+ make_long(0xffffffffffffffff)) -+ self.assertRaises(Exception, types.Int16, -+ make_long(0x8000000000000000)) -+ self.assertRaises(Exception, types.Int16, -+ make_long(-0x8000000000000001)) -+ self.assertRaises(Exception, types.UInt16, -+ make_long(0x10000000000000000)) - - def test_Signature(self): - self.assertRaises(Exception, types.Signature, 'a') -- self.assertEquals(types.Signature('ab', variant_level=23), 'ab') -- self.assert_(isinstance(types.Signature('ab'), str)) -- self.assertEquals(tuple(types.Signature('ab(xt)a{sv}')), -- ('ab', '(xt)', 'a{sv}')) -- self.assert_(isinstance(tuple(types.Signature('ab'))[0], -- types.Signature)) -+ self.assertEqual(types.Signature('ab', variant_level=23), 'ab') -+ self.assertTrue(isinstance(types.Signature('ab'), str)) -+ self.assertEqual(tuple(types.Signature('ab(xt)a{sv}')), -+ ('ab', '(xt)', 'a{sv}')) -+ self.assertTrue(isinstance(tuple(types.Signature('ab'))[0], -+ types.Signature)) - - - class TestMessageMarshalling(unittest.TestCase): - -+ def test_path(self): -+ s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') -+ self.assertEqual(s.get_path(), types.ObjectPath('/a/b/c')) -+ self.assertEqual(type(s.get_path()), types.ObjectPath) -+ self.assertEqual(s.get_path_decomposed(), ['a', 'b', 'c']) -+ # this is true in both major versions: it's a bytestring in -+ # Python 2 and a Unicode string in Python 3 -+ self.assertEqual(type(s.get_path_decomposed()[0]), str) -+ self.assertTrue(s.has_path('/a/b/c')) -+ self.assertFalse(s.has_path('/a/b')) -+ self.assertFalse(s.has_path('/a/b/c/d')) -+ -+ s = lowlevel.SignalMessage('/', 'foo.bar', 'baz') -+ self.assertEqual(s.get_path(), types.ObjectPath('/')) -+ self.assertEqual(s.get_path().__class__, types.ObjectPath) -+ self.assertEqual(s.get_path_decomposed(), []) -+ self.assertTrue(s.has_path('/')) -+ self.assertFalse(s.has_path(None)) -+ -+ def test_sender(self): -+ s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') -+ self.assertEqual(s.get_sender(), None) -+ self.assertFalse(s.has_sender(':1.23')) -+ s.set_sender(':1.23') -+ self.assertEqual(s.get_sender(), ':1.23') -+ # bytestring in Python 2, Unicode string in Python 3 -+ self.assertEqual(type(s.get_sender()), str) -+ self.assertTrue(s.has_sender(':1.23')) -+ -+ def test_destination(self): -+ s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') -+ self.assertEqual(s.get_destination(), None) -+ self.assertFalse(s.has_destination(':1.23')) -+ s.set_destination(':1.23') -+ self.assertEqual(s.get_destination(), ':1.23') -+ # bytestring in Python 2, Unicode string in Python 3 -+ self.assertEqual(type(s.get_destination()), str) -+ self.assertTrue(s.has_destination(':1.23')) -+ -+ def test_interface(self): -+ s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') -+ self.assertEqual(s.get_interface(), 'foo.bar') -+ # bytestring in Python 2, Unicode string in Python 3 -+ self.assertEqual(type(s.get_interface()), str) -+ self.assertTrue(s.has_interface('foo.bar')) -+ -+ def test_member(self): -+ s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') -+ self.assertEqual(s.get_member(), 'baz') -+ # bytestring in Python 2, Unicode string in Python 3 -+ self.assertEqual(type(s.get_member()), str) -+ self.assertTrue(s.has_member('baz')) -+ - def test_count(self): - from _dbus_bindings import SignalMessage - s = SignalMessage('/', 'foo.bar', 'baz') -@@ -158,7 +242,7 @@ - 'should fail') - - def test_append(self): -- aeq = self.assertEquals -+ aeq = self.assertEqual - from _dbus_bindings import SignalMessage - s = SignalMessage('/', 'foo.bar', 'baz') - s.append([types.Byte(1)], signature='ay') -@@ -169,28 +253,49 @@ - s.append([], signature='ay') - aeq(s.get_args_list(), [[]]) - -+ def test_append_Byte(self): -+ aeq = self.assertEqual -+ from _dbus_bindings import SignalMessage -+ -+ s = SignalMessage('/', 'foo.bar', 'baz') -+ s.append(0xFE, signature='y') -+ aeq(s.get_args_list(), [types.Byte(0xFE)]) -+ -+ s = SignalMessage('/', 'foo.bar', 'baz') -+ s.append(b'\xfe', signature='y') -+ aeq(s.get_args_list(), [types.Byte(0xFE)]) -+ -+ # appending a unicode object (including str in Python 3) -+ # is not allowed -+ s = SignalMessage('/', 'foo.bar', 'baz') -+ self.assertRaises(Exception, -+ lambda: s.append('a'.decode('latin-1'), signature='y')) -+ -+ s = SignalMessage('/', 'foo.bar', 'baz') -+ self.assertRaises(Exception, -+ lambda: s.append(b'ab', signature='y')) -+ - def test_append_ByteArray(self): -- aeq = self.assertEquals -+ aeq = self.assertEqual - from _dbus_bindings import SignalMessage - s = SignalMessage('/', 'foo.bar', 'baz') -- s.append(types.ByteArray('ab'), signature='ay') -- aeq(s.get_args_list(), [[types.Byte('a'), types.Byte('b')]]) -+ s.append(types.ByteArray(b'ab'), signature='ay') -+ aeq(s.get_args_list(), [[types.Byte(b'a'), types.Byte(b'b')]]) - s = SignalMessage('/', 'foo.bar', 'baz') -- s.append(types.ByteArray('ab'), signature='av') -- aeq(s.get_args_list(), [[types.Byte('a'), types.Byte('b')]]) -+ s.append(types.ByteArray(b'ab'), signature='av') -+ aeq(s.get_args_list(), [[types.Byte(b'a'), types.Byte(b'b')]]) - s = SignalMessage('/', 'foo.bar', 'baz') -- s.append(types.ByteArray(''), signature='ay') -+ s.append(types.ByteArray(b''), signature='ay') - aeq(s.get_args_list(), [[]]) -- aeq(s.get_args_list(byte_arrays=True), [types.ByteArray('')]) -+ aeq(s.get_args_list(byte_arrays=True), [types.ByteArray(b'')]) - - def test_append_Variant(self): -- a = self.assert_ -- aeq = self.assertEquals -+ aeq = self.assertEqual - from _dbus_bindings import SignalMessage - s = SignalMessage('/', 'foo.bar', 'baz') - s.append(types.Int32(1, variant_level=0), - types.String('a', variant_level=42), -- types.Array([types.Byte('a', variant_level=1), -+ types.Array([types.Byte(b'a', variant_level=1), - types.UInt32(123, variant_level=1)], - signature='v'), - signature='vvv') -@@ -205,7 +310,7 @@ - aeq(args[2].signature, 'v') - - def test_guess_signature(self): -- aeq = self.assertEquals -+ aeq = self.assertEqual - from _dbus_bindings import Message - aeq(Message.guess_signature(('a','b')), '(ss)') - aeq(Message.guess_signature('a','b'), 'ss') -@@ -213,13 +318,20 @@ - aeq(Message.guess_signature(('a',)), '(s)') - aeq(Message.guess_signature('abc'), 's') - aeq(Message.guess_signature(types.Int32(123)), 'i') -- aeq(Message.guess_signature(types.ByteArray('abc')), 'ay') -+ aeq(Message.guess_signature(types.ByteArray(b'abc')), 'ay') - aeq(Message.guess_signature(('a',)), '(s)') - aeq(Message.guess_signature(['a']), 'as') - aeq(Message.guess_signature({'a':'b'}), 'a{ss}') - -+ def test_guess_signature_python_ints(self): -+ aeq = self.assertEqual -+ from _dbus_bindings import Message -+ aeq(Message.guess_signature(7), 'i') -+ if is_py2: -+ aeq(Message.guess_signature(make_long(7)), 'x') -+ - def test_guess_signature_dbus_types(self): -- aeq = self.assertEquals -+ aeq = self.assertEqual - from _dbus_bindings import Message - gs = Message.guess_signature - aeq(gs(types.Dictionary({'a':'b'})), 'a{ss}') -@@ -229,12 +341,14 @@ - aeq(gs(types.Array([types.Int32(1)], signature='u')), 'au') - - def test_get_args_options(self): -- aeq = self.assertEquals -+ aeq = self.assertEqual - s = _dbus_bindings.SignalMessage('/', 'foo.bar', 'baz') -- s.append('b', 'bytes', -1, 1, 'str', 'var', signature='yayiusv') -- aeq(s.get_args_list(), [ord('b'), -- [ord('b'),ord('y'),ord('t'),ord('e'), ord('s')], -- -1, 1, u'str', u'var']) -+ s.append(b'b', b'bytes', -1, 1, 'str', 'var', signature='yayiusv') -+ aeq(s.get_args_list(), [ -+ ord('b'), -+ [ord('b'),ord('y'),ord('t'),ord('e'), ord('s')], -+ -1, 1, 'str', 'var' -+ ]) - byte, bytes, int32, uint32, string, variant = s.get_args_list() - aeq(byte.__class__, types.Byte) - aeq(bytes.__class__, types.Array) -@@ -250,24 +364,32 @@ - byte_arrays=True) - aeq(byte.__class__, types.Byte) - aeq(bytes.__class__, types.ByteArray) -- aeq(bytes, 'bytes') -- aeq(bytes[0].__class__, str) -+ aeq(bytes, b'bytes') -+ if is_py3: -+ aeq(bytes[0].__class__, int) -+ else: -+ aeq(bytes[0].__class__, str) - aeq(int32.__class__, types.Int32) - aeq(uint32.__class__, types.UInt32) - aeq(string.__class__, types.String) - aeq(variant.__class__, types.String) - aeq(variant.variant_level, 1) - -+ kwargs = {} -+ if is_py2: -+ kwargs['utf8_strings'] = True - byte, bytes, int32, uint32, string, variant = s.get_args_list( -- utf8_strings=True) -+ **kwargs) - aeq(byte.__class__, types.Byte) - aeq(bytes.__class__, types.Array) - aeq(bytes[0].__class__, types.Byte) - aeq(int32.__class__, types.Int32) - aeq(uint32.__class__, types.UInt32) -- aeq(string.__class__, types.UTF8String) -+ if is_py2: -+ aeq(string.__class__, types.UTF8String) - aeq(string, 'str') -- aeq(variant.__class__, types.UTF8String) -+ if is_py2: -+ aeq(variant.__class__, types.UTF8String) - aeq(variant.variant_level, 1) - aeq(variant, 'var') - -@@ -278,7 +400,7 @@ - s = SignalMessage('/', 'foo.bar', 'baz') - s.append(MyObject(), signature='o') - s.append(MyObject()) -- self.assertEquals(s.get_args_list(), ['/foo', '/foo']) -+ self.assertEqual(s.get_args_list(), ['/foo', '/foo']) - - def test_struct(self): - from _dbus_bindings import SignalMessage -@@ -300,5 +422,28 @@ - 'should fail') - - -+class TestMatching(unittest.TestCase): -+ def setUp(self): -+ from _dbus_bindings import SignalMessage -+ from dbus.connection import SignalMatch -+ self._message = SignalMessage('/', 'a.b', 'c') -+ class FakeConn(object): pass -+ def ignore_cb(*args, **kws): pass -+ self._match = SignalMatch(FakeConn(), None, '/', None, None, -+ ignore_cb, arg0='/') -+ -+ def test_string_match(self): -+ self._message.append('/', signature='s') -+ self.assertTrue(self._match.maybe_handle_message(self._message)) -+ -+ def test_object_path_no_match(self): -+ self._message.append('/', signature='o') -+ self.assertFalse(self._match.maybe_handle_message(self._message)) -+ -+ - if __name__ == '__main__': -- unittest.main() -+ # Python 2.6 doesn't accept a `verbosity` keyword. -+ kwargs = {} -+ if sys.version_info[:2] >= (2, 7): -+ kwargs['verbosity'] = 2 -+ unittest.main(**kwargs) ---- a/test/test-unusable-main-loop.py -+++ b/test/test-unusable-main-loop.py -@@ -22,6 +22,7 @@ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - # DEALINGS IN THE SOFTWARE. - -+from __future__ import print_function - import dbus - - from dbus_py_test import UnusableMainLoop -@@ -30,8 +31,8 @@ - UnusableMainLoop(set_as_default=True) - try: - bus = dbus.SessionBus() -- except ValueError, e: -- print "Correctly got ValueError from UnusableMainLoop" -+ except ValueError as e: -+ print("Correctly got ValueError from UnusableMainLoop") - else: - raise AssertionError("Expected ValueError from UnusableMainLoop") - ---- a/Makefile.am -+++ b/Makefile.am -@@ -20,6 +20,7 @@ - nobase_python_PYTHON = \ - dbus/bus.py \ - dbus/connection.py \ -+ dbus/_compat.py \ - dbus/_dbus.py \ - dbus/_version.py \ - dbus/decorators.py \ diff -Nru dbus-python-0.84.0/debian/patches/series dbus-python-1.0.0/debian/patches/series --- dbus-python-0.84.0/debian/patches/series 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -since-0.84.0.patch -python3-support.patch diff -Nru dbus-python-0.84.0/debian/patches/since-0.84.0.patch dbus-python-1.0.0/debian/patches/since-0.84.0.patch --- dbus-python-0.84.0/debian/patches/since-0.84.0.patch 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/patches/since-0.84.0.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,1064 +0,0 @@ -Description: Upstream patch applied to git master branch from 0.84.0 to HEAD. - This is prepares the tree for Python 3 support. -Author: Barry Warsaw -Bug-Ubuntu: https://bugs.launchpad.net/bugs/893091 -Bug: https://bugs.freedesktop.org/show_bug.cgi?id=26420 -Forwarded: not-needed - -diff --git a/Makefile.am b/Makefile.am -index 3b5a46b..01c8a5a 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -18,10 +18,8 @@ EXTRA_DIST = \ - # === dbus package === - - nobase_python_PYTHON = \ -- dbus_bindings.py \ - dbus/bus.py \ - dbus/connection.py \ -- dbus/dbus_bindings.py \ - dbus/_dbus.py \ - dbus/_version.py \ - dbus/decorators.py \ -@@ -127,7 +125,7 @@ api api/index.html: $(nobase_python_PYTHON) \ - $(PYTHON) -Wignore::DeprecationWarning \ - $(EPYDOC) -o $(abs_top_builddir)/api --html \ - --docformat restructuredtext -v \ -- `find dbus -name '*.py' | grep -v dbus_bindings \ -+ `find dbus -name '*.py' \ - | sed -e 's#/__init__\.py##g' \ - -e 's/\.py\>//g' -e 's#/#.#'g` \ - || { rm -rf api; exit 1; } -diff --git a/NEWS b/NEWS -index 652ce41..c45030a 100644 ---- a/NEWS -+++ b/NEWS -@@ -1,3 +1,28 @@ -+D-Bus Python Bindings 0.84.1 (UNRELEASED) -+========================================= -+ -+Dependencies: -+ -+* libdbus 1.4 or later is now required. -+ -+* Python 2.6 or later is now required. -+ -+API changes: -+ -+* dbus_bindings, which was never meant to be public API and has been -+ deprecated for nearly 5 years, has finally been removed. -+ -+Fixes: -+ -+* OOM while appending a unicode object to a message no longer leaks a string -+ (Barry Warsaw) -+ -+* If libdbus somehow gives us invalid UTF-8, don't crash (Barry Warsaw) -+ -+* Fix rst2html failure in non-UTF-8 locales (Alexandre Rostovtsev) -+ -+* Start to port to Python 3 compatibility (Barry Warsaw) -+ - D-Bus Python Bindings 0.84.0 (2011-05-25) - ========================================= - -diff --git a/_dbus_bindings/abstract.c b/_dbus_bindings/abstract.c -index 30def6e..4797ca5 100644 ---- a/_dbus_bindings/abstract.c -+++ b/_dbus_bindings/abstract.c -@@ -201,12 +201,12 @@ DBusPythonInt_tp_repr(PyObject *self) - if (!parent_repr) return NULL; - if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, -+ my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr)); - } - /* whether my_repr is NULL or not: */ -@@ -313,12 +313,12 @@ DBusPythonFloat_tp_repr(PyObject *self) - if (!parent_repr) return NULL; - if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, -+ my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr)); - } - /* whether my_repr is NULL or not: */ -@@ -424,12 +424,12 @@ DBusPythonString_tp_repr(PyObject *self) - Py_CLEAR(vl_obj); - if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, -+ my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr)); - } - /* whether my_repr is NULL or not: */ -@@ -542,12 +542,12 @@ DBusPythonLong_tp_repr(PyObject *self) - Py_CLEAR(vl_obj); - if (variant_level) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, -+ my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr)); - } - /* whether my_repr is NULL or not: */ -diff --git a/_dbus_bindings/bytes.c b/_dbus_bindings/bytes.c -index 5c76ec2..d59e70b 100644 ---- a/_dbus_bindings/bytes.c -+++ b/_dbus_bindings/bytes.c -@@ -89,7 +89,7 @@ Byte_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - else if (PyInt_Check(obj)) { - long i = PyInt_AS_LONG(obj); - -- if (obj->ob_type == cls && -+ if (Py_TYPE(obj) == cls && - ((DBusPyIntBase *)obj)->variant_level == variantness) { - Py_INCREF(obj); - return obj; -@@ -127,8 +127,7 @@ Byte_tp_str(PyObject *self) - } - - PyTypeObject DBusPyByte_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Byte", - 0, - 0, -@@ -194,8 +193,7 @@ PyDoc_STRVAR(ByteArray_tp_doc, - ); - - PyTypeObject DBusPyByteArray_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.ByteArray", - 0, - 0, -diff --git a/_dbus_bindings/conn.c b/_dbus_bindings/conn.c -index c90edf7..933cfdb 100644 ---- a/_dbus_bindings/conn.c -+++ b/_dbus_bindings/conn.c -@@ -398,7 +398,7 @@ static void Connection_tp_dealloc(Connection *self) - - DBG("Connection at %p: freeing self", self); - PyErr_Restore(et, ev, etb); -- (self->ob_type->tp_free)((PyObject *)self); -+ (Py_TYPE(self)->tp_free)((PyObject *)self); - } - - /* Connection type object =========================================== */ -diff --git a/_dbus_bindings/containers.c b/_dbus_bindings/containers.c -index 7c4d535..a9278f4 100644 ---- a/_dbus_bindings/containers.c -+++ b/_dbus_bindings/containers.c -@@ -195,8 +195,7 @@ Array_tp_init (DBusPyArray *self, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyArray_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Array", - sizeof(DBusPyArray), - 0, -@@ -431,8 +430,7 @@ Dict_tp_init(DBusPyDict *self, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyDict_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Dictionary", - sizeof(DBusPyDict), - 0, -@@ -525,14 +523,14 @@ Struct_tp_repr(PyObject *self) - if (variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, signature=%s, " - "variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr), - variant_level); - } - else { - my_repr = PyString_FromFormat("%s(%s, signature=%s)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - PyString_AS_STRING(sig_repr)); - } -@@ -686,8 +684,7 @@ Struct_tp_getattro(PyObject *obj, PyObject *name) - } - - PyTypeObject DBusPyStruct_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Struct", - 0, - 0, -diff --git a/_dbus_bindings/dbus_bindings-internal.h b/_dbus_bindings/dbus_bindings-internal.h -index 3b15706..fd2efb6 100644 ---- a/_dbus_bindings/dbus_bindings-internal.h -+++ b/_dbus_bindings/dbus_bindings-internal.h -@@ -30,13 +30,6 @@ - - #include - --/* Python < 2.5 compat */ --#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) --typedef int Py_ssize_t; --#define PY_SSIZE_T_MAX INT_MAX --#define PY_SSIZE_T_MIN INT_MIN --#endif -- - #define INSIDE_DBUS_PYTHON_BINDINGS - #include "dbus-python.h" - -@@ -55,7 +48,7 @@ static inline int type##_Check (PyObject *o) \ - } \ - static inline int type##_CheckExact (PyObject *o) \ - { \ -- return ((o)->ob_type == &type##_Type); \ -+ return (Py_TYPE(o) == &type##_Type); \ - } - - PyMODINIT_FUNC init_dbus_bindings(void); -@@ -134,10 +127,6 @@ int dbus_py_unix_fd_get_fd(PyObject *self); - /* generic */ - extern void dbus_py_take_gil_and_xdecref(PyObject *); - extern int dbus_py_immutable_setattro(PyObject *, PyObject *, PyObject *); --extern PyObject *dbus_py_tp_richcompare_by_pointer(PyObject *, -- PyObject *, -- int); --extern long dbus_py_tp_hash_by_pointer(PyObject *self); - extern PyObject *dbus_py_empty_tuple; - extern dbus_bool_t dbus_py_init_generic(void); - -@@ -214,7 +203,7 @@ void _dbus_py_dbg_dump_message(DBusMessage *); - - # define TRACE(self) do { fprintf(stderr, "TRACE: <%s at %p> in %s, " \ - "%d refs\n", \ -- self->ob_type->tp_name, \ -+ Py_TYPE(self)->tp_name, \ - self, __func__, \ - self->ob_refcnt); } while (0) - # define DBG(format, ...) fprintf(stderr, "DEBUG: " format "\n",\ -diff --git a/_dbus_bindings/float.c b/_dbus_bindings/float.c -index 734c4ab..9ea8413 100644 ---- a/_dbus_bindings/float.c -+++ b/_dbus_bindings/float.c -@@ -40,8 +40,7 @@ PyDoc_STRVAR(Float_tp_doc, - #endif - - PyTypeObject DBusPyDouble_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Double", - 0, - 0, -@@ -84,8 +83,7 @@ PyTypeObject DBusPyDouble_Type = { - #ifdef WITH_DBUS_FLOAT32 - - PyTypeObject DBusPyFloat_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Float", - 0, - 0, -diff --git a/_dbus_bindings/generic.c b/_dbus_bindings/generic.c -index 05906ae..8894bb5 100644 ---- a/_dbus_bindings/generic.c -+++ b/_dbus_bindings/generic.c -@@ -31,29 +31,6 @@ - */ - PyObject *dbus_py_empty_tuple = NULL; - --PyObject * --dbus_py_tp_richcompare_by_pointer(PyObject *self, -- PyObject *other, -- int op) --{ -- if (op == Py_EQ || op == Py_NE) { -- if (self == other) { -- return PyInt_FromLong(op == Py_EQ); -- } -- return PyInt_FromLong(op == Py_NE); -- } -- PyErr_SetString(PyExc_TypeError, -- "Instances of this type are not ordered"); -- return NULL; --} -- --long --dbus_py_tp_hash_by_pointer(PyObject *self) --{ -- long hash = (long)self; -- return (hash == -1L ? -2L : hash); --} -- - int - dbus_py_immutable_setattro(PyObject *obj UNUSED, - PyObject *name UNUSED, -diff --git a/_dbus_bindings/int.c b/_dbus_bindings/int.c -index f49d50a..fbc4163 100644 ---- a/_dbus_bindings/int.c -+++ b/_dbus_bindings/int.c -@@ -76,12 +76,12 @@ Boolean_tp_repr (PyObject *self) - long variant_level = ((DBusPyIntBase *)self)->variant_level; - if (variant_level > 0) { - return PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyInt_AsLong(self) ? "True" : "False", - variant_level); - } - return PyString_FromFormat("%s(%s)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyInt_AsLong(self) ? "True" : "False"); - } - -@@ -175,8 +175,7 @@ Int16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyInt16_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Int16", - 0, - 0, -@@ -265,8 +264,7 @@ UInt16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyUInt16_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.UInt16", - 0, - 0, -@@ -354,8 +352,7 @@ Int32_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyInt32_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Int32", - 0, - 0, -@@ -456,8 +453,7 @@ UInt32_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyUInt32_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.UInt32", - 0, - 0, -@@ -567,8 +563,7 @@ Int64_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyInt64_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Int64", - 0, - 0, -@@ -674,8 +669,7 @@ UInt64_tp_new (PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyUInt64_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.UInt64", - 0, - 0, -diff --git a/_dbus_bindings/libdbusconn.c b/_dbus_bindings/libdbusconn.c -index 0c87078..f426650 100644 ---- a/_dbus_bindings/libdbusconn.c -+++ b/_dbus_bindings/libdbusconn.c -@@ -73,7 +73,7 @@ DBusPyLibDBusConnection_tp_dealloc(Connection *self) - } - - PyErr_Restore(et, ev, etb); -- (self->ob_type->tp_free)((PyObject *) self); -+ (Py_TYPE(self)->tp_free)((PyObject *) self); - } - - PyTypeObject DBusPyLibDBusConnection_Type = { -diff --git a/_dbus_bindings/mainloop.c b/_dbus_bindings/mainloop.c -index 710f474..367ae0e 100644 ---- a/_dbus_bindings/mainloop.c -+++ b/_dbus_bindings/mainloop.c -@@ -59,8 +59,7 @@ static void NativeMainLoop_tp_dealloc(NativeMainLoop *self) - } - - static PyTypeObject NativeMainLoop_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.mainloop.NativeMainLoop", - sizeof(NativeMainLoop), - 0, -diff --git a/_dbus_bindings/message-append.c b/_dbus_bindings/message-append.c -index 772966e..9f8c3c7 100644 ---- a/_dbus_bindings/message-append.c -+++ b/_dbus_bindings/message-append.c -@@ -360,7 +360,7 @@ _signature_string_from_pyobject(PyObject *obj, long *variant_level_ptr) - else { - PyErr_Format(PyExc_TypeError, "Don't know how which D-Bus type " - "to use to encode type \"%s\"", -- obj->ob_type->tp_name); -+ Py_TYPE(obj)->tp_name); - return NULL; - } - } -@@ -478,6 +478,7 @@ _message_iter_append_string(DBusMessageIter *appender, - if (PyString_AsStringAndSize(utf8, &s, NULL) < 0) return -1; - DBG("Performing actual append: string (from unicode) %s", s); - if (!dbus_message_iter_append_basic(appender, sig_type, &s)) { -+ Py_CLEAR(utf8); - PyErr_NoMemory(); - return -1; - } -@@ -529,14 +530,10 @@ dbuspy_message_iter_close_container(DBusMessageIter *iter, - DBusMessageIter *sub, - dbus_bool_t is_ok) - { --#ifdef HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER - if (!is_ok) { - dbus_message_iter_abandon_container(iter, sub); - return TRUE; - } --#else -- (void) is_ok; --#endif - return dbus_message_iter_close_container(iter, sub); - } - -@@ -671,7 +668,7 @@ _message_iter_append_multi(DBusMessageIter *appender, - } - /* else leave sig set to NULL. */ - -- DBG("Opening %c container", container); -+ DBG("Opening '%c' container", container); - if (!dbus_message_iter_open_container(appender, container, - sig, &sub_appender)) { - PyErr_NoMemory(); -@@ -752,7 +749,7 @@ _message_iter_append_multi(DBusMessageIter *appender, - } - - /* This must be run as cleanup, even on failure. */ -- DBG("Closing %c container", container); -+ DBG("Closing '%c' container", container); - if (!dbuspy_message_iter_close_container(appender, &sub_appender, (ret == 0))) { - PyErr_NoMemory(); - ret = -1; -@@ -781,7 +778,7 @@ _message_iter_append_string_as_byte_array(DBusMessageIter *appender, - PyErr_NoMemory(); - return -1; - } -- DBG("Appending fixed array of %d bytes", len); -+ DBG("Appending fixed array of %d bytes", (int)len); - if (dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &s, len)) { - ret = 0; - } -diff --git a/_dbus_bindings/message-get-args.c b/_dbus_bindings/message-get-args.c -index 5f3d89c..fef2a45 100644 ---- a/_dbus_bindings/message-get-args.c -+++ b/_dbus_bindings/message-get-args.c -@@ -94,7 +94,7 @@ _message_iter_append_all_to_list(DBusMessageIter *iter, PyObject *list, - #ifdef USING_DBG - fprintf(stderr, "DBG/%ld: appending to list: %p == ", (long)getpid(), item); - PyObject_Print(item, stderr, 0); -- fprintf(stderr, " of type %p\n", item->ob_type); -+ fprintf(stderr, " of type %p\n", Py_TYPE(item)); - #endif - ret = PyList_Append(list, item); - Py_CLEAR(item); -@@ -245,9 +245,13 @@ _message_iter_get_pyobject(DBusMessageIter *iter, - args, kwargs); - } - else { -- args = Py_BuildValue("(N)", PyUnicode_DecodeUTF8(u.s, -- strlen(u.s), -- NULL)); -+ PyObject *unicode; -+ -+ unicode = PyUnicode_DecodeUTF8(u.s, strlen(u.s), NULL); -+ if (!unicode) { -+ break; -+ } -+ args = Py_BuildValue("(N)", unicode); - if (!args) { - break; - } -diff --git a/_dbus_bindings/message.c b/_dbus_bindings/message.c -index 5aed54d..1658acb 100644 ---- a/_dbus_bindings/message.c -+++ b/_dbus_bindings/message.c -@@ -32,7 +32,7 @@ static PyTypeObject MethodReturnMessageType, MethodCallMessageType; - - static inline int Message_Check(PyObject *o) - { -- return (o->ob_type == &MessageType) -+ return (Py_TYPE(o) == &MessageType) - || PyObject_IsInstance(o, (PyObject *)&MessageType); - } - -@@ -53,7 +53,7 @@ static void Message_tp_dealloc(Message *self) - if (self->msg) { - dbus_message_unref(self->msg); - } -- self->ob_type->tp_free((PyObject *)self); -+ Py_TYPE(self)->tp_free((PyObject *)self); - } - - static PyObject * -diff --git a/_dbus_bindings/module.c b/_dbus_bindings/module.c -index 6a8e455..f6fca5f 100644 ---- a/_dbus_bindings/module.c -+++ b/_dbus_bindings/module.c -@@ -246,16 +246,6 @@ init_dbus_bindings(void) - - default_main_loop = NULL; - -- /* I'd rather not initialize threads if we can help it - dbus-python and -- pygobject both release and re-obtain the GIL on a regular basis, which is -- much simpler (basically free) before threads are initialized. -- -- However, on Python < 2.4.2c1 you aren't allowed to call -- PyGILState_Release without initializing threads first. */ -- if (strcmp(Py_GetVersion(), "2.4.2c1") < 0) { -- PyEval_InitThreads(); -- } -- - if (!dbus_py_init_generic()) return; - if (!dbus_py_init_abstract()) return; - if (!dbus_py_init_signature()) return; -diff --git a/_dbus_bindings/pending-call.c b/_dbus_bindings/pending-call.c -index aac2af8..469c997 100644 ---- a/_dbus_bindings/pending-call.c -+++ b/_dbus_bindings/pending-call.c -@@ -34,7 +34,7 @@ static PyTypeObject PendingCallType; - - static inline int PendingCall_Check (PyObject *o) - { -- return (o->ob_type == &PendingCallType) -+ return (Py_TYPE(o) == &PendingCallType) - || PyObject_IsInstance(o, (PyObject *)&PendingCallType); - } - -@@ -233,8 +233,7 @@ static PyMethodDef PendingCall_tp_methods[] = { - }; - - static PyTypeObject PendingCallType = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.lowlevel.PendingCall", - sizeof(PendingCall), - 0, -diff --git a/_dbus_bindings/server.c b/_dbus_bindings/server.c -index a575fc0..f733990 100644 ---- a/_dbus_bindings/server.c -+++ b/_dbus_bindings/server.c -@@ -429,7 +429,7 @@ static void Server_tp_dealloc(Server *self) - - DBG("Server at %p: freeing self", self); - PyErr_Restore(et, ev, etb); -- (self->ob_type->tp_free)((PyObject *)self); -+ (Py_TYPE(self)->tp_free)((PyObject *)self); - } - - PyDoc_STRVAR(Server_disconnect__doc__, -diff --git a/_dbus_bindings/signature.c b/_dbus_bindings/signature.c -index 28fa7a1..75fe154 100644 ---- a/_dbus_bindings/signature.c -+++ b/_dbus_bindings/signature.c -@@ -97,8 +97,7 @@ SignatureIter_tp_iter(PyObject *self) - } - - static PyTypeObject SignatureIterType = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "_dbus_bindings._SignatureIter", - sizeof(SignatureIter), - 0, -@@ -175,8 +174,7 @@ Signature_tp_new (PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPySignature_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.Signature", - 0, - 0, -diff --git a/_dbus_bindings/string.c b/_dbus_bindings/string.c -index 03f966c..bdc94ec 100644 ---- a/_dbus_bindings/string.c -+++ b/_dbus_bindings/string.c -@@ -82,8 +82,7 @@ UTF8String_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyUTF8String_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.UTF8String", - 0, - 0, -@@ -161,8 +160,7 @@ ObjectPath_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) - } - - PyTypeObject DBusPyObjectPath_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.ObjectPath", - 0, - 0, -@@ -276,12 +274,12 @@ String_tp_repr(PyObject *self) - } - if (((DBusPyString *)self)->variant_level > 0) { - my_repr = PyString_FromFormat("%s(%s, variant_level=%ld)", -- self->ob_type->tp_name, -+ Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr), - ((DBusPyString *)self)->variant_level); - } - else { -- my_repr = PyString_FromFormat("%s(%s)", self->ob_type->tp_name, -+ my_repr = PyString_FromFormat("%s(%s)", Py_TYPE(self)->tp_name, - PyString_AS_STRING(parent_repr)); - } - /* whether my_repr is NULL or not: */ -@@ -290,8 +288,7 @@ String_tp_repr(PyObject *self) - } - - PyTypeObject DBusPyString_Type = { -- PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) -- 0, -+ PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - "dbus.String", - sizeof(DBusPyString), - 0, -diff --git a/_dbus_bindings/unixfd.c b/_dbus_bindings/unixfd.c -index 6e515f7..3d6bc11 100644 ---- a/_dbus_bindings/unixfd.c -+++ b/_dbus_bindings/unixfd.c -@@ -159,8 +159,7 @@ static PyMethodDef UnixFd_methods[] = { - }; - - PyTypeObject DBusPyUnixFd_Type = { -- PyObject_HEAD_INIT(NULL) -- 0, -+ PyVarObject_HEAD_INIT(NULL, 0) - "dbus.UnixFd", - sizeof(UnixFdObject), - 0, -diff --git a/configure.ac b/configure.ac -index 5a5202c..873d16d 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2,7 +2,7 @@ - AC_PREREQ(2.59c) - - dnl If not 1, append datestamp to the version number --m4_define(dbus_python_released, 1) -+m4_define(dbus_python_released, 0) - dnl The dbus-python version number (must actually be numeric at the moment) - m4_define(dbus_python_major_version, 0) - m4_define(dbus_python_minor_version, 84) -@@ -46,7 +46,7 @@ m4_define([_LT_AC_TAGCONFIG],[]) - AC_PROG_LIBTOOL - AM_PROG_CC_C_O - --AM_PATH_PYTHON(2.4.0) -+AM_PATH_PYTHON([2.6]) - - AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) - -@@ -140,6 +140,7 @@ if test "${enable_html_docs}" != no; then - DBUS_PY_ADD_RST2HTMLFLAG([--no-raw]) - DBUS_PY_ADD_RST2HTMLFLAG([--no-file-insertion]) - DBUS_PY_ADD_RST2HTMLFLAG([--cloak-email-addresses]) -+ DBUS_PY_ADD_RST2HTMLFLAG([--input-encoding=UTF-8]) - fi - fi - AC_SUBST([RST2HTML]) -@@ -148,19 +149,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.0]) -+PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.4]) - PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.70]) - --dnl avoid deprecated stuff if possible --AC_CHECK_LIB([dbus-1], [dbus_watch_get_unix_fd], -- [AC_DEFINE([HAVE_DBUS_WATCH_GET_UNIX_FD], [], -- [Define if libdbus-1 has dbus_watch_get_unix_fd])], -- [:], [$DBUS_LIBS]) --AC_CHECK_LIB([dbus-1], [dbus_message_iter_abandon_container], -- [AC_DEFINE([HAVE_DBUS_MESSAGE_ITER_ABANDON_CONTAINER], [], -- [Define if libdbus-1 has dbus_message_iter_abandon_container])], -- [:], [$DBUS_LIBS]) -- - TP_COMPILER_WARNINGS([CFLAGS_WARNINGS], [test] dbus_python_released [= 0], - [all \ - extra \ -@@ -175,7 +166,8 @@ TP_COMPILER_WARNINGS([CFLAGS_WARNINGS], [test] dbus_python_released [= 0], - pointer-arith \ - format-security \ - init-self], -- [missing-field-initializers]) -+ [missing-field-initializers \ -+ unused-parameter]) - - JH_ADD_CFLAG([-std=c9x]) - JH_ADD_CFLAG([-fno-strict-aliasing]) -diff --git a/dbus/__init__.py b/dbus/__init__.py -index e990ec3..1807a30 100644 ---- a/dbus/__init__.py -+++ b/dbus/__init__.py -@@ -99,7 +99,3 @@ from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte, Boolean,\ - UTF8String - from dbus._dbus import Bus, SystemBus, SessionBus, StarterBus - from dbus.proxies import Interface -- -- --if 'DBUS_PYTHON_NO_DEPRECATED' not in os.environ: -- from dbus._dbus import dbus_bindings # for backwards compat -diff --git a/dbus/_dbus.py b/dbus/_dbus.py -index 60e7933..d1df72e 100644 ---- a/dbus/_dbus.py -+++ b/dbus/_dbus.py -@@ -236,21 +236,3 @@ class StarterBus(Bus): - """ - return Bus.__new__(cls, Bus.TYPE_STARTER, private=private, - mainloop=mainloop) -- -- --if 'DBUS_PYTHON_NO_DEPRECATED' not in os.environ: -- -- class _DBusBindingsEmulation: -- """A partial emulation of the dbus_bindings module.""" -- def __str__(self): -- return '_DBusBindingsEmulation()' -- def __repr__(self): -- return '_DBusBindingsEmulation()' -- def __getattr__(self, attr): -- global dbus_bindings -- import dbus.dbus_bindings as m -- dbus_bindings = m -- return getattr(m, attr) -- -- dbus_bindings = _DBusBindingsEmulation() -- """Deprecated, don't use.""" -diff --git a/dbus/_expat_introspect_parser.py b/dbus/_expat_introspect_parser.py -index 96b27ad..de38c45 100644 ---- a/dbus/_expat_introspect_parser.py -+++ b/dbus/_expat_introspect_parser.py -@@ -81,5 +81,5 @@ def process_introspection_data(data): - """ - try: - return _Parser().parse(data) -- except Exception, e: -+ except Exception as e: - raise IntrospectionParserException('%s: %s' % (e.__class__, e)) -diff --git a/dbus/bus.py b/dbus/bus.py -index 86c655d..6f775de 100644 ---- a/dbus/bus.py -+++ b/dbus/bus.py -@@ -176,7 +176,7 @@ class BusConnection(Connection): - and bus_name != BUS_DAEMON_NAME): - try: - return self.get_name_owner(bus_name) -- except DBusException, e: -+ except DBusException as e: - if e.get_dbus_name() != _NAME_HAS_NO_OWNER: - raise - # else it doesn't exist: try to start it -diff --git a/dbus/connection.py b/dbus/connection.py -index d76aaf2..10f03c7 100644 ---- a/dbus/connection.py -+++ b/dbus/connection.py -@@ -525,7 +525,7 @@ class Connection(_Connection): - for cb in self.__call_on_disconnection: - try: - cb(self) -- except Exception, e: -+ except Exception as e: - # basicConfig is a no-op if logging is already configured - logging.basicConfig() - _logger.error('Exception in handler for Disconnected ' -@@ -564,7 +564,7 @@ class Connection(_Connection): - # Add the arguments to the function - try: - message.append(signature=signature, *args) -- except Exception, e: -+ except Exception as e: - logging.basicConfig() - _logger.error('Unable to set arguments %r according to ' - 'signature %r: %s: %s', -@@ -618,7 +618,7 @@ class Connection(_Connection): - # Add the arguments to the function - try: - message.append(signature=signature, *args) -- except Exception, e: -+ except Exception as e: - logging.basicConfig() - _logger.error('Unable to set arguments %r according to ' - 'signature %r: %s: %s', -diff --git a/dbus/dbus_bindings.py b/dbus/dbus_bindings.py -deleted file mode 100644 -index a45ca9f..0000000 ---- a/dbus/dbus_bindings.py -+++ /dev/null -@@ -1,37 +0,0 @@ --# Backwards-compatibility with the old dbus_bindings. -- --from warnings import warn as _warn -- --_dbus_bindings_warning = DeprecationWarning("""\ --The dbus_bindings module is not public API and will go away soon. -- --Most uses of dbus_bindings are applications catching the exception --dbus.dbus_bindings.DBusException. You should use dbus.DBusException --instead (this is compatible with all dbus-python versions since 0.40.2). -- --If you need additional public API, please contact the maintainers via --. --""") -- --_warn(_dbus_bindings_warning, DeprecationWarning, stacklevel=2) -- --# Exceptions --from dbus.exceptions import DBusException --class ConnectionError(Exception): pass -- --# Types --from dbus.types import * -- --# Messages --from _dbus_bindings import Message, SignalMessage as Signal,\ -- MethodCallMessage as MethodCall,\ -- MethodReturnMessage as MethodReturn,\ -- ErrorMessage as Error --# MessageIter has gone away, thankfully -- --# Connection --from _dbus_bindings import Connection -- --from dbus import Bus --bus_request_name = Bus.request_name --bus_release_name = Bus.release_name -diff --git a/dbus/proxies.py b/dbus/proxies.py -index bf99a1c..51d8d9f 100644 ---- a/dbus/proxies.py -+++ b/dbus/proxies.py -@@ -388,7 +388,7 @@ class ProxyObject(object): - try: - try: - self._introspect_method_map = process_introspection_data(data) -- except IntrospectionParserException, e: -+ except IntrospectionParserException as e: - self._introspect_error_handler(e) - return - -diff --git a/dbus/service.py b/dbus/service.py -index b92d840..f1b3a9b 100644 ---- a/dbus/service.py -+++ b/dbus/service.py -@@ -250,12 +250,12 @@ def _method_reply_return(connection, message, method_name, signature, *retval): - reply = MethodReturnMessage(message) - try: - reply.append(signature=signature, *retval) -- except Exception, e: -+ except Exception as e: - logging.basicConfig() - if signature is None: - try: - signature = reply.guess_signature(retval) + ' (guessed)' -- except Exception, e: -+ except Exception as e: - _logger.error('Unable to guess signature for arguments %r: ' - '%s: %s', retval, e.__class__, e) - raise -@@ -743,7 +743,7 @@ class Object(Interface): - retval = (retval,) - - _method_reply_return(connection, message, method_name, signature, *retval) -- except Exception, exception: -+ except Exception as exception: - # send error reply - _method_reply_error(connection, message, exception) - -diff --git a/dbus_bindings.py b/dbus_bindings.py -deleted file mode 100644 -index f6dcf81..0000000 ---- a/dbus_bindings.py -+++ /dev/null -@@ -1 +0,0 @@ --from dbus.dbus_bindings import * -diff --git a/examples/example-client.py b/examples/example-client.py -index 796f262..262f892 100644 ---- a/examples/example-client.py -+++ b/examples/example-client.py -@@ -65,7 +65,7 @@ def main(): - # D-Bus exceptions are mapped to Python exceptions - try: - iface.RaiseException() -- except dbus.DBusException, e: -+ except dbus.DBusException as e: - print str(e) - - # introspection is automatically supported -diff --git a/test/cross-test-client.py b/test/cross-test-client.py -index ee18f77..e2e155f 100644 ---- a/test/cross-test-client.py -+++ b/test/cross-test-client.py -@@ -86,7 +86,7 @@ class Client(SignalTestsImpl): - method = getattr(if_obj, member) - try: - real_ret = method(*args) -- except Exception, e: -+ except Exception as e: - self.fail_id += 1 - print "%s.%s fail %d" % (interface, member, self.fail_id) - s = ("report %d: %s.%s%r: raised %r \"%s\"" -@@ -97,7 +97,7 @@ class Client(SignalTestsImpl): - return - try: - check_fn(real_ret, check_arg) -- except Exception, e: -+ except Exception as e: - self.fail_id += 1 - print "%s.%s fail %d" % (interface, member, self.fail_id) - s = ("report %d: %s.%s%r: %s" -@@ -122,7 +122,7 @@ class Client(SignalTestsImpl): - for i in xrange(len(exp)): - try: - equals(real_ret[i], exp[i]) -- except AssertionError, e: -+ except AssertionError as e: - if not isinstance(e.args, tuple): - e.args = (e.args,) - e.args = e.args + ('(at position %d in sequence)' % i,) -@@ -131,7 +131,7 @@ class Client(SignalTestsImpl): - for k in exp: - try: - equals(real_ret[k], exp[k]) -- except AssertionError, e: -+ except AssertionError as e: - if not isinstance(e.args, tuple): - e.args = (e.args,) - e.args = e.args + ('(at key %r in dict)' % k,) -diff --git a/test/test-client.py b/test/test-client.py -index 753d892..e0e639c 100755 ---- a/test/test-client.py -+++ b/test/test-client.py -@@ -199,7 +199,7 @@ class TestDBusBindings(unittest.TestCase): - elif not self.utf8 and isinstance(val, dbus.UTF8String): - failures.append('%r should not have been utf8' % val) - return -- except Exception, e: -+ except Exception as e: - failures.append("%s:\n%s" % (e.__class__, e)) - - def error_handler(self, error): -@@ -371,7 +371,7 @@ class TestDBusBindings(unittest.TestCase): - try: - print "requesting %s" % name - busname = dbus.service.BusName(name, dbus.SessionBus()) -- except Exception, e: -+ except Exception as e: - print "%s:\n%s" % (e.__class__, e) - self.assert_(not succeed, 'did not expect registering bus name %s to fail' % name) - else: -@@ -462,7 +462,7 @@ class TestDBusBindings(unittest.TestCase): - self.assertRaises(dbus.DBusException, self.iface.AsyncRaise) - try: - self.iface.AsyncRaise() -- except dbus.DBusException, e: -+ except dbus.DBusException as e: - self.assert_(e.get_dbus_name() == - 'org.freedesktop.bugzilla.bug12403', - e.get_dbus_name()) -@@ -518,7 +518,7 @@ class TestDBusBindings(unittest.TestCase): - - try: - self.iface.RaiseValueError() -- except Exception, e: -+ except Exception as e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assert_('.ValueError: Traceback ' in str(e), - 'Wanted a traceback but got:\n"""%s"""' % str(e)) -@@ -527,7 +527,7 @@ class TestDBusBindings(unittest.TestCase): - - try: - self.iface.RaiseDBusExceptionNoTraceback() -- except Exception, e: -+ except Exception as e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assertEquals(str(e), - 'com.example.Networking.ServerError: ' -@@ -537,7 +537,7 @@ class TestDBusBindings(unittest.TestCase): - - try: - self.iface.RaiseDBusExceptionWithTraceback() -- except Exception, e: -+ except Exception as e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assert_(str(e).startswith('com.example.Misc.RealityFailure: ' - 'Traceback '), -diff --git a/test/test-service.py b/test/test-service.py -index 51865eb..bd80f26 100755 ---- a/test/test-service.py -+++ b/test/test-service.py -@@ -267,7 +267,7 @@ class TestObject(dbus.service.Object, TestInterface): - return_cb(variant) - - return False # do not run again -- except Exception, e: -+ except Exception as e: - error_cb(e) - - @dbus.service.method(IFACE, in_signature='', out_signature='s', sender_keyword='sender') diff -Nru dbus-python-0.84.0/debian/python3-dbus-dbg.install dbus-python-1.0.0/debian/python3-dbus-dbg.install --- dbus-python-0.84.0/debian/python3-dbus-dbg.install 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/debian/python3-dbus-dbg.install 2012-01-24 20:52:48.000000000 +0000 @@ -0,0 +1 @@ +debian/tmp-dbg/usr/lib/python3/dist-packages/*.so usr/lib/python3/dist-packages diff -Nru dbus-python-0.84.0/debian/python3-dbus-dbg.links dbus-python-1.0.0/debian/python3-dbus-dbg.links --- dbus-python-0.84.0/debian/python3-dbus-dbg.links 2012-01-16 16:41:56.000000000 +0000 +++ dbus-python-1.0.0/debian/python3-dbus-dbg.links 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/share/doc/python3-dbus usr/share/doc/python3-dbus-dbg diff -Nru dbus-python-0.84.0/debian/python3-dbus.docs dbus-python-1.0.0/debian/python3-dbus.docs --- dbus-python-0.84.0/debian/python3-dbus.docs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/debian/python3-dbus.docs 2012-01-24 20:52:48.000000000 +0000 @@ -0,0 +1,2 @@ +NEWS +README diff -Nru dbus-python-0.84.0/debian/python3-dbus.install dbus-python-1.0.0/debian/python3-dbus.install --- dbus-python-0.84.0/debian/python3-dbus.install 2012-01-16 16:41:56.000000000 +0000 +++ dbus-python-1.0.0/debian/python3-dbus.install 2012-01-24 20:52:48.000000000 +0000 @@ -1 +1,3 @@ -usr/lib/python3/*-packages/* +usr/lib/python3/dist-packages/*.so +usr/lib/python3/dist-packages/dbus/*.py +usr/lib/python3/dist-packages/dbus/*/*.py diff -Nru dbus-python-0.84.0/debian/python-dbus-common.install dbus-python-1.0.0/debian/python-dbus-common.install --- dbus-python-0.84.0/debian/python-dbus-common.install 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/python-dbus-common.install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -debian/tmp/usr/include/* -debian/tmp/usr/lib/pkgconfig/* diff -Nru dbus-python-0.84.0/debian/python-dbus-dbg.install dbus-python-1.0.0/debian/python-dbus-dbg.install --- dbus-python-0.84.0/debian/python-dbus-dbg.install 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/debian/python-dbus-dbg.install 2012-01-24 20:52:48.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/python2.*/*-packages/*_d.so diff -Nru dbus-python-0.84.0/debian/python-dbus-dbg.links dbus-python-1.0.0/debian/python-dbus-dbg.links --- dbus-python-0.84.0/debian/python-dbus-dbg.links 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/python-dbus-dbg.links 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/share/doc/python-dbus usr/share/doc/python-dbus-dbg diff -Nru dbus-python-0.84.0/debian/python-dbus-dev.install dbus-python-1.0.0/debian/python-dbus-dev.install --- dbus-python-0.84.0/debian/python-dbus-dev.install 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/debian/python-dbus-dev.install 2012-01-24 20:52:48.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/pkgconfig/dbus-python.pc +usr/include/dbus-1.0/dbus/dbus-python.h diff -Nru dbus-python-0.84.0/debian/python-dbus.install dbus-python-1.0.0/debian/python-dbus.install --- dbus-python-0.84.0/debian/python-dbus.install 2012-01-16 16:25:29.000000000 +0000 +++ dbus-python-1.0.0/debian/python-dbus.install 2012-01-24 20:52:48.000000000 +0000 @@ -1 +1,4 @@ -usr/lib/python2.*/*-packages/* +usr/lib/python2.*/*-packages/_dbus_bindings.so +usr/lib/python2.*/*-packages/_dbus_glib_bindings.so +usr/lib/python2.*/*-packages/dbus/*.py +usr/lib/python2.*/*-packages/dbus/*/*.py diff -Nru dbus-python-0.84.0/debian/rules dbus-python-1.0.0/debian/rules --- dbus-python-0.84.0/debian/rules 2012-01-16 20:48:20.000000000 +0000 +++ dbus-python-1.0.0/debian/rules 2012-01-24 20:52:48.000000000 +0000 @@ -2,182 +2,112 @@ # Copyright © 2002,2003 Colin Walters # Copyright © 2003 Daniel Stone # Copyright © 2006 Sjoerd Simons - -# DH_VERBOSE=1 -# DEB_BUILD_OPTIONS=nocheck - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -CFLAGS += -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2) +# Copyright © 2012 Collabora Ltd. PYVERS := $(shell pyversions --requested --version debian/control) +PY3VERS := $(shell py3versions --requested --version debian/control) PYDEFAULTVER := $(shell pyversions --default --version) -PY3VERS := $(shell py3versions --requested --version debian/control) -PY3DEFAULTVER := $(shell py3versions --default --version) +FLAVOURS := $(patsubst %,%-dbg,$(PYVERS) $(PY3VERS)) $(PYVERS) $(PY3VERS) -ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - CONFIGURE_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) -else - CONFIGURE_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) -endif - -CONFIGURE_FLAGS += \ - --prefix=/usr \ - --docdir=/usr/share/doc/deleteme - -autoreconf-stamp: - dh_autoreconf - touch $@ - -# We build the documentation using Debian's default Python version, as an -# extra build pass. -build-%/configure-stamp: autoreconf-stamp - dh_testdir - mkdir -p build-$* - case $* in \ - *-dbg) \ - CFLAGS="$(CFLAGS) -g -O0"; \ - export CFLAGS; \ - ;; \ - esac; \ - maybe_disable_doc="--disable-html-docs --disable-api-docs"; \ - PYTHON="/usr/bin/python$*"; \ - if test doc = $*; then \ - maybe_disable_doc=""; \ - PYTHON="/usr/bin/python"; \ - fi; \ - cd build-$* && PYTHON=$$PYTHON ../configure \ - $(CONFIGURE_FLAGS) $$maybe_disable_doc - touch $@ - -build-%/build-stamp: build-%/configure-stamp - dh_testdir - PYTHON=/usr/bin/python$* $(MAKE) -C build-$* -ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) - $(MAKE) -C build-$* check -endif - touch $@ - -build-doc/build-doc-stamp: build-doc/configure-stamp - dh_testdir - PYTHON=/usr/bin/python $(MAKE) -C build-doc - touch $@ - -build: build-arch -#build: build-indep - -build-arch: $(PYVERS:%=build-%/build-stamp) \ - $(PYVERS:%=build-%-dbg/build-stamp) \ - $(PY3VERS:%=build-%/build-stamp) \ - $(PY3VERS:%=build-%-dbg/build-stamp) - -build-indep: build-doc/build-doc-stamp - -install-clean: - dh_testdir - dh_testroot - dh_prep - -install-%: build-%/build-stamp - dh_testdir - dh_testroot - $(MAKE) -C build-$* install DESTDIR=$(CURDIR)/debian/tmp - # keep a copy of /usr/include/debian-python.h and - # /usr/lib/pkgconfig/debian-python.pc to verify they match later - cp debian/tmp/usr/include/dbus-1.0/dbus/dbus-python.h debian/tmp-$*.h - cp debian/tmp/usr/lib/pkgconfig/dbus-python.pc debian/tmp-$*.pc - -dbg-install-%: build-%-dbg/build-stamp - dh_testdir - dh_testroot - $(MAKE) -C build-$*-dbg install DESTDIR=$(CURDIR)/debian/python-dbus-dbg - find debian/python-dbus-dbg ! -type d ! -name '*.so' -print0 | xargs -0 rm -f - find debian/python-dbus-dbg -depth -empty -exec rmdir {} \; - -dbg-install3-%: build-%-dbg/build-stamp - dh_testdir - dh_testroot - $(MAKE) -C build-$*-dbg install DESTDIR=$(CURDIR)/debian/python3-dbus-dbg - find debian/python3-dbus-dbg ! -type d ! -name '*.so' -print0 | xargs -0 rm -f - find debian/python3-dbus-dbg -depth -empty -exec rmdir {} \; - -install-arch: build-arch install-clean \ - $(PYVERS:%=install-%) $(PYVERS:%=dbg-install-%) \ - $(PY3VERS:%=install-%) $(PY3VERS:%=dbg-install3-%) - rm -f debian/tmp/usr/lib/python*/*-packages/*.la - rm -rf debian/tmp/usr/share/doc/deleteme - rm -f debian/python*-dbus-dbg/usr/lib/python*/*-packages/*.la - rm -rf debian/python*-dbus-dbg/usr/share/doc/deleteme - # compare installed .pc and .h, asserting that the ones all versions - # wanted are the same as what we ended up with - for v in $(PYVERS) $(PY3VERS); do \ - diff --brief debian/tmp/usr/include/dbus-1.0/dbus/dbus-python.h \ - debian/tmp-$$v.h || exit 1; \ - diff --brief debian/tmp/usr/lib/pkgconfig/dbus-python.pc \ - debian/tmp-$$v.pc || exit 1; \ +%: + dh $@ --with python2,autoreconf + +override_dh_auto_configure-arch: + set -e && for x in $(FLAVOURS); do \ + dh_auto_configure \ + --builddirectory=build-$$x \ + -- \ + PYTHON=/usr/bin/python$$x \ + --disable-api-docs \ + --disable-html-docs \ + --libdir=/usr/lib \ + ; \ done - rm -f debian/tmp-*.pc debian/tmp-*.h - for i in $$(find debian/python*-dbus-dbg -name '*.so'); do \ - b=$$(basename $$i .so); \ - mv $$i $$(dirname $$i)/$${b}_d.so; \ +override_dh_auto_configure-indep: + dh_auto_configure --builddirectory=build-doc + +override_dh_auto_build-arch: + set -e && for x in $(FLAVOURS); do \ + PYTHON=/usr/bin/python$$x \ + dh_auto_build --arch --builddirectory=build-$$x; \ done +override_dh_auto_build-indep: + dh_auto_build --indep --builddirectory=build-doc -clean:: - dh_testdir - dh_testroot - rm -Rf debian/tmp-* - rm -Rf build-* - -test -f config.sub && \ - test -r /usr/share/misc/config.sub && \ - cp -f /usr/share/misc/config.sub config.sub - -test -f config.guess && \ - test -r /usr/share/misc/config.guess && \ - cp -f /usr/share/misc/config.guess config.guess - find dbus -name '*.py[co]' -print0 | xargs -0 rm -f - dh_autoreconf_clean - dh_clean - -binary-indep: build-indep - dh_testdir - dh_testroot - dh_install -i - dh_installchangelogs ChangeLog -i - dh_installdocs -i - dh_installexamples -i - dh_compress -i -X.js - dh_fixperms -i - dh_installdeb -i - dh_shlibdeps -i - dh_gencontrol -i - dh_md5sums -i - dh_builddeb -i - -# Build architecture-dependent files here. -binary-arch: build-arch install-arch - dh_testdir - dh_testroot - dh_install -s - dh_installdocs -s - dh_installchangelogs ChangeLog -s - dh_installexamples -s - rm -rf debian/python-dbus-dbg/usr/share/doc/python-dbus-dbg - rm -rf debian/python3-dbus-dbg/usr/share/doc/python3-dbus-dbg - dh_strip -ppython-dbus --dbg-package=python-dbus-dbg - dh_strip -ppython3-dbus --dbg-package=python3-dbus-dbg - dh_link -s - dh_compress -s -X.py -X.js - dh_fixperms -s - dh_python2 -s - dh_python3 -s - dh_installdeb -s - dh_shlibdeps -s - dh_gencontrol -s - dh_md5sums -s - dh_builddeb -s +override_dh_auto_test-arch: + : +# set -e && for x in $(PYVERS) $(PY3VERS); do \ +# PYTHON=/usr/bin/python$$x \ +# dh_auto_test --arch --builddirectory=build-$$x; \ +# done +override_dh_auto_test-indep: + : + +override_dh_auto_install-arch: + set -e && for x in $(PYVERS); do \ + PYTHON=/usr/bin/python$$x \ + dh_auto_install \ + --arch \ + --builddirectory=build-$$x \ + --destdir=debian/tmp \ + ; \ + PYTHON=/usr/bin/python$$x-dbg \ + dh_auto_install \ + --arch \ + --builddirectory=build-$$x-dbg \ + --destdir=debian/tmp-dbg \ + ; \ + install debian/tmp-dbg/usr/lib/python$$x/dist-packages/_dbus_bindings.so \ + debian/tmp/usr/lib/python$$x/dist-packages/_dbus_bindings_d.so; \ + install debian/tmp-dbg/usr/lib/python$$x/dist-packages/_dbus_glib_bindings.so \ + debian/tmp/usr/lib/python$$x/dist-packages/_dbus_glib_bindings_d.so; \ + done + set -e && for x in $(PY3VERS); do \ + PYTHON=/usr/bin/python$$x \ + dh_auto_install \ + --arch \ + --builddirectory=build-$$x \ + --destdir=debian/tmp \ + ; \ + so=`/usr/bin/python$$x -c "print(__import__('sysconfig').get_config_var('SO'))"`; \ + mv debian/tmp/usr/lib/python3/dist-packages/_dbus_bindings.so \ + debian/tmp/usr/lib/python3/dist-packages/_dbus_bindings$$so; \ + mv debian/tmp/usr/lib/python3/dist-packages/_dbus_glib_bindings.so \ + debian/tmp/usr/lib/python3/dist-packages/_dbus_glib_bindings$$so; \ + PYTHON=/usr/bin/python$$x-dbg \ + dh_auto_install \ + --arch \ + --builddirectory=build-$$x-dbg \ + --destdir=debian/tmp-dbg \ + ; \ + so=`/usr/bin/python$$x-dbg -c "print(__import__('sysconfig').get_config_var('SO'))"`; \ + mv debian/tmp-dbg/usr/lib/python3/dist-packages/_dbus_bindings.so \ + debian/tmp-dbg/usr/lib/python3/dist-packages/_dbus_bindings$$so; \ + mv debian/tmp-dbg/usr/lib/python3/dist-packages/_dbus_glib_bindings.so \ + debian/tmp-dbg/usr/lib/python3/dist-packages/_dbus_glib_bindings$$so; \ + done -binary: binary-arch binary-indep -.PHONY: build clean binary-indep binary-arch binary install-arch install-clean +# do not install any docs, we copy those from the builddir +override_dh_auto_install-indep: + : + +override_dh_install: + rm -fr debian/tmp/usr/share/doc/dbus-python + find debian/tmp -name '*.py[co]' -print0 | xargs -0 rm -f + find debian/tmp -name '*.la' -print0 | xargs -0 rm -f + dh_install + +override_dh_installdocs-arch: + dh_installdocs --link-doc=python-dbus -ppython-dbus-dbg + dh_installdocs --link-doc=python3-dbus -ppython3-dbus-dbg + dh_installdocs --remaining-packages + +override_dh_auto_clean: + dh_auto_clean + rm -Rf build-* install-2* install-3* debian/tmp-dbg + find . -name '*.py[co]' -print0 | xargs -0 rm -f + +override_dh_strip: + dh_strip --dbg-package=python-dbus-dbg -ppython-dbus -ppython-dbus-dbg + dh_strip --dbg-package=python3-dbus-dbg -ppython3-dbus -ppython3-dbus-dbg diff -Nru dbus-python-0.84.0/depcomp dbus-python-1.0.0/depcomp --- dbus-python-0.84.0/depcomp 2011-05-25 11:45:21.000000000 +0000 +++ dbus-python-1.0.0/depcomp 2012-01-24 16:37:30.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-12-04.11; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free -# Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, +# 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. + tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . @@ -90,10 +90,18 @@ # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 - cygpath_u="sed s,\\\\\\\\,/,g" + cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what @@ -158,10 +166,12 @@ ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as -## well. +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -405,6 +415,52 @@ rm -f "$tmpdepfile" ;; +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test "$stat" = 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/ \1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/ / + G + p +}' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. @@ -503,7 +559,9 @@ touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation diff -Nru dbus-python-0.84.0/doc/PY3PORT.txt dbus-python-1.0.0/doc/PY3PORT.txt --- dbus-python-0.84.0/doc/PY3PORT.txt 1970-01-01 00:00:00.000000000 +0000 +++ dbus-python-1.0.0/doc/PY3PORT.txt 2012-01-24 16:25:57.000000000 +0000 @@ -0,0 +1,224 @@ +=============================== +Porting python-dbus to Python 3 +=============================== + +This is an experimental port to Python 3.x where x >= 2. There are lots of +great sources for porting C extensions to Python 3, including: + + * http://python3porting.com/toc.html + * http://docs.python.org/howto/cporting.html + * http://docs.python.org/py3k/c-api/index.html + +I also consulted an early take on this port by John Palmieri and David Malcolm +in the context of Fedora: + + * https://bugs.freedesktop.org/show_bug.cgi?id=26420 + +although I have made some different choices. The patches in that tracker +issue also don't cover porting the Python bits (e.g. the test suite), nor the +pygtk -> pygi porting, both which I've also attempted to do in this branch. + +This document outlines my notes and strategies for doing this port. Please +feel free to contact me with any bugs, issues, disagreements, suggestions, +kudos, and curses. + +Barry Warsaw +barry@python.org +2011-11-11 + + +User visible changes +==================== + +You've got some dbus-python code that works great in Python 2. This branch +should generally allow your existing Python 2 code to continue to work +unchanged. There are a few changes you'll notice in Python 2 though: + + - The minimum supported Python 2 version is 2.6. + - All object reprs are unicodes. This change was made because it greatly + simplifies the implementation and cross-compatibility with Python 3. + - Some exception strings have changed. + - `MethodCallMessage` and `SignalMessage` objects have better reprs now. + +What do you need to do to port that to Python 3? Here are the user visible +changes you should be aware of, relative to Python 2. Python 3.2 is the +minimal required version: + + - `ByteArray` objects must be initialized with bytes objects, not unicodes. + Use `b''` literals in the constructor. This also works in Python 2, where + bytes objects are aliases for 8-bit strings. + - `Byte` objects must be initialized with either a length-1 bytes object + (again, use `b''` literals to be compatible with either Python 2 or 3) + or an integer. + - byte signatures (i.e. `y` type codes) must be passed either a length-1 + bytes object or an integer. unicodes (str in Python 3) are not allowed. + - `ByteArray` is now a subclass of `bytes`, where in Python 2 it is a + subclass of `str`. + - `dbus.UTF8String` is gone, use `dbus.String`. Also `utf8_string` arguments + are no longer allowed. + - All longs are now ints, since Python 3 has only a single int type. This + also means that the class hierarchy for the dbus numeric types has changed + (all derive from int in Python 3). + + +Bytes vs. Strings +================= + +All strings in dbus are defined as UTF-8: + +http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures + +However, the dbus C API accepts `char*` which must be UTF-8 strings NUL +terminated and no other NUL bytes. + +This page describes the mapping between Python types and dbus types: + + http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#basic-types + +Notice that it maps dbus `string` (`'s'`) to `dbus.String` (unicode) or +`dbus.UTF8String` (str). Also notice that there is no direct dbus equivalent +of Python's bytes type (although dbus does have byte arrays), so I am mapping +dbus strings to unicodes in all cases, and getting rid of `dbus.UTF8String` in +Python 3. I've also added a `dbus._BytesBase` type which is unused in Python +2, but which forms the base class for `dbus.ByteArray` in Python 3. This is +an implementation detail and not part of the public API. + +In Python 3, object paths (`'o'` or `dbus.ObjectPath`), signatures (`'g'` or +`dbus.Signature`), bus names, interfaces, and methods are all strings. A +previous aborted effort was made to use bytes for these, which at first blush +may makes some sense, but on deeper consideration does not. This approach +also tended to impose too many changes on user code, and caused lots of +difficult to track down problems. + +In Python 3, all such objects are subclasses of `str` (i.e. `unicode`). + +(As an example, dbus-python's callback dispatching pretty much assumes all +these things are strings. When they are bytes, the fact that `'foo' != b'foo'` +causes dispatch matching to fail in difficult to debug ways. Even bus names +are not immune, since they do things like `bus_name[:1] == ':'` which fails in +multiple ways when `bus_name` is a bytes. For sanity purposes, these are all +unicode strings now, and we just eat the complexity at the C level.) + +I am using `#include `, which exposes the PyBytes API to Python +2.6 and 2.7, and I have converted all internal PyString calls to PyBytes +calls. Where this is inappropriate, we'll use PyUnicode calls explicitly. +E.g. all repr() implementations now return unicodes. Most of these changes +shouldn't be noticed, even in existing Python 2 code. + +Generally, I've left the descriptions and docstrings saying "str" instead of +"unicode" since there's no distinction in Python 3. + +APIs which previously returned PyStrings will usually return PyUnicodes, not +PyBytes. + + +Ints vs. Longs +============== + +Python 3 only has PyLong types; PyInts are gone. For that reason, I've +switched all PyInt calls to use PyLong in both Python 2 and Python 3. Python +3.0 had a nice `` header that aliased PyInt to PyLong, but that's +gone as of Python 3.1, and the minimal required Python 3 version is 3.2. + +In the above page mapping basic types, you'll notice that the Python int type +is mapped to 32-bit signed integers ('i') and the Python long type is mapped +to 64-bit signed integers ('x'). Python 3 doesn't have this distinction, so +ints map to 'i' even though ints can be larger in Python 3. Use the +dbus-specific integer types if you must have more exact mappings. + +APIs which accepted ints in Python 2 will still do so, but they'll also now +accept longs. These APIs obviously only accept longs in Python 3. + +Long literals in Python code are an interesting thing to have to port. Don't +use them if you want your code to work in both Python versions. + +`dbus._IntBase` is removed in Python 3, you only have `dbus._LongBase`, which +inherits from a Python 3 int (i.e. a PyLong). Again, this is an +implementation detail that users should never care about. + + +Macros +====== + +In types-internal.h, I define `PY3K` when `PY_MAJOR_VERSION` >= 3, so you'll +see ifdefs on the former symbol within the C code. + +Python 3 really could use a PY_REFCNT() wrapper for ob_refcnt access. + + +PyCapsule vs. PyCObject +======================= + +`_dbus_bindings._C_API` is an attribute exposed to Python in the module. In +Python 2, this is a PyCObject, but these do not exist in Python >= 3.2, so it +is replaced with a PyCapsules for Python 3. However, since PyCapsules were +only introduced in Python 2.7, and I want to support Python 2.6, PyCObjects +are still used when this module is compiled for Python 2. + + +Python level compatibility +========================== + +`from dbus import _is_py3` gives you a flag to check if you must do something +different in Python 3. In general I use this flag to support both versions in +one set of sources, which seems better than trying to use 2to3. It's not part +of the dbus-python public API, so you must not use it in third-party projects. + + +Miscellaneous +============= + +The PyDoc_STRVAR() documentation is probably out of date. Once the API +choices have been green-lighted upstream, I'll make a pass through the code to +update them. It might be tricky based on any differences between Python 2 and +Python 3. + +There were a few places where I noticed what might be considered bugs, +unchecked exception conditions, or possible reference count leaks. In these +cases, I've just fixed what I can and hopefully haven't made the situation +worse. + +`dbus_py_variant_level_get()` did not check possible error conditions, nor did +their callers. When `dbus_py_variant_level_get()` encounters an error, it now +returns -1, and callers check this. + +As much as possible, I've refrained from general code cleanups (e.g. 80 +columns), unless it just bugged me too much or I touched the code for reasons +related to the port. I've also tried to stick to existing C code style, +e.g. through the use of pervasive `Py_CLEAR()` calls, comparison against NULL +usually with `!foo`, and such. As Bart Simpson might write on his classroom +blackboard:: + + This is not a rewrite + This is not a rewrite + This is not a rewrite + This is not a rewrite + ... + +and so on. Well, mostly ;). + +I think I fixed a reference leak in `DBusPyServer_set_auth_mechanisms()`. +`PySequence_Fast()` returns a new reference, which wasn't getting decref'd in +any return path. + + - Instantiation of metaclasses uses different, incompatible syntax in Python + 2 and 3. You have to use direct calling of the metaclass to work across + versions, i.e. `Interface = InterfaceType('Interface', (object,), {})` + - `iteritems()` and friends are gone. I dropped the "iter" prefixes. + - `xrange() is gone. I changed them to use `range()`. + - `isSequenceType()` is gone in Python 3, so I use a different idiom there. + - `__next__()` vs. `next()` + - `PyUnicode_FromFormat()` `%V` flag is a clever hack! + - `sys.version_info` is a tuple in Python 2.6, not a namedtuple. i.e. there + is no `sys.version_info.major` + - `PyArg_Parse()`: No 'y' code in Python 2; in Python 3, no equivalent of 'z' + for bytes objects. + + +Open issues +=========== + +Here are a few things that still need to be done, or for which there may be +open questions:: + + - Update all C extension docstrings for accuracy. diff -Nru dbus-python-0.84.0/examples/example-client.py dbus-python-1.0.0/examples/example-client.py --- dbus-python-0.84.0/examples/example-client.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/examples/example-client.py 2012-01-11 12:26:09.000000000 +0000 @@ -65,7 +65,7 @@ # D-Bus exceptions are mapped to Python exceptions try: iface.RaiseException() - except dbus.DBusException, e: + except dbus.DBusException as e: print str(e) # introspection is automatically supported diff -Nru dbus-python-0.84.0/examples/Makefile.in dbus-python-1.0.0/examples/Makefile.in --- dbus-python-0.84.0/examples/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/examples/Makefile.in 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -297,10 +297,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru dbus-python-0.84.0/include/dbus-python.h dbus-python-1.0.0/include/dbus-python.h --- dbus-python-0.84.0/include/dbus-python.h 2008-11-28 15:53:44.000000000 +0000 +++ dbus-python-1.0.0/include/dbus-python.h 2012-01-24 15:55:44.000000000 +0000 @@ -32,6 +32,11 @@ #include #include +#if PY_MAJOR_VERSION >= 3 +#define PY3 +#define PYDBUS_CAPSULE_NAME "_dbus_bindings._C_API" +#endif + DBUS_BEGIN_DECLS typedef void (*_dbus_py_func_ptr)(void); @@ -73,6 +78,18 @@ } c_api = PyObject_GetAttrString(_dbus_bindings_module, "_C_API"); if (c_api == NULL) return -1; +#ifdef PY3 + dbus_bindings_API = NULL; + if (PyCapsule_IsValid(c_api, PYDBUS_CAPSULE_NAME)) { + dbus_bindings_API = (_dbus_py_func_ptr *)PyCapsule_GetPointer( + c_api, PYDBUS_CAPSULE_NAME); + } + Py_CLEAR(c_api); + if (!dbus_bindings_API) { + PyErr_SetString(PyExc_RuntimeError, "C API is not a PyCapsule"); + return -1; + } +#else if (PyCObject_Check(c_api)) { dbus_bindings_API = (_dbus_py_func_ptr *)PyCObject_AsVoidPtr(c_api); } @@ -82,6 +99,7 @@ return -1; } Py_DECREF (c_api); +#endif count = *(int *)dbus_bindings_API[0]; if (count < DBUS_BINDINGS_API_COUNT) { PyErr_Format(PyExc_RuntimeError, diff -Nru dbus-python-0.84.0/INSTALL dbus-python-1.0.0/INSTALL --- dbus-python-0.84.0/INSTALL 2011-05-25 11:45:21.000000000 +0000 +++ dbus-python-1.0.0/INSTALL 2012-01-24 16:37:31.000000000 +0000 @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008, 2009 Free Software Foundation, Inc. +Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, +Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -226,6 +226,11 @@ and if that doesn't work, install pre-built binaries of GCC for HP-UX. + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended diff -Nru dbus-python-0.84.0/install-sh dbus-python-1.0.0/install-sh --- dbus-python-0.84.0/install-sh 2011-05-25 11:45:20.000000000 +0000 +++ dbus-python-1.0.0/install-sh 2012-01-24 16:37:30.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -156,6 +156,10 @@ -s) stripcmd=$stripprog;; -t) dst_arg=$2 + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac shift;; -T) no_target_directory=true;; @@ -186,6 +190,10 @@ fi shift # arg dst_arg=$arg + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -200,7 +208,11 @@ fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,9 +240,9 @@ for src do - # Protect names starting with `-'. + # Protect names problematic for `test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,12 +264,7 @@ echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. @@ -385,7 +392,7 @@ case $dstdir in /*) prefix='/';; - -*) prefix='./';; + [-=\(\)!]*) prefix='./';; *) prefix='';; esac @@ -403,7 +410,7 @@ for d do - test -z "$d" && continue + test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then diff -Nru dbus-python-0.84.0/ltmain.sh dbus-python-1.0.0/ltmain.sh --- dbus-python-0.84.0/ltmain.sh 2011-05-25 11:45:17.000000000 +0000 +++ dbus-python-1.0.0/ltmain.sh 2012-01-24 16:37:26.000000000 +0000 @@ -1,9 +1,9 @@ -# libtool (GNU libtool) 2.4 +# libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -41,6 +41,7 @@ # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) +# --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages @@ -69,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4 Debian-2.4-2 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1 # automake: $automake_version # autoconf: $autoconf_version # @@ -79,9 +80,9 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4 Debian-2.4-2" +VERSION="2.4.2 Debian-2.4.2-1" TIMESTAMP="" -package_revision=1.3293 +package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then @@ -136,15 +137,10 @@ : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${EGREP="/bin/grep -E"} -: ${FGREP="/bin/grep -F"} -: ${GREP="/bin/grep"} -: ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} -: ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} @@ -387,7 +383,7 @@ ;; *) save_IFS="$IFS" - IFS=: + IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break @@ -771,8 +767,8 @@ s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } @@ -1052,6 +1048,7 @@ opt_help=false opt_help_all=false opt_silent=: +opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false @@ -1120,6 +1117,10 @@ opt_silent=false func_append preserve_args " $opt" ;; + --no-warning|--no-warn) + opt_warning=false +func_append preserve_args " $opt" + ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" @@ -2059,7 +2060,7 @@ *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; @@ -3201,11 +3202,13 @@ # Set up the ranlib parameters. oldlib="$destdir/$name" + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $oldlib" 'exit $?' + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. @@ -3470,7 +3473,7 @@ # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; @@ -3982,14 +3985,17 @@ # launches target application with the remaining arguments. func_exec_program () { - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac func_exec_program_core \${1+\"\$@\"} } @@ -5057,9 +5063,15 @@ { EOF func_emit_wrapper yes | - $SED -e 's/\([\\"]\)/\\\1/g' \ - -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' - + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' cat <<"EOF" } EOF @@ -5643,7 +5655,8 @@ continue ;; - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" @@ -6150,7 +6163,8 @@ lib= found=no case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" @@ -6834,7 +6848,7 @@ test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" + add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in @@ -7319,6 +7333,7 @@ # which has an extra 1 added just for fun # case $version_type in + # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result @@ -7438,7 +7453,7 @@ versuffix="$major.$revision" ;; - linux) + linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" @@ -8026,6 +8041,11 @@ # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then + # Remove ${wl} instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= @@ -8056,7 +8076,7 @@ elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) func_apped perm_rpath " $libdir" ;; + *) func_append perm_rpath " $libdir" ;; esac fi done @@ -8064,11 +8084,7 @@ if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. @@ -9158,6 +9174,8 @@ esac done fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" @@ -9267,7 +9285,8 @@ *.la) func_basename "$deplib" name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + func_resolve_sysroot "$deplib" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" diff -Nru dbus-python-0.84.0/m4/libtool.m4 dbus-python-1.0.0/m4/libtool.m4 --- dbus-python-0.84.0/m4/libtool.m4 2011-05-25 11:45:17.000000000 +0000 +++ dbus-python-1.0.0/m4/libtool.m4 2012-01-24 16:37:26.000000000 +0000 @@ -1,8 +1,8 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -11,8 +11,8 @@ m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -146,6 +146,8 @@ AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl @@ -637,7 +639,7 @@ m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." @@ -801,6 +803,7 @@ m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], @@ -822,6 +825,31 @@ ])# _LT_LANG +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], @@ -852,6 +880,10 @@ m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -954,7 +986,13 @@ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -962,6 +1000,7 @@ rm -rf libconftest.dylib* rm -f conftest.* fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -973,6 +1012,7 @@ [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF @@ -990,7 +1030,9 @@ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1035,8 +1077,8 @@ ]) -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ @@ -1047,6 +1089,8 @@ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi @@ -1330,14 +1374,27 @@ CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -1414,13 +1471,13 @@ if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1600,6 +1657,11 @@ lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -1639,7 +1701,7 @@ # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -2185,7 +2247,7 @@ case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -2194,7 +2256,7 @@ ;; aix[[4-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -2259,7 +2321,7 @@ ;; bsdi[[45]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -2398,7 +2460,7 @@ ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -2406,10 +2468,6 @@ shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -2417,7 +2475,7 @@ objformat=`/usr/bin/objformat` else case $host_os in - freebsd[[123]]*) objformat=aout ;; + freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -2435,7 +2493,7 @@ esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) @@ -2455,7 +2513,7 @@ ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' @@ -2466,7 +2524,7 @@ ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -2527,7 +2585,7 @@ ;; interix[[3-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -2543,7 +2601,7 @@ nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -2580,9 +2638,9 @@ dynamic_linker=no ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2657,7 +2715,7 @@ ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -2726,7 +2784,7 @@ ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2751,7 +2809,7 @@ ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2775,7 +2833,7 @@ sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -2806,7 +2864,7 @@ tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2816,7 +2874,7 @@ ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -3238,7 +3296,7 @@ lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -3658,6 +3716,7 @@ # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -4242,7 +4301,9 @@ case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi ;; esac else @@ -4334,18 +4395,33 @@ ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; esac ;; esac @@ -4505,7 +4581,9 @@ ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) ;; + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] @@ -4533,7 +4611,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -4787,8 +4864,7 @@ xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ @@ -5084,6 +5160,7 @@ # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' @@ -5130,10 +5207,6 @@ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -5146,7 +5219,7 @@ ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -5185,7 +5258,6 @@ fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes @@ -5627,9 +5699,6 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], @@ -5787,7 +5856,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -6157,7 +6225,7 @@ esac ;; - freebsd[[12]]*) + freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no @@ -6918,12 +6986,18 @@ } }; _LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary @@ -7120,7 +7194,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7253,7 +7326,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7440,6 +7512,77 @@ ])# _LT_LANG_GCJ_CONFIG +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -7509,6 +7652,13 @@ dnl AC_DEFUN([LT_AC_PROG_GCJ], []) +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], diff -Nru dbus-python-0.84.0/m4/ltoptions.m4 dbus-python-1.0.0/m4/ltoptions.m4 --- dbus-python-0.84.0/m4/ltoptions.m4 2011-05-25 11:45:17.000000000 +0000 +++ dbus-python-1.0.0/m4/ltoptions.m4 2012-01-24 16:37:26.000000000 +0000 @@ -326,9 +326,24 @@ # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) diff -Nru dbus-python-0.84.0/m4/ltversion.m4 dbus-python-1.0.0/m4/ltversion.m4 --- dbus-python-0.84.0/m4/ltversion.m4 2011-05-25 11:45:17.000000000 +0000 +++ dbus-python-1.0.0/m4/ltversion.m4 2012-01-24 16:37:26.000000000 +0000 @@ -9,15 +9,15 @@ # @configure_input@ -# serial 3293 ltversion.m4 +# serial 3337 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4]) -m4_define([LT_PACKAGE_REVISION], [1.3293]) +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4' -macro_revision='1.3293' +[macro_version='2.4.2' +macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff -Nru dbus-python-0.84.0/m4/Makefile.in dbus-python-1.0.0/m4/Makefile.in --- dbus-python-0.84.0/m4/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/m4/Makefile.in 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -297,10 +297,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru dbus-python-0.84.0/Makefile.am dbus-python-1.0.0/Makefile.am --- dbus-python-0.84.0/Makefile.am 2010-12-02 15:07:21.000000000 +0000 +++ dbus-python-1.0.0/Makefile.am 2012-01-24 16:42:13.000000000 +0000 @@ -18,10 +18,9 @@ # === dbus package === nobase_python_PYTHON = \ - dbus_bindings.py \ dbus/bus.py \ dbus/connection.py \ - dbus/dbus_bindings.py \ + dbus/_compat.py \ dbus/_dbus.py \ dbus/_version.py \ dbus/decorators.py \ @@ -62,15 +61,23 @@ dist-hook: chmod u+w $(distdir)/ChangeLog if test -d $(top_srcdir)/.git; then \ - if git log --stat > $(distdir)/ChangeLog; then \ + if GIT_DIR=$(top_srcdir)/.git git log --stat > $(distdir)/ChangeLog; then \ : ; \ else \ - git log > $(distdir)/ChangeLog; \ + GIT_DIR=$(top_srcdir)/.git git log > $(distdir)/ChangeLog; \ fi; \ fi -TXT_RSTDOCS = doc/tutorial.txt doc/API_CHANGES.txt doc/HACKING.txt -RSTDOCS = README NEWS TODO +TXT_RSTDOCS = \ + doc/tutorial.txt \ + doc/API_CHANGES.txt \ + doc/HACKING.txt \ + doc/PY3PORT.txt \ + $(NULL) +RSTDOCS = \ + README \ + NEWS \ + TODO dist_doc_DATA = $(TXT_RSTDOCS) $(RSTDOCS) maintainer-upload: @@ -86,8 +93,8 @@ $(RSTDOCS) $(HTML_RSTDOCS) \ dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/doc/dbus-python/ -HTML_TXT_RSTDOCS = doc/tutorial.html doc/API_CHANGES.html doc/HACKING.html -HTML_RSTDOCS = README.html NEWS.html TODO.html +HTML_TXT_RSTDOCS = $(patsubst %.txt,%.html,$(TXT_RSTDOCS)) +HTML_RSTDOCS = $(patsubst %,%.html,$(RSTDOCS)) nodist_doc_DATA = $(HTML_TXT_RSTDOCS) $(HTML_RSTDOCS) CLEANFILES += $(nodist_doc_DATA) @@ -127,7 +134,7 @@ $(PYTHON) -Wignore::DeprecationWarning \ $(EPYDOC) -o $(abs_top_builddir)/api --html \ --docformat restructuredtext -v \ - `find dbus -name '*.py' | grep -v dbus_bindings \ + `find dbus -name '*.py' \ | sed -e 's#/__init__\.py##g' \ -e 's/\.py\>//g' -e 's#/#.#'g` \ || { rm -rf api; exit 1; } diff -Nru dbus-python-0.84.0/Makefile.in dbus-python-1.0.0/Makefile.in --- dbus-python-0.84.0/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/Makefile.in 2012-01-24 16:43:19.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -99,6 +99,13 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile) am__installdirs = "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(docdir)" \ "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" \ "$(DESTDIR)$(dbusincludedir)" @@ -148,6 +155,8 @@ DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -304,10 +313,9 @@ # === dbus package === nobase_python_PYTHON = \ - dbus_bindings.py \ dbus/bus.py \ dbus/connection.py \ - dbus/dbus_bindings.py \ + dbus/_compat.py \ dbus/_dbus.py \ dbus/_version.py \ dbus/decorators.py \ @@ -331,18 +339,28 @@ pkgconfig_DATA = dbus-python.pc dbusincludedir = $(includedir)/dbus-1.0/dbus dbusinclude_HEADERS = include/dbus-python.h -TXT_RSTDOCS = doc/tutorial.txt doc/API_CHANGES.txt doc/HACKING.txt -RSTDOCS = README NEWS TODO +TXT_RSTDOCS = \ + doc/tutorial.txt \ + doc/API_CHANGES.txt \ + doc/HACKING.txt \ + doc/PY3PORT.txt \ + $(NULL) + +RSTDOCS = \ + README \ + NEWS \ + TODO + dist_doc_DATA = $(TXT_RSTDOCS) $(RSTDOCS) -@ENABLE_DOCS_TRUE@HTML_TXT_RSTDOCS = doc/tutorial.html doc/API_CHANGES.html doc/HACKING.html -@ENABLE_DOCS_TRUE@HTML_RSTDOCS = README.html NEWS.html TODO.html +@ENABLE_DOCS_TRUE@HTML_TXT_RSTDOCS = $(patsubst %.txt,%.html,$(TXT_RSTDOCS)) +@ENABLE_DOCS_TRUE@HTML_RSTDOCS = $(patsubst %,%.html,$(RSTDOCS)) @ENABLE_DOCS_TRUE@nodist_doc_DATA = $(HTML_TXT_RSTDOCS) $(HTML_RSTDOCS) @ENABLE_API_DOCS_TRUE@APIDOC_PYTHONPATH = $(abs_top_srcdir):$(abs_top_builddir)/_dbus_bindings/.libs:$(abs_top_builddir)/_dbus_glib_bindings/.libs all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -am--refresh: +am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/tools/check-coding-style.mk $(am__configure_deps) @for dep in $?; do \ @@ -378,10 +396,8 @@ $(am__aclocal_m4_deps): config.h: stamp-h1 - @if test ! -f $@; then \ - rm -f stamp-h1; \ - $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ - else :; fi + @if test ! -f $@; then rm -f stamp-h1; else :; fi + @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 @@ -422,11 +438,8 @@ echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(pythondir)/$$dir'"; \ $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(pythondir)/$$dir" || exit $$?; }; \ if test -n "$$dlist"; then \ - if test -z "$(DESTDIR)"; then \ - PYTHON=$(PYTHON) $(py_compile) --basedir "$(pythondir)" $$dlist; \ - else \ - PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pythondir)" $$dlist; \ - fi; \ + $(am__py_compile) --destdir "$(DESTDIR)" \ + --basedir "$(pythondir)" $$dlist; \ else :; fi \ done @@ -435,14 +448,14 @@ @list='$(nobase_python_PYTHON)'; test -n "$(pythondir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ test -n "$$files" || exit 0; \ + dir='$(DESTDIR)$(pythondir)'; \ filesc=`echo "$$files" | sed 's|$$|c|'`; \ fileso=`echo "$$files" | sed 's|$$|o|'`; \ - echo " ( cd '$(DESTDIR)$(pythondir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pythondir)" && rm -f $$files || exit $$?; \ - echo " ( cd '$(DESTDIR)$(pythondir)' && rm -f" $$filesc ")"; \ - cd "$(DESTDIR)$(pythondir)" && rm -f $$filesc || exit $$?; \ - echo " ( cd '$(DESTDIR)$(pythondir)' && rm -f" $$fileso ")"; \ - cd "$(DESTDIR)$(pythondir)" && rm -f $$fileso + st=0; \ + for files in "$$files" "$$filesc" "$$fileso"; do \ + $(am__uninstall_files_from_dir) || st=$$?; \ + done; \ + exit $$st install-dist_docDATA: $(dist_doc_DATA) @$(NORMAL_INSTALL) test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" @@ -460,9 +473,7 @@ @$(NORMAL_UNINSTALL) @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(docdir)" && rm -f $$files + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) install-nodist_docDATA: $(nodist_doc_DATA) @$(NORMAL_INSTALL) test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" @@ -480,9 +491,7 @@ @$(NORMAL_UNINSTALL) @list='$(nodist_doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(docdir)" && rm -f $$files + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @@ -500,9 +509,7 @@ @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-dbusincludeHEADERS: $(dbusinclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(dbusincludedir)" || $(MKDIR_P) "$(DESTDIR)$(dbusincludedir)" @@ -520,9 +527,7 @@ @$(NORMAL_UNINSTALL) @list='$(dbusinclude_HEADERS)'; test -n "$(dbusincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(dbusincludedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(dbusincludedir)" && rm -f $$files + dir='$(DESTDIR)$(dbusincludedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -734,7 +739,7 @@ $(am__remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir @@ -742,7 +747,7 @@ $(am__remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir @@ -792,6 +797,7 @@ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ @@ -820,8 +826,16 @@ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -856,10 +870,15 @@ installcheck: installcheck-recursive install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -1012,10 +1031,10 @@ dist-hook: chmod u+w $(distdir)/ChangeLog if test -d $(top_srcdir)/.git; then \ - if git log --stat > $(distdir)/ChangeLog; then \ + if GIT_DIR=$(top_srcdir)/.git git log --stat > $(distdir)/ChangeLog; then \ : ; \ else \ - git log > $(distdir)/ChangeLog; \ + GIT_DIR=$(top_srcdir)/.git git log > $(distdir)/ChangeLog; \ fi; \ fi @@ -1061,7 +1080,7 @@ @ENABLE_API_DOCS_TRUE@ $(PYTHON) -Wignore::DeprecationWarning \ @ENABLE_API_DOCS_TRUE@ $(EPYDOC) -o $(abs_top_builddir)/api --html \ @ENABLE_API_DOCS_TRUE@ --docformat restructuredtext -v \ -@ENABLE_API_DOCS_TRUE@ `find dbus -name '*.py' | grep -v dbus_bindings \ +@ENABLE_API_DOCS_TRUE@ `find dbus -name '*.py' \ @ENABLE_API_DOCS_TRUE@ | sed -e 's#/__init__\.py##g' \ @ENABLE_API_DOCS_TRUE@ -e 's/\.py\>//g' -e 's#/#.#'g` \ @ENABLE_API_DOCS_TRUE@ || { rm -rf api; exit 1; } diff -Nru dbus-python-0.84.0/NEWS dbus-python-1.0.0/NEWS --- dbus-python-0.84.0/NEWS 2011-05-25 10:57:37.000000000 +0000 +++ dbus-python-1.0.0/NEWS 2012-01-24 16:29:30.000000000 +0000 @@ -1,3 +1,44 @@ +D-Bus Python Bindings 1.0.0 (UNRELEASED) +======================================== + +The "never trust a .0 release?" release. + +Dependencies: + +* libdbus 1.4 or later is now required. + +* Python 2.6 or later is now required. If Python 3 is used, it must be + version 3.2 or later. + +* GNU make (or, at your own risk, another make with the GNU $(patsubst) + extension) is now required. + +API changes: + +* dbus_bindings, which was never meant to be public API and has been + deprecated for nearly 5 years, has finally been removed. + +* The repr() of every dbus-python object is now unicode. + +* The Python 3 API is not the same as the Python 2 API; see PY3PORT.rst + for details. + +Enhancements: + +* Python 3 compatibility (fd.o #26420, Barry Warsaw) + +* MethodCallMessage and SignalMessage now have a more useful repr() + (Barry Warsaw) + +Fixes: + +* OOM while appending a unicode object to a message no longer leaks a string + (Barry Warsaw) + +* If libdbus somehow gives us invalid UTF-8, don't crash (Barry Warsaw) + +* Fix rst2html failure in non-UTF-8 locales (Alexandre Rostovtsev) + D-Bus Python Bindings 0.84.0 (2011-05-25) ========================================= diff -Nru dbus-python-0.84.0/py-compile dbus-python-1.0.0/py-compile --- dbus-python-0.84.0/py-compile 2011-05-25 11:45:21.000000000 +0000 +++ dbus-python-1.0.0/py-compile 2012-01-24 16:37:31.000000000 +0000 @@ -1,10 +1,10 @@ #!/bin/sh # py-compile - Compile a Python program -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-06-08.12; # UTC -# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008, 2009 Free Software -# Foundation, Inc. +# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008, 2009, 2011 Free +# Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,28 +32,36 @@ PYTHON=python fi +me=py-compile + +usage_error () +{ + echo "$me: $*" >&2 + echo "Try \`$me --help' for more information." >&2 + exit 1 +} + basedir= destdir= -files= while test $# -ne 0; do case "$1" in --basedir) - basedir=$2 - if test -z "$basedir"; then - echo "$0: Missing argument to --basedir." 1>&2 - exit 1 + if test $# -lt 2; then + usage_error "option '--basedir' requires an argument" + else + basedir=$2 fi shift ;; --destdir) - destdir=$2 - if test -z "$destdir"; then - echo "$0: Missing argument to --destdir." 1>&2 - exit 1 + if test $# -lt 2; then + usage_error "option '--destdir' requires an argument" + else + destdir=$2 fi shift ;; - -h|--h*) + -h|--help) cat <<\EOF Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." @@ -69,20 +77,27 @@ EOF exit $? ;; - -v|--v*) - echo "py-compile $scriptversion" + -v|--version) + echo "$me $scriptversion" exit $? ;; + --) + shift + break + ;; + -*) + usage_error "unrecognized option '$1'" + ;; *) - files="$files $1" + break ;; esac shift done +files=$* if test -z "$files"; then - echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 - exit 1 + usage_error "no files given" fi # if basedir was given, then it should be prepended to filenames before diff -Nru dbus-python-0.84.0/README dbus-python-1.0.0/README --- dbus-python-0.84.0/README 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/README 2012-01-24 16:37:03.000000000 +0000 @@ -32,3 +32,27 @@ __ doc/HACKING.txt __ doc/HACKING.html + +Problems and alternatives +========================= + +dbus-python might not be the best D-Bus binding for you to use. dbus-python +does not follow the principle of "In the face of ambiguity, refuse the +temptation to guess", and can't be changed to not do so without seriously +breaking compatibility. + +In addition, it uses libdbus (which has known problems with multi-threaded +use) and attempts to be main-loop-agnostic (which means you have to select +a suitable main loop for your application). + +Alternative ways to get your Python code onto D-Bus include: + +* GDBus, part of the GIO module of `GLib`_, via GObject-Introspection and + `PyGI`_ (uses the GLib main loop and object model) + +* QtDBus, part of `Qt`_, via `PyQt`_ (uses the Qt main loop and object model) + +.. _GLib: http://developer.gnome.org/glib/ +.. _PyGI: https://live.gnome.org/PyGObject +.. _Qt: https://qt.nokia.com/ +.. _PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro diff -Nru dbus-python-0.84.0/test/cross-test-client.py dbus-python-1.0.0/test/cross-test-client.py --- dbus-python-0.84.0/test/cross-test-client.py 2010-02-18 17:02:23.000000000 +0000 +++ dbus-python-1.0.0/test/cross-test-client.py 2012-01-24 15:55:44.000000000 +0000 @@ -20,19 +20,31 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from time import sleep +from __future__ import print_function, unicode_literals import logging -import gobject +from gi.repository import GObject as gobject -from dbus import SessionBus, Interface, Array, Byte, Double, Boolean, ByteArray, Int16, Int32, Int64, UInt16, UInt32, UInt64, String, UTF8String, Struct, Dictionary -from dbus.service import BusName +from dbus import ( + Array, Boolean, Byte, ByteArray, Double, Int16, Int32, Int64, + Interface, SessionBus, String, UInt16, UInt32, UInt64) +from dbus._compat import is_py2, is_py3 import dbus.glib -from crosstest import CROSS_TEST_PATH, CROSS_TEST_BUS_NAME,\ - INTERFACE_SINGLE_TESTS, INTERFACE_TESTS,\ - INTERFACE_SIGNAL_TESTS, INTERFACE_CALLBACK_TESTS,\ - SignalTestsImpl +if is_py2: + from dbus import UTF8String + +from crosstest import ( + CROSS_TEST_BUS_NAME, CROSS_TEST_PATH, INTERFACE_CALLBACK_TESTS, + INTERFACE_SIGNAL_TESTS, INTERFACE_SINGLE_TESTS, INTERFACE_TESTS, + SignalTestsImpl) + +if is_py3: + def make_long(n): + return n +else: + def make_long(n): + return long(n) logging.basicConfig() @@ -47,9 +59,9 @@ def quit(self): for x in self.expected: self.fail_id += 1 - print "%s fail %d" % (x, self.fail_id) + print("%s fail %d" % (x, self.fail_id)) s = "report %d: reply to %s didn't arrive" % (self.fail_id, x) - print s + print(s) logger.error(s) logger.info("asking server to Exit") Interface(self.obj, INTERFACE_TESTS).Exit(reply_handler=self.quit_reply_handler, error_handler=self.quit_error_handler) @@ -72,40 +84,42 @@ self.expected.discard('%s.Trigger' % INTERFACE_SIGNAL_TESTS) if (input1, input2) != (42, 23): self.fail_id += 1 - print "%s.Trigger fail %d" % (INTERFACE_SIGNAL_TESTS, self.fail_id) + print("%s.Trigger fail %d" % + (INTERFACE_SIGNAL_TESTS, self.fail_id)) s = ("report %d: expected (42,23), got %r" % (self.fail_id, (input1, input2))) logger.error(s) - print s + print(s) else: - print "%s.Trigger pass" % INTERFACE_SIGNAL_TESTS + print("%s.Trigger pass" % INTERFACE_SIGNAL_TESTS) self.quit() - def assert_method_matches(self, interface, check_fn, check_arg, member, *args): + def assert_method_matches(self, interface, check_fn, check_arg, member, + *args): if_obj = Interface(self.obj, interface) method = getattr(if_obj, member) try: real_ret = method(*args) - except Exception, e: + except Exception as e: self.fail_id += 1 - print "%s.%s fail %d" % (interface, member, self.fail_id) + print("%s.%s fail %d" % (interface, member, self.fail_id)) s = ("report %d: %s.%s%r: raised %r \"%s\"" % (self.fail_id, interface, member, args, e, e)) - print s + print(s) logger.error(s) __import__('traceback').print_exc() return try: check_fn(real_ret, check_arg) - except Exception, e: + except Exception as e: self.fail_id += 1 - print "%s.%s fail %d" % (interface, member, self.fail_id) + print("%s.%s fail %d" % (interface, member, self.fail_id)) s = ("report %d: %s.%s%r: %s" % (self.fail_id, interface, member, args, e)) - print s + print(s) logger.error(s) return - print "%s.%s pass" % (interface, member) + print("%s.%s pass" % (interface, member)) def assert_method_eq(self, interface, ret, member, *args): def equals(real_ret, exp): @@ -119,10 +133,10 @@ % (getattr(exp, 'variant_level', 0), real_ret, real_ret.variant_level)) if isinstance(exp, list) or isinstance(exp, tuple): - for i in xrange(len(exp)): + for i in range(len(exp)): try: equals(real_ret[i], exp[i]) - except AssertionError, e: + except AssertionError as e: if not isinstance(e.args, tuple): e.args = (e.args,) e.args = e.args + ('(at position %d in sequence)' % i,) @@ -131,7 +145,7 @@ for k in exp: try: equals(real_ret[k], exp[k]) - except AssertionError, e: + except AssertionError as e: if not isinstance(e.args, tuple): e.args = (e.args,) e.args = e.args + ('(at key %r in dict)' % k,) @@ -161,20 +175,20 @@ self.expected.discard('%s.Trigger' % INTERFACE_TESTS) if sender_path != '/Where/Ever': self.fail_id += 1 - print "%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id) + print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id)) s = ("report %d: expected signal from /Where/Ever, got %r" % (self.fail_id, sender_path)) - print s + print(s) logger.error(s) elif param != 42: self.fail_id += 1 - print "%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id) + print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id)) s = ("report %d: expected signal param 42, got %r" - % (self.fail_id, parameter)) - print s + % (self.fail_id, param)) + print(s) logger.error(s) else: - print "%s.Trigger pass" % INTERFACE_TESTS + print("%s.Trigger pass" % INTERFACE_TESTS) def trigger_returned_cb(self): logger.info('method/signal: Trigger() returned') @@ -202,7 +216,10 @@ path_keyword='sender_path') logger.info("method/signal: Triggering signal") self.expected.add('%s.Trigger' % INTERFACE_TESTS) - Interface(obj, INTERFACE_TESTS).Trigger(u'/Where/Ever', dbus.UInt64(42), reply_handler=self.trigger_returned_cb, error_handler=self.trigger_error_handler) + Interface(obj, INTERFACE_TESTS).Trigger( + '/Where/Ever', dbus.UInt64(42), + reply_handler=self.trigger_returned_cb, + error_handler=self.trigger_error_handler) def trigger_error_handler(self, e): logger.error("method/signal: %s %s", e.__class__, e) @@ -217,20 +234,22 @@ # "Single tests" if have_signatures: self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [1, 2, 3]) - self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ['\x01', '\x02', '\x03']) + self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', + [b'\x01', b'\x02', b'\x03']) self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [Byte(1), Byte(2), Byte(3)]) - self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ByteArray('\x01\x02\x03')) + self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ByteArray(b'\x01\x02\x03')) # Main tests - self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', String('foo')) - self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', UTF8String('foo')) + self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', String('foo')) + if is_py2: + self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', UTF8String('foo')) self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42)) self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=23), 'Identity', Byte(42, variant_level=23)) self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', 42.5) self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5) if have_signatures: - self.assert_method_eq(INTERFACE_TESTS, String(u'foo', variant_level=1), 'Identity', 'foo') + self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', 'foo') self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42)) self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', Double(42.5)) self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5) @@ -246,9 +265,12 @@ self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt16', UInt16(i)) for i in (-0x7fffffff-1, 0, 42, 0x7fffffff): self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt32', Int32(i)) - for i in (0L, 42L, 0xffffffffL): + for i in (0, 42, 0xffffffff): + i = make_long(i) self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt32', UInt32(i)) - MANY = 0x8000L * 0x10000L * 0x10000L * 0x10000L + MANY = 1 + for n in (0x8000, 0x10000, 0x10000, 0x10000): + MANY *= make_long(n) for i in (-MANY, 0, 42, MANY-1): self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt64', Int64(i)) for i in (0, 42, 2*MANY - 1): @@ -257,11 +279,12 @@ self.assert_method_eq(INTERFACE_TESTS, 42.3, 'IdentityDouble', 42.3) for i in ('', 'foo'): self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityString', i) - for i in (u'\xa9', '\xc2\xa9'): - self.assert_method_eq(INTERFACE_TESTS, u'\xa9', 'IdentityString', i) + for i in ('\xa9', b'\xc2\xa9'): + self.assert_method_eq(INTERFACE_TESTS, '\xa9', 'IdentityString', i) if have_signatures: - self.assert_method_eq(INTERFACE_TESTS, Byte(0x42), 'IdentityByte', '\x42') + self.assert_method_eq(INTERFACE_TESTS, Byte(0x42), + 'IdentityByte', b'\x42') self.assert_method_eq(INTERFACE_TESTS, True, 'IdentityBool', 42) self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityInt16', 42) self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt16', 42) @@ -271,13 +294,13 @@ self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt64', 42) self.assert_method_eq(INTERFACE_TESTS, 42.0, 'IdentityDouble', 42) - self.assert_method_eq(INTERFACE_TESTS, [Byte('\x01', variant_level=1), - Byte('\x02', variant_level=1), - Byte('\x03', variant_level=1)], + self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1), + Byte(b'\x02', variant_level=1), + Byte(b'\x03', variant_level=1)], 'IdentityArray', - Array([Byte('\x01'), - Byte('\x02'), - Byte('\x03')], + Array([Byte(b'\x01'), + Byte(b'\x02'), + Byte(b'\x03')], signature='v')) self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1), @@ -288,9 +311,9 @@ Int32(2), Int32(3)], signature='v')) - self.assert_method_eq(INTERFACE_TESTS, [String(u'a', variant_level=1), - String(u'b', variant_level=1), - String(u'c', variant_level=1)], + self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1), + String('b', variant_level=1), + String('c', variant_level=1)], 'IdentityArray', Array([String('a'), String('b'), @@ -298,11 +321,11 @@ signature='v')) if have_signatures: - self.assert_method_eq(INTERFACE_TESTS, [Byte('\x01', variant_level=1), - Byte('\x02', variant_level=1), - Byte('\x03', variant_level=1)], + self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1), + Byte(b'\x02', variant_level=1), + Byte(b'\x03', variant_level=1)], 'IdentityArray', - ByteArray('\x01\x02\x03')) + ByteArray(b'\x01\x02\x03')) self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1), Int32(2, variant_level=1), Int32(3, variant_level=1)], @@ -310,18 +333,20 @@ [Int32(1), Int32(2), Int32(3)]) - self.assert_method_eq(INTERFACE_TESTS, [String(u'a', variant_level=1), - String(u'b', variant_level=1), - String(u'c', variant_level=1)], + self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1), + String('b', variant_level=1), + String('c', variant_level=1)], 'IdentityArray', ['a','b','c']) self.assert_method_eq(INTERFACE_TESTS, [Byte(1), Byte(2), Byte(3)], 'IdentityByteArray', - ByteArray('\x01\x02\x03')) + ByteArray(b'\x01\x02\x03')) if have_signatures: - self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityByteArray', ['\x01', '\x02', '\x03']) + self.assert_method_eq(INTERFACE_TESTS, [1,2,3], + 'IdentityByteArray', + [b'\x01', b'\x02', b'\x03']) self.assert_method_eq(INTERFACE_TESTS, [False,True], 'IdentityBoolArray', [False,True]) if have_signatures: self.assert_method_eq(INTERFACE_TESTS, [False,True,True], 'IdentityBoolArray', [0,1,2]) diff -Nru dbus-python-0.84.0/test/cross-test-server.py dbus-python-1.0.0/test/cross-test-server.py --- dbus-python-0.84.0/test/cross-test-server.py 2010-02-18 17:02:23.000000000 +0000 +++ dbus-python-1.0.0/test/cross-test-server.py 2012-01-24 15:55:44.000000000 +0000 @@ -20,18 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import print_function import logging -import gobject +from gi.repository import GObject as gobject import dbus.glib from dbus import SessionBus from dbus.service import BusName +from dbus._compat import is_py2 -from crosstest import CROSS_TEST_PATH, CROSS_TEST_BUS_NAME, \ - INTERFACE_SINGLE_TESTS, INTERFACE_TESTS,\ - INTERFACE_CALLBACK_TESTS, INTERFACE_SIGNAL_TESTS,\ - SignalTestsImpl +from crosstest import ( + CROSS_TEST_BUS_NAME, CROSS_TEST_PATH, INTERFACE_CALLBACK_TESTS, + INTERFACE_SIGNAL_TESTS, INTERFACE_SINGLE_TESTS, INTERFACE_TESTS, + SignalTestsImpl) logging.basicConfig() @@ -41,7 +43,7 @@ class VerboseSet(set): def add(self, thing): - print '%s ok' % thing + print('%s ok' % thing) set.add(self, thing) @@ -218,11 +220,15 @@ return x - @dbus.service.method(INTERFACE_TESTS, 'a{ss}', 'a{sas}', utf8_strings=True) + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True + + @dbus.service.method(INTERFACE_TESTS, 'a{ss}', 'a{sas}', **kwargs) def InvertMapping(self, input): tested_things.add(INTERFACE_TESTS + '.InvertMapping') output = dbus.Dictionary({}) - for k, v in input.iteritems(): + for k, v in input.items(): output.setdefault(v, []).append(k) return output @@ -261,8 +267,9 @@ tested_things.add(INTERFACE_TESTS + '.Invert') return not input - @dbus.service.method(INTERFACE_TESTS, 'st', '', utf8_strings=True, - connection_keyword='conn') + @dbus.service.method(INTERFACE_TESTS, 'st', '', + connection_keyword='conn', + **kwargs) def Trigger(self, object, parameter, conn=None): assert isinstance(object, str) logger.info('method/signal: client wants me to emit Triggered(%r) from %r', parameter, object) @@ -286,7 +293,7 @@ tested_things.add(INTERFACE_TESTS + '.Exit') for x in testable_things: if x not in tested_things: - print '%s untested' % x + print('%s untested' % x) logger.info('will quit when idle') gobject.idle_add(self._exit_fn) @@ -309,6 +316,9 @@ loop = gobject.MainLoop() obj = Server(bus_name, CROSS_TEST_PATH, loop.quit) objects[CROSS_TEST_PATH] = obj + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True bus.add_signal_receiver(obj.triggered_by_client, signal_name='Trigger', dbus_interface=INTERFACE_SIGNAL_TESTS, @@ -316,7 +326,7 @@ path=None, sender_keyword='sender', path_keyword='sender_path', - utf8_strings=True) + **kwargs) logger.info("running...") loop.run() diff -Nru dbus-python-0.84.0/test/dbus_py_test.c dbus-python-1.0.0/test/dbus_py_test.c --- dbus-python-0.84.0/test/dbus_py_test.c 2010-12-02 16:18:35.000000000 +0000 +++ dbus-python-1.0.0/test/dbus_py_test.c 2012-01-24 15:55:44.000000000 +0000 @@ -26,7 +26,11 @@ #include #include "dbus-python.h" +#ifdef PY3 +PyMODINIT_FUNC PyInit_dbus_py_test(void); +#else PyMODINIT_FUNC initdbus_py_test(void); +#endif #if defined(__GNUC__) # if __GNUC__ >= 3 @@ -113,6 +117,27 @@ {NULL, NULL, 0, NULL} }; +#ifdef PY3 +PyMODINIT_FUNC +PyInit_dbus_py_test(void) +{ + static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "dbus_py_test", /* m_name */ + NULL, /* m_doc */ + -1, /* m_size */ + module_functions, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ + }; + if (import_dbus_bindings("dbus_py_test") < 0) + return NULL; + + return PyModule_Create(&moduledef); +} +#else PyMODINIT_FUNC initdbus_py_test(void) { @@ -122,5 +147,6 @@ this_module = Py_InitModule3 ("dbus_py_test", module_functions, ""); if (!this_module) return; } +#endif /* vim:set ft=c cino< sw=4 sts=4 et: */ diff -Nru dbus-python-0.84.0/test/Makefile.in dbus-python-1.0.0/test/Makefile.in --- dbus-python-0.84.0/test/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/test/Makefile.in 2012-01-24 16:37:30.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -78,6 +78,12 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(pyexecdir)" LTLIBRARIES = $(pyexec_LTLIBRARIES) dbus_py_test_la_LIBADD = @@ -405,50 +411,44 @@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< dbus_py_test_la-dbus_py_test.lo: dbus_py_test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dbus_py_test_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dbus_py_test_la-dbus_py_test.lo -MD -MP -MF $(DEPDIR)/dbus_py_test_la-dbus_py_test.Tpo -c -o dbus_py_test_la-dbus_py_test.lo `test -f 'dbus_py_test.c' || echo '$(srcdir)/'`dbus_py_test.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dbus_py_test_la-dbus_py_test.Tpo $(DEPDIR)/dbus_py_test_la-dbus_py_test.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dbus_py_test.c' object='dbus_py_test_la-dbus_py_test.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus_py_test.c' object='dbus_py_test_la-dbus_py_test.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dbus_py_test_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dbus_py_test_la-dbus_py_test.lo `test -f 'dbus_py_test.c' || echo '$(srcdir)/'`dbus_py_test.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dbus_py_test_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dbus_py_test_la-dbus_py_test.lo `test -f 'dbus_py_test.c' || echo '$(srcdir)/'`dbus_py_test.c test_import_repeatedly-import-repeatedly.o: import-repeatedly.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_import_repeatedly-import-repeatedly.o -MD -MP -MF $(DEPDIR)/test_import_repeatedly-import-repeatedly.Tpo -c -o test_import_repeatedly-import-repeatedly.o `test -f 'import-repeatedly.c' || echo '$(srcdir)/'`import-repeatedly.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_import_repeatedly-import-repeatedly.Tpo $(DEPDIR)/test_import_repeatedly-import-repeatedly.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='import-repeatedly.c' object='test_import_repeatedly-import-repeatedly.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='import-repeatedly.c' object='test_import_repeatedly-import-repeatedly.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_import_repeatedly-import-repeatedly.o `test -f 'import-repeatedly.c' || echo '$(srcdir)/'`import-repeatedly.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_import_repeatedly-import-repeatedly.o `test -f 'import-repeatedly.c' || echo '$(srcdir)/'`import-repeatedly.c test_import_repeatedly-import-repeatedly.obj: import-repeatedly.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_import_repeatedly-import-repeatedly.obj -MD -MP -MF $(DEPDIR)/test_import_repeatedly-import-repeatedly.Tpo -c -o test_import_repeatedly-import-repeatedly.obj `if test -f 'import-repeatedly.c'; then $(CYGPATH_W) 'import-repeatedly.c'; else $(CYGPATH_W) '$(srcdir)/import-repeatedly.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_import_repeatedly-import-repeatedly.Tpo $(DEPDIR)/test_import_repeatedly-import-repeatedly.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='import-repeatedly.c' object='test_import_repeatedly-import-repeatedly.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='import-repeatedly.c' object='test_import_repeatedly-import-repeatedly.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_import_repeatedly-import-repeatedly.obj `if test -f 'import-repeatedly.c'; then $(CYGPATH_W) 'import-repeatedly.c'; else $(CYGPATH_W) '$(srcdir)/import-repeatedly.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_import_repeatedly_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_import_repeatedly-import-repeatedly.obj `if test -f 'import-repeatedly.c'; then $(CYGPATH_W) 'import-repeatedly.c'; else $(CYGPATH_W) '$(srcdir)/import-repeatedly.c'; fi` mostlyclean-libtool: -rm -f *.lo @@ -589,14 +589,15 @@ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ + col="$$grn"; \ else \ - echo "$$red$$dashes"; \ + col="$$red"; \ fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi @@ -648,10 +649,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff -Nru dbus-python-0.84.0/test/run-test.sh dbus-python-1.0.0/test/run-test.sh --- dbus-python-0.84.0/test/run-test.sh 2010-12-02 15:08:29.000000000 +0000 +++ dbus-python-1.0.0/test/run-test.sh 2012-01-24 15:55:44.000000000 +0000 @@ -62,6 +62,11 @@ dbus-monitor > "$DBUS_TOP_BUILDDIR"/test/monitor.log & +echo "DBUS_TOP_SRCDIR=$DBUS_TOP_SRCDIR" +echo "DBUS_TOP_BUILDDIR=$DBUS_TOP_BUILDDIR" +echo "PYTHONPATH=$PYTHONPATH" +echo "PYTHON=$PYTHON" + echo "running test-standalone.py" $PYTHON "$DBUS_TOP_SRCDIR"/test/test-standalone.py || die "test-standalone.py failed" diff -Nru dbus-python-0.84.0/test/test-client.py dbus-python-1.0.0/test/test-client.py --- dbus-python-0.84.0/test/test-client.py 2010-12-02 15:08:29.000000000 +0000 +++ dbus-python-1.0.0/test/test-client.py 2012-01-24 15:55:44.000000000 +0000 @@ -23,7 +23,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -import sys +from __future__ import print_function import os import unittest import time @@ -35,10 +35,12 @@ import dbus import _dbus_bindings -import gobject import dbus.glib import dbus.service +from dbus._compat import is_py2, is_py3 +from gi.repository import GObject as gobject + logging.basicConfig() @@ -52,8 +54,8 @@ test_types_vals = [1, 12323231, 3.14159265, 99999999.99, "dude", "123", "What is all the fuss about?", "gob@gob.com", - u'\\u310c\\u310e\\u3114', u'\\u0413\\u0414\\u0415', - u'\\u2200software \\u2203crack', u'\\xf4\\xe5\\xe8', + '\\u310c\\u310e\\u3114', '\\u0413\\u0414\\u0415', + '\\u2200software \\u2203crack', '\\xf4\\xe5\\xe8', [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"], (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2), {1:"a", 2:"b"}, {"a":1, "b":2}, #{"a":(1,"B")}, @@ -76,50 +78,59 @@ self.iface = dbus.Interface(self.remote_object, IFACE) def testGObject(self): - print "Testing ExportedGObject... ", + print("Testing ExportedGObject... ", end='') remote_gobject = self.bus.get_object(NAME, OBJECT + '/GObject') iface = dbus.Interface(remote_gobject, IFACE) - print "introspection, ", + print("introspection, ", end='') remote_gobject.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE) - print "method call, ", - self.assertEquals(iface.Echo('123'), '123') - print "... OK" + print("method call, ", end='') + self.assertEqual(iface.Echo('123'), '123') + print("... OK") def testWeakRefs(self): # regression test for Sugar crash caused by smcv getting weak refs # wrong - pre-bugfix, this would segfault bus = dbus.SessionBus(private=True) ref = weakref.ref(bus) - self.assert_(ref() is bus) + self.assertTrue(ref() is bus) del bus - self.assert_(ref() is None) + self.assertTrue(ref() is None) def testInterfaceKeyword(self): #test dbus_interface parameter - print self.remote_object.Echo("dbus_interface on Proxy test Passed", dbus_interface = IFACE) - print self.iface.Echo("dbus_interface on Interface test Passed", dbus_interface = IFACE) - self.assert_(True) + print(self.remote_object.Echo("dbus_interface on Proxy test Passed", + dbus_interface = IFACE)) + print(self.iface.Echo("dbus_interface on Interface test Passed", + dbus_interface = IFACE)) + self.assertTrue(True) def testGetDBusMethod(self): - self.assertEquals(self.iface.get_dbus_method('AcceptListOfByte')('\1\2\3'), [1,2,3]) - self.assertEquals(self.remote_object.get_dbus_method('AcceptListOfByte', dbus_interface=IFACE)('\1\2\3'), [1,2,3]) + self.assertEqual(self.iface.get_dbus_method('AcceptListOfByte')(b'\1\2\3'), [1,2,3]) + self.assertEqual(self.remote_object.get_dbus_method('AcceptListOfByte', dbus_interface=IFACE)(b'\1\2\3'), [1,2,3]) def testCallingConventionOptions(self): - self.assertEquals(self.iface.AcceptListOfByte('\1\2\3'), [1,2,3]) - self.assertEquals(self.iface.AcceptListOfByte('\1\2\3', byte_arrays=True), '\1\2\3') - self.assertEquals(self.iface.AcceptByteArray('\1\2\3'), [1,2,3]) - self.assertEquals(self.iface.AcceptByteArray('\1\2\3', byte_arrays=True), '\1\2\3') - self.assert_(isinstance(self.iface.AcceptUTF8String('abc'), unicode)) - self.assert_(isinstance(self.iface.AcceptUTF8String('abc', utf8_strings=True), str)) - self.assert_(isinstance(self.iface.AcceptUnicodeString('abc'), unicode)) - self.assert_(isinstance(self.iface.AcceptUnicodeString('abc', utf8_strings=True), str)) + self.assertEqual(self.iface.AcceptListOfByte(b'\1\2\3'), [1,2,3]) + self.assertEqual(self.iface.AcceptListOfByte(b'\1\2\3', byte_arrays=True), b'\1\2\3') + self.assertEqual(self.iface.AcceptByteArray(b'\1\2\3'), [1,2,3]) + self.assertEqual(self.iface.AcceptByteArray(b'\1\2\3', byte_arrays=True), b'\1\2\3') + if is_py2: + self.assertTrue(isinstance(self.iface.AcceptUTF8String('abc'), unicode)) + self.assertTrue(isinstance(self.iface.AcceptUTF8String('abc', utf8_strings=True), str)) + unicode_type = (str if is_py3 else unicode) + self.assertTrue(isinstance(self.iface.AcceptUnicodeString('abc'), + unicode_type)) + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True + self.assertTrue(isinstance(self.iface.AcceptUnicodeString('abc', **kwargs), str)) def testIntrospection(self): #test introspection - print "\n********* Introspection Test ************" - print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") - print "Introspection test passed" - self.assert_(True) + print("\n********* Introspection Test ************") + print(self.remote_object.Introspect( + dbus_interface="org.freedesktop.DBus.Introspectable")) + print("Introspection test passed") + self.assertTrue(True) def testMultiPathIntrospection(self): # test introspection on an object exported in multiple places @@ -130,80 +141,86 @@ remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") remote_object = self.bus.get_object(NAME, OBJECT + '/Multi2/3') remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") - self.assert_(True) + self.assertTrue(True) def testPythonTypes(self): #test sending python types and getting them back - print "\n********* Testing Python Types ***********" + print("\n********* Testing Python Types ***********") for send_val in test_types_vals: - print "Testing %s"% str(send_val) + print("Testing %s"% str(send_val)) recv_val = self.iface.Echo(send_val) - self.assertEquals(send_val, recv_val) - self.assertEquals(recv_val.variant_level, 1) + self.assertEqual(send_val, recv_val) + self.assertEqual(recv_val.variant_level, 1) def testMethodExtraInfoKeywords(self): - print "Testing MethodExtraInfoKeywords..." + print("Testing MethodExtraInfoKeywords...") sender, path, destination, message_cls = self.iface.MethodExtraInfoKeywords() - self.assert_(sender.startswith(':')) - self.assertEquals(path, '/org/freedesktop/DBus/TestSuitePythonObject') + self.assertTrue(sender.startswith(':')) + self.assertEqual(path, '/org/freedesktop/DBus/TestSuitePythonObject') # we're using the "early binding" form of get_object (without # follow_name_owner_changes), so the destination we actually sent it # to will be the unique name - self.assert_(destination.startswith(':')) - self.assertEquals(message_cls, 'dbus.lowlevel.MethodCallMessage') + self.assertTrue(destination.startswith(':')) + self.assertEqual(message_cls, 'dbus.lowlevel.MethodCallMessage') def testUtf8StringsSync(self): - send_val = u'foo' + if is_py3: + return + send_val = 'foo' recv_val = self.iface.Echo(send_val, utf8_strings=True) - self.assert_(isinstance(recv_val, str)) - self.assert_(isinstance(recv_val, dbus.UTF8String)) + self.assertTrue(isinstance(recv_val, str)) + self.assertTrue(isinstance(recv_val, dbus.UTF8String)) recv_val = self.iface.Echo(send_val, utf8_strings=False) - self.assert_(isinstance(recv_val, unicode)) - self.assert_(isinstance(recv_val, dbus.String)) + self.assertTrue(isinstance(recv_val, unicode)) + self.assertTrue(isinstance(recv_val, dbus.String)) def testBenchmarkIntrospect(self): - print "\n********* Benchmark Introspect ************" + print("\n********* Benchmark Introspect ************") a = time.time() - print a - print self.iface.GetComplexArray() + print(a) + print(self.iface.GetComplexArray()) b = time.time() - print b - print "Delta: %f" % (b - a) - self.assert_(True) + print(b) + print("Delta: %f" % (b - a)) + self.assertTrue(True) def testAsyncCalls(self): #test sending python types and getting them back async - print "\n********* Testing Async Calls ***********" + print("\n********* Testing Async Calls ***********") failures = [] main_loop = gobject.MainLoop() class async_check: - def __init__(self, test_controler, expected_result, do_exit, utf8): + def __init__(self, test_controler, expected_result, do_exit, **kwargs): self.expected_result = expected_result self.do_exit = do_exit - self.utf8 = utf8 self.test_controler = test_controler + if is_py2: + self.utf8 = kwargs['utf8'] + elif 'utf8' in kwargs: + raise TypeError("unexpected keyword argument 'utf8'") def callback(self, val): try: if self.do_exit: main_loop.quit() - self.test_controler.assertEquals(val, self.expected_result) - self.test_controler.assertEquals(val.variant_level, 1) - if self.utf8 and not isinstance(val, dbus.UTF8String): - failures.append('%r should have been utf8 but was not' % val) - return - elif not self.utf8 and isinstance(val, dbus.UTF8String): - failures.append('%r should not have been utf8' % val) - return - except Exception, e: + self.test_controler.assertEqual(val, self.expected_result) + self.test_controler.assertEqual(val.variant_level, 1) + if is_py2: + if self.utf8 and not isinstance(val, dbus.UTF8String): + failures.append('%r should have been utf8 but was not' % val) + return + elif not self.utf8 and isinstance(val, dbus.UTF8String): + failures.append('%r should not have been utf8' % val) + return + except Exception as e: failures.append("%s:\n%s" % (e.__class__, e)) def error_handler(self, error): - print error + print(error) if self.do_exit: main_loop.quit() @@ -211,20 +228,24 @@ last_type = test_types_vals[-1] for send_val in test_types_vals: - print "Testing %s" % str(send_val) - utf8 = (send_val == 'gob@gob.com') + print("Testing %s" % str(send_val)) + kwargs = {} + if is_py2: + utf8 = (send_val == 'gob@gob.com') + kwargs['utf8'] = utf8 + kwargs['utf8_strings'] = utf8 check = async_check(self, send_val, last_type == send_val, - utf8) + **kwargs) recv_val = self.iface.Echo(send_val, reply_handler=check.callback, error_handler=check.error_handler, - utf8_strings=utf8) + **kwargs) main_loop.run() if failures: - self.assert_(False, failures) + self.assertTrue(False, failures) def testStrictMarshalling(self): - print "\n********* Testing strict return & signal marshalling ***********" + print("\n********* Testing strict return & signal marshalling ***********") # these values are the same as in the server, and the # methods should only succeed when they are called with @@ -233,82 +254,95 @@ # with a different number values = ["", ("",""), ("","",""), [], {}, ["",""], ["","",""]] methods = [ - (self.iface.ReturnOneString, 'SignalOneString', set([0]), set([0])), - (self.iface.ReturnTwoStrings, 'SignalTwoStrings', set([1, 5]), set([1])), - (self.iface.ReturnStruct, 'SignalStruct', set([1, 5]), set([1])), - # all of our test values are sequences so will marshall correctly into an array :P - (self.iface.ReturnArray, 'SignalArray', set(range(len(values))), set([3, 5, 6])), - (self.iface.ReturnDict, 'SignalDict', set([0, 3, 4]), set([4])) - ] + (self.iface.ReturnOneString, 'SignalOneString', set([0]), set([0])), + (self.iface.ReturnTwoStrings, 'SignalTwoStrings', set([1, 5]), set([1])), + (self.iface.ReturnStruct, 'SignalStruct', set([1, 5]), set([1])), + # all of our test values are sequences so will marshall correctly + # into an array :P + (self.iface.ReturnArray, 'SignalArray', set(range(len(values))), set([3, 5, 6])), + (self.iface.ReturnDict, 'SignalDict', set([0, 3, 4]), set([4])) + ] for (method, signal, success_values, return_values) in methods: - print "\nTrying correct behaviour of", method._method_name + print("\nTrying correct behaviour of", method._method_name) for value in range(len(values)): try: ret = method(value) - except Exception, e: - print "%s(%r) raised %s: %s" % (method._method_name, values[value], e.__class__, e) + except Exception as e: + print("%s(%r) raised %s: %s" % + (method._method_name, values[value], e.__class__, e)) # should fail if it tried to marshal the wrong type - self.assert_(value not in success_values, "%s should succeed when we ask it to return %r\n%s\n%s" % (method._method_name, values[value], e.__class__, e)) + self.assertTrue(value not in success_values, + "%s should succeed when we ask it to " + "return %r\n%s\n%s" % ( + method._method_name, values[value], + e.__class__, e)) else: - print "%s(%r) returned %r" % (method._method_name, values[value], ret) + print("%s(%r) returned %r" % ( + method._method_name, values[value], ret)) # should only succeed if it's the right return type - self.assert_(value in success_values, "%s should fail when we ask it to return %r" % (method._method_name, values[value])) + self.assertTrue(value in success_values, + "%s should fail when we ask it to " + "return %r" % ( + method._method_name, values[value])) # check the value is right too :D returns = map(lambda n: values[n], return_values) - self.assert_(ret in returns, "%s should return one of %r but it returned %r instead" % (method._method_name, returns, ret)) + self.assertTrue(ret in returns, + "%s should return one of %r but it " + "returned %r instead" % ( + method._method_name, returns, ret)) - print "\nTrying correct emission of", signal + print("\nTrying correct emission of", signal) for value in range(len(values)): try: self.iface.EmitSignal(signal, value) - except Exception, e: - print "EmitSignal(%s, %r) raised %s" % (signal, values[value], e.__class__) + except Exception as e: + print("EmitSignal(%s, %r) raised %s" % (signal, values[value], e.__class__)) # should fail if it tried to marshal the wrong type - self.assert_(value not in success_values, "EmitSignal(%s) should succeed when we ask it to return %r\n%s\n%s" % (signal, values[value], e.__class__, e)) + self.assertTrue(value not in success_values, "EmitSignal(%s) should succeed when we ask it to return %r\n%s\n%s" % (signal, values[value], e.__class__, e)) else: - print "EmitSignal(%s, %r) appeared to succeed" % (signal, values[value]) + print("EmitSignal(%s, %r) appeared to succeed" % (signal, values[value])) # should only succeed if it's the right return type - self.assert_(value in success_values, "EmitSignal(%s) should fail when we ask it to return %r" % (signal, values[value])) + self.assertTrue(value in success_values, "EmitSignal(%s) should fail when we ask it to return %r" % (signal, values[value])) # FIXME: wait for the signal here - print + print() def testInheritance(self): - print "\n********* Testing inheritance from dbus.method.Interface ***********" + print("\n********* Testing inheritance from dbus.method.Interface ***********") ret = self.iface.CheckInheritance() - print "CheckInheritance returned %s" % ret - self.assert_(ret, "overriding CheckInheritance from TestInterface failed") + print("CheckInheritance returned %s" % ret) + self.assertTrue(ret, "overriding CheckInheritance from TestInterface failed") def testAsyncMethods(self): - print "\n********* Testing asynchronous method implementation *******" + print("\n********* Testing asynchronous method implementation *******") for async in (True, False): for fail in (True, False): try: val = ('a', 1, False, [1,2], {1:2}) - print "calling AsynchronousMethod with %s %s %s" % (async, fail, val) + print("calling AsynchronousMethod with %s %s %s" % (async, fail, val)) ret = self.iface.AsynchronousMethod(async, fail, val) - except Exception, e: - self.assert_(fail, '%s: %s' % (e.__class__, e)) - print "Expected failure: %s: %s" % (e.__class__, e) + except Exception as e: + self.assertTrue(fail, '%s: %s' % (e.__class__, e)) + print("Expected failure: %s: %s" % (e.__class__, e)) else: - self.assert_(not fail, 'Expected failure but succeeded?!') - self.assertEquals(val, ret) - self.assertEquals(1, ret.variant_level) + self.assertTrue(not fail, 'Expected failure but succeeded?!') + self.assertEqual(val, ret) + self.assertEqual(1, ret.variant_level) def testBusInstanceCaching(self): - print "\n********* Testing dbus.Bus instance sharing *********" + print("\n********* Testing dbus.Bus instance sharing *********") # unfortunately we can't test the system bus here # but the codepaths are the same for (cls, type, func) in ((dbus.SessionBus, dbus.Bus.TYPE_SESSION, dbus.Bus.get_session), (dbus.StarterBus, dbus.Bus.TYPE_STARTER, dbus.Bus.get_starter)): - print "\nTesting %s:" % cls.__name__ + print("\nTesting %s:" % cls.__name__) share_cls = cls() share_type = dbus.Bus(bus_type=type) @@ -318,43 +352,43 @@ private_type = dbus.Bus(bus_type=type, private=True) private_func = func(private=True) - print " - checking shared instances are the same..." - self.assert_(share_cls == share_type, '%s should equal %s' % (share_cls, share_type)) - self.assert_(share_type == share_func, '%s should equal %s' % (share_type, share_func)) - - print " - checking private instances are distinct from the shared instance..." - self.assert_(share_cls != private_cls, '%s should not equal %s' % (share_cls, private_cls)) - self.assert_(share_type != private_type, '%s should not equal %s' % (share_type, private_type)) - self.assert_(share_func != private_func, '%s should not equal %s' % (share_func, private_func)) - - print " - checking private instances are distinct from each other..." - self.assert_(private_cls != private_type, '%s should not equal %s' % (private_cls, private_type)) - self.assert_(private_type != private_func, '%s should not equal %s' % (private_type, private_func)) - self.assert_(private_func != private_cls, '%s should not equal %s' % (private_func, private_cls)) + print(" - checking shared instances are the same...") + self.assertTrue(share_cls == share_type, '%s should equal %s' % (share_cls, share_type)) + self.assertTrue(share_type == share_func, '%s should equal %s' % (share_type, share_func)) + + print(" - checking private instances are distinct from the shared instance...") + self.assertTrue(share_cls != private_cls, '%s should not equal %s' % (share_cls, private_cls)) + self.assertTrue(share_type != private_type, '%s should not equal %s' % (share_type, private_type)) + self.assertTrue(share_func != private_func, '%s should not equal %s' % (share_func, private_func)) + + print(" - checking private instances are distinct from each other...") + self.assertTrue(private_cls != private_type, '%s should not equal %s' % (private_cls, private_type)) + self.assertTrue(private_type != private_func, '%s should not equal %s' % (private_type, private_func)) + self.assertTrue(private_func != private_cls, '%s should not equal %s' % (private_func, private_cls)) def testSenderName(self): - print '\n******** Testing sender name keyword ********' + print('\n******** Testing sender name keyword ********') myself = self.iface.WhoAmI() - print "I am", myself + print("I am", myself) def testBusGetNameOwner(self): ret = self.bus.get_name_owner(NAME) - self.assert_(ret.startswith(':'), ret) + self.assertTrue(ret.startswith(':'), ret) def testBusListNames(self): ret = self.bus.list_names() - self.assert_(NAME in ret, ret) + self.assertTrue(NAME in ret, ret) def testBusListActivatableNames(self): ret = self.bus.list_activatable_names() - self.assert_(NAME in ret, ret) + self.assertTrue(NAME in ret, ret) def testBusNameHasOwner(self): - self.assert_(self.bus.name_has_owner(NAME)) - self.assert_(not self.bus.name_has_owner('badger.mushroom.snake')) + self.assertTrue(self.bus.name_has_owner(NAME)) + self.assertTrue(not self.bus.name_has_owner('badger.mushroom.snake')) def testBusNameCreation(self): - print '\n******** Testing BusName creation ********' + print('\n******** Testing BusName creation ********') test = [('org.freedesktop.DBus.Python.TestName', True), ('org.freedesktop.DBus.Python.TestName', True), ('org.freedesktop.DBus.Python.InvalidName&^*%$', False)] @@ -369,92 +403,92 @@ names = {} for (name, succeed) in test: try: - print "requesting %s" % name + print("requesting %s" % name) busname = dbus.service.BusName(name, dbus.SessionBus()) - except Exception, e: - print "%s:\n%s" % (e.__class__, e) - self.assert_(not succeed, 'did not expect registering bus name %s to fail' % name) + except Exception as e: + print("%s:\n%s" % (e.__class__, e)) + self.assertTrue(not succeed, 'did not expect registering bus name %s to fail' % name) else: - print busname - self.assert_(succeed, 'expected registering bus name %s to fail'% name) + print(busname) + self.assertTrue(succeed, 'expected registering bus name %s to fail'% name) if name in names: - self.assert_(names[name] == busname, 'got a new instance for same name %s' % name) - print "instance of %s re-used, good!" % name + self.assertTrue(names[name] == busname, 'got a new instance for same name %s' % name) + print("instance of %s re-used, good!" % name) else: names[name] = busname del busname - print + print() del names bus = dbus.Bus() ret = bus.name_has_owner('org.freedesktop.DBus.Python.TestName') - self.assert_(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName') + self.assertTrue(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName') def testMultipleReturnWithoutSignature(self): # https://bugs.freedesktop.org/show_bug.cgi?id=10174 ret = self.iface.MultipleReturnWithoutSignature() - self.assert_(not isinstance(ret, dbus.Struct), repr(ret)) - self.assertEquals(ret, ('abc', 123)) + self.assertTrue(not isinstance(ret, dbus.Struct), repr(ret)) + self.assertEqual(ret, ('abc', 123)) def testListExportedChildObjects(self): - self.assert_(self.iface.TestListExportedChildObjects()) + self.assertTrue(self.iface.TestListExportedChildObjects()) def testRemoveFromConnection(self): # https://bugs.freedesktop.org/show_bug.cgi?id=10457 - self.assert_(not self.iface.HasRemovableObject()) - self.assert_(self.iface.AddRemovableObject()) - self.assert_(self.iface.HasRemovableObject()) + self.assertTrue(not self.iface.HasRemovableObject()) + self.assertTrue(self.iface.AddRemovableObject()) + self.assertTrue(self.iface.HasRemovableObject()) removable = self.bus.get_object(NAME, OBJECT + '/RemovableObject') iface = dbus.Interface(removable, IFACE) - self.assert_(iface.IsThere()) - self.assert_(iface.RemoveSelf()) + self.assertTrue(iface.IsThere()) + self.assertTrue(iface.RemoveSelf()) - self.assert_(not self.iface.HasRemovableObject()) + self.assertTrue(not self.iface.HasRemovableObject()) # and again... - self.assert_(self.iface.AddRemovableObject()) - self.assert_(self.iface.HasRemovableObject()) - self.assert_(iface.IsThere()) - self.assert_(iface.RemoveSelf()) - self.assert_(not self.iface.HasRemovableObject()) + self.assertTrue(self.iface.AddRemovableObject()) + self.assertTrue(self.iface.HasRemovableObject()) + self.assertTrue(iface.IsThere()) + self.assertTrue(iface.RemoveSelf()) + self.assertTrue(not self.iface.HasRemovableObject()) def testFallbackObjectTrivial(self): obj = self.bus.get_object(NAME, OBJECT + '/Fallback') iface = dbus.Interface(obj, IFACE) path, rel, unique_name = iface.TestPathAndConnKeywords() - self.assertEquals(path, OBJECT + '/Fallback') - self.assertEquals(rel, '/') - self.assertEquals(unique_name, obj.bus_name) + self.assertEqual(path, OBJECT + '/Fallback') + self.assertEqual(rel, '/') + self.assertEqual(unique_name, obj.bus_name) def testFallbackObjectNested(self): obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Nested') iface = dbus.Interface(obj, IFACE) path, rel, unique_name = iface.TestPathAndConnKeywords() - self.assertEquals(path, OBJECT + '/Fallback/Nested') - self.assertEquals(rel, '/') - self.assertEquals(unique_name, obj.bus_name) + self.assertEqual(path, OBJECT + '/Fallback/Nested') + self.assertEqual(rel, '/') + self.assertEqual(unique_name, obj.bus_name) obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Nested/Badger/Mushroom') iface = dbus.Interface(obj, IFACE) path, rel, unique_name = iface.TestPathAndConnKeywords() - self.assertEquals(path, OBJECT + '/Fallback/Nested/Badger/Mushroom') - self.assertEquals(rel, '/Badger/Mushroom') - self.assertEquals(unique_name, obj.bus_name) + self.assertEqual(path, OBJECT + '/Fallback/Nested/Badger/Mushroom') + self.assertEqual(rel, '/Badger/Mushroom') + self.assertEqual(unique_name, obj.bus_name) def testFallbackObject(self): obj = self.bus.get_object(NAME, OBJECT + '/Fallback/Badger/Mushroom') iface = dbus.Interface(obj, IFACE) path, rel, unique_name = iface.TestPathAndConnKeywords() - self.assertEquals(path, OBJECT + '/Fallback/Badger/Mushroom') - self.assertEquals(rel, '/Badger/Mushroom') - self.assertEquals(unique_name, obj.bus_name) + self.assertEqual(path, OBJECT + '/Fallback/Badger/Mushroom') + self.assertEqual(rel, '/Badger/Mushroom') + self.assertEqual(unique_name, obj.bus_name) def testTimeoutSync(self): - self.assert_(self.iface.BlockFor500ms(timeout=1.0) is None) + self.assertTrue(self.iface.BlockFor500ms(timeout=1.0) is None) self.assertRaises(dbus.DBusException, lambda: self.iface.BlockFor500ms(timeout=0.25)) @@ -462,12 +496,12 @@ self.assertRaises(dbus.DBusException, self.iface.AsyncRaise) try: self.iface.AsyncRaise() - except dbus.DBusException, e: - self.assert_(e.get_dbus_name() == + except dbus.DBusException as e: + self.assertTrue(e.get_dbus_name() == 'org.freedesktop.bugzilla.bug12403', e.get_dbus_name()) else: - self.assert_(False) + self.assertTrue(False) def testClosePrivateBus(self): # fd.o #12096 @@ -500,11 +534,11 @@ reply_handler=incorrectly_returned, error_handler=correctly_failed) loop.run() - self.assertEquals(passes, ['250', '1000']) - self.assertEquals(fails, []) + self.assertEqual(passes, ['250', '1000']) + self.assertEqual(fails, []) def testTimeoutAsyncService(self): - self.assert_(self.iface.AsyncWait500ms(timeout=1.0) is None) + self.assertTrue(self.iface.AsyncWait500ms(timeout=1.0) is None) self.assertRaises(dbus.DBusException, lambda: self.iface.AsyncWait500ms(timeout=0.25)) @@ -518,18 +552,18 @@ try: self.iface.RaiseValueError() - except Exception, e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assert_('.ValueError: Traceback ' in str(e), + except Exception as e: + self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) + self.assertTrue('.ValueError: Traceback ' in str(e), 'Wanted a traceback but got:\n"""%s"""' % str(e)) else: raise AssertionError('Wanted an exception') try: self.iface.RaiseDBusExceptionNoTraceback() - except Exception, e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assertEquals(str(e), + except Exception as e: + self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) + self.assertEqual(str(e), 'com.example.Networking.ServerError: ' 'Server not responding') else: @@ -537,9 +571,9 @@ try: self.iface.RaiseDBusExceptionWithTraceback() - except Exception, e: - self.assert_(isinstance(e, dbus.DBusException), e.__class__) - self.assert_(str(e).startswith('com.example.Misc.RealityFailure: ' + except Exception as e: + self.assertTrue(isinstance(e, dbus.DBusException), e.__class__) + self.assertTrue(str(e).startswith('com.example.Misc.RealityFailure: ' 'Traceback '), 'Wanted a traceback but got:\n%s' % str(e)) else: @@ -557,20 +591,20 @@ print "\n********* Introspection Test ************" print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") print "Introspection test passed" - self.assert_(True) + self.assertTrue(True) def testCalls(self): print "\n********* Call Test ************" result = self.iface.ManyArgs(1000, 'Hello GLib', 2) print result - self.assert_(result == [2002.0, 'HELLO GLIB']) + self.assertTrue(result == [2002.0, 'HELLO GLIB']) arg0 = {"Dude": 1, "john": "palmieri", "python": 2.4} result = self.iface.ManyStringify(arg0) print result print "Call test passed" - self.assert_(True) + self.assertTrue(True) def testPythonTypes(self): print "\n********* Testing Python Types ***********" @@ -578,7 +612,7 @@ for send_val in test_types_vals: print "Testing %s"% str(send_val) recv_val = self.iface.EchoVariant(send_val) - self.assertEquals(send_val, recv_val.object) + self.assertEqual(send_val, recv_val.object) """ if __name__ == '__main__': gobject.threads_init() diff -Nru dbus-python-0.84.0/test/test-p2p.py dbus-python-1.0.0/test/test-p2p.py --- dbus-python-0.84.0/test/test-p2p.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/test/test-p2p.py 2012-01-24 15:55:44.000000000 +0000 @@ -24,22 +24,20 @@ # DEALINGS IN THE SOFTWARE. -import sys import os import unittest -import time import logging -import weakref builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) import dbus -import _dbus_bindings -import gobject import dbus.glib import dbus.service +from dbus._compat import is_py2 +from gi.repository import GObject as gobject + logging.basicConfig() logging.getLogger().setLevel(1) @@ -58,33 +56,40 @@ # using dbus.bus.BusConnection! conn = dbus.connection.Connection( os.environ['DBUS_SESSION_BUS_ADDRESS']) + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True unique = conn.call_blocking('org.freedesktop.DBus', '/org/freedesktop/DBus', 'org.freedesktop.DBus', 'Hello', - '', (), utf8_strings=True) - self.assert_(unique.__class__ == dbus.UTF8String, repr(unique)) - self.assert_(unique.startswith(':'), unique) + '', (), **kwargs) + if is_py2: + self.assertTrue(unique.__class__ == dbus.UTF8String, repr(unique)) + self.assertTrue(unique.startswith(':'), unique) conn.set_unique_name(unique) return conn, unique def testCall(self): conn, unique = self.get_conn_and_unique() ret = conn.call_blocking(NAME, OBJECT, IFACE, 'Echo', 'v', ('V',)) - self.assertEquals(ret, 'V') + self.assertEqual(ret, 'V') def testCallThroughProxy(self): conn, unique = self.get_conn_and_unique() proxy = conn.get_object(NAME, OBJECT) iface = dbus.Interface(proxy, IFACE) ret = iface.Echo('V') - self.assertEquals(ret, 'V') + self.assertEqual(ret, 'V') def testSetUniqueName(self): conn, unique = self.get_conn_and_unique() + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True ret = conn.call_blocking(NAME, OBJECT, IFACE, 'MethodExtraInfoKeywords', '', (), - utf8_strings=True) - self.assertEquals(ret, (unique, OBJECT, NAME, + **kwargs) + self.assertEqual(ret, (unique, OBJECT, NAME, 'dbus.lowlevel.MethodCallMessage')) diff -Nru dbus-python-0.84.0/test/test-service.py dbus-python-1.0.0/test/test-service.py --- dbus-python-0.84.0/test/test-service.py 2010-12-02 15:08:29.000000000 +0000 +++ dbus-python-1.0.0/test/test-service.py 2012-01-24 15:55:44.000000000 +0000 @@ -23,7 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -import sys import os import logging from time import sleep @@ -38,17 +37,17 @@ import dbus.service import dbus.glib -import gobject import random from dbus.gobject_service import ExportedGObject +from gi.repository import GObject as gobject +from dbus._compat import is_py2, is_py3 -logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='w') +logging.basicConfig(filename=builddir + '/test/test-service.log', filemode='a') logging.getLogger().setLevel(1) logger = logging.getLogger('test-service') - NAME = "org.freedesktop.DBus.TestSuitePythonService" IFACE = "org.freedesktop.DBus.TestSuiteInterface" OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject" @@ -137,10 +136,14 @@ @dbus.service.method(IFACE, in_signature='s', out_signature='s') def AcceptUnicodeString(self, foo): - assert isinstance(foo, unicode), (foo, foo.__class__.__mro__) + unicode_type = (str if is_py3 else unicode) + assert isinstance(foo, unicode_type), (foo, foo.__class__.__mro__) return foo - @dbus.service.method(IFACE, in_signature='s', out_signature='s', utf8_strings=True) + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True + @dbus.service.method(IFACE, in_signature='s', out_signature='s', **kwargs) def AcceptUTF8String(self, foo): assert isinstance(foo, str), (foo, foo.__class__.__mro__) return foo @@ -158,9 +161,10 @@ assert isinstance(foo, list), (foo, foo.__class__.__mro__) return foo - @dbus.service.method(IFACE, in_signature='ay', out_signature='ay', byte_arrays=True) + @dbus.service.method(IFACE, in_signature='ay', out_signature='ay', + byte_arrays=True) def AcceptByteArray(self, foo): - assert isinstance(foo, str), (foo, foo.__class__.__mro__) + assert isinstance(foo, bytes), (foo, foo.__class__.__mro__) return foo @dbus.service.method(IFACE) @@ -254,11 +258,13 @@ assert objs_org == ['freedesktop'], objs_org return True - @dbus.service.method(IFACE, in_signature='bbv', out_signature='v', async_callbacks=('return_cb', 'error_cb')) + @dbus.service.method(IFACE, in_signature='bbv', out_signature='v', + async_callbacks=('return_cb', 'error_cb')) def AsynchronousMethod(self, async, fail, variant, return_cb, error_cb): try: if async: - gobject.timeout_add(500, self.AsynchronousMethod, False, fail, variant, return_cb, error_cb) + gobject.timeout_add(500, self.AsynchronousMethod, False, fail, + variant, return_cb, error_cb) return else: if fail: @@ -267,10 +273,11 @@ return_cb(variant) return False # do not run again - except Exception, e: + except Exception as e: error_cb(e) - @dbus.service.method(IFACE, in_signature='', out_signature='s', sender_keyword='sender') + @dbus.service.method(IFACE, in_signature='', out_signature='s', + sender_keyword='sender') def WhoAmI(self, sender): return sender @@ -335,10 +342,31 @@ raise_cb(Fdo12403Error()) -session_bus = dbus.SessionBus() -global_name = dbus.service.BusName(NAME, bus=session_bus) -object = TestObject(global_name) -g_object = TestGObject(global_name) -fallback_object = Fallback(session_bus) -loop = gobject.MainLoop() -loop.run() + +def main(): + global session_bus + logger.info('getting session bus') + session_bus = dbus.SessionBus() + logger.info('getting bus name %s', NAME) + global_name = dbus.service.BusName(NAME, bus=session_bus) + logger.info('making TestObject') + object = TestObject(global_name) + logger.info('making TestGObject') + g_object = TestGObject(global_name) + logger.info('making Fallback') + fallback_object = Fallback(session_bus) + logger.info('creating mainloop') + loop = gobject.MainLoop() + logger.info('running') + loop.run() + logger.info('done') + + +if __name__ == '__main__': + session_bus = None + try: + logger.info('entering main') + main() + except: + logger.exception('test-service main failure') + raise diff -Nru dbus-python-0.84.0/test/test-signals.py dbus-python-1.0.0/test/test-signals.py --- dbus-python-0.84.0/test/test-signals.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/test/test-signals.py 2012-01-24 15:55:44.000000000 +0000 @@ -34,9 +34,9 @@ import dbus import _dbus_bindings -import gobject import dbus.glib import dbus.service +from gi.repository import GObject as gobject logging.basicConfig() diff -Nru dbus-python-0.84.0/test/test-standalone.py dbus-python-1.0.0/test/test-standalone.py --- dbus-python-0.84.0/test/test-standalone.py 2010-11-23 19:14:43.000000000 +0000 +++ dbus-python-1.0.0/test/test-standalone.py 2012-01-24 15:55:44.000000000 +0000 @@ -26,18 +26,28 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import unicode_literals + import sys import os import unittest -import time -from traceback import print_exc builddir = os.path.normpath(os.environ["DBUS_TOP_BUILDDIR"]) pydir = os.path.normpath(os.environ["DBUS_TOP_SRCDIR"]) import _dbus_bindings import dbus +import dbus.lowlevel as lowlevel import dbus.types as types +from dbus._compat import is_py2, is_py3 + +if is_py3: + def make_long(n): + return n +else: + def make_long(n): + return long(n) + # Check that we're using the right versions if not dbus.__file__.startswith(pydir): @@ -57,87 +67,161 @@ class TestTypes(unittest.TestCase): def test_Dictionary(self): - self.assertEquals(types.Dictionary({'foo':'bar'}), {'foo':'bar'}) - self.assertEquals(types.Dictionary({}, variant_level=2), {}) - self.assertEquals(types.Dictionary({}, variant_level=2).variant_level, 2) + self.assertEqual(types.Dictionary({'foo':'bar'}), {'foo':'bar'}) + self.assertEqual(types.Dictionary({}, variant_level=2), {}) + self.assertEqual(types.Dictionary({}, variant_level=2).variant_level, 2) def test_Array(self): - self.assertEquals(types.Array(['foo','bar']), ['foo','bar']) - self.assertEquals(types.Array([], variant_level=2), []) - self.assertEquals(types.Array([], variant_level=2).variant_level, 2) + self.assertEqual(types.Array(['foo','bar']), ['foo','bar']) + self.assertEqual(types.Array([], variant_level=2), []) + self.assertEqual(types.Array([], variant_level=2).variant_level, 2) def test_Double(self): - self.assertEquals(types.Double(0.0), 0.0) - self.assertEquals(types.Double(0.125, variant_level=2), 0.125) - self.assertEquals(types.Double(0.125, variant_level=2).variant_level, 2) + 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) def test_Struct(self): x = types.Struct(('',)) - self.assertEquals(x.variant_level, 0) - self.assertEquals(x, ('',)) + self.assertEqual(x.variant_level, 0) + self.assertEqual(x, ('',)) x = types.Struct('abc', variant_level=42) - self.assertEquals(x.variant_level, 42) - self.assertEquals(x, ('a','b','c')) + self.assertEqual(x.variant_level, 42) + self.assertEqual(x, ('a','b','c')) def test_Byte(self): - self.assertEquals(types.Byte('x', variant_level=2), types.Byte(ord('x'))) + self.assertEqual(types.Byte(b'x', variant_level=2), + types.Byte(ord('x'))) + self.assertEqual(types.Byte(1), 1) + self.assertEqual(types.Byte(make_long(1)), 1) + self.assertRaises(Exception, lambda: types.Byte(b'ab')) + self.assertRaises(TypeError, types.Byte, '\x12xxxxxxxxxxxxx') + + # Byte from a unicode object: what would that even mean? + self.assertRaises(Exception, + lambda: types.Byte(b'a'.decode('latin-1'))) def test_ByteArray(self): - self.assertEquals(types.ByteArray(''), '') + self.assertEqual(types.ByteArray(b''), b'') def test_object_path_attr(self): class MyObject(object): __dbus_object_path__ = '/foo' from _dbus_bindings import SignalMessage - self.assertEquals(SignalMessage.guess_signature(MyObject()), 'o') + self.assertEqual(SignalMessage.guess_signature(MyObject()), 'o') def test_integers(self): + subclasses = [int] + if is_py2: + subclasses.append(long) + subclasses = tuple(subclasses) # This is an API guarantee. Note that exactly which of these types # are ints and which of them are longs is *not* guaranteed. for cls in (types.Int16, types.UInt16, types.Int32, types.UInt32, types.Int64, types.UInt64): - self.assert_(issubclass(cls, (int, long))) - self.assert_(isinstance(cls(0), (int, long))) - self.assertEquals(cls(0), 0) - self.assertEquals(cls(23, variant_level=1), 23) - self.assertEquals(cls(23, variant_level=1).variant_level, 1) + self.assertTrue(issubclass(cls, subclasses)) + self.assertTrue(isinstance(cls(0), subclasses)) + self.assertEqual(cls(0), 0) + self.assertEqual(cls(23, variant_level=1), 23) + self.assertEqual(cls(23, variant_level=1).variant_level, 1) def test_integer_limits_16(self): - self.assertEquals(types.Int16(0x7fff), 0x7fff) - self.assertEquals(types.Int16(-0x8000), -0x8000) - self.assertEquals(types.UInt16(0xffff), 0xffff) + self.assertEqual(types.Int16(0x7fff), 0x7fff) + self.assertEqual(types.Int16(-0x8000), -0x8000) + self.assertEqual(types.UInt16(0xffff), 0xffff) self.assertRaises(Exception, types.Int16, 0x8000) self.assertRaises(Exception, types.Int16, -0x8001) self.assertRaises(Exception, types.UInt16, 0x10000) def test_integer_limits_32(self): - self.assertEquals(types.Int32(0x7fffffff), 0x7fffffff) - self.assertEquals(types.Int32(-0x80000000L), -0x80000000L) - self.assertEquals(types.UInt32(0xffffffffL), 0xffffffffL) - self.assertRaises(Exception, types.Int32, 0x80000000L) - self.assertRaises(Exception, types.Int32, -0x80000001L) - self.assertRaises(Exception, types.UInt32, 0x100000000L) + self.assertEqual(types.Int32(0x7fffffff), 0x7fffffff) + self.assertEqual(types.Int32(make_long(-0x80000000)), + make_long(-0x80000000)) + self.assertEqual(types.UInt32(make_long(0xffffffff)), + make_long(0xffffffff)) + self.assertRaises(Exception, types.Int32, make_long(0x80000000)) + self.assertRaises(Exception, types.Int32, make_long(-0x80000001)) + self.assertRaises(Exception, types.UInt32, make_long(0x100000000)) def test_integer_limits_64(self): - self.assertEquals(types.Int64(0x7fffffffffffffffL), 0x7fffffffffffffffL) - self.assertEquals(types.Int64(-0x8000000000000000L), -0x8000000000000000L) - self.assertEquals(types.UInt64(0xffffffffffffffffL), 0xffffffffffffffffL) - self.assertRaises(Exception, types.Int16, 0x8000000000000000L) - self.assertRaises(Exception, types.Int16, -0x8000000000000001L) - self.assertRaises(Exception, types.UInt16, 0x10000000000000000L) + self.assertEqual(types.Int64(make_long(0x7fffffffffffffff)), + make_long(0x7fffffffffffffff)) + self.assertEqual(types.Int64(make_long(-0x8000000000000000)), + make_long(-0x8000000000000000)) + self.assertEqual(types.UInt64(make_long(0xffffffffffffffff)), + make_long(0xffffffffffffffff)) + self.assertRaises(Exception, types.Int16, + make_long(0x8000000000000000)) + self.assertRaises(Exception, types.Int16, + make_long(-0x8000000000000001)) + self.assertRaises(Exception, types.UInt16, + make_long(0x10000000000000000)) def test_Signature(self): self.assertRaises(Exception, types.Signature, 'a') - self.assertEquals(types.Signature('ab', variant_level=23), 'ab') - self.assert_(isinstance(types.Signature('ab'), str)) - self.assertEquals(tuple(types.Signature('ab(xt)a{sv}')), - ('ab', '(xt)', 'a{sv}')) - self.assert_(isinstance(tuple(types.Signature('ab'))[0], - types.Signature)) + self.assertEqual(types.Signature('ab', variant_level=23), 'ab') + self.assertTrue(isinstance(types.Signature('ab'), str)) + self.assertEqual(tuple(types.Signature('ab(xt)a{sv}')), + ('ab', '(xt)', 'a{sv}')) + self.assertTrue(isinstance(tuple(types.Signature('ab'))[0], + types.Signature)) class TestMessageMarshalling(unittest.TestCase): + def test_path(self): + s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') + self.assertEqual(s.get_path(), types.ObjectPath('/a/b/c')) + self.assertEqual(type(s.get_path()), types.ObjectPath) + self.assertEqual(s.get_path_decomposed(), ['a', 'b', 'c']) + # this is true in both major versions: it's a bytestring in + # Python 2 and a Unicode string in Python 3 + self.assertEqual(type(s.get_path_decomposed()[0]), str) + self.assertTrue(s.has_path('/a/b/c')) + self.assertFalse(s.has_path('/a/b')) + self.assertFalse(s.has_path('/a/b/c/d')) + + s = lowlevel.SignalMessage('/', 'foo.bar', 'baz') + self.assertEqual(s.get_path(), types.ObjectPath('/')) + self.assertEqual(s.get_path().__class__, types.ObjectPath) + self.assertEqual(s.get_path_decomposed(), []) + self.assertTrue(s.has_path('/')) + self.assertFalse(s.has_path(None)) + + def test_sender(self): + s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') + self.assertEqual(s.get_sender(), None) + self.assertFalse(s.has_sender(':1.23')) + s.set_sender(':1.23') + self.assertEqual(s.get_sender(), ':1.23') + # bytestring in Python 2, Unicode string in Python 3 + self.assertEqual(type(s.get_sender()), str) + self.assertTrue(s.has_sender(':1.23')) + + def test_destination(self): + s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') + self.assertEqual(s.get_destination(), None) + self.assertFalse(s.has_destination(':1.23')) + s.set_destination(':1.23') + self.assertEqual(s.get_destination(), ':1.23') + # bytestring in Python 2, Unicode string in Python 3 + self.assertEqual(type(s.get_destination()), str) + self.assertTrue(s.has_destination(':1.23')) + + def test_interface(self): + s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') + self.assertEqual(s.get_interface(), 'foo.bar') + # bytestring in Python 2, Unicode string in Python 3 + self.assertEqual(type(s.get_interface()), str) + self.assertTrue(s.has_interface('foo.bar')) + + def test_member(self): + s = lowlevel.SignalMessage('/a/b/c', 'foo.bar', 'baz') + self.assertEqual(s.get_member(), 'baz') + # bytestring in Python 2, Unicode string in Python 3 + self.assertEqual(type(s.get_member()), str) + self.assertTrue(s.has_member('baz')) + def test_count(self): from _dbus_bindings import SignalMessage s = SignalMessage('/', 'foo.bar', 'baz') @@ -158,7 +242,7 @@ 'should fail') def test_append(self): - aeq = self.assertEquals + aeq = self.assertEqual from _dbus_bindings import SignalMessage s = SignalMessage('/', 'foo.bar', 'baz') s.append([types.Byte(1)], signature='ay') @@ -169,28 +253,49 @@ s.append([], signature='ay') aeq(s.get_args_list(), [[]]) + def test_append_Byte(self): + aeq = self.assertEqual + from _dbus_bindings import SignalMessage + + s = SignalMessage('/', 'foo.bar', 'baz') + s.append(0xFE, signature='y') + aeq(s.get_args_list(), [types.Byte(0xFE)]) + + s = SignalMessage('/', 'foo.bar', 'baz') + s.append(b'\xfe', signature='y') + aeq(s.get_args_list(), [types.Byte(0xFE)]) + + # appending a unicode object (including str in Python 3) + # is not allowed + s = SignalMessage('/', 'foo.bar', 'baz') + self.assertRaises(Exception, + lambda: s.append('a'.decode('latin-1'), signature='y')) + + s = SignalMessage('/', 'foo.bar', 'baz') + self.assertRaises(Exception, + lambda: s.append(b'ab', signature='y')) + def test_append_ByteArray(self): - aeq = self.assertEquals + aeq = self.assertEqual from _dbus_bindings import SignalMessage s = SignalMessage('/', 'foo.bar', 'baz') - s.append(types.ByteArray('ab'), signature='ay') - aeq(s.get_args_list(), [[types.Byte('a'), types.Byte('b')]]) + s.append(types.ByteArray(b'ab'), signature='ay') + aeq(s.get_args_list(), [[types.Byte(b'a'), types.Byte(b'b')]]) s = SignalMessage('/', 'foo.bar', 'baz') - s.append(types.ByteArray('ab'), signature='av') - aeq(s.get_args_list(), [[types.Byte('a'), types.Byte('b')]]) + s.append(types.ByteArray(b'ab'), signature='av') + aeq(s.get_args_list(), [[types.Byte(b'a'), types.Byte(b'b')]]) s = SignalMessage('/', 'foo.bar', 'baz') - s.append(types.ByteArray(''), signature='ay') + s.append(types.ByteArray(b''), signature='ay') aeq(s.get_args_list(), [[]]) - aeq(s.get_args_list(byte_arrays=True), [types.ByteArray('')]) + aeq(s.get_args_list(byte_arrays=True), [types.ByteArray(b'')]) def test_append_Variant(self): - a = self.assert_ - aeq = self.assertEquals + aeq = self.assertEqual from _dbus_bindings import SignalMessage s = SignalMessage('/', 'foo.bar', 'baz') s.append(types.Int32(1, variant_level=0), types.String('a', variant_level=42), - types.Array([types.Byte('a', variant_level=1), + types.Array([types.Byte(b'a', variant_level=1), types.UInt32(123, variant_level=1)], signature='v'), signature='vvv') @@ -205,7 +310,7 @@ aeq(args[2].signature, 'v') def test_guess_signature(self): - aeq = self.assertEquals + aeq = self.assertEqual from _dbus_bindings import Message aeq(Message.guess_signature(('a','b')), '(ss)') aeq(Message.guess_signature('a','b'), 'ss') @@ -213,13 +318,20 @@ aeq(Message.guess_signature(('a',)), '(s)') aeq(Message.guess_signature('abc'), 's') aeq(Message.guess_signature(types.Int32(123)), 'i') - aeq(Message.guess_signature(types.ByteArray('abc')), 'ay') + aeq(Message.guess_signature(types.ByteArray(b'abc')), 'ay') aeq(Message.guess_signature(('a',)), '(s)') aeq(Message.guess_signature(['a']), 'as') aeq(Message.guess_signature({'a':'b'}), 'a{ss}') + def test_guess_signature_python_ints(self): + aeq = self.assertEqual + from _dbus_bindings import Message + aeq(Message.guess_signature(7), 'i') + if is_py2: + aeq(Message.guess_signature(make_long(7)), 'x') + def test_guess_signature_dbus_types(self): - aeq = self.assertEquals + aeq = self.assertEqual from _dbus_bindings import Message gs = Message.guess_signature aeq(gs(types.Dictionary({'a':'b'})), 'a{ss}') @@ -229,12 +341,14 @@ aeq(gs(types.Array([types.Int32(1)], signature='u')), 'au') def test_get_args_options(self): - aeq = self.assertEquals + aeq = self.assertEqual s = _dbus_bindings.SignalMessage('/', 'foo.bar', 'baz') - s.append('b', 'bytes', -1, 1, 'str', 'var', signature='yayiusv') - aeq(s.get_args_list(), [ord('b'), - [ord('b'),ord('y'),ord('t'),ord('e'), ord('s')], - -1, 1, u'str', u'var']) + s.append(b'b', b'bytes', -1, 1, 'str', 'var', signature='yayiusv') + aeq(s.get_args_list(), [ + ord('b'), + [ord('b'),ord('y'),ord('t'),ord('e'), ord('s')], + -1, 1, 'str', 'var' + ]) byte, bytes, int32, uint32, string, variant = s.get_args_list() aeq(byte.__class__, types.Byte) aeq(bytes.__class__, types.Array) @@ -250,24 +364,32 @@ byte_arrays=True) aeq(byte.__class__, types.Byte) aeq(bytes.__class__, types.ByteArray) - aeq(bytes, 'bytes') - aeq(bytes[0].__class__, str) + aeq(bytes, b'bytes') + if is_py3: + aeq(bytes[0].__class__, int) + else: + aeq(bytes[0].__class__, str) aeq(int32.__class__, types.Int32) aeq(uint32.__class__, types.UInt32) aeq(string.__class__, types.String) aeq(variant.__class__, types.String) aeq(variant.variant_level, 1) + kwargs = {} + if is_py2: + kwargs['utf8_strings'] = True byte, bytes, int32, uint32, string, variant = s.get_args_list( - utf8_strings=True) + **kwargs) aeq(byte.__class__, types.Byte) aeq(bytes.__class__, types.Array) aeq(bytes[0].__class__, types.Byte) aeq(int32.__class__, types.Int32) aeq(uint32.__class__, types.UInt32) - aeq(string.__class__, types.UTF8String) + if is_py2: + aeq(string.__class__, types.UTF8String) aeq(string, 'str') - aeq(variant.__class__, types.UTF8String) + if is_py2: + aeq(variant.__class__, types.UTF8String) aeq(variant.variant_level, 1) aeq(variant, 'var') @@ -278,7 +400,7 @@ s = SignalMessage('/', 'foo.bar', 'baz') s.append(MyObject(), signature='o') s.append(MyObject()) - self.assertEquals(s.get_args_list(), ['/foo', '/foo']) + self.assertEqual(s.get_args_list(), ['/foo', '/foo']) def test_struct(self): from _dbus_bindings import SignalMessage @@ -300,5 +422,28 @@ 'should fail') +class TestMatching(unittest.TestCase): + def setUp(self): + from _dbus_bindings import SignalMessage + from dbus.connection import SignalMatch + self._message = SignalMessage('/', 'a.b', 'c') + class FakeConn(object): pass + def ignore_cb(*args, **kws): pass + self._match = SignalMatch(FakeConn(), None, '/', None, None, + ignore_cb, arg0='/') + + def test_string_match(self): + self._message.append('/', signature='s') + self.assertTrue(self._match.maybe_handle_message(self._message)) + + def test_object_path_no_match(self): + self._message.append('/', signature='o') + self.assertFalse(self._match.maybe_handle_message(self._message)) + + if __name__ == '__main__': - unittest.main() + # Python 2.6 doesn't accept a `verbosity` keyword. + kwargs = {} + if sys.version_info[:2] >= (2, 7): + kwargs['verbosity'] = 2 + unittest.main(**kwargs) diff -Nru dbus-python-0.84.0/test/test-unusable-main-loop.py dbus-python-1.0.0/test/test-unusable-main-loop.py --- dbus-python-0.84.0/test/test-unusable-main-loop.py 2008-11-28 15:50:03.000000000 +0000 +++ dbus-python-1.0.0/test/test-unusable-main-loop.py 2012-01-24 15:55:44.000000000 +0000 @@ -22,6 +22,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from __future__ import print_function import dbus from dbus_py_test import UnusableMainLoop @@ -30,8 +31,8 @@ UnusableMainLoop(set_as_default=True) try: bus = dbus.SessionBus() - except ValueError, e: - print "Correctly got ValueError from UnusableMainLoop" + except ValueError as e: + print("Correctly got ValueError from UnusableMainLoop") else: raise AssertionError("Expected ValueError from UnusableMainLoop") diff -Nru dbus-python-0.84.0/tools/Makefile.in dbus-python-1.0.0/tools/Makefile.in --- dbus-python-0.84.0/tools/Makefile.in 2011-05-25 11:50:04.000000000 +0000 +++ dbus-python-1.0.0/tools/Makefile.in 2012-01-24 16:37:31.000000000 +0000 @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -295,10 +295,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: