Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1095)

Unified Diff: Objects/unicodeobject.c

Issue 9076: Add C-API documentation for PyUnicode_AsDecodedObject/Unicode and PyUnicode_AsEncodedObject/Unicode
Patch Set: Created 2 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Include/unicodeobject.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c (révision 82199)
+++ Objects/unicodeobject.c (copie de travail)
@@ -1382,100 +1382,6 @@
return NULL;
}
-PyObject *PyUnicode_AsDecodedObject(PyObject *unicode,
- const char *encoding,
- const char *errors)
-{
- PyObject *v;
-
- if (!PyUnicode_Check(unicode)) {
- PyErr_BadArgument();
- goto onError;
- }
-
- if (encoding == NULL)
- encoding = PyUnicode_GetDefaultEncoding();
-
- /* Decode via the codec registry */
- v = PyCodec_Decode(unicode, encoding, errors);
- if (v == NULL)
- goto onError;
- return v;
-
- onError:
- return NULL;
-}
-
-PyObject *PyUnicode_AsDecodedUnicode(PyObject *unicode,
- const char *encoding,
- const char *errors)
-{
- PyObject *v;
-
- if (!PyUnicode_Check(unicode)) {
- PyErr_BadArgument();
- goto onError;
- }
-
- if (encoding == NULL)
- encoding = PyUnicode_GetDefaultEncoding();
-
- /* Decode via the codec registry */
- v = PyCodec_Decode(unicode, encoding, errors);
- if (v == NULL)
- goto onError;
- if (!PyUnicode_Check(v)) {
- PyErr_Format(PyExc_TypeError,
- "decoder did not return a str object (type=%.400s)",
- Py_TYPE(v)->tp_name);
- Py_DECREF(v);
- goto onError;
- }
- return v;
-
- onError:
- return NULL;
-}
-
-PyObject *PyUnicode_Encode(const Py_UNICODE *s,
- Py_ssize_t size,
- const char *encoding,
- const char *errors)
-{
- PyObject *v, *unicode;
-
- unicode = PyUnicode_FromUnicode(s, size);
- if (unicode == NULL)
- return NULL;
- v = PyUnicode_AsEncodedString(unicode, encoding, errors);
- Py_DECREF(unicode);
- return v;
-}
-
-PyObject *PyUnicode_AsEncodedObject(PyObject *unicode,
- const char *encoding,
- const char *errors)
-{
- PyObject *v;
-
- if (!PyUnicode_Check(unicode)) {
- PyErr_BadArgument();
- goto onError;
- }
-
- if (encoding == NULL)
- encoding = PyUnicode_GetDefaultEncoding();
-
- /* Encode via the codec registry */
- v = PyCodec_Encode(unicode, encoding, errors);
- if (v == NULL)
- goto onError;
- return v;
-
- onError:
- return NULL;
-}
-
PyObject *PyUnicode_EncodeFSDefault(PyObject *unicode)
{
if (Py_FileSystemDefaultEncoding) {
« no previous file with comments | « Include/unicodeobject.h ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7