question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cgi.escape was removed in Python 3.8

See original GitHub issue

I just stumbled across this grepping for cgi.escape . I am not sure Tempita is public and documented for usage but found a usage causing AttributeError. cgi.escape was removed in Python 3.8 with https://github.com/python/cpython/pull/7662 . Usage of html.escape is recommended.

https://github.com/cython/cython/blob/6e72d84f43fc8f8da4ddc7695ac9f5b434788ef5/Cython/Tempita/_tempita.py#L444

Python 3.8.0 (default, Nov  6 2019, 21:49:08) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Cython.Tempita
>>> Cython.Tempita.HTMLTemplate("a")._repr(1, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Cython/Tempita/_tempita.py", line 489, in Cython.Tempita._tempita.HTMLTemplate._repr
  File "Cython/Tempita/_tempita.py", line 446, in Cython.Tempita._tempita.html_quote
AttributeError: module 'cgi' has no attribute 'escape'

Thanks for Cython!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
scodercommented, Nov 7, 2022

+1 for removing the obviously broken HTML parts. If users employ Tempita on their side, it’s for source code generation, not HTML. There are much better tools for the latter.

0reactions
da-woodscommented, Nov 7, 2022

The background is that Tempita was originally a generic templating tool. It was incorporated into Cython to use for templating Cython’s utility code, but obviously contains quote a bit of stale code from its original general use.

My view would be to just remove html_quote and the stuff that depends on it. We’ll quite rapidly find out if it breaks any of Cython’s utility code generation (its primary use) since that is covered by the the test-suite.

A few projects (Pandas, Scipy) do use Tempita from Cython to do some code-generation of Cython code. This is also a use-case that we’re keen to support better, so possibly we possibly shouldn’t be too brutal removing everything that’s unused. I still think it’s reasonable to remove these html bits that have been broken for years.


With that said, I’m happy to do the removal myself if you’d rather someone else gets the blame for it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

cgi.escape is deprecated since python 3.2 and not ... - GitLab
escape is deprecated since python 3.2 and not available on python 3.8. All threads resolved!
Read more >
salt: cgi.escape() has been removed in python 3.8
escape has been deprecated since python 3.2 and removed in 3.8. + +Index: salt/returners/highstate_return.py +--- salt/returners/ ...
Read more >
ImportError: cannot import name 'escape' from 'cgi'
cgi.escape() has been removed in python 3.8. Quoting from here,. parse_qs, parse_qsl, and escape are removed from the cgi module.
Read more >
1827745 – Python 3.8: module 'cgi' has no attribute 'escape'
Description of problem: urlwatch uses cgi.escape which was deprecated in Python 3.7 and removed in 3.8. A possible alternative is html.escape.
Read more >
AttributeError: module 'cgi' has no attribute 'escape' in Python ...
The problem is the function cgi.escape in https://gitlab.com/inorton/junit2html/-/blob/master/junit2htmlreport/tag.py#L17 which is removed in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found