diff options
author | Barry Warsaw <barry@python.org> | 2002-09-10 16:09:06 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-09-10 16:09:06 (GMT) |
commit | 356afac41ff5384e8c82236f9fae162cf83d0559 (patch) | |
tree | 66a3aef7394b3430d8105a9d4e9e7dc9665e410a /Lib/email/_compat21.py | |
parent | 45d9bde6c1053cde2a73043785778e5e0262103d (diff) | |
download | cpython-356afac41ff5384e8c82236f9fae162cf83d0559.zip cpython-356afac41ff5384e8c82236f9fae162cf83d0559.tar.gz cpython-356afac41ff5384e8c82236f9fae162cf83d0559.tar.bz2 |
_isstring(): Factor out "stringiness" test, e.g. for StringType or
UnicodeType, which is different between Python 2.1 and 2.2.
Diffstat (limited to 'Lib/email/_compat21.py')
-rw-r--r-- | Lib/email/_compat21.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/email/_compat21.py b/Lib/email/_compat21.py index 76d6f50..de8c447 100644 --- a/Lib/email/_compat21.py +++ b/Lib/email/_compat21.py @@ -30,6 +30,10 @@ def _floordiv(i, j): return i / j +def _isstring(obj): + return isinstance(obj, StringType) or isinstance(obj, UnicodeType) + + # These two functions are imported into the Iterators.py interface module. # The Python 2.2 version uses generators for efficiency. @@ -38,7 +42,7 @@ def body_line_iterator(msg): lines = [] for subpart in msg.walk(): payload = subpart.get_payload() - if isinstance(payload, StringType) or isinstance(payload, UnicodeType): + if _isstring(payload): for line in StringIO(payload).readlines(): lines.append(line) return lines |