Issue #9738: Document encodings of error and warning functions

This commit is contained in:
Victor Stinner 2010-12-27 01:49:26 +00:00
parent ab9d8d64a7
commit 555a24f206
3 changed files with 78 additions and 24 deletions

View file

@ -201,7 +201,9 @@ PyAPI_FUNC(PyObject *) PyErr_Format(
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
int, const char *);
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
int, const char *);
int ierr,
const char *filename /* decoded from UTF-8 */
);
#ifndef Py_LIMITED_API
/* XXX redeclare to use WSTRING */
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
@ -211,7 +213,10 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
PyObject *,int, PyObject *);
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
PyObject *,int, const char *);
PyObject *exc,
int ierr,
const char *filename /* decoded from UTF-8 */
);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
PyObject *,int, const Py_UNICODE *);
@ -243,27 +248,51 @@ int PySignal_SetWakeupFd(int fd);
#endif
/* Support for adding program text to SyntaxErrors */
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
PyAPI_FUNC(void) PyErr_SyntaxLocationEx(const char *, int, int);
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
PyAPI_FUNC(void) PyErr_SyntaxLocation(
const char *filename, /* decoded from the filesystem encoding */
int lineno);
PyAPI_FUNC(void) PyErr_SyntaxLocationEx(
const char *filename, /* decoded from the filesystem encoding */
int lineno,
int col_offset);
PyAPI_FUNC(PyObject *) PyErr_ProgramText(
const char *filename, /* decoded from the filesystem encoding */
int lineno);
/* 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 *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
const char *encoding, /* UTF-8 encoded string */
const char *object,
Py_ssize_t length,
Py_ssize_t start,
Py_ssize_t end,
const char *reason /* UTF-8 encoded string */
);
/* create a UnicodeEncodeError object */
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
const char *encoding, /* UTF-8 encoded string */
const Py_UNICODE *object,
Py_ssize_t length,
Py_ssize_t start,
Py_ssize_t end,
const char *reason /* UTF-8 encoded string */
);
#endif
/* create a UnicodeTranslateError object */
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
const Py_UNICODE *object,
Py_ssize_t length,
Py_ssize_t start,
Py_ssize_t end,
const char *reason /* UTF-8 encoded string */
);
#endif
/* get the encoding attribute */
@ -307,11 +336,17 @@ 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 *);
PyObject *exc,
const char *reason /* UTF-8 encoded string */
);
PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
PyObject *, const char *);
PyObject *exc,
const char *reason /* UTF-8 encoded string */
);
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
PyObject *, const char *);
PyObject *exc,
const char *reason /* UTF-8 encoded string */
);
/* These APIs aren't really part of the error implementation, but

View file

@ -8,10 +8,22 @@ extern "C" {
PyAPI_FUNC(PyObject*) _PyWarnings_Init(void);
#endif
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
PyAPI_FUNC(int) PyErr_WarnFormat(PyObject *, Py_ssize_t, const char *, ...);
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
const char *, PyObject *);
PyAPI_FUNC(int) PyErr_WarnEx(
PyObject *category,
const char *message, /* UTF-8 encoded string */
Py_ssize_t stack_level);
PyAPI_FUNC(int) PyErr_WarnFormat(
PyObject *category,
Py_ssize_t stack_level,
const char *format, /* ASCII-encoded string */
...);
PyAPI_FUNC(int) PyErr_WarnExplicit(
PyObject *category,
const char *message, /* UTF-8 encoded string */
const char *filename, /* UTF-8 encoded string */
int lineno,
const char *module, /* UTF-8 encoded string */
PyObject *registry);
/* DEPRECATED: Use PyErr_WarnEx() instead. */
#ifndef Py_LIMITED_API