vilcans / screenplain

Write your screenplay in plain text and run it through this program to make it look good
MIT License
163 stars 29 forks source link

Fix Python 3/3.8 compatibility #56

Closed jstasiak closed 4 years ago

jstasiak commented 4 years ago

Full error:

% screenplain Big-Fish.fountain Big-Fish.html
Traceback (most recent call last):
  File "/Users/user/.ve38/bin/screenplain", line 6, in <module>
    main(sys.argv[1:])
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/main.py", line 125, in main
    convert(
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 183, in convert
    convert_full(
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 210, in convert_full
    convert_bare(screenplay, out)
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 225, in convert_bare
    formatter.convert(screenplay)
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 99, in convert
    format_function(para)
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 153, in format_action
    self.out.write(to_html(line))
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/export/html.py", line 60, in to_html
    html = text.to_html()
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/richstring.py", line 62, in to_html
    html = ''.join(seg.to_html() for seg in self.segments)
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/richstring.py", line 62, in <genexpr>
    html = ''.join(seg.to_html() for seg in self.segments)
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/richstring.py", line 136, in to_html
    _escape(self.text),
  File "/Users/user/.ve38/lib/python3.8/site-packages/screenplain/richstring.py", line 17, in _escape
    encoded = cgi.escape(s).encode('ascii', 'xmlcharrefreplace')
AttributeError: module 'cgi' has no attribute 'escape'

cgi.escape() is gone in Python 3.8, html.escape() should be used instead. Since html.escape() defaults to quote=True, we need to explicitly disable escaping quotation marks to keep doing the same thing. A question arises though – should quotation marks be actually kept verbatim here or was it unintentional?

jstasiak commented 4 years ago

The Python 3.3 CI failure is not related to this patch I believe.