summaryrefslogtreecommitdiff
path: root/Lib/email/feedparser.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-10 00:22:25 -0400
committerR David Murray <rdmurray@bitdance.com>2016-09-10 00:22:25 -0400
commitb067c8fdd1e205bd0411417b6d5e4b832c3773fc (patch)
tree1bd428963f46ae7cec4bceedfc9c3a049ce3102e /Lib/email/feedparser.py
parentc7454ff5fcd8d216495990df7db11be73e273a33 (diff)
downloadcpython-git-b067c8fdd1e205bd0411417b6d5e4b832c3773fc.tar.gz
#20476: Deal with the message_factory circular import differently.
It turns out we can't depend on email.message getting imported every place message_factory is needed, so to avoid a circular import we need to special case Policy.message_factory=None in the parser instead of using monkey patching. I had a feeling that was a bad idea when I did it.
Diffstat (limited to 'Lib/email/feedparser.py')
-rw-r--r--Lib/email/feedparser.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
index 3d74978cdb..7c07ca8645 100644
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -147,7 +147,11 @@ class FeedParser:
self.policy = policy
self._old_style_factory = False
if _factory is None:
- self._factory = policy.message_factory
+ if policy.message_factory is None:
+ from email.message import Message
+ self._factory = Message
+ else:
+ self._factory = policy.message_factory
else:
self._factory = _factory
try: