TypeError: argument 2 to map() must support iteration

Bug #192892 reported by Martin Pitt
2
Affects Status Importance Assigned to Milestone
python-launchpad-bugs (Ubuntu)
Fix Released
High
Markus Korn

Bug Description

Binary package hint: python-launchpad-bugs

The apport retracer just failed on bug #192452:

  File "/home/ubuntu-archive/apport-retracer-i386/bin/crash-digger", line 148, in run
    self.dupcheck_next()
  File "/home/ubuntu-archive/apport-retracer-i386/bin/crash-digger", line 129, in dupcheck_next
    res = self.crashdb.check_duplicate(id)
  File "/home/ubuntu-archive/apport-retracer-i386/apport/apport/crashdb.py", line 148, in check_duplicate
    self.mark_regression(id, ex_id)
  File "/home/ubuntu-archive/apport-retracer-i386/apport/apport/crashdb_impl/launchpad.py", line 307, in mark_regression
    in a dependent package.' % master)
  File "/home/ubuntu-archive/apport-retracer-i386/apport/launchpadbugs/connector.py", line 95, in NewComment
    return getattr(self.module, "Comment")(*args, **kwargs)
  File "/home/ubuntu-archive/apport-retracer-i386/apport/launchpadbugs/html_bug.py", line 673, in __init__
    LPComment.__init__(self, subject, text, attachments)
  File "/home/ubuntu-archive/apport-retracer-i386/apport/launchpadbugs/commentsbase.py", line 14, in __init__
    if not any(map(lambda x: isinstance(x, LPAttachment), attachments)):
TypeError: argument 2 to map() must support iteration

Revision history for this message
Apport retracing service (apport) wrote :

Affects bug #191065, too.

Revision history for this message
Apport retracing service (apport) wrote :

#192033, too. This is blocking retracers, raising priority.

Changed in python-launchpad-bugs:
importance: Undecided → High
Revision history for this message
Apport retracing service (apport) wrote :

The apport code does

        bug = Bug(id)
        comment = Bug.NewComment(subject='Possible regression detected',
            text='This crash has the same stack trace characteristics as bug #%i. \
However, the latter was already fixed in an earlier package version than the \
one in this report. This might be a regression or because the problem is \
in a dependent package.' % master)
        bug.comments.add(comment)
        bug.commit()

Is this wrong in any way?

Revision history for this message
Apport retracing service (apport) wrote :

Ah, I got it, I think:

    def __init__(self, subject=None, text=None, attachments=set()):

This usually does not what you want in Python. You should do "attachments=None" and explicitly check for None in the function body:

--- /home/ubuntu-archive/apport-retracer-i386/apport/launchpadbugs/commentsbase.py.orig 2008-02-18 12:26:38.000000000 +0000
+++ /home/ubuntu-archive/apport-retracer-i386/apport/launchpadbugs/commentsbase.py 2008-02-18 12:27:13.000000000 +0000
@@ -4,10 +4,11 @@

 class LPComment(object):
- def __init__(self, subject=None, text=None, attachments=set()):
+ def __init__(self, subject=None, text=None, attachments=None):
         self.subject = subject
         self.text = text
- self.__attachments = set()
+ if attachments is None:
+ attachments = set()
         if isinstance(attachments, LPAttachment):
             self.__attachments = set([attachments])
         else:

(This removes the redundant self.__attachments = set(), too, since it's assigned in both the then and else clause further down).

Changed in python-launchpad-bugs:
status: New → Confirmed
Revision history for this message
Apport retracing service (apport) wrote :
Revision history for this message
Markus Korn (thekorn) wrote :

thanks Martin for all your work,
the attached patch should fix this issue in py-lp-bugs.

I had no time to test it yet, but will do it later today.

Markus

Changed in python-launchpad-bugs:
assignee: nobody → thekorn
status: Confirmed → Fix Committed
Revision history for this message
Markus Korn (thekorn) wrote :

It's in .main!
------------------------------------------------------------
revno: 69
committer: Markus Korn <email address hidden>
branch nick: main
timestamp: Tue 2008-02-19 08:18:09 +0100
message:
  applied patch to fix Bug 192892: thanks Martin Pitt to track this down
------------------------------------------------------------

Revision history for this message
Daniel Holbach (dholbach) wrote :

Brian or Markus: will you prepare a new release with all the fixes?

Revision history for this message
Markus Korn (thekorn) wrote :

Good idea! - I can take it and work on a new release of py-lp-bugs and bughelper over the weekend

Markus

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-launchpad-bugs - 0.2.28

---------------
python-launchpad-bugs (0.2.28) hardy; urgency=low

  [ Markus Korn ]
  * created an examples/ directory and added some sample scripts
  * merged Martin Pitt's patch resolving a crash in bug attachment affecting
    the apport retracer (LP: #192892)

  [ Brian Murray ]
  * merged Markus's patch adding bzr branch attribute to a bug (LP: #196218)
  * added ability to filter on bugs with bzr branches to basebuglistfilter.py
  * to basebuglistfilter.py added URL filters for:
    - assignee, contact, commenter, subscriber, CVE (LP: #141388)

  [ Jamie Strandboge ]
  * handle firefox3 sqlite backend (LP: #192575) based on work by Kees Cook

 -- Brian Murray <email address hidden> Mon, 10 Mar 2008 15:12:56 -0700

Changed in python-launchpad-bugs:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.