def run_cgi(self):
"""Execute a CGI script."""
dir, rest = self.cgi_info
- i = string.rfind(rest, '?')
+ i = rest.rfind('?')
if i >= 0:
rest, query = rest[:i], rest[i+1:]
else:
query = ''
- i = string.find(rest, '/')
+ i = rest.find('/')
if i >= 0:
script, rest = rest[:i], rest[i:]
else:
accept = []
for line in self.headers.getallmatchingheaders('accept'):
if line[:1] in string.whitespace:
- accept.append(string.strip(line))
+ accept.append(line.strip())
else:
- accept = accept + string.split(line[7:], ',')
- env['HTTP_ACCEPT'] = string.joinfields(accept, ',')
+ accept = accept + line[7:].split(',')
+ env['HTTP_ACCEPT'] = ','.join(accept)
ua = self.headers.getheader('user-agent')
if ua:
env['HTTP_USER_AGENT'] = ua
co = filter(None, self.headers.getheaders('cookie'))
if co:
- env['HTTP_COOKIE'] = string.join(co, ', ')
+ env['HTTP_COOKIE'] = ', '.join(co)
# XXX Other HTTP_* headers
if not self.have_fork:
# Since we're setting the env in the parent, provide empty
self.send_response(200, "Script output follows")
- decoded_query = string.replace(query, '+', ' ')
+ decoded_query = query.replace('+', ' ')
if self.have_fork:
# Unix -- fork as we should
"""Utility to compile possibly incomplete Python source code."""
import sys
-import string
import traceback
__all__ = ["compile_command"]
"""
# Check for source consisting of only blank lines and comments
- for line in string.split(source, "\n"):
- line = string.strip(line)
+ for line in source.split("\n"):
+ line = line.strip()
if line and line[0] != '#':
break # Leave it alone
else:
try:
codeobject = __builtin__.compile(codestring, dfile or file, 'exec')
except SyntaxError, detail:
- import traceback, sys, string
+ import traceback, sys
lines = traceback.format_exception_only(SyntaxError, detail)
for line in lines:
- sys.stderr.write(string.replace(line, 'File "<string>"',
+ sys.stderr.write(line.replace('File "<string>"',
'File "%s"' % (dfile or file)))
return
if not cfile:
"""Redo the `...` (representation) but with limits on most sizes."""
-import string
-
class Repr:
def __init__(self):
self.maxlevel = 6
def repr1(self, x, level):
typename = `type(x)`[7:-2] # "<type '......'>"
if ' ' in typename:
- parts = string.split(typename)
- typename = string.joinfields(parts, '_')
+ parts = typename.split()
+ typename = '_'.join(parts)
if hasattr(self, 'repr_' + typename):
return getattr(self, 'repr_' + typename)(x, level)
else: