``cgi.escape()`` is deprecated since Python 3.2. It is recommended to use ``html.escape()`` instead, which was only introduced in 3.2. For compatibility with previous versions it should be OK to use ``xml.sax.saxutils.escape()`` instead.