feed: Don't pop from extra_headers while iterating over it
authorW. Trevor King <wking@tremily.us>
Wed, 25 Feb 2015 18:07:34 +0000 (10:07 -0800)
committerW. Trevor King <wking@tremily.us>
Wed, 25 Feb 2015 18:07:34 +0000 (10:07 -0800)
commit60870d9ff7f23441919df79d710ad49ecbcedf73
tree2769c4b12456a23a25e90367700ab975a128b07c
parentd3d9538a99a380f126a7d959aac590826ae28eca
feed: Don't pop from extra_headers while iterating over it

Avoid:

  Traceback (most recent call last):
    ...
      for k,v in extra_headers.items():
    File "/.../Python-3.5.0a1/Lib/_collections_abc.py", line 503, in __iter__
      for key in self._mapping:
    File "/.../Python-3.5.0a1/Lib/collections/__init__.py", line 112, in __iter__
      yield curr.key
  AttributeError: 'NoneType' object has no attribute 'key'

from continuing to iterate on items() after popping a key.  This
worked in Python 3.4 but no longer works in Python 3.5.  In any case,
mutating an object while iterating over it is always a bit
questionable, so rephrase to find the keys in one pass, and then
remove them after the iteration completes.

Reported-by: Raniere Silva <raniere@ime.unicamp.br>
Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/feed.py