[python-bugzilla] [PATCH 1/2] post_translation is called twice on query
Cole Robinson
crobinso at redhat.com
Mon Mar 25 20:14:51 UTC 2013
On 03/21/2013 02:25 PM, Don Zickus wrote:
> I have been fighting with python bugzilla 0.7.0 and 0.8.0 environments for
> awhile. Recently I noticed the rhbz_back_compat flag that would help unify
> them until everything is straightened out upstream.
>
> However, setting rhbz_back_compat to True caused my scripts which use 'flags'
> to fail. The reason is the bugzilla.query command.
>
> After querying for a list of bugs, they get post_translated and then returned
> to the query command. The query command the re-initializes the the bugs with a
> _Bug object which causes the post_translated bugs to be re-post_translated
> again. This causes a fault with the 'flags' attribute as it goes from a list to a
> string. :-(
>
> The flow is:
>
> bugzilla/base.py::query()
> self._query
> bugzilla/rhbugzilla.py::_query()
> self.post_translation()
> return [_Bug(...]
> bugzilla/bug.py::__init__
> self._update_dict()
> self.bugzilla.post_translation()
> ^^^^OOPS
>
Thanks for pointing this out. Indeed something is wrong here.
> I don't know the reason the post_translation moved to begin with, but I am just
> moving it back to where it was for now. This fixes my 'flags' issue.
>
The reason it was moved is that there are several other places where we
initialize a _Bug() but were never calling post_translation: getbug* and
createbug. I tried to stick it in a central place (_update_dict) so we would
get it for free everywhere. This should also be fixed by dropping the
post_translation call in rhbugzilla.py, done now:
http://git.fedorahosted.org/cgit/python-bugzilla.git/commit/?id=5217a0c91f2045febcf4d36c58d115849580bad6
However post_translation also should be safe to run multiple times, at least
to prevent this type of issue in the future. I fixed that up and added some
unittests to make sure it all works:
http://git.fedorahosted.org/cgit/python-bugzilla.git/commit/?id=5217a0c91f2045febcf4d36c58d115849580bad6
Please confirm that latest git fixes the original issue.
Thanks,
Cole
More information about the python-bugzilla
mailing list