diff options
author | Inada Naoki <songofacandy@gmail.com> | 2019-03-18 06:44:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-18 06:44:11 (GMT) |
commit | 6a16b18224fa98f6d192aa5014affeccc0376eb3 (patch) | |
tree | d42d5fb270ce1a0e77235b9d5841fe2daa64b4e6 /Modules | |
parent | 6fb544d8bc994ceb96b0fc5059c65fa82997743e (diff) | |
download | cpython-6a16b18224fa98f6d192aa5014affeccc0376eb3.zip cpython-6a16b18224fa98f6d192aa5014affeccc0376eb3.tar.gz cpython-6a16b18224fa98f6d192aa5014affeccc0376eb3.tar.bz2 |
bpo-36297: remove "unicode_internal" codec (GH-12342)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_codecsmodule.c | 82 | ||||
-rw-r--r-- | Modules/clinic/_codecsmodule.c.h | 104 |
2 files changed, 2 insertions, 184 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c index e0d6902..90b3e37 100644 --- a/Modules/_codecsmodule.c +++ b/Modules/_codecsmodule.c @@ -21,8 +21,7 @@ (Unicode object, bytes consumed) These <encoding>s are available: utf_8, unicode_escape, - raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit), - mbcs (on win32). + raw_unicode_escape, latin_1, ascii (7-bit), mbcs (on win32). Written by Marc-Andre Lemburg (mal@lemburg.com). @@ -251,38 +250,6 @@ _codecs_escape_encode_impl(PyObject *module, PyObject *data, /* --- Decoder ------------------------------------------------------------ */ /*[clinic input] -_codecs.unicode_internal_decode - obj: object - errors: str(accept={str, NoneType}) = NULL - / -[clinic start generated code]*/ - -static PyObject * -_codecs_unicode_internal_decode_impl(PyObject *module, PyObject *obj, - const char *errors) -/*[clinic end generated code: output=edbfe175e09eff9a input=8d57930aeda170c6]*/ -{ - if (PyUnicode_Check(obj)) { - if (PyUnicode_READY(obj) < 0) - return NULL; - Py_INCREF(obj); - return codec_tuple(obj, PyUnicode_GET_LENGTH(obj)); - } - else { - Py_buffer view; - PyObject *result; - if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) != 0) - return NULL; - - result = codec_tuple( - _PyUnicode_DecodeUnicodeInternal(view.buf, view.len, errors), - view.len); - PyBuffer_Release(&view); - return result; - } -} - -/*[clinic input] _codecs.utf_7_decode data: Py_buffer errors: str(accept={str, NoneType}) = NULL @@ -687,51 +654,6 @@ _codecs_readbuffer_encode_impl(PyObject *module, Py_buffer *data, } /*[clinic input] -_codecs.unicode_internal_encode - obj: object - errors: str(accept={str, NoneType}) = NULL - / -[clinic start generated code]*/ - -static PyObject * -_codecs_unicode_internal_encode_impl(PyObject *module, PyObject *obj, - const char *errors) -/*[clinic end generated code: output=a72507dde4ea558f input=8628f0280cf5ba61]*/ -{ - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "unicode_internal codec has been deprecated", - 1)) - return NULL; - - if (PyUnicode_Check(obj)) { - Py_UNICODE *u; - Py_ssize_t len, size; - - if (PyUnicode_READY(obj) < 0) - return NULL; - - u = PyUnicode_AsUnicodeAndSize(obj, &len); - if (u == NULL) - return NULL; - if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE)) - return PyErr_NoMemory(); - size = len * sizeof(Py_UNICODE); - return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size), - PyUnicode_GET_LENGTH(obj)); - } - else { - Py_buffer view; - PyObject *result; - if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) != 0) - return NULL; - result = codec_tuple(PyBytes_FromStringAndSize(view.buf, view.len), - view.len); - PyBuffer_Release(&view); - return result; - } -} - -/*[clinic input] _codecs.utf_7_encode str: unicode errors: str(accept={str, NoneType}) = NULL @@ -1095,8 +1017,6 @@ static PyMethodDef _codecs_functions[] = { _CODECS_UTF_32_EX_DECODE_METHODDEF _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF - _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF - _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF _CODECS_LATIN_1_ENCODE_METHODDEF diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h index d1f4cf3..65e2483 100644 --- a/Modules/clinic/_codecsmodule.c.h +++ b/Modules/clinic/_codecsmodule.c.h @@ -370,57 +370,6 @@ exit: return return_value; } -PyDoc_STRVAR(_codecs_unicode_internal_decode__doc__, -"unicode_internal_decode($module, obj, errors=None, /)\n" -"--\n" -"\n"); - -#define _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF \ - {"unicode_internal_decode", (PyCFunction)(void(*)(void))_codecs_unicode_internal_decode, METH_FASTCALL, _codecs_unicode_internal_decode__doc__}, - -static PyObject * -_codecs_unicode_internal_decode_impl(PyObject *module, PyObject *obj, - const char *errors); - -static PyObject * -_codecs_unicode_internal_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *obj; - const char *errors = NULL; - - if (!_PyArg_CheckPositional("unicode_internal_decode", nargs, 1, 2)) { - goto exit; - } - obj = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("unicode_internal_decode", 2, "str or None", args[1]); - goto exit; - } -skip_optional: - return_value = _codecs_unicode_internal_decode_impl(module, obj, errors); - -exit: - return return_value; -} - PyDoc_STRVAR(_codecs_utf_7_decode__doc__, "utf_7_decode($module, data, errors=None, final=False, /)\n" "--\n" @@ -1853,57 +1802,6 @@ exit: return return_value; } -PyDoc_STRVAR(_codecs_unicode_internal_encode__doc__, -"unicode_internal_encode($module, obj, errors=None, /)\n" -"--\n" -"\n"); - -#define _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF \ - {"unicode_internal_encode", (PyCFunction)(void(*)(void))_codecs_unicode_internal_encode, METH_FASTCALL, _codecs_unicode_internal_encode__doc__}, - -static PyObject * -_codecs_unicode_internal_encode_impl(PyObject *module, PyObject *obj, - const char *errors); - -static PyObject * -_codecs_unicode_internal_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *obj; - const char *errors = NULL; - - if (!_PyArg_CheckPositional("unicode_internal_encode", nargs, 1, 2)) { - goto exit; - } - obj = args[0]; - if (nargs < 2) { - goto skip_optional; - } - if (args[1] == Py_None) { - errors = NULL; - } - else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); - if (errors == NULL) { - goto exit; - } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - } - else { - _PyArg_BadArgument("unicode_internal_encode", 2, "str or None", args[1]); - goto exit; - } -skip_optional: - return_value = _codecs_unicode_internal_encode_impl(module, obj, errors); - -exit: - return return_value; -} - PyDoc_STRVAR(_codecs_utf_7_encode__doc__, "utf_7_encode($module, str, errors=None, /)\n" "--\n" @@ -3024,4 +2922,4 @@ exit: #ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF #define _CODECS_CODE_PAGE_ENCODE_METHODDEF #endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=02bd0f0cf9a28150 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=da3c47709a55a05e input=a9049054013a1b77]*/ |