Debian Codegraph @

Include/internal/pycore_codecs.h

raw
1 #ifndef Py_INTERNAL_CODECS_H
2 #define Py_INTERNAL_CODECS_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #ifndef Py_BUILD_CORE
8 # error "this header requires Py_BUILD_CORE define"
9 #endif
10
11 #include "pycore_interp_structs.h" // struct codecs_state
12
13 /* Initialize codecs-related state for the given interpreter, including
14 registering the first codec search function. Must be called before any other
15 PyCodec-related functions, and while only one thread is active. */
16 extern PyStatus _PyCodec_InitRegistry(PyInterpreterState *interp);
17
18 /* Finalize codecs-related state for the given interpreter. No PyCodec-related
19 functions other than PyCodec_Unregister() may be called after this. */
20 extern void _PyCodec_Fini(PyInterpreterState *interp);
21
22 extern PyObject* _PyCodec_Lookup(const char *encoding);
23
24 /*
25 * Un-register the error handling callback function registered under
26 * the given 'name'. Only custom error handlers can be un-registered.
27 *
28 * - Return -1 and set an exception if 'name' refers to a built-in
29 * error handling name (e.g., 'strict'), or if an error occurred.
30 * - Return 0 if no custom error handler can be found for 'name'.
31 * - Return 1 if the custom error handler was successfully removed.
32 */
33 extern int _PyCodec_UnregisterError(const char *name);
34
35 /* Text codec specific encoding and decoding API.
36
37 Checks the encoding against a list of codecs which do not
38 implement a str<->bytes encoding before attempting the
39 operation.
40
41 Please note that these APIs are internal and should not
42 be used in Python C extensions.
43
44 XXX (ncoghlan): should we make these, or something like them, public
45 in Python 3.5+?
46
47 */
48 extern PyObject* _PyCodec_LookupTextEncoding(
49 const char *encoding,
50 const char *alternate_command);
51
52 extern PyObject* _PyCodec_EncodeText(
53 PyObject *object,
54 const char *encoding,
55 const char *errors);
56
57 extern PyObject* _PyCodec_DecodeText(
58 PyObject *object,
59 const char *encoding,
60 const char *errors);
61
62 /* These two aren't actually text encoding specific, but _io.TextIOWrapper
63 * is the only current API consumer.
64 */
65 extern PyObject* _PyCodecInfo_GetIncrementalDecoder(
66 PyObject *codec_info,
67 const char *errors);
68
69 extern PyObject* _PyCodecInfo_GetIncrementalEncoder(
70 PyObject *codec_info,
71 const char *errors);
72
73 #ifdef __cplusplus
74 }
75 #endif
76 #endif /* !Py_INTERNAL_CODECS_H */