Use string.replace instead of regsub.[g]sub.
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
index 85e1721..b40edbc 100644
--- a/Lib/CGIHTTPServer.py
+++ b/Lib/CGIHTTPServer.py
@@ -148,8 +148,7 @@
if ua:
env['HTTP_USER_AGENT'] = ua
# XXX Other HTTP_* headers
- import regsub
- decoded_query = regsub.gsub('+', ' ', query)
+ decoded_query = string.replace(query, '+', ' ')
try:
os.setuid(nobody)
except os.error:
diff --git a/Lib/binhex.py b/Lib/binhex.py
index 7c22c4e..4693443 100644
--- a/Lib/binhex.py
+++ b/Lib/binhex.py
@@ -76,7 +76,6 @@
#
# Glue code for non-macintosh useage
#
- import regsub
class FInfo:
def __init__(self):
@@ -99,7 +98,7 @@
dsize = fp.tell()
fp.close()
dir, file = os.path.split(name)
- file = regsub.sub(':', '-', file)
+ file = string.replace(file, ':', '-', 1)
return file, finfo, dsize, 0
class openrsrc:
diff --git a/Lib/cgi.py b/Lib/cgi.py
index fb3076c..e4cb217 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -420,7 +420,6 @@
import sys
import os
import urllib
-import regsub
import mimetools
import rfc822
from StringIO import StringIO
@@ -564,8 +563,8 @@
if strict_parsing:
raise ValueError, "bad query field: %s" % `name_value`
continue
- name = urllib.unquote(regsub.gsub('+', ' ', nv[0]))
- value = urllib.unquote(regsub.gsub('+', ' ', nv[1]))
+ name = urllib.unquote(string.replace(nv[0], '+', ' '))
+ value = urllib.unquote(string.replace(nv[1], '+', ' '))
if len(value) or keep_blank_values:
if dict.has_key (name):
dict[name].append(value)
@@ -1317,11 +1316,11 @@
def escape(s, quote=None):
"""Replace special characters '&', '<' and '>' by SGML entities."""
- s = regsub.gsub("&", "&", s) # Must be done first!
- s = regsub.gsub("<", "<", s)
- s = regsub.gsub(">", ">", s)
+ s = string.replace(s, "&", "&") # Must be done first!
+ s = string.replace(s, "<", "<")
+ s = string.replace(s, ">", ">",)
if quote:
- s = regsub.gsub('"', """, s)
+ s = string.replace(s, '"', """)
return s
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index 69a33ec..dc98712 100644
--- a/Lib/mhlib.py
+++ b/Lib/mhlib.py
@@ -773,7 +773,7 @@
# - the string used to initialize the set (default ''),
# - the separator between ranges (default ',')
# - the separator between begin and end of a range (default '-')
-# The separators may be regular expressions and should be different.
+# The separators must be strings (not regexprs) and should be different.
#
# The tostring() function yields a string that can be passed to another
# IntSet constructor; __repr__() is a valid IntSet constructor itself.
@@ -882,11 +882,11 @@
self.normalize()
def fromstring(self, data):
- import string, regsub
+ import string
new = []
- for part in regsub.split(data, self.sep):
+ for part in string.splitfields(data, self.sep):
list = []
- for subp in regsub.split(part, self.rng):
+ for subp in string.splitfields(part, self.rng):
s = string.strip(subp)
list.append(string.atoi(s))
if len(list) == 1:
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index 4595426..0f20fb4 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -38,7 +38,6 @@
import socket
import select
import string
-import regsub
# Tunable parameters
DEBUGLEVEL = 0
@@ -185,7 +184,7 @@
"""
if IAC in buffer:
- buffer = regsub.gsub(IAC, IAC+IAC, buffer)
+ buffer = string.replace(buffer, IAC, IAC+IAC)
self.sock.send(buffer)
def read_until(self, match, timeout=None):