Do not insert characters for unicode-escape decoders if the error mode

is "ignore". Fixes #529104.
This commit is contained in:
Martin v. Löwis 2002-03-21 08:55:28 +00:00
parent bdf1f19fee
commit 047c05ebc4
2 changed files with 32 additions and 14 deletions

View file

@ -541,6 +541,14 @@ else:
verify(unicode('Andr\202 x','ascii','ignore') == u"Andr x")
verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x')
verify("\\N{foo}xx".decode("unicode-escape", "ignore") == u"xx")
try:
"\\".decode("unicode-escape")
except ValueError:
pass
else:
raise TestFailed, '"\\".decode("unicode-escape") should fail'
verify(u'hello'.encode('ascii') == 'hello')
verify(u'hello'.encode('utf-7') == 'hello')
verify(u'hello'.encode('utf-8') == 'hello')