def test_mbcs_decode_force_ignore(self): if sys.platform != 'win32': py.test.skip("mbcs encoding is win32-specific") # XXX: requires a locale w/ a restrictive encoding to test from rpython.rlib.rlocale import getdefaultlocale if getdefaultlocale()[1] != 'cp932': py.test.skip("requires cp932 locale") s = '\xff\xf4\x8f\xbf\xbf' decoder = self.getdecoder('mbcs') assert decoder(s, len(s), 'strict') == (u'\U0010ffff', 5) py.test.raises(UnicodeEncodeError, decoder, s, len(s), 'strict', force_ignore=False)
def getdefaultlocale(space): language, encoding = rlocale.getdefaultlocale() return space.newtuple([space.wrap(language), space.wrap(encoding)])
def getdefaultlocale(space): language, encoding = rlocale.getdefaultlocale() return space.newtuple2(space.newtext(language), space.newtext(encoding))