[Python-checkins] python/dist/src/Lib/email Message.py,1.35,1.36 (original) (raw)

bwarsaw at users.sourceforge.net bwarsaw at users.sourceforge.net
Sat May 8 23:44:58 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13586

Modified Files: Message.py Log Message: Update to Python 2.3, getting rid of backward compatiblity crud.

Index: Message.py

Regular expression used to split header parameters. BAW: this may be too

simple. It isn't strictly RFC 2045 (section 5.1) compliant, but it catches

--- 17,20 ---- *************** *** 43,50 **** """ if value is not None and len(value) > 0: ! # TupleType is used for RFC 2231 encoded parameter values where items # are (charset, language, value). charset is a string, not a Charset # instance. ! if isinstance(value, TupleType): # Encode as per RFC 2231 param += '' --- 35,42 ---- """ if value is not None and len(value) > 0: ! # A tuple is used for RFC 2231 encoded parameter values where items # are (charset, language, value). charset is a string, not a Charset # instance. ! if isinstance(value, tuple): # Encode as per RFC 2231 param += '' *************** *** 78,82 ****
def _unquotevalue(value): ! if isinstance(value, TupleType): return value[0], value[1], Utils.unquote(value[2]) else: --- 70,74 ----
def _unquotevalue(value): ! if isinstance(value, tuple): return value[0], value[1], Utils.unquote(value[2]) else: *************** *** 133,137 **** def is_multipart(self): """Return True if the message consists of multiple parts.""" ! if isinstance(self._payload, ListType): return True return False --- 125,129 ---- def is_multipart(self): """Return True if the message consists of multiple parts.""" ! if isinstance(self._payload, list): return True return False *************** *** 161,165 **** if self._payload is None: self._payload = payload ! elif isinstance(self._payload, ListType): self._payload.append(payload) elif self.get_main_type() not in (None, 'multipart'): --- 153,157 ---- if self._payload is None: self._payload = payload ! elif isinstance(self._payload, list): self._payload.append(payload) elif self.get_main_type() not in (None, 'multipart'): *************** *** 203,207 **** if i is None: payload = self._payload ! elif not isinstance(self._payload, ListType): raise TypeError, 'Expected list, got %s' % type(self._payload) else: --- 195,199 ---- if i is None: payload = self._payload ! elif not isinstance(self._payload, list): raise TypeError, 'Expected list, got %s' % type(self._payload) else: *************** *** 260,264 **** self._charset = None return ! if isinstance(charset, StringType): charset = Charset.Charset(charset) if not isinstance(charset, Charset.Charset): --- 252,256 ---- self._charset = None return ! if isinstance(charset, str): charset = Charset.Charset(charset) if not isinstance(charset, Charset.Charset): *************** *** 632,636 **** to the empty string. Both charset and language should be strings. """ ! if not isinstance(value, TupleType) and charset: value = (charset, language, value)
--- 624,628 ---- to the empty string. Both charset and language should be strings. """ ! if not isinstance(value, tuple) and charset: value = (charset, language, value)
*************** *** 726,730 **** if filename is missing: return failobj ! if isinstance(filename, TupleType): # It's an RFC 2231 encoded parameter newvalue = _unquotevalue(filename) --- 718,722 ---- if filename is missing: return failobj ! if isinstance(filename, tuple): # It's an RFC 2231 encoded parameter newvalue = _unquotevalue(filename) *************** *** 744,748 **** if boundary is missing: return failobj ! if isinstance(boundary, TupleType): # RFC 2231 encoded, so decode. It better end up as ascii charset = boundary[0] or 'us-ascii' --- 736,740 ---- if boundary is missing: return failobj ! if isinstance(boundary, tuple): # RFC 2231 encoded, so decode. It better end up as ascii charset = boundary[0] or 'us-ascii' *************** *** 795,804 **** self._headers = newheaders
- try: - from email._compat22 import walk - except SyntaxError: - # Must be using Python 2.1 - from email._compat21 import walk

  def get_content_charset(self, failobj=None):
      """Return the charset parameter of the Content-Type header.

--- 787,790 ----


*** 812,816 **** if charset is missing: return failobj ! if isinstance(charset, TupleType): # RFC 2231 encoded, so decode it, and it better end up as ascii. pcharset = charset[0] or 'us-ascii' --- 798,802 ---- if charset is missing: return failobj ! if isinstance(charset, tuple): # RFC 2231 encoded, so decode it, and it better end up as ascii. pcharset = charset[0] or 'us-ascii'


*** 836,837 **** --- 822,826 ---- """ return [part.get_content_charset(failobj) for part in self.walk()]

+



More information about the Python-checkins mailing list