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
41f6ad61
Commit
41f6ad61
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.
parent
09356d41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
16 deletions
+7
-16
Lib/email/Charset.py
Lib/email/Charset.py
+7
-16
No files found.
Lib/email/Charset.py
View file @
41f6ad61
# Copyright (C) 2001,2002 Python Software Foundation
# Copyright (C) 2001-2004 Python Software Foundation
# Author: che@debian.org (Ben Gertzfield), barry@zope.com (Barry Warsaw)
# Author: che@debian.org (Ben Gertzfield), barry@python.org (Barry Warsaw)
# XXX The following information needs updating.
# Python 2.3 doesn't come with any Asian codecs by default. Two packages are
# Python 2.3 doesn't come with any Asian codecs by default. Two packages are
# currently available and supported as of this writing (30-Dec-2003):
# currently available and supported as of this writing (30-Dec-2003):
...
@@ -12,20 +14,9 @@
...
@@ -12,20 +14,9 @@
# http://www.asahi-net.or.jp/~rd6t-kjym/python
# http://www.asahi-net.or.jp/~rd6t-kjym/python
# Some Japanese users prefer this codec package
# Some Japanese users prefer this codec package
from
types
import
UnicodeType
from
email.Encoders
import
encode_7or8bit
import
email.base64MIME
import
email.base64MIME
import
email.quopriMIME
import
email.quopriMIME
from
email.Encoders
import
encode_7or8bit
def
_isunicode
(
s
):
return
isinstance
(
s
,
UnicodeType
)
# Python 2.2.1 and beyond has these symbols
try
:
True
,
False
except
NameError
:
True
=
1
False
=
0
...
@@ -280,7 +271,7 @@ class Charset:
...
@@ -280,7 +271,7 @@ class Charset:
Characters that could not be converted to Unicode will be replaced
Characters that could not be converted to Unicode will be replaced
with the Unicode replacement character U+FFFD.
with the Unicode replacement character U+FFFD.
"""
"""
if
_isunicode
(
s
)
or
self
.
input_codec
is
None
:
if
isinstance
(
s
,
unicode
)
or
self
.
input_codec
is
None
:
return
s
return
s
try
:
try
:
return
unicode
(
s
,
self
.
input_codec
,
'replace'
)
return
unicode
(
s
,
self
.
input_codec
,
'replace'
)
...
@@ -306,7 +297,7 @@ class Charset:
...
@@ -306,7 +297,7 @@ class Charset:
codec
=
self
.
output_codec
codec
=
self
.
output_codec
else
:
else
:
codec
=
self
.
input_codec
codec
=
self
.
input_codec
if
not
_isunicode
(
ustr
)
or
codec
is
None
:
if
not
isinstance
(
ustr
,
unicode
)
or
codec
is
None
:
return
ustr
return
ustr
try
:
try
:
return
ustr
.
encode
(
codec
,
'replace'
)
return
ustr
.
encode
(
codec
,
'replace'
)
...
...
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