On Mon, Jun 25, 2012 at 10:39:48PM -0700, Toshio Kuratomi wrote:
* 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)
This is correct. Can anyone comment on what python versions
python-bugzilla is required to support? EPEL6 is on python-2.6 now.
* New dependency on python-six
Correct.
* There are places that str(foo) is used that haven't been
converted to
a six.XXX() method. These might fail in some circumstances.
I took on the remainder of these in one of the new patches listed below.
* 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.
Nice catch! I fixed to_encoding so it always returns byte strings now.
* 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.
I went through all the uses of it and couldn't find anywhere where byte or
unicode strings are implicitly coerced. I checked the fields in query
results and in every case I tested, they were unicode strings (thus
making it all consistent). unicode-nazi only complained about some stuff in
stdlib.
* 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))
Done! (The *original* loop modified the dict during iteration;
illegal in Python 3).
Here's my list of updated patches (including a rename of my original).
I kept them separated out instead of rebasing just to preserve
history and make them easier to cherry-pick.
http://threebean.org/patches/python-bugzilla/0001-Python3-support.patch
http://threebean.org/patches/python-bugzilla/0002-Replace-str-foo-with-si...
http://threebean.org/patches/python-bugzilla/0003-Rewrite-two-loops-as-on...
http://threebean.org/patches/python-bugzilla/0004-Regression-fix.patch
http://threebean.org/patches/python-bugzilla/0005-Always-return-bytestrin...
-Ralph