Mercurial > cpython-lru_cache-weakref
annotate Modules/_codecsmodule.c @ 27680:b19aaaeb6d64 legacy-trunk
Fix for [ 543344 ] Interpreter crashes when recoding; suggested
by Michael Stone (mbrierst).
Python 2.1.4, 2.2.2 candidate.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Tue, 04 Feb 2003 19:35:03 +0000 |
| parents | 040af9c736bb |
| children | 8ea2cb1ec598 |
| rev | line source |
|---|---|
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* ------------------------------------------------------------------------ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 _codecs -- Provides access to the codec registry and the builtin |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 codecs. |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 This module should never be imported directly. The standard library |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 module "codecs" wraps this builtin module for use within Python. |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 The codec registry is accessible via: |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 register(search_function) -> None |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 lookup(encoding) -> (encoder, decoder, stream_reader, stream_writer) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 The builtin Unicode codecs use the following interface: |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 <encoding>_encode(Unicode_object[,errors='strict']) -> |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 (string object, bytes consumed) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 <encoding>_decode(char_buffer_obj[,errors='strict']) -> |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 (Unicode object, bytes consumed) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
23 <encoding>_encode() interfaces also accept non-Unicode object as |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
24 input. The objects are then converted to Unicode using |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
25 PyUnicode_FromObject() prior to applying the conversion. |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
26 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 These <encoding>s are available: utf_8, unicode_escape, |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
28 raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
29 mbcs (on win32). |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
30 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 Written by Marc-Andre Lemburg (mal@lemburg.com). |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
13828
254f8b7c4a83
Changing the CNRI copyright notice according to CNRI's instructions.
Guido van Rossum <guido@python.org>
parents:
13651
diff
changeset
|
34 Copyright (c) Corporation for National Research Initiatives. |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 ------------------------------------------------------------------------ */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 #include "Python.h" |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 /* --- Registry ----------------------------------------------------------- */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
42 PyDoc_STRVAR(register__doc__, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
43 "register(search_function)\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
44 \n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
45 Register a codec search function. Search functions are expected to take\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
46 one argument, the encoding name in all lower case letters, and return\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
47 a tuple of functions (encoder, decoder, stream_reader, stream_writer)."); |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
48 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 static |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 PyObject *codecregister(PyObject *self, PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 PyObject *search_function; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 if (!PyArg_ParseTuple(args, "O:register", &search_function)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 goto onError; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 if (PyCodec_Register(search_function)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 goto onError; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 Py_INCREF(Py_None); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 return Py_None; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 onError: |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
67 PyDoc_STRVAR(lookup__doc__, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
68 "lookup(encoding) -> (encoder, decoder, stream_reader, stream_writer)\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
69 \n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
70 Looks up a codec tuple in the Python codec registry and returns\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
71 a tuple of functions."); |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
72 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 static |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 PyObject *codeclookup(PyObject *self, PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 char *encoding; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 if (!PyArg_ParseTuple(args, "s:lookup", &encoding)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 goto onError; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 return _PyCodec_Lookup(encoding); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 onError: |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 /* --- Helpers ------------------------------------------------------------ */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 static |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 PyObject *codec_tuple(PyObject *unicode, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 int len) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 PyObject *v,*w; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 if (unicode == NULL) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 v = PyTuple_New(2); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 if (v == NULL) { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 Py_DECREF(unicode); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 PyTuple_SET_ITEM(v,0,unicode); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 w = PyInt_FromLong(len); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 if (w == NULL) { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 Py_DECREF(v); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 PyTuple_SET_ITEM(v,1,w); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 return v; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
24808
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
112 /* --- String codecs ------------------------------------------------------ */ |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
113 static PyObject * |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
114 escape_decode(PyObject *self, |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
115 PyObject *args) |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
116 { |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
117 const char *errors = NULL; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
118 const char *data; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
119 int size; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
120 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
121 if (!PyArg_ParseTuple(args, "s#|z:escape_decode", |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
122 &data, &size, &errors)) |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
123 return NULL; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
124 return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL), |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
125 size); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
126 } |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
127 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
128 static PyObject * |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
129 escape_encode(PyObject *self, |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
130 PyObject *args) |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
131 { |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
132 PyObject *str; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
133 const char *errors = NULL; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
134 char *buf; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
135 int len; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
136 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
137 if (!PyArg_ParseTuple(args, "O!|z:escape_encode", |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
138 &PyString_Type, &str, &errors)) |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
139 return NULL; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
140 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
141 str = PyString_Repr(str, 0); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
142 if (!str) |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
143 return NULL; |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
144 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
145 /* The string will be quoted. Unquote, similar to unicode-escape. */ |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
146 buf = PyString_AS_STRING (str); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
147 len = PyString_GET_SIZE (str); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
148 memmove(buf, buf+1, len-2); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
149 _PyString_Resize(&str, len-2); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
150 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
151 return codec_tuple(str, PyString_Size(str)); |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
152 } |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
153 |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
154 #ifdef Py_USING_UNICODE |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 /* --- Decoder ------------------------------------------------------------ */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 unicode_internal_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 { |
|
14733
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
161 PyObject *obj; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
162 const char *errors = NULL; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 |
|
14733
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
166 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode", |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
167 &obj, &errors)) |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 |
|
27680
b19aaaeb6d64
Fix for [ 543344 ] Interpreter crashes when recoding; suggested
Marc-André Lemburg <mal@egenix.com>
parents:
25974
diff
changeset
|
170 if (PyUnicode_Check(obj)) { |
|
b19aaaeb6d64
Fix for [ 543344 ] Interpreter crashes when recoding; suggested
Marc-André Lemburg <mal@egenix.com>
parents:
25974
diff
changeset
|
171 Py_INCREF(obj); |
|
14733
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
172 return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); |
|
27680
b19aaaeb6d64
Fix for [ 543344 ] Interpreter crashes when recoding; suggested
Marc-André Lemburg <mal@egenix.com>
parents:
25974
diff
changeset
|
173 } |
|
14733
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
174 else { |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
175 if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
176 return NULL; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
177 return codec_tuple(PyUnicode_FromUnicode((Py_UNICODE *)data, |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
178 size / sizeof(Py_UNICODE)), |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
179 size); |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
180 } |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 static PyObject * |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
184 utf_7_decode(PyObject *self, |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
185 PyObject *args) |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
186 { |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
187 const char *data; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
188 int size; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
189 const char *errors = NULL; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
190 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
191 if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode", |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
192 &data, &size, &errors)) |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
193 return NULL; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
194 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
195 return codec_tuple(PyUnicode_DecodeUTF7(data, size, errors), |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
196 size); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
197 } |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
198 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
199 static PyObject * |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 utf_8_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 if (!PyArg_ParseTuple(args, "t#|z:utf_8_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 return codec_tuple(PyUnicode_DecodeUTF8(data, size, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 utf_16_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 int byteorder = 0; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 if (!PyArg_ParseTuple(args, "t#|z:utf_16_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 utf_16_le_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 int byteorder = -1; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 if (!PyArg_ParseTuple(args, "t#|z:utf_16_le_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 utf_16_be_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 int byteorder = 1; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 if (!PyArg_ParseTuple(args, "t#|z:utf_16_be_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
257 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
259 return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 /* This non-standard version also provides access to the byteorder |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 parameter of the builtin UTF-16 codec. |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 It returns a tuple (unicode, bytesread, byteorder) with byteorder |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 being the value in effect at the end of data. |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 utf_16_ex_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 int byteorder = 0; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 PyObject *unicode, *tuple; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 if (!PyArg_ParseTuple(args, "t#|zi:utf_16_ex_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 &data, &size, &errors, &byteorder)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 unicode = PyUnicode_DecodeUTF16(data, size, errors, &byteorder); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 if (unicode == NULL) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 tuple = Py_BuildValue("Oii", unicode, size, byteorder); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 Py_DECREF(unicode); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 return tuple; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 unicode_escape_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 return codec_tuple(PyUnicode_DecodeUnicodeEscape(data, size, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
308 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 raw_unicode_escape_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 return codec_tuple(PyUnicode_DecodeRawUnicodeEscape(data, size, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 latin_1_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
337 return codec_tuple(PyUnicode_DecodeLatin1(data, size, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
339 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
342 ascii_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
343 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
349 if (!PyArg_ParseTuple(args, "t#|z:ascii_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
352 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
353 return codec_tuple(PyUnicode_DecodeASCII(data, size, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
354 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
357 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
358 charmap_decode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
359 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
360 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 PyObject *mapping = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 if (!PyArg_ParseTuple(args, "t#|zO:charmap_decode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
367 &data, &size, &errors, &mapping)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
368 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 if (mapping == Py_None) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 mapping = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 return codec_tuple(PyUnicode_DecodeCharmap(data, size, mapping, errors), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
373 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 |
|
24071
8142f8d668a0
Patch #569753: Remove support for WIN16.
Martin v. Löwis <martin@v.loewis.de>
parents:
21757
diff
changeset
|
376 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) |
| 12074 | 377 |
| 378 static PyObject * | |
| 379 mbcs_decode(PyObject *self, | |
| 380 PyObject *args) | |
| 381 { | |
| 382 const char *data; | |
| 383 int size; | |
| 384 const char *errors = NULL; | |
| 385 | |
| 386 if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode", | |
| 387 &data, &size, &errors)) | |
| 388 return NULL; | |
| 389 | |
| 390 return codec_tuple(PyUnicode_DecodeMBCS(data, size, errors), | |
| 391 size); | |
| 392 } | |
| 393 | |
|
24071
8142f8d668a0
Patch #569753: Remove support for WIN16.
Martin v. Löwis <martin@v.loewis.de>
parents:
21757
diff
changeset
|
394 #endif /* MS_WINDOWS */ |
| 12074 | 395 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 /* --- Encoder ------------------------------------------------------------ */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 readbuffer_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
408 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 return codec_tuple(PyString_FromStringAndSize(data, size), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
413 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
414 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 charbuffer_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 const char *data; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 int size; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
422 if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode", |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
423 &data, &size, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
424 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
425 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 return codec_tuple(PyString_FromStringAndSize(data, size), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 size); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 static PyObject * |
|
14733
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
431 unicode_internal_encode(PyObject *self, |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
432 PyObject *args) |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
433 { |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
434 PyObject *obj; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
435 const char *errors = NULL; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
436 const char *data; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
437 int size; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
438 |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
439 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode", |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
440 &obj, &errors)) |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
441 return NULL; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
442 |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
443 if (PyUnicode_Check(obj)) { |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
444 data = PyUnicode_AS_DATA(obj); |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
445 size = PyUnicode_GET_DATA_SIZE(obj); |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
446 return codec_tuple(PyString_FromStringAndSize(data, size), |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
447 size); |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
448 } |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
449 else { |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
450 if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
451 return NULL; |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
452 return codec_tuple(PyString_FromStringAndSize(data, size), |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
453 size); |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
454 } |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
455 } |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
456 |
|
814f421e0326
Added a true unicode_internal_encode function and fixed the
Marc-André Lemburg <mal@egenix.com>
parents:
13828
diff
changeset
|
457 static PyObject * |
|
19998
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
458 utf_7_encode(PyObject *self, |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
459 PyObject *args) |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
460 { |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
461 PyObject *str, *v; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
462 const char *errors = NULL; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
463 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
464 if (!PyArg_ParseTuple(args, "O|z:utf_7_encode", |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
465 &str, &errors)) |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
466 return NULL; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
467 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
468 str = PyUnicode_FromObject(str); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
469 if (str == NULL) |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
470 return NULL; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
471 v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str), |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
472 PyUnicode_GET_SIZE(str), |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
473 0, |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
474 0, |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
475 errors), |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
476 PyUnicode_GET_SIZE(str)); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
477 Py_DECREF(str); |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
478 return v; |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
479 } |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
480 |
|
8a0c97453df4
Patch #435971: UTF-7 codec by Brian Quinlan.
Marc-André Lemburg <mal@egenix.com>
parents:
19343
diff
changeset
|
481 static PyObject * |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
482 utf_8_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
483 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
484 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
485 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
487 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
488 if (!PyArg_ParseTuple(args, "O|z:utf_8_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
490 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
491 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
492 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
493 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
494 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
495 v = codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
496 PyUnicode_GET_SIZE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
497 errors), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
498 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
499 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
500 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
501 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
502 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
503 /* This version provides access to the byteorder parameter of the |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 builtin UTF-16 codecs as optional third argument. It defaults to 0 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
505 which means: use the native byte order and prepend the data with a |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
506 BOM mark. |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
510 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 utf_16_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
514 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 int byteorder = 0; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
518 if (!PyArg_ParseTuple(args, "O|zi:utf_16_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 &str, &errors, &byteorder)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
520 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
522 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
523 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
524 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
525 v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
526 PyUnicode_GET_SIZE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
527 errors, |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
528 byteorder), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
529 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
530 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
531 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
532 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
533 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
534 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
535 utf_16_le_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
536 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
537 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
538 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
539 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
540 |
|
18139
354a4df09e38
Fix for bug [ #433047 ] missing args to PyArg_ParseTuple
Marc-André Lemburg <mal@egenix.com>
parents:
14733
diff
changeset
|
541 if (!PyArg_ParseTuple(args, "O|z:utf_16_le_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
542 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
543 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
544 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
545 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
546 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
547 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
548 v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
549 PyUnicode_GET_SIZE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
550 errors, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
551 -1), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
552 PyUnicode_GET_SIZE(str)); |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
553 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
554 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
555 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
556 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
557 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 utf_16_be_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
559 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
561 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
562 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
563 |
|
18139
354a4df09e38
Fix for bug [ #433047 ] missing args to PyArg_ParseTuple
Marc-André Lemburg <mal@egenix.com>
parents:
14733
diff
changeset
|
564 if (!PyArg_ParseTuple(args, "O|z:utf_16_be_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
565 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
567 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
568 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
569 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
570 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
571 v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
572 PyUnicode_GET_SIZE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
573 errors, |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
574 +1), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
575 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
576 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
577 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
578 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
579 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
580 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
581 unicode_escape_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
582 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
583 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
584 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
585 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
586 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
587 if (!PyArg_ParseTuple(args, "O|z:unicode_escape_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
588 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
589 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
590 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
591 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
592 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
593 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
594 v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
595 PyUnicode_GET_SIZE(str)), |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
596 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
597 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
598 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
599 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
600 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
601 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
602 raw_unicode_escape_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
603 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
604 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
605 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
606 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
607 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
608 if (!PyArg_ParseTuple(args, "O|z:raw_unicode_escape_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
609 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
610 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
611 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
612 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
613 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
614 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
615 v = codec_tuple(PyUnicode_EncodeRawUnicodeEscape( |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
616 PyUnicode_AS_UNICODE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
617 PyUnicode_GET_SIZE(str)), |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
618 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
619 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
620 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
621 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
622 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
623 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
624 latin_1_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
625 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
626 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
627 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
628 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
629 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
630 if (!PyArg_ParseTuple(args, "O|z:latin_1_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
631 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
632 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
633 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
634 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
635 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
636 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
637 v = codec_tuple(PyUnicode_EncodeLatin1( |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
638 PyUnicode_AS_UNICODE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
639 PyUnicode_GET_SIZE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
640 errors), |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
641 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
642 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
643 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
644 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
645 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
646 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
647 ascii_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
648 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
649 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
650 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
651 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
652 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
653 if (!PyArg_ParseTuple(args, "O|z:ascii_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
654 &str, &errors)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
655 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
656 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
657 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
658 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
659 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
660 v = codec_tuple(PyUnicode_EncodeASCII( |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
661 PyUnicode_AS_UNICODE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
662 PyUnicode_GET_SIZE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
663 errors), |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
664 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
665 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
666 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
667 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
668 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
669 static PyObject * |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
670 charmap_encode(PyObject *self, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
671 PyObject *args) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
672 { |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
673 PyObject *str, *v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
674 const char *errors = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
675 PyObject *mapping = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
676 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
677 if (!PyArg_ParseTuple(args, "O|zO:charmap_encode", |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
678 &str, &errors, &mapping)) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
679 return NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
680 if (mapping == Py_None) |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
681 mapping = NULL; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
682 |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
683 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
684 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
685 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
686 v = codec_tuple(PyUnicode_EncodeCharmap( |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
687 PyUnicode_AS_UNICODE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
688 PyUnicode_GET_SIZE(str), |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
689 mapping, |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
690 errors), |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
691 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
692 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
693 return v; |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
694 } |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
695 |
|
24071
8142f8d668a0
Patch #569753: Remove support for WIN16.
Martin v. Löwis <martin@v.loewis.de>
parents:
21757
diff
changeset
|
696 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) |
| 12074 | 697 |
| 698 static PyObject * | |
| 699 mbcs_encode(PyObject *self, | |
| 700 PyObject *args) | |
| 701 { | |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
702 PyObject *str, *v; |
| 12074 | 703 const char *errors = NULL; |
| 704 | |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
705 if (!PyArg_ParseTuple(args, "O|z:mbcs_encode", |
| 12074 | 706 &str, &errors)) |
| 707 return NULL; | |
| 708 | |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
709 str = PyUnicode_FromObject(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
710 if (str == NULL) |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
711 return NULL; |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
712 v = codec_tuple(PyUnicode_EncodeMBCS( |
| 12074 | 713 PyUnicode_AS_UNICODE(str), |
| 714 PyUnicode_GET_SIZE(str), | |
| 715 errors), | |
|
13358
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
716 PyUnicode_GET_SIZE(str)); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
717 Py_DECREF(str); |
|
c8706e5a882f
Modified the encode interfaces of all builtin codecs to accept
Marc-André Lemburg <mal@egenix.com>
parents:
12074
diff
changeset
|
718 return v; |
| 12074 | 719 } |
| 720 | |
|
24071
8142f8d668a0
Patch #569753: Remove support for WIN16.
Martin v. Löwis <martin@v.loewis.de>
parents:
21757
diff
changeset
|
721 #endif /* MS_WINDOWS */ |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
18278
diff
changeset
|
722 #endif /* Py_USING_UNICODE */ |
| 12074 | 723 |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
724 /* --- Error handler registry --------------------------------------------- */ |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
725 |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
726 PyDoc_STRVAR(register_error__doc__, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
727 "register_error(errors, handler)\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
728 \n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
729 Register the specified error handler under the name\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
730 errors. handler must be a callable object, that\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
731 will be called with an exception instance containing\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
732 information about the location of the encoding/decoding\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
733 error and must return a (replacement, new position) tuple."); |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
734 |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
735 static PyObject *register_error(PyObject *self, PyObject *args) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
736 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
737 const char *name; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
738 PyObject *handler; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
739 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
740 if (!PyArg_ParseTuple(args, "sO:register_error", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
741 &name, &handler)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
742 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
743 if (PyCodec_RegisterError(name, handler)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
744 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
745 Py_INCREF(Py_None); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
746 return Py_None; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
747 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
748 |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
749 PyDoc_STRVAR(lookup_error__doc__, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
750 "lookup_error(errors) -> handler\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
751 \n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
752 Return the error handler for the specified error handling name\n\ |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
753 or raise a LookupError, if no handler exists under this name."); |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
754 |
|
25091
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
755 static PyObject *lookup_error(PyObject *self, PyObject *args) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
756 { |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
757 const char *name; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
758 |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
759 if (!PyArg_ParseTuple(args, "s:lookup_error", |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
760 &name)) |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
761 return NULL; |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
762 return PyCodec_LookupError(name); |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
763 } |
|
0337dad8403e
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents:
24808
diff
changeset
|
764 |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
765 /* --- Module API --------------------------------------------------------- */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
766 |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
767 static PyMethodDef _codecs_functions[] = { |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
768 {"register", codecregister, METH_VARARGS, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
769 register__doc__}, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
770 {"lookup", codeclookup, METH_VARARGS, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
771 lookup__doc__}, |
|
24808
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
772 {"escape_encode", escape_encode, METH_VARARGS}, |
|
ab63af3ec349
Patch #505705: Remove eval in pickle and cPickle.
Martin v. Löwis <martin@v.loewis.de>
parents:
24471
diff
changeset
|
773 {"escape_decode", escape_decode, METH_VARARGS}, |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
18278
diff
changeset
|
774 #ifdef Py_USING_UNICODE |
|
21757
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
775 {"utf_8_encode", utf_8_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
776 {"utf_8_decode", utf_8_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
777 {"utf_7_encode", utf_7_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
778 {"utf_7_decode", utf_7_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
779 {"utf_16_encode", utf_16_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
780 {"utf_16_le_encode", utf_16_le_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
781 {"utf_16_be_encode", utf_16_be_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
782 {"utf_16_decode", utf_16_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
783 {"utf_16_le_decode", utf_16_le_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
784 {"utf_16_be_decode", utf_16_be_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
785 {"utf_16_ex_decode", utf_16_ex_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
786 {"unicode_escape_encode", unicode_escape_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
787 {"unicode_escape_decode", unicode_escape_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
788 {"unicode_internal_encode", unicode_internal_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
789 {"unicode_internal_decode", unicode_internal_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
790 {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
791 {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
792 {"latin_1_encode", latin_1_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
793 {"latin_1_decode", latin_1_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
794 {"ascii_encode", ascii_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
795 {"ascii_decode", ascii_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
796 {"charmap_encode", charmap_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
797 {"charmap_decode", charmap_decode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
798 {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
799 {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, |
|
24071
8142f8d668a0
Patch #569753: Remove support for WIN16.
Martin v. Löwis <martin@v.loewis.de>
parents:
21757
diff
changeset
|
800 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) |
|
21757
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
801 {"mbcs_encode", mbcs_encode, METH_VARARGS}, |
|
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
19998
diff
changeset
|
802 {"mbcs_decode", mbcs_decode, METH_VARARGS}, |
| 12074 | 803 #endif |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
18278
diff
changeset
|
804 #endif /* Py_USING_UNICODE */ |
|
25974
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
805 {"register_error", register_error, METH_VARARGS, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
806 register_error__doc__}, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
807 {"lookup_error", lookup_error, METH_VARARGS, |
|
040af9c736bb
Add docstrings to register, lookup, register_error
Walter Dörwald <walter@livinglogic.de>
parents:
25091
diff
changeset
|
808 lookup_error__doc__}, |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
809 {NULL, NULL} /* sentinel */ |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
810 }; |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
811 |
|
24471
f66b3a3509c7
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents:
24071
diff
changeset
|
812 PyMODINIT_FUNC |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13358
diff
changeset
|
813 init_codecs(void) |
|
11980
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
814 { |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
815 Py_InitModule("_codecs", _codecs_functions); |
|
a9b5a31ff8cb
Internal module _codecs -- Provides access to the codec registry and
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
816 } |
