_isstring(): Factor out "stringiness" test, e.g. for StringType or
UnicodeType, which is different between Python 2.1 and 2.2.
diff --git a/Lib/email/_compat22.py b/Lib/email/_compat22.py
index 2581568..a05451f 100644
--- a/Lib/email/_compat22.py
+++ b/Lib/email/_compat22.py
@@ -31,6 +31,10 @@
return i // j
+def _isstring(obj):
+ return isinstance(obj, StringTypes)
+
+
# These two functions are imported into the Iterators.py interface module.
# The Python 2.2 version uses generators for efficiency.
@@ -38,7 +42,7 @@
"""Iterate over the parts, returning string payloads line-by-line."""
for subpart in msg.walk():
payload = subpart.get_payload()
- if isinstance(payload, StringTypes):
+ if _isstring(payload):
for line in StringIO(payload):
yield line