mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Update to Python 2.3, getting rid of backward compatiblity crud.
This commit is contained in:
parent
235c8eba62
commit
24f79762a1
5 changed files with 20 additions and 85 deletions
|
@ -1,17 +1,16 @@
|
||||||
# Copyright (C) 2001,2002 Python Software Foundation
|
# Copyright (C) 2001-2004 Python Software Foundation
|
||||||
# Author: barry@zope.com (Barry Warsaw)
|
# Author: barry@python.org (Barry Warsaw)
|
||||||
|
|
||||||
"""Miscellaneous utilities.
|
"""Miscellaneous utilities."""
|
||||||
"""
|
|
||||||
|
|
||||||
import time
|
|
||||||
import socket
|
|
||||||
import re
|
|
||||||
import random
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
import base64
|
||||||
|
import random
|
||||||
|
import socket
|
||||||
import warnings
|
import warnings
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from types import ListType
|
|
||||||
|
|
||||||
from email._parseaddr import quote
|
from email._parseaddr import quote
|
||||||
from email._parseaddr import AddressList as _AddressList
|
from email._parseaddr import AddressList as _AddressList
|
||||||
|
@ -21,30 +20,7 @@ from email._parseaddr import mktime_tz
|
||||||
from email._parseaddr import parsedate as _parsedate
|
from email._parseaddr import parsedate as _parsedate
|
||||||
from email._parseaddr import parsedate_tz as _parsedate_tz
|
from email._parseaddr import parsedate_tz as _parsedate_tz
|
||||||
|
|
||||||
try:
|
|
||||||
True, False
|
|
||||||
except NameError:
|
|
||||||
True = 1
|
|
||||||
False = 0
|
|
||||||
|
|
||||||
try:
|
|
||||||
from quopri import decodestring as _qdecode
|
from quopri import decodestring as _qdecode
|
||||||
except ImportError:
|
|
||||||
# Python 2.1 doesn't have quopri.decodestring()
|
|
||||||
def _qdecode(s):
|
|
||||||
import quopri as _quopri
|
|
||||||
|
|
||||||
if not s:
|
|
||||||
return s
|
|
||||||
infp = StringIO(s)
|
|
||||||
outfp = StringIO()
|
|
||||||
_quopri.decode(infp, outfp)
|
|
||||||
value = outfp.getvalue()
|
|
||||||
if not s.endswith('\n') and value.endswith('\n'):
|
|
||||||
return value[:-1]
|
|
||||||
return value
|
|
||||||
|
|
||||||
import base64
|
|
||||||
|
|
||||||
# Intrapackage imports
|
# Intrapackage imports
|
||||||
from email.Encoders import _bencode, _qencode
|
from email.Encoders import _bencode, _qencode
|
||||||
|
@ -140,7 +116,7 @@ def decode(s):
|
||||||
# Intra-package import here to avoid circular import problems.
|
# Intra-package import here to avoid circular import problems.
|
||||||
from email.Header import decode_header
|
from email.Header import decode_header
|
||||||
L = decode_header(s)
|
L = decode_header(s)
|
||||||
if not isinstance(L, ListType):
|
if not isinstance(L, list):
|
||||||
# s wasn't decoded
|
# s wasn't decoded
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# Copyright (C) 2001,2002 Python Software Foundation
|
# Copyright (C) 2001-2004 Python Software Foundation
|
||||||
# Author: barry@zope.com (Barry Warsaw)
|
# Author: barry@python.org (Barry Warsaw)
|
||||||
|
|
||||||
"""A package for parsing, handling, and generating email messages.
|
"""A package for parsing, handling, and generating email messages."""
|
||||||
"""
|
|
||||||
|
|
||||||
__version__ = '2.5.5'
|
__version__ = '3.0a0'
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'base64MIME',
|
'base64MIME',
|
||||||
|
@ -29,12 +28,6 @@ __all__ = [
|
||||||
'message_from_file',
|
'message_from_file',
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
|
||||||
True, False
|
|
||||||
except NameError:
|
|
||||||
True = 1
|
|
||||||
False = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Some convenience routines. Don't import Parser and Message as side-effects
|
# Some convenience routines. Don't import Parser and Message as side-effects
|
||||||
|
@ -51,6 +44,7 @@ def message_from_string(s, _class=None, strict=False):
|
||||||
_class = Message
|
_class = Message
|
||||||
return Parser(_class, strict=strict).parsestr(s)
|
return Parser(_class, strict=strict).parsestr(s)
|
||||||
|
|
||||||
|
|
||||||
def message_from_file(fp, _class=None, strict=False):
|
def message_from_file(fp, _class=None, strict=False):
|
||||||
"""Read a file and parse its contents into a Message object model.
|
"""Read a file and parse its contents into a Message object model.
|
||||||
|
|
||||||
|
@ -61,12 +55,3 @@ def message_from_file(fp, _class=None, strict=False):
|
||||||
from email.Message import Message
|
from email.Message import Message
|
||||||
_class = Message
|
_class = Message
|
||||||
return Parser(_class, strict=strict).parse(fp)
|
return Parser(_class, strict=strict).parse(fp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Patch encodings.aliases to recognize 'ansi_x3.4_1968' which isn't a standard
|
|
||||||
# alias in Python 2.1.3, but is used by the email package test suite.
|
|
||||||
from encodings.aliases import aliases # The aliases dictionary
|
|
||||||
if not aliases.has_key('ansi_x3.4_1968'):
|
|
||||||
aliases['ansi_x3.4_1968'] = 'ascii'
|
|
||||||
del aliases # Not needed any more
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2002 Python Software Foundation
|
# Copyright (C) 2002-2004 Python Software Foundation
|
||||||
|
|
||||||
"""Email address parsing code.
|
"""Email address parsing code.
|
||||||
|
|
||||||
|
@ -6,13 +6,6 @@ Lifted directly from rfc822.py. This should eventually be rewritten.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from types import TupleType
|
|
||||||
|
|
||||||
try:
|
|
||||||
True, False
|
|
||||||
except NameError:
|
|
||||||
True = 1
|
|
||||||
False = 0
|
|
||||||
|
|
||||||
SPACE = ' '
|
SPACE = ' '
|
||||||
EMPTYSTRING = ''
|
EMPTYSTRING = ''
|
||||||
|
@ -130,7 +123,7 @@ def parsedate_tz(data):
|
||||||
def parsedate(data):
|
def parsedate(data):
|
||||||
"""Convert a time string to a time tuple."""
|
"""Convert a time string to a time tuple."""
|
||||||
t = parsedate_tz(data)
|
t = parsedate_tz(data)
|
||||||
if isinstance(t, TupleType):
|
if isinstance(t, tuple):
|
||||||
return t[:9]
|
return t[:9]
|
||||||
else:
|
else:
|
||||||
return t
|
return t
|
||||||
|
|
|
@ -27,13 +27,6 @@ import re
|
||||||
from binascii import b2a_base64, a2b_base64
|
from binascii import b2a_base64, a2b_base64
|
||||||
from email.Utils import fix_eols
|
from email.Utils import fix_eols
|
||||||
|
|
||||||
try:
|
|
||||||
from email._compat22 import _floordiv
|
|
||||||
except SyntaxError:
|
|
||||||
# Python 2.1 spells integer division differently
|
|
||||||
from email._compat21 import _floordiv
|
|
||||||
|
|
||||||
|
|
||||||
CRLF = '\r\n'
|
CRLF = '\r\n'
|
||||||
NL = '\n'
|
NL = '\n'
|
||||||
EMPTYSTRING = ''
|
EMPTYSTRING = ''
|
||||||
|
@ -41,12 +34,6 @@ EMPTYSTRING = ''
|
||||||
# See also Charset.py
|
# See also Charset.py
|
||||||
MISC_LEN = 7
|
MISC_LEN = 7
|
||||||
|
|
||||||
try:
|
|
||||||
True, False
|
|
||||||
except NameError:
|
|
||||||
True = 1
|
|
||||||
False = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
|
@ -100,7 +87,7 @@ def header_encode(header, charset='iso-8859-1', keep_eols=False,
|
||||||
# length, after the RFC chrome is added in.
|
# length, after the RFC chrome is added in.
|
||||||
base64ed = []
|
base64ed = []
|
||||||
max_encoded = maxlinelen - len(charset) - MISC_LEN
|
max_encoded = maxlinelen - len(charset) - MISC_LEN
|
||||||
max_unencoded = _floordiv(max_encoded * 3, 4)
|
max_unencoded = max_encoded * 3 // 4
|
||||||
|
|
||||||
for i in range(0, len(header), max_unencoded):
|
for i in range(0, len(header), max_unencoded):
|
||||||
base64ed.append(b2a_base64(header[i:i+max_unencoded]))
|
base64ed.append(b2a_base64(header[i:i+max_unencoded]))
|
||||||
|
@ -141,7 +128,7 @@ def encode(s, binary=True, maxlinelen=76, eol=NL):
|
||||||
s = fix_eols(s)
|
s = fix_eols(s)
|
||||||
|
|
||||||
encvec = []
|
encvec = []
|
||||||
max_unencoded = _floordiv(maxlinelen * 3, 4)
|
max_unencoded = maxlinelen * 3 // 4
|
||||||
for i in range(0, len(s), max_unencoded):
|
for i in range(0, len(s), max_unencoded):
|
||||||
# BAW: should encode() inherit b2a_base64()'s dubious behavior in
|
# BAW: should encode() inherit b2a_base64()'s dubious behavior in
|
||||||
# adding a newline to the encoded string?
|
# adding a newline to the encoded string?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2001,2002 Python Software Foundation
|
# Copyright (C) 2001-2004 Python Software Foundation
|
||||||
# Author: che@debian.org (Ben Gertzfield)
|
# Author: che@debian.org (Ben Gertzfield)
|
||||||
|
|
||||||
"""Quoted-printable content transfer encoding per RFCs 2045-2047.
|
"""Quoted-printable content transfer encoding per RFCs 2045-2047.
|
||||||
|
@ -38,12 +38,6 @@ MISC_LEN = 7
|
||||||
hqre = re.compile(r'[^-a-zA-Z0-9!*+/ ]')
|
hqre = re.compile(r'[^-a-zA-Z0-9!*+/ ]')
|
||||||
bqre = re.compile(r'[^ !-<>-~\t]')
|
bqre = re.compile(r'[^ !-<>-~\t]')
|
||||||
|
|
||||||
try:
|
|
||||||
True, False
|
|
||||||
except NameError:
|
|
||||||
True = 1
|
|
||||||
False = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue