Skip to content

Commit 1257936

Browse files
committed
fix(htmlparser): handle zipimporter without exec_module for embedded Python
1 parent e7a0efb commit 1257936

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

markdown/htmlparser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
# Users can still do `from html import parser` and get the default behavior.
4141
spec = importlib.util.find_spec('html.parser')
4242
htmlparser = importlib.util.module_from_spec(spec)
43-
spec.loader.exec_module(htmlparser)
43+
if hasattr(spec.loader, 'exec_module'):
44+
spec.loader.exec_module(htmlparser)
45+
else:
46+
import importlib
47+
htmlparser.__dict__.update(importlib.import_module('html.parser').__dict__)
4448
sys.modules['htmlparser'] = htmlparser
4549

4650
# This is a hack. We are sneaking in `</>` so we can capture it without the HTML parser

0 commit comments

Comments
 (0)