cpython-fullhistory: 8ea2cb1ec598 (original) (raw)

--- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -336,6 +336,15 @@ class CodecTest(unittest.TestCase): def test_builtin(self): self.assertEquals(unicode("python.org", "idna"), u"python.org") +class CodecsModuleTest(unittest.TestCase): +

+ def test_main(): test_support.run_unittest( UTF16Test, @@ -343,7 +352,8 @@ def test_main(): RecodingTest, PunycodeTest, NameprepTest,

--- a/Modules/codecsmodule.c +++ b/Modules/codecsmodule.c @@ -47,7 +47,7 @@ one argument, the encoding name in all l a tuple of functions (encoder, decoder, stream_reader, stream_writer)."); static -PyObject *codecregister(PyObject *self, PyObject *args) +PyObject *codec_register(PyObject *self, PyObject *args) { PyObject *search_function; @@ -71,7 +71,7 @@ Looks up a codec tuple in the Python cod a tuple of functions."); static -PyObject *codeclookup(PyObject *self, PyObject *args) +PyObject *codec_lookup(PyObject *self, PyObject *args) { char *encoding; @@ -84,6 +84,72 @@ PyObject *codeclookup(PyObject *self, Py return NULL; } +PyDoc_STRVAR(encode__doc, +"encode(obj, [encoding[,errors]]) -> object\n[](#l2.26) +\n[](#l2.27) +Encodes obj using the codec registered for encoding. encoding defaults\n[](#l2.28) +to the default encoding. errors may be given to set a different error\n[](#l2.29) +handling scheme. Default is 'strict' meaning that encoding errors raise\n[](#l2.30) +a ValueError. Other possible values are 'ignore', 'replace' and\n[](#l2.31) +'xmlcharrefreplace' as well as any other name registered with\n[](#l2.32) +codecs.register_error that can handle ValueErrors."); + +static PyObject * +codec_encode(PyObject *self, PyObject *args) +{

+

+

+} + +PyDoc_STRVAR(decode__doc__, +"decode(obj, [encoding[,errors]]) -> object\n[](#l2.59) +\n[](#l2.60) +Decodes obj using the codec registered for encoding. encoding defaults\n[](#l2.61) +to the default encoding. errors may be given to set a different error\n[](#l2.62) +handling scheme. Default is 'strict' meaning that encoding errors raise\n[](#l2.63) +a ValueError. Other possible values are 'ignore' and 'replace'\n[](#l2.64) +as well as any other name registerd with codecs.register_error that is\n[](#l2.65) +able to handle ValueErrors."); + +static PyObject * +codec_decode(PyObject *self, PyObject *args) +{

+

+

+} + /* --- Helpers ------------------------------------------------------------ */ static @@ -765,10 +831,12 @@ static PyObject *lookup_error(PyObject / --- Module API --------------------------------------------------------- */ static PyMethodDef _codecs_functions[] = {

#ifdef Py_USING_UNICODE