Comment 79 for bug 893091

Revision history for this message
In , Simon McVittie (smcv) wrote :

(In reply to comment #70)
> Please re-review. The revisions should be small enough and incremental enough
> (with just the last few actually adding Python 3 support) to make it not as
> painful as last time. ;)

The "add Python 3 support" commit was still too big, but never mind.

I've pushed a python3 branch based on yours to the official dbus-python repository; please review/test. I believe it's about ready for merging, and it passes tests on Python 2.6, 2.7, 3.2 under Debian sid. Changes made, relative to your branch:

(In reply to comment #69)
> The semantic question is more interesting though. Just what should it mean to
> append a byte signature with a unicode object?

I concluded that the answer is "nothing", and disallowed Byte('A') in the Python 3 world too. You now have to use Byte(ord('A')) or Byte(b'A') if that's what you want. (This is consistent with ByteArray.)

I also moved the Python 2 API back to how it used to be:

* things that used to return str (other than __str__/__repr__) are back
  to returning str, not unicode, via NATIVESTR_FROMSTR

* things that used to return int (in particular, variant levels) still
  return int, not long, via a new NATIVEINT_FROMLONG

so we won't break existing Python 2 code. In Python 3, those methods return long or unicode, of course.

I also added an INTORLONG_CHECK macro so we don't keep repeating "is it a long (or in Python 2, an int)?" #ifdefs.