On Tue, Jun 26, 2012 at 12:32:38AM -0400, Ralph Bean wrote:
Hello all,
I created a patch to update python-bugzilla to work on both python 2
and python 3. The unit tests all pass under both py2.7 and py3.2.
I have tested the login and query commands by hand on py2.6, py2.7,
and py3.2.
http://threebean.org/patches/python-bugzilla-Python3-support.patch
The patch is against the master branch (7ca8a60). If I should
recreate it against another branch, please let me know.
I'm also willing to update and maintain a spec file supporting both
versions if and when that time comes.
Dependency notes (and note, these are just notes -- I don't know if the
project has defintions of what is acceptable)
* Needs python-2.6 or greater (as python-2.5 doesn't have from __future__
import print_function, the new format of "except Foo as bar:", and
relative imports)
* New dependency on python-six
* There are places that str(foo) is used that haven't been converted to
a six.XXX() method. These might fail in some circumstances.
* Note: the to_encoding() function looks to handle edge cases wrong. This
would become more apparent in python3 than in python2. It looks like it's
intended to take a unicode string or a byte string and return a byte
string. However, if the parameter passed in is neither a unicode nor
a byte string, it will return an empty unicode string. This will likely
trigger tracebacks in python3 where bytes and unicode cannot be combined
implictly.
* Note2: Some of the lines that use to_encoding() look like they can still
throw exceptions. they look like they can mix unicode and bytes in some
circumstances. Running with python-unicodenazi installed and enabled (see
that package's documentation) might find some of these cases.
* This might better be rewritten:
to_remove = [k for k in query.keys() if query[k] is None]
for key in to_remove:
del query[key]
as this:
query = dict(((k, v) for k, v in six.iteritems(query) if v is not None))
which condenses two loops into one (Note that the generator expression there
can be made into a list comprehension if compatibility with older python's
is desired).
-Toshio