Kaydet (Commit) 29273c87 authored tarafından Marc-André Lemburg's avatar Marc-André Lemburg

Fix for [ 543344 ] Interpreter crashes when recoding; suggested

by Michael Stone (mbrierst).

Python 2.1.4, 2.2.2 candidate.
üst 604ade4e
......@@ -27,11 +27,20 @@ class EscapeDecodeTest(unittest.TestCase):
def test_empty_escape_decode(self):
self.assertEquals(codecs.escape_decode(""), ("", 0))
class RecodingTest(unittest.TestCase):
def test_recoding(self):
f = StringIO.StringIO()
f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8")
f2.write(u"a")
f2.close()
# Python used to crash on this at exit because of a refcount
# bug in _codecsmodule.c
def test_main():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(UTF16Test))
suite.addTest(unittest.makeSuite(EscapeDecodeTest))
suite.addTest(unittest.makeSuite(RecodingTest))
test_support.run_suite(suite)
......
......@@ -167,8 +167,10 @@ unicode_internal_decode(PyObject *self,
&obj, &errors))
return NULL;
if (PyUnicode_Check(obj))
if (PyUnicode_Check(obj)) {
Py_INCREF(obj);
return codec_tuple(obj, PyUnicode_GET_SIZE(obj));
}
else {
if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment