#1885 Remove usage deprecated cgi function
Closed 4 years ago by tkopecek. Opened 4 years ago by mbelluzzo.
mbelluzzo/koji python-3.8  into  master

@@ -1,5 +1,5 @@ 

  #encoding UTF-8

- #import cgi

+ #import html

  #import koji

  #from kojiweb import util

  #from koji_cli.lib import greetings
@@ -51,7 +51,7 @@ 

                #end if

              </select>

              #try

-                 #set $old_terms = cgi.escape($terms)

+                 #set $old_terms = html.escape($terms)

              #except

                  #set $old_terms = ""

              #end try

file modified
+2 -2
@@ -1,4 +1,4 @@ 

- #import cgi

+ #import html

  #from kojiweb import util

  #from six.moves.urllib.parse import quote

  
@@ -14,7 +14,7 @@ 

          #end if

          <th>Search</th>

          #try

-             #set $old_terms = cgi.escape($terms)

+             #set $old_terms = html.escape($terms)

          #except

              #set $old_terms = ""

          #end try

@@ -1,7 +1,6 @@ 

  #import koji

  #from kojiweb import util

  #from six.moves.urllib.parse import quote

- #import cgi

  #import time

  

  #def printValue($key, $value, $sep=', ')

file modified
+3 -3
@@ -21,9 +21,9 @@ 

  #       Mike McLean <mikem@redhat.com>

  from __future__ import absolute_import, division

  

- import cgi

  import datetime

  import hashlib

+ import html

  import os

  import ssl

  import stat
@@ -669,7 +669,7 @@ 

          else:

              text = self.text[:length]

          if self.need_escape:

-             text = cgi.escape(text)

+             text = html.escape(text)

          if self.size > 0 and text == '':

              text = self.empty_str_placeholder

          return '%s%s%s' % (self.begin_tag, text, self.end_tag)
@@ -725,7 +725,7 @@ 

                  size += fragment.size

  

          if self.need_escape:

-             line_text = cgi.escape(line_text)

+             line_text = html.escape(line_text)

  

          return '%s%s%s%s' % (self.begin_tag, line_text, postscript, self.end_tag)

  

Changes should work for most of Python3.X versions out there and should cause no change on behaviour, but those changes are required to have koji properly working with Python3.8 since in there the function is actually gone.

does the html.escape() method exist in Python 2? I don't think it does...

Hmm .. don't think so. But Python2 itself is to be EOLed by end of this month.

How is that being handled by this project?

Py 2.7 doesn't even have html module in system lib.

Anyway, it seems, that we've escapeHTML in utils, which does exactly what cgi.escape does, so we can replace them.

pretty please pagure-ci rebuild

4 years ago

Pull-Request has been closed by tkopecek

4 years ago