]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backporting:
authorBarry Warsaw <barry@python.org>
Fri, 4 Apr 2003 02:48:18 +0000 (02:48 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 4 Apr 2003 02:48:18 +0000 (02:48 +0000)
    typed_subpart_iterator(): Fix these to use non-deprecated APIs,
    i.e. get_content_maintype() and get_content_subtype().

Lib/email/_compat21.py
Lib/email/_compat22.py

index 0e0b3d07652b4a7ecece63f2d2253e9c30c71c47..1e1f66692feb74efdc6f2ddde08bb0978c7d5f09 100644 (file)
@@ -63,7 +63,7 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None):
     """
     parts = []
     for subpart in msg.walk():
-        if subpart.get_main_type('text') == maintype:
-            if subtype is None or subpart.get_subtype('plain') == subtype:
+        if subpart.get_content_maintype() == maintype:
+            if subtype is None or subpart.get_content_subtype() == subtype:
                 parts.append(subpart)
     return parts
index ec2d2f8a0a9e52b583f521714b2c15840547ae4a..fc1d32a5559c0c90337bfbffa5f44c452f22a2eb 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 2002 Python Software Foundation
 # Author: barry@zope.com
 
-"""Module containing compatibility functions for Python 2.1.
+"""Module containing compatibility functions for Python 2.2.
 """
 
 from __future__ import generators
@@ -9,6 +9,13 @@ from __future__ import division
 from cStringIO import StringIO
 from types import StringTypes
 
+# Python 2.2.x where x < 1 lacks True/False
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 \f
 # This function will become a method of the Message class
@@ -58,6 +65,6 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None):
     omitted, only the main type is matched.
     """
     for subpart in msg.walk():
-        if subpart.get_main_type('text') == maintype:
-            if subtype is None or subpart.get_subtype('plain') == subtype:
+        if subpart.get_content_maintype() == maintype:
+            if subtype is None or subpart.get_content_subtype() == subtype:
                 yield subpart