[ python-Bugs-850997 ] mbcs encoding ignores errors

SourceForge.net noreply at sourceforge.net
Sat Nov 29 10:18:42 EST 2003


Bugs item #850997, was opened at 2003-11-29 02:24
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=850997&group_id=5470

Category: Windows
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Hammond (mhammond)
>Assigned to: Nobody/Anonymous (nobody)
Summary: mbcs encoding ignores errors

Initial Comment:
The following snippet:

>>> u'@test-\u5171'.encode("mbcs", "strict")
'@test-?'

Should raise a UnicodeError.  The errors param is
completely ignored, and the function always works as
though errors='replace'.

Attaching a test case, and the start of a patch.  The
patch has a number of issues:
* I'm not sure what errors are considered 'mandatory'.
 I have handled 'strict', 'ignore' and 'replace' -
however, 'ignore' and 'replace' currently are exactly
the same (ie, replace)
* The Windows functions don't tell us exactly what
character failed in the conversion.  Thus, the
exception I raise implies the first character is the
one that failed.  For the same reason, I have made no
attempt to support error callbacks.

Comments/guidance appreciated.

----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2003-11-29 16:18

Message:
Logged In: YES 
user_id=11105

No idea why this was assigned to me - unicode is certainly
not one of my strengths.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2003-11-29 02:31

Message:
Logged In: YES 
user_id=14198

Attaching a patch.  This patch also attempts to handle
Encode, but I haven't worked out how to exercise this
code-path - ie, what mbcs encoded string can I pass that can
not be converted to unicode?

As I mentioned, patch has a few issues

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=850997&group_id=5470



More information about the Python-bugs-list mailing list