mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Fix for SF bug [ 817156 ] invalid \U escape gives 0=length unistr.
This commit is contained in:
parent
dbe3d280e7
commit
504de6bd2c
2 changed files with 8 additions and 1 deletions
|
@ -33,6 +33,13 @@ class UnicodeTest(
|
||||||
self.assertEqual(realresult, result)
|
self.assertEqual(realresult, result)
|
||||||
self.assert_(object is not realresult)
|
self.assert_(object is not realresult)
|
||||||
|
|
||||||
|
def test_literals(self):
|
||||||
|
self.assertEqual(u'\xff', u'\u00ff')
|
||||||
|
self.assertEqual(u'\uffff', u'\U0000ffff')
|
||||||
|
self.assertRaises(UnicodeError, eval, 'u\'\\Ufffffffe\'')
|
||||||
|
self.assertRaises(UnicodeError, eval, 'u\'\\Uffffffff\'')
|
||||||
|
self.assertRaises(UnicodeError, eval, 'u\'\\U%08x\'' % 0x110000)
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
if not sys.platform.startswith('java'):
|
if not sys.platform.startswith('java'):
|
||||||
# Test basic sanity of repr()
|
# Test basic sanity of repr()
|
||||||
|
|
|
@ -1750,7 +1750,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
|
||||||
chr += 10 + c - 'A';
|
chr += 10 + c - 'A';
|
||||||
}
|
}
|
||||||
s += i;
|
s += i;
|
||||||
if (chr == 0xffffffff)
|
if (chr == 0xffffffff && PyErr_Occurred())
|
||||||
/* _decoding_error will have already written into the
|
/* _decoding_error will have already written into the
|
||||||
target buffer. */
|
target buffer. */
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue