bpo-30011: Fixed race condition in HTMLParser.unescape(). (#1140)
diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py
index 3f97830..fb9380e 100644
--- a/Lib/HTMLParser.py
+++ b/Lib/HTMLParser.py
@@ -462,11 +462,12 @@
else:
# Cannot use name2codepoint directly, because HTMLParser supports apos,
# which is not part of HTML 4
- import htmlentitydefs
if HTMLParser.entitydefs is None:
- entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
+ import htmlentitydefs
+ entitydefs = {'apos':u"'"}
for k, v in htmlentitydefs.name2codepoint.iteritems():
entitydefs[k] = unichr(v)
+ HTMLParser.entitydefs = entitydefs
try:
return self.entitydefs[s]
except KeyError:
diff --git a/Misc/NEWS b/Misc/NEWS
index 5f1b64b..a090820 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -42,6 +42,8 @@
Library
-------
+- bpo-30011: Fixed race condition in HTMLParser.unescape().
+
- bpo-30068: _io._IOBase.readlines will check if it's closed first when
hint is present.