summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/Archiver/HyperArch.py7
-rw-r--r--Mailman/Bouncer.py3
-rw-r--r--Mailman/Bouncers/Microsoft.py8
-rw-r--r--Mailman/Cgi/admin.py11
-rw-r--r--Mailman/Cgi/admindb.py9
-rw-r--r--Mailman/Cgi/create.py4
-rw-r--r--Mailman/Cgi/options.py6
-rw-r--r--Mailman/Gui/GUIBase.py14
-rw-r--r--Mailman/Handlers/CookHeaders.py8
-rw-r--r--Mailman/Handlers/Decorate.py3
-rw-r--r--Mailman/Handlers/SMTPDirect.py3
-rw-r--r--Mailman/Handlers/Scrubber.py5
-rw-r--r--Mailman/Handlers/ToDigest.py3
-rw-r--r--Mailman/MailList.py14
-rw-r--r--Mailman/Message.py7
-rw-r--r--Mailman/OldStyleMemberships.py14
-rw-r--r--Mailman/Queue/CommandRunner.py5
-rw-r--r--Mailman/SecurityManager.py5
-rw-r--r--Mailman/UserDesc.py12
-rw-r--r--Mailman/Utils.py5
-rw-r--r--Mailman/htmlformat.py8
-rw-r--r--Mailman/i18n.py5
-rw-r--r--Mailman/versions.py10
-rw-r--r--tests/test_handlers.py16
24 files changed, 79 insertions, 106 deletions
diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py
index e38d35e16..44f683d6d 100644
--- a/Mailman/Archiver/HyperArch.py
+++ b/Mailman/Archiver/HyperArch.py
@@ -31,7 +31,6 @@ import re
import sys
import time
import errno
-import types
import urllib
import logging
import weakref
@@ -133,7 +132,7 @@ html_charset = '<META http-equiv="Content-Type" ' \
'content="text/html; charset=%s">'
def CGIescape(arg, lang=None):
- if isinstance(arg, types.UnicodeType):
+ if isinstance(arg, unicode):
s = Utils.websafe(arg)
else:
s = Utils.websafe(str(arg))
@@ -560,7 +559,7 @@ class Article(pipermail.Article):
body = EMPTYSTRING.join(self.body)
cset = Utils.GetCharSet(self._lang)
# Coerce the body to Unicode and replace any invalid characters.
- if not isinstance(body, types.UnicodeType):
+ if not isinstance(body, unicode):
body = unicode(body, cset, 'replace')
if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS:
otrans = i18n.get_translation()
@@ -1168,7 +1167,7 @@ class HyperArchive(pipermail.T):
# 3. make it faster
# TK: Prepare for unicode obscure.
atmark = _(' at ')
- if lines and isinstance(lines[0], types.UnicodeType):
+ if lines and isinstance(lines[0], unicode):
atmark = unicode(atmark, Utils.GetCharSet(self.lang), 'replace')
source = lines[:]
dest = lines
diff --git a/Mailman/Bouncer.py b/Mailman/Bouncer.py
index caa4e0bb1..99774b398 100644
--- a/Mailman/Bouncer.py
+++ b/Mailman/Bouncer.py
@@ -23,7 +23,6 @@ import logging
from email.MIMEMessage import MIMEMessage
from email.MIMEText import MIMEText
-from types import StringType
from Mailman import MemberAdaptor
from Mailman import Message
@@ -207,7 +206,7 @@ class Bouncer:
umsg.set_type('multipart/mixed')
umsg.attach(
MIMEText(text, _charset=Utils.GetCharSet(self.preferred_language)))
- if isinstance(msg, StringType):
+ if isinstance(msg, str):
umsg.attach(MIMEText(msg))
else:
umsg.attach(MIMEMessage(msg))
diff --git a/Mailman/Bouncers/Microsoft.py b/Mailman/Bouncers/Microsoft.py
index f5adcf5ce..16f56813d 100644
--- a/Mailman/Bouncers/Microsoft.py
+++ b/Mailman/Bouncers/Microsoft.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,13 +12,13 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Microsoft's `SMTPSVC' nears I kin tell."""
import re
from cStringIO import StringIO
-from types import ListType
scre = re.compile(r'transcript of session follows', re.IGNORECASE)
@@ -34,7 +34,7 @@ def process(msg):
# The message *looked* like a multipart but wasn't
return None
data = subpart.get_payload()
- if isinstance(data, ListType):
+ if isinstance(data, list):
# The message is a multi-multipart, so not a matching bounce
return None
body = StringIO(data)
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py
index 74aba72fa..d3feab649 100644
--- a/Mailman/Cgi/admin.py
+++ b/Mailman/Cgi/admin.py
@@ -28,7 +28,6 @@ import logging
from email.Utils import unquote, parseaddr, formataddr
from string import lowercase, digits
-from types import *
from Mailman import Errors
from Mailman import i18n
@@ -119,7 +118,7 @@ def main():
# POST methods, even if their actions have a query string, don't get
# put into FieldStorage's keys :-(
qs = parsedqs.get('VARHELP')
- if qs and isinstance(qs, ListType):
+ if qs and isinstance(qs, list):
varhelp = qs[0]
if varhelp:
option_help(mlist, varhelp)
@@ -536,7 +535,7 @@ def show_variables(mlist, category, subcat, cgidata, doc):
# The very first item in the config info will be treated as a general
# description if it is a string
description = options[0]
- if isinstance(description, StringType):
+ if isinstance(description, str):
table.AddRow([description])
table.AddCellInfo(table.GetCurrentRowIndex(), 0, colspan=2)
options = options[1:]
@@ -553,7 +552,7 @@ def show_variables(mlist, category, subcat, cgidata, doc):
width='85%')
for item in options:
- if type(item) == StringType:
+ if isinstance(type, str):
# The very first banner option (string in an options list) is
# treated as a general description, while any others are
# treated as section headers - centered and italicized...
@@ -1084,7 +1083,7 @@ def membership_options(mlist, subcat, cgidata, doc, form):
qsenviron = os.environ.get('QUERY_STRING')
if qsenviron:
qs = cgi.parse_qs(qsenviron).get('legend')
- if qs and isinstance(qs, ListType):
+ if qs and isinstance(qs, list):
qs = qs[0]
if qs == 'yes':
addlegend = 'legend=yes&'
@@ -1409,7 +1408,7 @@ def change_options(mlist, category, subcat, cgidata, doc):
# do the user options for members category
if cgidata.has_key('setmemberopts_btn') and cgidata.has_key('user'):
user = cgidata['user']
- if type(user) is ListType:
+ if isinstance(user, list):
users = []
for ui in range(len(user)):
users.append(urllib.unquote(user[ui].value))
diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py
index 9add54e0c..47db8945c 100644
--- a/Mailman/Cgi/admindb.py
+++ b/Mailman/Cgi/admindb.py
@@ -25,7 +25,6 @@ import email
import errno
import signal
-from types import ListType
from urllib import quote_plus, unquote_plus
from Mailman import Errors
@@ -126,13 +125,13 @@ def main():
# POST methods, even if their actions have a query string, don't get
# put into FieldStorage's keys :-(
qs = cgi.parse_qs(envar).get('sender')
- if qs and type(qs) == ListType:
+ if qs and isinstance(qs, list):
sender = qs[0]
qs = cgi.parse_qs(envar).get('msgid')
- if qs and type(qs) == ListType:
+ if qs and isinstance(qs, list):
msgid = qs[0]
qs = cgi.parse_qs(envar).get('details')
- if qs and type(qs) == ListType:
+ if qs and isinstance(qs, list):
details = qs[0]
# We need a signal handler to catch the SIGTERM that can come from Apache
@@ -753,7 +752,7 @@ def process_form(mlist, doc, cgidata):
erroraddrs = []
for k in cgidata.keys():
formv = cgidata[k]
- if type(formv) == ListType:
+ if isinstance(formv, list):
continue
try:
v = int(formv.value)
diff --git a/Mailman/Cgi/create.py b/Mailman/Cgi/create.py
index 0c517c2cd..767400569 100644
--- a/Mailman/Cgi/create.py
+++ b/Mailman/Cgi/create.py
@@ -24,8 +24,6 @@ import sys
import signal
import logging
-from types import ListType
-
from Mailman import Errors
from Mailman import i18n
from Mailman import MailList
@@ -99,7 +97,7 @@ def process_request(doc, cgidata):
auth = cgidata.getvalue('auth', '').strip()
langs = cgidata.getvalue('langs', [mm_cfg.DEFAULT_SERVER_LANGUAGE])
- if not isinstance(langs, ListType):
+ if not isinstance(langs, list):
langs = [langs]
# Sanity check
safelistname = Utils.websafe(listname)
diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py
index b2d63735f..2f24c112b 100644
--- a/Mailman/Cgi/options.py
+++ b/Mailman/Cgi/options.py
@@ -24,8 +24,6 @@ import signal
import urllib
import logging
-from types import ListType
-
from Mailman import Errors
from Mailman import i18n
from Mailman import MailList
@@ -152,7 +150,7 @@ def main():
# POST methods, even if their actions have a query string, don't get
# put into FieldStorage's keys :-(
qs = cgi.parse_qs(os.environ['QUERY_STRING']).get('VARHELP')
- if qs and type(qs) == types.ListType:
+ if qs and isinstance(qs, list):
varhelp = qs[0]
if varhelp:
topic_details(mlist, doc, user, cpuser, userlang, varhelp)
@@ -569,7 +567,7 @@ address. Upon confirmation, any other mailing list containing the address
# Some topics were selected. topicnames can actually be a string
# or a list of strings depending on whether more than one topic
# was selected or not.
- if not isinstance(topicnames, ListType):
+ if not isinstance(topicnames, list):
# Assume it was a bare string, so listify it
topicnames = [topicnames]
# unquote the topic names
diff --git a/Mailman/Gui/GUIBase.py b/Mailman/Gui/GUIBase.py
index 5f0f2c1e6..53cc3e490 100644
--- a/Mailman/Gui/GUIBase.py
+++ b/Mailman/Gui/GUIBase.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2004 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,12 +12,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Base class for all web GUI components."""
import re
-from types import TupleType, ListType
from Mailman import mm_cfg
from Mailman import Utils
@@ -59,7 +59,7 @@ class GUIBase:
if wtype in (mm_cfg.EmailList, mm_cfg.EmailListEx):
# BAW: value might already be a list, if this is coming from
# config_list input. Sigh.
- if isinstance(val, ListType):
+ if isinstance(val, list):
return val
addrs = []
for addr in [s.strip() for s in val.split(NL)]:
@@ -101,7 +101,7 @@ class GUIBase:
# Checkboxes return a list of the selected items, even if only one is
# selected.
if wtype == mm_cfg.Checkbox:
- if isinstance(val, ListType):
+ if isinstance(val, list):
return val
return [val]
if wtype == mm_cfg.FileUpload:
@@ -129,7 +129,7 @@ class GUIBase:
def handleForm(self, mlist, category, subcat, cgidata, doc):
for item in self.GetConfigInfo(mlist, category, subcat):
# Skip descriptions and legacy non-attributes
- if not isinstance(item, TupleType) or len(item) < 5:
+ if not isinstance(item, tuple) or len(item) < 5:
continue
# Unpack the gui item description
property, wtype, args, deps, desc = item[0:5]
@@ -143,7 +143,7 @@ class GUIBase:
val = cgidata[uploadprop].value
elif not cgidata.has_key(property):
continue
- elif isinstance(cgidata[property], ListType):
+ elif isinstance(cgidata[property], list):
val = [self._escape(property, x.value)
for x in cgidata[property]]
else:
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index 458f9d362..f384f6357 100644
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -18,7 +18,6 @@
"""Cook a message's Subject header."""
import re
-from types import UnicodeType
from email.Charset import Charset
from email.Errors import HeaderParseError
@@ -33,13 +32,10 @@ CONTINUATION = ',\n\t'
COMMASPACE = ', '
MAXLINELEN = 78
-
-
-def _isunicode(s):
- return isinstance(s, UnicodeType)
-
nonascii = re.compile('[^\s!-~]')
+
+
def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None):
# Get the charset to encode the string in. Then search if there is any
# non-ascii character is in the string. If there is and the charset is
diff --git a/Mailman/Handlers/Decorate.py b/Mailman/Handlers/Decorate.py
index 770114a49..2e1d11bf0 100644
--- a/Mailman/Handlers/Decorate.py
+++ b/Mailman/Handlers/Decorate.py
@@ -20,7 +20,6 @@
import logging
from email.MIMEText import MIMEText
-from types import ListType
from Mailman import Errors
from Mailman import mm_cfg
@@ -42,7 +41,7 @@ def process(mlist, msg, msgdata):
# Calculate the extra personalization dictionary. Note that the
# length of the recips list better be exactly 1.
recips = msgdata.get('recips')
- assert type(recips) == ListType and len(recips) == 1
+ assert isinstance(recips, list) and len(recips) == 1
member = recips[0].lower()
d['user_address'] = member
try:
diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py
index c68d269bf..e4fa6ec3b 100644
--- a/Mailman/Handlers/SMTPDirect.py
+++ b/Mailman/Handlers/SMTPDirect.py
@@ -36,7 +36,6 @@ import smtplib
from email.Charset import Charset
from email.Header import Header
from email.Utils import formataddr
-from types import UnicodeType
from Mailman import Errors
from Mailman import mm_cfg
@@ -323,7 +322,7 @@ def verpdeliver(mlist, msg, msgdata, envsender, failures, conn):
charset = 'iso-8859-1'
charset = Charset(charset)
codec = charset.input_codec or 'ascii'
- if not isinstance(name, UnicodeType):
+ if not isinstance(name, unicode):
name = unicode(name, codec, 'replace')
name = Header(name, charset).encode()
msgcopy['To'] = formataddr((name, recip))
diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py
index a96bb0b39..a1325c47a 100644
--- a/Mailman/Handlers/Scrubber.py
+++ b/Mailman/Handlers/Scrubber.py
@@ -28,7 +28,6 @@ import tempfile
from cStringIO import StringIO
from mimetypes import guess_all_extensions
-from types import IntType, StringType
from email.Charset import Charset
from email.Generator import Generator
@@ -189,7 +188,7 @@ An embedded and charset-unspecified text was scrubbed...
Name: %(filename)s
Url: %(url)s
"""), lcset)
- elif ctype == 'text/html' and isinstance(sanitize, IntType):
+ elif ctype == 'text/html' and isinstance(sanitize, int):
if sanitize == 0:
if outer:
raise DiscardMessage
@@ -352,7 +351,7 @@ Url : %(url)s
except (UnicodeError, LookupError, ValueError):
t = t.encode(lcset, 'replace')
# Separation is useful
- if isinstance(t, StringType):
+ if isinstance(t, str):
if not t.endswith('\n'):
t += '\n'
text.append(t)
diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py
index 21acb10c1..5c5d4105b 100644
--- a/Mailman/Handlers/ToDigest.py
+++ b/Mailman/Handlers/ToDigest.py
@@ -40,7 +40,6 @@ from email.MIMEMessage import MIMEMessage
from email.MIMEText import MIMEText
from email.Parser import Parser
from email.Utils import getaddresses, formatdate
-from types import ListType
from Mailman import Errors
from Mailman import i18n
@@ -238,7 +237,7 @@ def send_i18n_digests(mlist, mboxfp):
username = ''
addresses = getaddresses([Utils.oneline(msg.get('from', ''), lcset)])
# Take only the first author we find
- if isinstance(addresses, ListType) and addresses:
+ if isinstance(addresses, list) and addresses:
username = addresses[0][0]
if not username:
username = addresses[0][1]
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index a47a94316..6ea41f801 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -36,7 +36,7 @@ import email.Iterators
from UserDict import UserDict
from cStringIO import StringIO
-from types import *
+from types import MethodType
from urlparse import urlparse
from email.Header import Header
@@ -549,7 +549,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
# copy all public attributes to serializable dictionary
dict = {}
for key, value in self.__dict__.items():
- if key[0] == '_' or type(value) is MethodType:
+ if key[0] == '_' or isinstance(value, MethodType):
continue
dict[key] = value
# Make config.pck unreadable by `other', as it contains all the
@@ -597,8 +597,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
return None, e
try:
try:
- dict = loadfunc(fp)
- if type(dict) <> DictType:
+ d = loadfunc(fp)
+ if isinstance(d, dict):
return None, 'Load() expected to return a dictionary'
except (EOFError, ValueError, TypeError, MemoryError,
cPickle.PicklingError, cPickle.UnpicklingError), e:
@@ -607,7 +607,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
fp.close()
# Update timestamp
self.__timestamp = mtime
- return dict, None
+ return d, None
def Load(self, check_version=True):
if not Utils.list_exists(self.internal_name()):
@@ -981,7 +981,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
subject = _('%(realname)s subscription notification')
finally:
i18n.set_translation(otrans)
- if isinstance(name, UnicodeType):
+ if isinstance(name, unicode):
name = name.encode(Utils.GetCharSet(lang), 'replace')
text = Utils.maketext(
"adminsubscribeack.txt",
@@ -1167,7 +1167,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
name = self.getMemberName(newaddr)
if name is None:
name = ''
- if isinstance(name, UnicodeType):
+ if isinstance(name, unicode):
name = name.encode(Utils.GetCharSet(lang), 'replace')
text = Utils.maketext(
'adminaddrchgack.txt',
diff --git a/Mailman/Message.py b/Mailman/Message.py
index bba484219..7216d7c9a 100644
--- a/Mailman/Message.py
+++ b/Mailman/Message.py
@@ -25,11 +25,10 @@ import re
import email
import email.Message
import email.Utils
+
from email.Charset import Charset
from email.Header import Header
-from types import ListType, StringType
-
from Mailman import mm_cfg
from Mailman import Utils
@@ -79,7 +78,7 @@ class Message(email.Message.Message):
chunks = []
cchanged = 0
for s, charset in v._chunks:
- if isinstance(charset, StringType):
+ if isinstance(charset, str):
charset = Charset(charset)
cchanged = 1
chunks.append((s, charset))
@@ -216,7 +215,7 @@ class UserNotification(Message):
self['Subject'] = Header(subject, charset, header_name='Subject',
errors='replace')
self['From'] = sender
- if isinstance(recip, ListType):
+ if isinstance(recip, list):
self['To'] = COMMASPACE.join(recip)
self.recips = recip
else:
diff --git a/Mailman/OldStyleMemberships.py b/Mailman/OldStyleMemberships.py
index 3222c2ae7..04f3d1a7c 100644
--- a/Mailman/OldStyleMemberships.py
+++ b/Mailman/OldStyleMemberships.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Old style Mailman membership adaptor.
@@ -24,12 +25,11 @@ This is the adaptor used by default in Mailman 2.1.
"""
import time
-from types import StringType
-from Mailman import mm_cfg
-from Mailman import Utils
from Mailman import Errors
+from Mailman import mm_cfg
from Mailman import MemberAdaptor
+from Mailman import Utils
ISREGULAR = 1
ISDIGEST = 2
@@ -63,13 +63,13 @@ class OldStyleMemberships(MemberAdaptor.MemberAdaptor):
missing = []
val = self.__mlist.members.get(lcmember, missing)
if val is not missing:
- if isinstance(val, StringType):
+ if isinstance(val, str):
return val, ISREGULAR
else:
return lcmember, ISREGULAR
val = self.__mlist.digest_members.get(lcmember, missing)
if val is not missing:
- if isinstance(val, StringType):
+ if isinstance(val, str):
return val, ISDIGEST
else:
return lcmember, ISDIGEST
diff --git a/Mailman/Queue/CommandRunner.py b/Mailman/Queue/CommandRunner.py
index 978cb05cd..fe30a3cd3 100644
--- a/Mailman/Queue/CommandRunner.py
+++ b/Mailman/Queue/CommandRunner.py
@@ -30,7 +30,6 @@ from email.Header import decode_header, make_header, Header
from email.Iterators import typed_subpart_iterator
from email.MIMEMessage import MIMEMessage
from email.MIMEText import MIMEText
-from types import StringType, UnicodeType
from Mailman import LockFile
from Mailman import Message
@@ -86,7 +85,7 @@ class Results:
return
body = part.get_payload()
# text/plain parts better have string payloads
- assert isinstance(body, StringType) or isinstance(body, UnicodeType)
+ assert isinstance(body, basestring)
lines = body.splitlines()
# Use no more lines than specified
self.commands.extend(lines[:mm_cfg.DEFAULT_MAIL_COMMANDS_MAX_LINES])
@@ -164,7 +163,7 @@ To obtain instructions, send a message containing just the word "help".
charset = Utils.GetCharSet(self.msgdata['lang'])
encoded_resp = []
for item in resp:
- if isinstance(item, UnicodeType):
+ if isinstance(item, unicode):
item = item.encode(charset, 'replace')
encoded_resp.append(item)
results = MIMEText(NL.join(encoded_resp), _charset=charset)
diff --git a/Mailman/SecurityManager.py b/Mailman/SecurityManager.py
index 91ab6f52f..46f90ad98 100644
--- a/Mailman/SecurityManager.py
+++ b/Mailman/SecurityManager.py
@@ -57,7 +57,6 @@ import logging
import marshal
import binascii
-from types import StringType, TupleType
from urlparse import urlparse
from Mailman import Errors
@@ -228,7 +227,7 @@ class SecurityManager:
def MakeCookie(self, authcontext, user=None):
key, secret = self.AuthContextInfo(authcontext, user)
- if key is None or secret is None or not isinstance(secret, StringType):
+ if key is None or secret is None or not isinstance(secret, str):
raise ValueError
# Timestamp
issued = int(time.time())
@@ -310,7 +309,7 @@ class SecurityManager:
key, secret = self.AuthContextInfo(authcontext, user)
except Errors.NotAMemberError:
return False
- if not c.has_key(key) or not isinstance(secret, StringType):
+ if not c.has_key(key) or not isinstance(secret, str):
return False
# Undo the encoding we performed in MakeCookie() above. BAW: I
# believe this is safe from exploit because marshal can't be forced to
diff --git a/Mailman/UserDesc.py b/Mailman/UserDesc.py
index ec7db748e..12722f819 100644
--- a/Mailman/UserDesc.py
+++ b/Mailman/UserDesc.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2004 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,14 +12,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""User description class/structure, for ApprovedAddMember and friends."""
-from types import UnicodeType
-
-
class UserDesc:
def __init__(self, address=None, fullname=None, password=None,
@@ -59,9 +57,9 @@ class UserDesc:
digest = 'yes'
language = getattr(self, 'language', 'n/a')
# Make sure fullname and password are encoded if they're strings
- if isinstance(fullname, UnicodeType):
+ if isinstance(fullname, unicode):
fullname = fullname.encode('ascii', 'replace')
- if isinstance(password, UnicodeType):
+ if isinstance(password, unicode):
password = password.encode('ascii', 'replace')
return '<UserDesc %s (%s) [%s] [digest? %s] [%s]>' % (
address, fullname, password, digest, language)
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index cb3444b17..5e319cad3 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -39,7 +39,6 @@ import email.Iterators
from email.Errors import HeaderParseError
from string import ascii_letters, digits, whitespace
-from types import UnicodeType
from Mailman import Errors
from Mailman import Site
@@ -787,7 +786,7 @@ def canonstr(s, lang=None):
else:
newparts.append(c)
newstr = EMPTYSTRING.join(newparts)
- if isinstance(newstr, UnicodeType):
+ if isinstance(newstr, unicode):
return newstr
# We want the default fallback to be iso-8859-1 even if the language is
# English (us-ascii). This seems like a practical compromise so that
@@ -818,7 +817,7 @@ def uncanonstr(s, lang=None):
# set. If so, return it unchanged, except for coercing it to a byte
# string.
try:
- if isinstance(s, UnicodeType):
+ if isinstance(s, unicode):
return s.encode(charset)
else:
u = unicode(s, charset)
diff --git a/Mailman/htmlformat.py b/Mailman/htmlformat.py
index 1fe44d885..0f005b1a0 100644
--- a/Mailman/htmlformat.py
+++ b/Mailman/htmlformat.py
@@ -27,8 +27,6 @@ for python and, recursively, for nested HTML formatting objects.
# shouldn't be adding their own newlines. The next object should.
-import types
-
from Mailman import mm_cfg
from Mailman import Utils
from Mailman.i18n import _
@@ -641,11 +639,11 @@ class SelectOptions:
self.multiple = multiple
# we convert any type to tuple, commas are needed
if not multiple:
- if type(selected) == types.IntType:
+ if isinstance(selected, int):
self.selected = (selected,)
- elif type(selected) == types.TupleType:
+ elif isinstance(selected, tuple):
self.selected = (selected[0],)
- elif type(selected) == types.ListType:
+ elif isinstance(selected, list):
self.selected = (selected[0],)
else:
self.selected = (0,)
diff --git a/Mailman/i18n.py b/Mailman/i18n.py
index 7fe3b7ce3..c913b2130 100644
--- a/Mailman/i18n.py
+++ b/Mailman/i18n.py
@@ -18,7 +18,6 @@
import sys
import time
import gettext
-from types import StringType, UnicodeType
from Mailman import mm_cfg
from Mailman.SafeDict import SafeDict
@@ -85,7 +84,7 @@ def _(s):
if not charset:
charset = 'us-ascii'
for k, v in dict.items():
- if isinstance(v, UnicodeType):
+ if isinstance(v, unicode):
dict[k] = v.encode(charset, 'replace')
return tns % dict
@@ -105,7 +104,7 @@ def ctime(date):
]
tzname = _('Server Local Time')
- if isinstance(date, StringType):
+ if isinstance(date, str):
try:
year, mon, day, hh, mm, ss, wday, ydat, dst = time.strptime(date)
if dst in (0,1):
diff --git a/Mailman/versions.py b/Mailman/versions.py
index 4b3990684..77a88056c 100644
--- a/Mailman/versions.py
+++ b/Mailman/versions.py
@@ -34,8 +34,6 @@ run again until another version change is detected.
import logging
-from types import ListType, StringType
-
from Mailman import mm_cfg
from Mailman import Message
from Mailman import Utils
@@ -268,12 +266,12 @@ def UpdateOldVars(l, stored_state):
# transfer the list data type for holding members and digest members
# to the dict data type starting file format version 11
#
- if type(l.members) is ListType:
+ if isinstance(l.members, list):
members = {}
for m in l.members:
members[m] = 1
l.members = members
- if type(l.digest_members) is ListType:
+ if isinstance(l.digest_members, list):
dmembers = {}
for dm in l.digest_members:
dmembers[dm] = 1
@@ -293,7 +291,7 @@ def UpdateOldVars(l, stored_state):
if k.lower() <> k:
l.members[k.lower()] = Utils.LCDomain(k)
del l.members[k]
- elif type(l.members[k]) == StringType and k == l.members[k].lower():
+ elif isinstance(l.members[k], str) and k == l.members[k].lower():
# already converted
pass
else:
@@ -302,7 +300,7 @@ def UpdateOldVars(l, stored_state):
if k.lower() <> k:
l.digest_members[k.lower()] = Utils.LCDomain(k)
del l.digest_members[k]
- elif type(l.digest_members[k]) == StringType and \
+ elif isinstance(l.digest_members[k], str) and \
k == l.digest_members[k].lower():
# already converted
pass
diff --git a/tests/test_handlers.py b/tests/test_handlers.py
index 66c583f7a..3d86bfaff 100644
--- a/tests/test_handlers.py
+++ b/tests/test_handlers.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
-"""Unit tests for the various Mailman/Handlers/*.py modules.
-"""
+"""Unit tests for the various Mailman/Handlers/*.py modules."""
import os
import sha
@@ -24,14 +24,14 @@ import email
import errno
import cPickle
import unittest
-from types import ListType
+
from email.Generator import Generator
-from Mailman import mm_cfg
-from Mailman.MailList import MailList
-from Mailman import Message
from Mailman import Errors
+from Mailman import Message
+from Mailman import mm_cfg
from Mailman import Pending
+from Mailman.MailList import MailList
from Mailman.Queue.Switchboard import Switchboard
from Mailman.Handlers import Acknowledge