| 
									
										
										
										
											2023-06-30 11:34:01 +02:00
										 |  |  | #ifndef Py_INTERNAL_CODECS_H
 | 
					
						
							|  |  |  | #define Py_INTERNAL_CODECS_H
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-21 19:15:52 +02:00
										 |  |  | #ifndef Py_BUILD_CORE
 | 
					
						
							|  |  |  | #  error "this header requires Py_BUILD_CORE define"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 15:25:36 -07:00
										 |  |  | #include "pycore_lock.h"          // PyMutex
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialize codecs-related state for the given interpreter, including
 | 
					
						
							|  |  |  |    registering the first codec search function. Must be called before any other | 
					
						
							|  |  |  |    PyCodec-related functions, and while only one thread is active. */ | 
					
						
							|  |  |  | extern PyStatus _PyCodec_InitRegistry(PyInterpreterState *interp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Finalize codecs-related state for the given interpreter. No PyCodec-related
 | 
					
						
							|  |  |  |    functions other than PyCodec_Unregister() may be called after this. */ | 
					
						
							|  |  |  | extern void _PyCodec_Fini(PyInterpreterState *interp); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-30 11:34:01 +02:00
										 |  |  | extern PyObject* _PyCodec_Lookup(const char *encoding); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-29 02:25:23 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Un-register the error handling callback function registered under | 
					
						
							|  |  |  |  * the given 'name'. Only custom error handlers can be un-registered. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * - Return -1 and set an exception if 'name' refers to a built-in | 
					
						
							|  |  |  |  *   error handling name (e.g., 'strict'), or if an error occurred. | 
					
						
							|  |  |  |  * - Return 0 if no custom error handler can be found for 'name'. | 
					
						
							|  |  |  |  * - Return 1 if the custom error handler was successfully removed. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern int _PyCodec_UnregisterError(const char *name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-30 11:34:01 +02:00
										 |  |  | /* Text codec specific encoding and decoding API.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Checks the encoding against a list of codecs which do not | 
					
						
							|  |  |  |    implement a str<->bytes encoding before attempting the | 
					
						
							|  |  |  |    operation. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Please note that these APIs are internal and should not | 
					
						
							|  |  |  |    be used in Python C extensions. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    XXX (ncoghlan): should we make these, or something like them, public | 
					
						
							|  |  |  |    in Python 3.5+? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern PyObject* _PyCodec_LookupTextEncoding( | 
					
						
							|  |  |  |    const char *encoding, | 
					
						
							|  |  |  |    const char *alternate_command); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern PyObject* _PyCodec_EncodeText( | 
					
						
							|  |  |  |    PyObject *object, | 
					
						
							|  |  |  |    const char *encoding, | 
					
						
							|  |  |  |    const char *errors); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern PyObject* _PyCodec_DecodeText( | 
					
						
							|  |  |  |    PyObject *object, | 
					
						
							|  |  |  |    const char *encoding, | 
					
						
							|  |  |  |    const char *errors); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* These two aren't actually text encoding specific, but _io.TextIOWrapper
 | 
					
						
							|  |  |  |  * is the only current API consumer. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern PyObject* _PyCodecInfo_GetIncrementalDecoder( | 
					
						
							|  |  |  |    PyObject *codec_info, | 
					
						
							|  |  |  |    const char *errors); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern PyObject* _PyCodecInfo_GetIncrementalEncoder( | 
					
						
							|  |  |  |    PyObject *codec_info, | 
					
						
							|  |  |  |    const char *errors); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 15:25:36 -07:00
										 |  |  | // Per-interpreter state used by codecs.c.
 | 
					
						
							|  |  |  | struct codecs_state { | 
					
						
							|  |  |  |     // A list of callable objects used to search for codecs.
 | 
					
						
							|  |  |  |     PyObject *search_path; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // A dict mapping codec names to codecs returned from a callable in
 | 
					
						
							|  |  |  |     // search_path.
 | 
					
						
							|  |  |  |     PyObject *search_cache; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // A dict mapping error handling strategies to functions to implement them.
 | 
					
						
							|  |  |  |     PyObject *error_registry; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef Py_GIL_DISABLED
 | 
					
						
							|  |  |  |     // Used to safely delete a specific item from search_path.
 | 
					
						
							|  |  |  |     PyMutex search_path_mutex; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Whether or not the rest of the state is initialized.
 | 
					
						
							|  |  |  |     int initialized; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-06-30 11:34:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif /* !Py_INTERNAL_CODECS_H */
 |