diff roundup/cgi/exceptions.py @ 5800:1a835db41674

Call cgi.escape only on python 2. Replace with html.escapeif it can be found.
author John Rouillard <rouilj@ieee.org>
date Tue, 11 Jun 2019 21:29:24 -0400
parents 07abc8d36940
children 883c9e90b403
line wrap: on
line diff
--- a/roundup/cgi/exceptions.py	Tue Jun 11 21:05:53 2019 -0400
+++ b/roundup/cgi/exceptions.py	Tue Jun 11 21:29:24 2019 -0400
@@ -4,7 +4,11 @@
 __docformat__ = 'restructuredtext'
 
 from roundup.exceptions import LoginError, Unauthorised
-import cgi
+
+try:
+    from html import escape as html_escape  # python 3
+except ImportError:
+    from cgi import escape as html_escape   # python 2 fallback
 
 class HTTPException(BaseException):
     pass
@@ -62,6 +66,6 @@
 <body class="body" marginwidth="0" marginheight="0">
  <p class="error-message">%s</p>
 </body></html>
-"""%cgi.escape(self.args[0])
+"""%html_escape(self.args[0])
 
 # vim: set filetype=python sts=4 sw=4 et si :

Roundup Issue Tracker: http://roundup-tracker.org/