Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize.py fails with Python 3.8 #313

Closed
downthomas opened this issue Nov 28, 2019 · 1 comment
Closed

normalize.py fails with Python 3.8 #313

downthomas opened this issue Nov 28, 2019 · 1 comment

Comments

@downthomas
Copy link

normalize.py fails with Python 3.8 as cgi.escape has been removed.

2/5 Testing: html_normalization
2/5 Test: html_normalization
Command: "/usr/local/bin/python3" "-m" "doctest" "/Volumes/RAMDisk/cmark-0.29.0/test/normalize.py"
Directory: /Volumes/RAMDisk/cmark-0.29.0/build/testdir
"html_normalization" start time: Nov 27 20:04 EST
Output:
----------------------------------------------------------
**********************************************************************
File "/Volumes/RAMDisk/cmark-0.29.0/test/normalize.py", line 169, in normalize.normalize_html
Failed example:
    normalize_html('<a title="bar" HREF="foo">x</a>')
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/doctest.py", line 1328, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest normalize.normalize_html[8]>", line 1, in <module>
        normalize_html('<a title="bar" HREF="foo">x</a>')
      File "/Volumes/RAMDisk/cmark-0.29.0/test/normalize.py", line 189, in normalize_html
        parser.feed(chunk.group(0))
      File "/usr/local/lib/python3.8/html/parser.py", line 111, in feed
        self.goahead(0)
      File "/usr/local/lib/python3.8/html/parser.py", line 171, in goahead
        k = self.parse_starttag(i)
      File "/usr/local/lib/python3.8/html/parser.py", line 345, in parse_starttag
        self.handle_starttag(tag, attrs)
      File "/Volumes/RAMDisk/cmark-0.29.0/test/normalize.py", line 69, in handle_starttag
        self.output += ("=" + '"' + cgi.escape(v,quote=True) + '"')
    AttributeError: module 'cgi' has no attribute 'escape'
**********************************************************************
1 items had failures:
   1 of  10 in normalize.normalize_html

Adding import html and replacing cgi.escape with html.escape fixed this. html.escape was added in Python 3.2 so it should be available for most now.

2/5 Test: html_normalization
Command: "/usr/local/bin/python3" "-m" "doctest" "/Volumes/RAMDisk/cmark-0.29.0/test/normalize.py"
Directory: /Volumes/RAMDisk/cmark-0.29.0/build/testdir
"html_normalization" start time: Nov 27 22:29 EST
Output:
----------------------------------------------------------
<end of output>
Test time =   0.13 sec
----------------------------------------------------------
Test Passed.

@jgm jgm closed this as completed in 68c3a91 Nov 28, 2019
@jgm
Copy link
Member

jgm commented Nov 28, 2019

thanks!

drexin pushed a commit to drexin/swift-cmark that referenced this issue May 8, 2020
tkremenek pushed a commit to swiftlang/swift-cmark that referenced this issue May 8, 2020
QuietMisdreavus pushed a commit to swiftlang/swift-cmark that referenced this issue Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants