Skip to content

Commit 50f948e

Browse files
bpo-30011: Fixed race condition in HTMLParser.unescape(). (python#1140)
1 parent 5fbdfc3 commit 50f948e

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/HTMLParser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,12 @@ def replaceEntities(s):
462462
else:
463463
# Cannot use name2codepoint directly, because HTMLParser supports apos,
464464
# which is not part of HTML 4
465-
import htmlentitydefs
466465
if HTMLParser.entitydefs is None:
467-
entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
466+
import htmlentitydefs
467+
entitydefs = {'apos':u"'"}
468468
for k, v in htmlentitydefs.name2codepoint.iteritems():
469469
entitydefs[k] = unichr(v)
470+
HTMLParser.entitydefs = entitydefs
470471
try:
471472
return self.entitydefs[s]
472473
except KeyError:

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Extension Modules
4242
Library
4343
-------
4444

45+
- bpo-30011: Fixed race condition in HTMLParser.unescape().
46+
4547
- bpo-30068: _io._IOBase.readlines will check if it's closed first when
4648
hint is present.
4749

0 commit comments

Comments
 (0)