mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Allow long objects as a position value of error callbacks returned.
This commit is contained in:
parent
7545a6bac2
commit
9f4b632212
3 changed files with 33 additions and 10 deletions
|
@ -60,7 +60,7 @@ class TestBase:
|
|||
"ଓଣୠ nd eggs"
|
||||
)
|
||||
|
||||
def test_customreplace(self):
|
||||
def test_customreplace_encode(self):
|
||||
if self.has_iso10646:
|
||||
return
|
||||
|
||||
|
@ -96,6 +96,19 @@ class TestBase:
|
|||
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
|
||||
'test.cjktest')
|
||||
|
||||
def test_callback_long_index(self):
|
||||
def myreplace(exc):
|
||||
return (u'x', long(exc.end))
|
||||
codecs.register_error("test.cjktest", myreplace)
|
||||
self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
|
||||
'test.cjktest'), ('abcdxefgh', 9))
|
||||
|
||||
def myreplace(exc):
|
||||
return (u'x', sys.maxint + 1)
|
||||
codecs.register_error("test.cjktest", myreplace)
|
||||
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
|
||||
'test.cjktest')
|
||||
|
||||
def test_callback_None_index(self):
|
||||
def myreplace(exc):
|
||||
return (u'x', None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue