annotate Include/codecs.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents d68df99d7a57
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #ifndef Py_CODECREGISTRY_H
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 #define Py_CODECREGISTRY_H
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #ifdef __cplusplus
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 extern "C" {
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #endif
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 /* ------------------------------------------------------------------------
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 Python Codec Registry and support functions
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 Written by Marc-Andre Lemburg (mal@lemburg.com).
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
13828
254f8b7c4a83 Changing the CNRI copyright notice according to CNRI's instructions.
Guido van Rossum <guido@python.org>
parents: 12642
diff changeset
14 Copyright (c) Corporation for National Research Initiatives.
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 ------------------------------------------------------------------------ */
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
18 /* Register a new codec search function.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
19
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
20 As side effect, this tries to load the encodings package, if not
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
21 yet done, to make sure that it is always first in the list of
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
22 search functions.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
23
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
24 The search_function's refcount is incremented by this function. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
25
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
26 PyAPI_FUNC(int) PyCodec_Register(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 PyObject *search_function
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
30 /* Codec registry lookup API.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
31
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
32 Looks up the given encoding and returns a CodecInfo object with
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
33 function attributes which implement the different aspects of
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
34 processing the encoding.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
35
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
36 The encoding string is looked up converted to all lower-case
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
37 characters. This makes encodings looked up through this mechanism
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
38 effectively case-insensitive.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
39
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
40 If no codec is found, a KeyError is set and NULL returned.
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
41
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
42 As side effect, this tries to load the encodings package, if not
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
43 yet done. This is part of the lazy load strategy for the encodings
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
44 package.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
45
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
46 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
47
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66277
diff changeset
48 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
49 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 );
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 66277
diff changeset
52 #endif
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
47496
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
54 /* Codec registry encoding check API.
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
55
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
56 Returns 1/0 depending on whether there is a registered codec for
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
57 the given encoding.
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
58
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
59 */
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
60
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
61 PyAPI_FUNC(int) PyCodec_KnownEncoding(
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
62 const char *encoding
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
63 );
2284fa89ab08 Move the codec decode type checks to bytes/bytearray.decode().
Marc-André Lemburg <mal@egenix.com>
parents: 36996
diff changeset
64
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
65 /* Generic codec based encoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
66
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
67 object is passed through the encoder function found for the given
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
68 encoding using the error handling method defined by errors. errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
69 may be NULL to use the default method defined for the codec.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
70
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
71 Raises a LookupError in case no encoder can be found.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
72
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
73 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
74
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
75 PyAPI_FUNC(PyObject *) PyCodec_Encode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
76 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
77 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
78 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
79 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
80
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
81 /* Generic codec based decoding API.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
82
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
83 object is passed through the decoder function found for the given
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
84 encoding using the error handling method defined by errors. errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
85 may be NULL to use the default method defined for the codec.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
86
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
87 Raises a LookupError in case no encoder can be found.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
88
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
89 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
90
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
91 PyAPI_FUNC(PyObject *) PyCodec_Decode(
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
92 PyObject *object,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
93 const char *encoding,
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
94 const char *errors
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
95 );
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
96
87338
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
97 #ifndef PY_LIMITED_API
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
98 /* Text codec specific encoding and decoding API.
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
99
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
100 Checks the encoding against a list of codecs which do not
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
101 implement a str<->bytes encoding before attempting the
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
102 operation.
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
103
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
104 Please note that these APIs are internal and should not
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
105 be used in Python C extensions.
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
106
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
107 */
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
108
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
109 PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
110 PyObject *object,
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
111 const char *encoding,
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
112 const char *errors
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
113 );
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
114
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
115 PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
116 PyObject *object,
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
117 const char *encoding,
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
118 const char *errors
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
119 );
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
120 #endif
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
121
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
122
d68df99d7a57 Issue #19619: Blacklist non-text codecs in method API
Nick Coghlan <ncoghlan@gmail.com>
parents: 72941
diff changeset
123
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
124 /* --- Codec Lookup APIs --------------------------------------------------
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
125
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
126 All APIs return a codec object with incremented refcount and are
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
127 based on _PyCodec_Lookup(). The same comments w/r to the encoding
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
128 name also apply to these APIs.
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
129
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
130 */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
131
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
132 /* Get an encoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
133
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
134 PyAPI_FUNC(PyObject *) PyCodec_Encoder(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
137
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
138 /* Get a decoder function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
139
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
140 PyAPI_FUNC(PyObject *) PyCodec_Decoder(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 const char *encoding
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
143
36996
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
144 /* Get a IncrementalEncoder object for the given encoding. */
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
145
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
146 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
147 const char *encoding,
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
148 const char *errors
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
149 );
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
150
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
151 /* Get a IncrementalDecoder object function for the given encoding. */
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
152
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
153 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
154 const char *encoding,
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
155 const char *errors
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
156 );
7fa4c29d7030 Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
Walter Dörwald <walter@livinglogic.de>
parents: 25091
diff changeset
157
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
158 /* Get a StreamReader factory function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
159
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
160 PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 const char *encoding,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 PyObject *stream,
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
166 /* Get a StreamWriter factory function for the given encoding. */
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
167
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 13828
diff changeset
168 PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 const char *encoding,
12642
91b2ec207633 M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents: 11961
diff changeset
170 PyObject *stream,
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 const char *errors
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
172 );
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
173
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
174 /* Unicode encoding error handling callback registry API */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
175
66277
debc76641912 #10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
176 /* Register the error handling callback function error under the given
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
177 name. This function will be called by the codec when it encounters
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
178 unencodable characters/undecodable bytes and doesn't know the
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
179 callback name, when name is specified as the error parameter
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
180 in the call to the encode/decode function.
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
181 Return 0 on success, -1 on error */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
182 PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
183
66277
debc76641912 #10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
184 /* Lookup the error handling callback function registered under the given
debc76641912 #10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
185 name. As a special case NULL can be passed, in which case
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
186 the error handling callback for "strict" will be returned. */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
187 PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
188
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
189 /* raise exc as an exception */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
190 PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
191
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
192 /* ignore the unicode error, skipping the faulty input */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
193 PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
194
66277
debc76641912 #10439: document PyCodec C APIs.
Georg Brandl <georg@python.org>
parents: 47496
diff changeset
195 /* replace the unicode encode error with ? or U+FFFD */
25091
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
196 PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
197
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
198 /* replace the unicode encode error with XML character references */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
199 PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
200
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
201 /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
202 PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
0337dad8403e PEP 293 implemention (from SF patch http://www.python.org/sf/432401)
Walter Dörwald <walter@livinglogic.de>
parents: 24752
diff changeset
203
72941
c63087ac1f6c Fix build under Windows
Antoine Pitrou <solipsis@pitrou.net>
parents: 72918
diff changeset
204 PyAPI_DATA(const char *) Py_hexdigits;
72918
d76338eacf7c Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
Victor Stinner <victor.stinner@haypocalc.com>
parents: 66664
diff changeset
205
11961
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
206 #ifdef __cplusplus
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 }
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 #endif
9d53fc8043ba Python Codec Registry and support functions, by Marc-Andre Lemburg.
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 #endif /* !Py_CODECREGISTRY_H */