diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-15 15:35:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-15 15:35:46 (GMT) |
commit | 50f948edda0e6465e194ecc50b85fa2646039b8d (patch) | |
tree | fc337eff2d5d63301543cb5bd38e8944c9e46484 /Lib/HTMLParser.py | |
parent | 5fbdfc36f397ad46f4057d527855dfacb77242ce (diff) | |
download | cpython-50f948edda0e6465e194ecc50b85fa2646039b8d.zip cpython-50f948edda0e6465e194ecc50b85fa2646039b8d.tar.gz cpython-50f948edda0e6465e194ecc50b85fa2646039b8d.tar.bz2 |
bpo-30011: Fixed race condition in HTMLParser.unescape(). (#1140)
Diffstat (limited to 'Lib/HTMLParser.py')
-rw-r--r-- | Lib/HTMLParser.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 @@ class HTMLParser(markupbase.ParserBase): 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: |