Commit 349c4396 authored by R David Murray's avatar R David Murray

#27522: break unintended cycle in feedparser.

Patch by Costas.
parent 439066e1
...@@ -145,7 +145,7 @@ class FeedParser: ...@@ -145,7 +145,7 @@ class FeedParser:
""" """
self.policy = policy self.policy = policy
self._factory_kwds = lambda: {'policy': self.policy} self._old_style_factory = False
if _factory is None: if _factory is None:
# What this should be: # What this should be:
#self._factory = policy.default_message_factory #self._factory = policy.default_message_factory
...@@ -160,7 +160,7 @@ class FeedParser: ...@@ -160,7 +160,7 @@ class FeedParser:
_factory(policy=self.policy) _factory(policy=self.policy)
except TypeError: except TypeError:
# Assume this is an old-style factory # Assume this is an old-style factory
self._factory_kwds = lambda: {} self._old_style_factory = True
self._input = BufferedSubFile() self._input = BufferedSubFile()
self._msgstack = [] self._msgstack = []
self._parse = self._parsegen().__next__ self._parse = self._parsegen().__next__
...@@ -197,7 +197,10 @@ class FeedParser: ...@@ -197,7 +197,10 @@ class FeedParser:
return root return root
def _new_message(self): 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': if self._cur and self._cur.get_content_type() == 'multipart/digest':
msg.set_default_type('message/rfc822') msg.set_default_type('message/rfc822')
if self._msgstack: if self._msgstack:
......
...@@ -24,6 +24,8 @@ Core and Builtins ...@@ -24,6 +24,8 @@ Core and Builtins
Library Library
------- -------
- Issue #27522: Avoid an unintentional reference cycle in email.feedparser.
- Issue #26844: Fix error message for imp.find_module() to refer to 'path' - Issue #26844: Fix error message for imp.find_module() to refer to 'path'
instead of 'name'. Patch by Lev Maximov. instead of 'name'. Patch by Lev Maximov.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment