I don't think that this is a duplicate. The code does
if attachments is None: attachments = set() if isinstance(attachments, LPAttachment): self.__attachments = set([attachments]) else: if not any(map(lambda x: isinstance(x, LPAttachment), attachments)): raise ValueError, "Unsupported attachment-type '%s'" %type(attachments) self.__attachments = set(attachments)
I. e. if attachments is the empty set (if none was given), then any(empty set) is false, and thus the exception is raised.
I did a quick fix:
if attachments and not any(map(lambda x: isinstance(x, LPAttachment), attachments)):
but the if/else clauses should be restructured. On hindsight, it would probably be better to write
if attachment is None: ... elif isinstance(attachments, LPAttachment): ... else ... # check set items
I don't think that this is a duplicate. The code does
if attachments is None:
attachment s = set() attachments, LPAttachment):
self. __attachments = set([attachments])
raise ValueError, "Unsupported attachment-type '%s'" %type(attachments)
self. __attachments = set(attachments)
if isinstance(
else:
if not any(map(lambda x: isinstance(x, LPAttachment), attachments)):
I. e. if attachments is the empty set (if none was given), then any(empty set) is false, and thus the exception is raised.
I did a quick fix:
if attachments and not any(map(lambda x: isinstance(x, LPAttachment), attachments)):
but the if/else clauses should be restructured. On hindsight, it would probably be better to write
if attachment is None: attachments, LPAttachment):
...
elif isinstance(
...
else
... # check set items