summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2006-03-26 06:21:34 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2006-03-26 06:21:34 (GMT)
commit9f4b632212742fbcd91e921e2516a6285fd7728b (patch)
treef1a1574241882414c5ce0e5042e349b604526013 /Lib
parent7545a6bac2827c5f1d6feb85c41dd19544d4d626 (diff)
downloadcpython-9f4b632212742fbcd91e921e2516a6285fd7728b.zip
cpython-9f4b632212742fbcd91e921e2516a6285fd7728b.tar.gz
cpython-9f4b632212742fbcd91e921e2516a6285fd7728b.tar.bz2
Allow long objects as a position value of error callbacks returned.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_multibytecodec.py8
-rw-r--r--Lib/test/test_multibytecodec_support.py15
2 files changed, 21 insertions, 2 deletions
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 8f9f6e9..4d02dee 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -7,7 +7,7 @@
from test import test_support
from test import test_multibytecodec_support
-import unittest, StringIO, codecs
+import unittest, StringIO, codecs, sys
class Test_MultibyteCodec(unittest.TestCase):
@@ -19,6 +19,12 @@ class Test_MultibyteCodec(unittest.TestCase):
def test_str_decode(self):
self.assertEqual('abcd'.encode('gb18030'), 'abcd')
+ def test_errorcallback_longindex(self):
+ dec = codecs.getdecoder('euc-kr')
+ myreplace = lambda exc: (u'', sys.maxint+1)
+ codecs.register_error('test.cjktest', myreplace)
+ self.assertRaises(IndexError, dec,
+ 'apple\x92ham\x93spam', 'test.cjktest')
class Test_IncrementalEncoder(unittest.TestCase):
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index 563a3ea..bec32de 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -60,7 +60,7 @@ class TestBase:
"&#2835;&#2851;&#2912; 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)