summaryrefslogtreecommitdiff
path: root/Mailman/Handlers
diff options
context:
space:
mode:
authorbwarsaw2006-04-17 13:10:09 +0000
committerbwarsaw2006-04-17 13:10:09 +0000
commit953d9bff95f70b66b1b6c04340959185a11c3d10 (patch)
treebd6aa3c6d30bcace2d628da71bc121f751ff1be2 /Mailman/Handlers
parent0ed815a216c7bb6f820cfdf99fc8d31bcfd19fc0 (diff)
downloadmailman-953d9bff95f70b66b1b6c04340959185a11c3d10.tar.gz
mailman-953d9bff95f70b66b1b6c04340959185a11c3d10.tar.zst
mailman-953d9bff95f70b66b1b6c04340959185a11c3d10.zip
Remove most uses of the types module, in favor of isinstance checks against
the builtin types. Two still remain: a check against ClassType and a check against MethodType. Also, fix some hinky type comparisons to use isinstance() consistently.
Diffstat (limited to 'Mailman/Handlers')
-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
5 files changed, 7 insertions, 15 deletions
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]