mwilliamson / python-mammoth

Convert Word documents (.docx files) to HTML
BSD 2-Clause "Simplified" License
811 stars 121 forks source link

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

Closed messense closed 5 years ago

messense commented 6 years ago
/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 commented 6 years ago

Thanks for the suggestion. A couple of thoughts:

messense commented 6 years ago

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

taleinat commented 5 years ago

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

taleinat commented 5 years ago

Also, why not:


try:
    from html import escape as html_escape
except ImportError:
    from cgi import escape as html_escape
mwilliamson commented 5 years ago

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