Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3d1f397f
Commit
3d1f397f
authored
May 09, 2004
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to Python 2.3, getting rid of backward compatiblity crud. Get rid of a
bunch of module globals that aren't used.
parent
36112f2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
27 deletions
+6
-27
Lib/email/Header.py
Lib/email/Header.py
+6
-27
No files found.
Lib/email/Header.py
View file @
3d1f397f
# Copyright (C) 2002 Python Software Foundation
# Author: che@debian.org (Ben Gertzfield), barry@
zope.com
(Barry Warsaw)
# Copyright (C) 2002
-2004
Python Software Foundation
# Author: che@debian.org (Ben Gertzfield), barry@
python.org
(Barry Warsaw)
"""Header encoding and decoding functionality."""
import
re
import
binascii
from
types
import
StringType
,
UnicodeType
import
email.quopriMIME
import
email.base64MIME
from
email.Errors
import
HeaderParseError
from
email.Charset
import
Charset
try
:
from
email._compat22
import
_floordiv
except
SyntaxError
:
# Python 2.1 spells integer division differently
from
email._compat21
import
_floordiv
try
:
True
,
False
except
NameError
:
True
=
1
False
=
0
CRLFSPACE
=
'
\
r
\
n
'
CRLF
=
'
\
r
\
n
'
NL
=
'
\
n
'
SPACE
=
' '
USPACE
=
u' '
SPACE8
=
' '
*
8
EMPTYSTRING
=
''
UEMPTYSTRING
=
u''
MAXLINELEN
=
76
ENCODE
=
1
DECODE
=
2
USASCII
=
Charset
(
'us-ascii'
)
UTF8
=
Charset
(
'utf-8'
)
...
...
@@ -52,8 +33,6 @@ ecre = re.compile(r'''
\
?= # li
teral ?=
'''
,
re
.
VERBOSE
|
re
.
IGNORECASE
)
pcre
=
re
.
compile
(
'([,;])'
)
# Field name regexp, including trailing colon, but not separating whitespace,
# according to RFC 2822. Character range is from tilde to exclamation mark.
# For use with .match()
...
...
@@ -244,8 +223,8 @@ class Header:
constructor is used.
s may be a byte string or a Unicode string. If it is a byte string
(i.e. isinstance(s,
StringType) is true), then charset is the encoding
of
that byte string, and a UnicodeError will be raised if the string
(i.e. isinstance(s,
str) is true), then charset is the encoding of
that byte string, and a UnicodeError will be raised if the string
cannot be decoded with that charset. If s is a Unicode string, then
charset is a hint specifying the character set of the characters in
the string. In this case, when producing an RFC 2822 compliant header
...
...
@@ -265,7 +244,7 @@ class Header:
# We need to test that the string can be converted to unicode and
# back to a byte string, given the input and output codecs of the
# charset.
if
isinstance
(
s
,
StringType
):
if
isinstance
(
s
,
str
):
# Possibly raise UnicodeError if the byte string can't be
# converted to a unicode with the input codec of the charset.
incodec
=
charset
.
input_codec
or
'us-ascii'
...
...
@@ -275,7 +254,7 @@ class Header:
# than the iput coded. Still, use the original byte string.
outcodec
=
charset
.
output_codec
or
'us-ascii'
ustr
.
encode
(
outcodec
,
errors
)
elif
isinstance
(
s
,
UnicodeTyp
e
):
elif
isinstance
(
s
,
unicod
e
):
# Now we have to be sure the unicode string can be converted
# to a byte string with a reasonable output codec. We want to
# use the byte string in the chunk.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment