[Python-checkins] python/dist/src/Include codecs.h,2.4,2.5 pyerrors.h,2.57,2.58

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Mon, 02 Sep 2002 06:14:32 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv19683/Include

Modified Files:
	codecs.h pyerrors.h 
Log Message:
PEP 293 implemention (from SF patch http://www.python.org/sf/432401)


Index: codecs.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/codecs.h,v
retrieving revision 2.4
retrieving revision 2.5
diff -C2 -d -r2.4 -r2.5
*** codecs.h	12 Aug 2002 07:21:56 -0000	2.4
--- codecs.h	2 Sep 2002 13:14:30 -0000	2.5
***************
*** 118,121 ****
--- 118,151 ----
         );
  
+ /* Unicode encoding error handling callback registry API */
+ 
+ /* Register the error handling callback function error under the name
+    name. This function will be called by the codec when it encounters
+    unencodable characters/undecodable bytes and doesn't know the
+    callback name, when name is specified as the error parameter
+    in the call to the encode/decode function.
+    Return 0 on success, -1 on error */
+ PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
+ 
+ /* Lookup the error handling callback function registered under the
+    name error. As a special case NULL can be passed, in which case
+    the error handling callback for "strict" will be returned. */
+ PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
+ 
+ /* raise exc as an exception */
+ PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
+ 
+ /* ignore the unicode error, skipping the faulty input */
+ PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
+ 
+ /* replace the unicode error with ? or U+FFFD */
+ PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
+ 
+ /* replace the unicode encode error with XML character references */
+ PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
+ 
+ /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
+ PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
+ 
  #ifdef __cplusplus
  }

Index: pyerrors.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyerrors.h,v
retrieving revision 2.57
retrieving revision 2.58
diff -C2 -d -r2.57 -r2.58
*** pyerrors.h	14 Aug 2002 15:51:28 -0000	2.57
--- pyerrors.h	2 Sep 2002 13:14:30 -0000	2.58
***************
*** 55,58 ****
--- 55,61 ----
  PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
  PyAPI_DATA(PyObject *) PyExc_UnicodeError;
+ PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
+ PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
+ PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
  PyAPI_DATA(PyObject *) PyExc_ValueError;
  PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
***************
*** 114,117 ****
--- 117,183 ----
  PyAPI_FUNC(void) PyErr_SyntaxLocation(char *, int);
  PyAPI_FUNC(PyObject *) PyErr_ProgramText(char *, int);
+ 
+ /* The following functions are used to create and modify unicode
+    exceptions from C */
+ /* create a UnicodeDecodeError object */
+ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
+ 	const char *, const char *, int, int, int, const char *);
+ 
+ /* create a UnicodeEncodeError object */
+ PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
+ 	const char *, const Py_UNICODE *, int, int, int, const char *);
+ 
+ /* create a UnicodeTranslateError object */
+ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
+ 	const Py_UNICODE *, int, int, int, const char *);
+ 
+ /* get the encoding attribute */
+ PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetEncoding(PyObject *);
+ 
+ /* get the object attribute */
+ PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
+ 
+ /* get the value of the start attribute (the int * may not be NULL)
+    return 0 on success, -1 on failure */
+ PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, int *);
+ PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, int *);
+ PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, int *);
+ 
+ /* assign a new value to the start attribute
+    return 0 on success, -1 on failure */
+ PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, int);
+ PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, int);
+ PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, int);
+ 
+ /* get the value of the end attribute (the int *may not be NULL)
+  return 0 on success, -1 on failure */
+ PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, int *);
+ PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, int *);
+ PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, int *);
+ 
+ /* assign a new value to the end attribute
+    return 0 on success, -1 on failure */
+ PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, int);
+ PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, int);
+ PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, int);
+ 
+ /* get the value of the reason attribute */
+ PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
+ PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
+ 
+ /* assign a new value to the reason attribute
+    return 0 on success, -1 on failure */
+ PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
+ 	PyObject *, const char *);
+ PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
+ 	PyObject *, const char *);
+ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
+ 	PyObject *, const char *);
+ 
  
  /* These APIs aren't really part of the error implementation, but