diff options
author | R David Murray <rdmurray@bitdance.com> | 2016-07-16 01:29:13 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2016-07-16 01:29:13 (GMT) |
commit | 702b0460d20fa699c1c703e00bcc93243e3020a1 (patch) | |
tree | a7aa7c18edb7de68d63db0c59a5ff56b74634593 /Lib/email | |
parent | 9305bba203747d7176baa1a216ac59d8705eadab (diff) | |
download | cpython-702b0460d20fa699c1c703e00bcc93243e3020a1.zip cpython-702b0460d20fa699c1c703e00bcc93243e3020a1.tar.gz cpython-702b0460d20fa699c1c703e00bcc93243e3020a1.tar.bz2 |
#27522: break unintended cycle in feedparser.
Patch by Costas.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/feedparser.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py index e2e3e96..c542018 100644 --- a/Lib/email/feedparser.py +++ b/Lib/email/feedparser.py @@ -145,7 +145,7 @@ class FeedParser: """ self.policy = policy - self._factory_kwds = lambda: {'policy': self.policy} + self._old_style_factory = False if _factory is None: # What this should be: #self._factory = policy.default_message_factory @@ -160,7 +160,7 @@ class FeedParser: _factory(policy=self.policy) except TypeError: # Assume this is an old-style factory - self._factory_kwds = lambda: {} + self._old_style_factory = True self._input = BufferedSubFile() self._msgstack = [] self._parse = self._parsegen().__next__ @@ -197,7 +197,10 @@ class FeedParser: return root def _new_message(self): - msg = self._factory(**self._factory_kwds()) + if self._old_style_factory: + msg = self._factory() + else: + msg = self._factory(policy=self.policy) if self._cur and self._cur.get_content_type() == 'multipart/digest': msg.set_default_type('message/rfc822') if self._msgstack: |