BugList should return a set of int, not string

Bug #123933 reported by Martin Pitt on 2007-07-04
2
Affects Status Importance Assigned to Milestone
Bug Helper
Undecided
Unassigned
python-launchpad-bugs
Medium
Unassigned
python-launchpad-bugs (Ubuntu)
Undecided
Markus Korn

Bug Description

Binary package hint: python-launchpad-bugs

In the apport crash digger I do some set operations with BugList results, and I just disbelievingly observed that one set grows like this:

  set([94694, 103275, 111139]) + set([94694, 103275, 111139]) == set([103275, 111139, 111139, 94694, 103275, 94694])

and so on, yielding an endlessly growing set with duplicates of the original three bug numbers.

This is because BugList returns a set of strings, not a set of ints, and apparently set collapsing uses object identity instead of object equivalence. So, for ints, 1 is 1, but for strings, "1" is not "1".

I worked around this in apport now by converting the set of strings into a set of ints. But this could bite other users, too, so I recommend to return a set of integers right away.

Markus Korn (thekorn) wrote :

Hello Martin,
thanks for your bug report.
The problem is that each element of these sets are BugInfo-objects not strings or integers. So I'm afraid we can't fix it in the current branch without bigger changes, or do you know a nice solution for this?

I think I can easily fix this in api.changes.gsoc, will commit a patch to this branch soon.

Markus

Changed in python-launchpad-bugs:
importance: Undecided → Medium
status: New → Confirmed
Markus Korn (thekorn) wrote :

Note: We should think about the 'upstream' option in bughelper!

Martin Pitt (pitti) wrote :

Ah, I see, that explains a lot, of course. so int(x) with x being a member of the BugList return set, works through some magic. :)

I filed this bug mainly for the api.changes.gsoc branch, no need to change the current production branch (main).

Markus Korn (thekorn) wrote :

To avoid parsing bug pages twice when using the 'upstream' option and to fix this issue we should commit this patch to 'main'.

Example:
bl1 = BugList(_Struct(url = 'https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs', upstream = None, tag=None, minbug = None, filterbug = None, status = '', importance = '', closed_bugs=None, duplicates = None, lastcomment = None)).bugs

bl2 = BugList(_Struct(url = 'https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs', upstream = None, tag=None, minbug = None, filterbug = None, status = '', importance = '', closed_bugs=None, duplicates = None, lastcomment = None)).bugs

print bl1
#set([88521, 88102])

print bl2
#set([88521, 88102])

print bl1 | bl2
#set([88521, 88102])

This is basically the solution from 'api.changes.gsoc'

Markus

Markus Korn (thekorn) wrote :

------------------------------------------------------------
revno: 24
committer: Markus Korn <email address hidden>
branch nick: main
timestamp: Wed 2007-07-04 20:31:30 +0200
message:
  added __hash__() and __eq__() to BugInfo class to fix bug 123933

Changed in python-launchpad-bugs:
assignee: nobody → thekorn
status: New → Fix Committed
status: Confirmed → Fix Released
Daniel Holbach (dholbach) wrote :

python-launchpad-bugs (0.2~r35) gutsy; urgency=low

  * Bug fix: BugList should return a set of int, not string (LP: #123933)

 -- Daniel Holbach <email address hidden> Thu, 05 Jul 2007 13:42:55 +0200

Changed in python-launchpad-bugs:
status: Fix Committed → Fix Released
Markus Korn (thekorn) wrote :

closed the Bug Helper task as invalid, will try to explain the problem for bughelper in a new bugreport soon

Markus

Changed in bughelper:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers