[Patches] [ python-Patches-490456 ] Unicode support in email.Utils.encode
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 11 Dec 2001 10:28:20 -0800
Patches item #490456, was opened at 2001-12-07 15:11
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=490456&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mikhail Zabaluev (mzabaluev)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unicode support in email.Utils.encode
Initial Comment:
It's essentially an updated patch 486375, this time
making a distinction of type for the passed string; if
it's Unicode, the function encodes it to the character
set specified as the charset parameter.
The reasons:
1. The function in its current version doesn't support
Unicode, throwing an exception if any non-ASCII
characters are found within it.
2. With this patch, we reach a sort of operational
symmetry on email.Utils.encode vs email.Utils.decode,
as it can be seen in the tests.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2001-12-11 10:28
Message:
Logged In: YES
user_id=21627
The patch looks good, except that I cannot really see the
value in using "replace" for .encode. Wouldn't it be better
to get an exception if the Unicode string contains an
un-encodable character?
Also, the Python 2.2 way to spell the type test is
if isinstance(s, unicode)
This makes use of the fact that the unicode builtin is a
type now, and it supports unicode subtypes. This is a minor
change, of course.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=490456&group_id=5470