From 50f948edda0e6465e194ecc50b85fa2646039b8d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 15 Apr 2017 18:35:46 +0300 Subject: [PATCH] bpo-30011: Fixed race condition in HTMLParser.unescape(). (#1140) --- Lib/HTMLParser.py | 5 +++-- Misc/NEWS | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py index 3f97830a9a..fb9380e128 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: diff --git a/Misc/NEWS b/Misc/NEWS index 5f1b64bf76..a0908204ee 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -42,6 +42,8 @@ Extension Modules 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. -- 2.50.0