From 0155778868cbd4b38d35a14686f5f6de66f73e43 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 20 Jun 2018 21:14:51 +0000 Subject: [PATCH 60/64] Python 3 preparation: avoid string.split(). --- frontends/roundup.cgi | 8 ++++---- roundup/cgi/apache.py | 2 +- roundup/cgi/cgitb.py | 2 +- roundup/mailgw.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontends/roundup.cgi b/frontends/roundup.cgi index 2c72756..6bfb77e 100755 --- a/frontends/roundup.cgi +++ b/frontends/roundup.cgi @@ -86,7 +86,7 @@ except: # Check environment for config items # def checkconfig(): - import os, string + import os global TRACKER_HOMES, LOG # see if there's an environment var. ROUNDUP_INSTANCE_HOMES is the @@ -97,9 +97,9 @@ def checkconfig(): homes = os.environ.get('TRACKER_HOMES', '') if homes: TRACKER_HOMES = {} - for home in string.split(homes, os.pathsep): + for home in homes.split(os.pathsep): try: - name, dir = string.split(home, '=', 1) + name, dir = home.split('=', 1) except ValueError: # ignore invalid definitions continue @@ -142,7 +142,7 @@ class RequestWrapper: def main(out, err): import os, string import roundup.instance - path = string.split(os.environ.get('PATH_INFO', '/'), '/') + path = os.environ.get('PATH_INFO', '/').split('/') request = RequestWrapper(out) request.path = os.environ.get('PATH_INFO', '/') tracker = path[1] diff --git a/roundup/cgi/apache.py b/roundup/cgi/apache.py index 2d2f1b0..9cf5dd5 100644 --- a/roundup/cgi/apache.py +++ b/roundup/cgi/apache.py @@ -122,7 +122,7 @@ def handler(req): req.add_common_vars() _env = dict(req.subprocess_env) # XXX classname must be the first item in PATH_INFO. roundup.cgi does: - # path = string.split(os.environ.get('PATH_INFO', '/'), '/') + # path = os.environ.get('PATH_INFO', '/').split('/') # os.environ['PATH_INFO'] = string.join(path[2:], '/') # we just remove the first character ('/') _env["PATH_INFO"] = req.path_info[1:] diff --git a/roundup/cgi/cgitb.py b/roundup/cgi/cgitb.py index 58b3fd0..e65bd90 100644 --- a/roundup/cgi/cgitb.py +++ b/roundup/cgi/cgitb.py @@ -112,7 +112,7 @@ def html(context=5, i18n=None): etype, evalue = sys.exc_info()[0], sys.exc_info()[1] if type(etype) is type: etype = etype.__name__ - pyver = 'Python ' + string.split(sys.version)[0] + '
' + sys.executable + pyver = 'Python ' + sys.version.split()[0] + '
' + sys.executable head = pydoc.html.heading( _('%(exc_type)s: %(exc_value)s') % {'exc_type': etype, 'exc_value': evalue}, diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 00e0048..4bc072d 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -95,7 +95,7 @@ explanatory message given in the exception. from __future__ import print_function __docformat__ = 'restructuredtext' -import string, re, os, mimetools, smtplib, socket, binascii, quopri +import re, os, mimetools, smtplib, socket, binascii, quopri import time, random, sys, logging import codecs import traceback @@ -1555,7 +1555,7 @@ class MailGW: except MailUsageHelp: # bounce the message back to the sender with the usage message self.logger.debug("MailUsageHelp raised, bouncing.") - fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) + fulldoc = '\n'.join(__doc__.split('\n')[2:]) m = [''] m.append('\n\nMail Gateway Help\n=================') m.append(fulldoc) @@ -1564,7 +1564,7 @@ class MailGW: except MailUsageError as value: # bounce the message back to the sender with the usage message self.logger.debug("MailUsageError raised, bouncing.") - fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) + fulldoc = '\n'.join(__doc__.split('\n')[2:]) m = [''] m.append(str(value)) m.append('\n\nMail Gateway Help\n=================') @@ -1719,7 +1719,7 @@ def setPropArrayFromString(self, cl, propString, nodeid=None): ''' props = {} errors = [] - for prop in string.split(propString, ';'): + for prop in propString.split(';'): # extract the property name and value try: propname, value = prop.split('=') -- 2.7.4