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

Use xml.sax.saxutils.escape instead of deprecated cgi.escape #67

Merged
merged 1 commit into from Oct 31, 2019
Merged

Use xml.sax.saxutils.escape instead of deprecated cgi.escape #67

merged 1 commit into from Oct 31, 2019

Conversation

messense
Copy link
Contributor

@messense messense commented Sep 7, 2018

/usr/local/lib/python3.6/dist-packages/mammoth/writers/html.py:34: DeprecationWarning: cgi.escape is deprecated, use html.escape instead
  return cgi.escape(text, quote=True)

Ref: Escaping HTML on Python wiki.

@mwilliamson
Copy link
Owner

Thanks for the suggestion. A couple of thoughts:

  • This introduces an inconsistency between Python 2 and 3 due to the different handling of single quotes
  • Importing on every function call rather than on module load seems unnecessary

@messense messense changed the title Use html.escape instead of deprecated cgi.escape when possible Use xml.sax.saxutils.escape instead of deprecated cgi.escape when possible Sep 10, 2018
@messense
Copy link
Contributor Author

Changed to use xml.sax.saxutils.escape instead of html.escape since it exists on both Python 2 & 3.

@messense messense changed the title Use xml.sax.saxutils.escape instead of deprecated cgi.escape when possible Use xml.sax.saxutils.escape instead of deprecated cgi.escape Sep 10, 2018
```
/usr/local/lib/python3.6/dist-packages/mammoth/writers/html.py:34: DeprecationWarning: cgi.escape is deprecated, use html.escape instead
  return cgi.escape(text, quote=True)
```
@taleinat
Copy link

Note that in Python 3.8 cgi.escape has been removed, so fixing this is required to support 3.8.

@taleinat
Copy link

taleinat commented Oct 31, 2019

Also, why not:

try:
    from html import escape as html_escape
except ImportError:
    from cgi import escape as html_escape

@mwilliamson mwilliamson merged commit 1599d4e into mwilliamson:master Oct 31, 2019
@mwilliamson
Copy link
Owner

Python 3.8 support should be fixed in the latest version. Thanks for the pull request!

@messense messense deleted the patch-1 branch October 31, 2019 11:13
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

Successfully merging this pull request may close these issues.

None yet

3 participants