[Python-checkins] cpython (3.5): #27522: break unintended cycle in feedparser.
r.david.murray
python-checkins at python.org
Fri Jul 15 21:30:32 EDT 2016
https://hg.python.org/cpython/rev/6c7fd035bce3
changeset: 102366:6c7fd035bce3
branch: 3.5
parent: 102364:8be87fde577f
user: R David Murray <rdmurray at bitdance.com>
date: Fri Jul 15 21:29:13 2016 -0400
summary:
#27522: break unintended cycle in feedparser.
Patch by Costas.
files:
Lib/email/feedparser.py | 9 ++++++---
Misc/NEWS | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -145,7 +145,7 @@
"""
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 @@
_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 @@
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:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,8 @@
Library
-------
+- Issue #27522: Avoid an unintentional reference cycle in email.feedparser.
+
- Issue #26844: Fix error message for imp.find_module() to refer to 'path'
instead of 'name'. Patch by Lev Maximov.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list