1993-07-28 06:05:47 -03:00
|
|
|
#ifndef Py_ERRORS_H
|
|
|
|
#define Py_ERRORS_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-05-27 09:29:24 -03:00
|
|
|
/* Error objects */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
} PyBaseExceptionObject;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
PyObject *msg;
|
|
|
|
PyObject *filename;
|
|
|
|
PyObject *lineno;
|
|
|
|
PyObject *offset;
|
|
|
|
PyObject *text;
|
|
|
|
PyObject *print_file_and_line;
|
|
|
|
} PySyntaxErrorObject;
|
|
|
|
|
|
|
|
#ifdef Py_USING_UNICODE
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
PyObject *encoding;
|
|
|
|
PyObject *object;
|
|
|
|
PyObject *start;
|
|
|
|
PyObject *end;
|
|
|
|
PyObject *reason;
|
|
|
|
} PyUnicodeErrorObject;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
PyObject *code;
|
|
|
|
} PySystemExitObject;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
PyObject *myerrno;
|
|
|
|
PyObject *strerror;
|
|
|
|
PyObject *filename;
|
|
|
|
} PyEnvironmentErrorObject;
|
|
|
|
|
|
|
|
#ifdef MS_WINDOWS
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *message;
|
|
|
|
PyObject *myerrno;
|
|
|
|
PyObject *strerror;
|
|
|
|
PyObject *filename;
|
|
|
|
PyObject *winerror;
|
|
|
|
} PyWindowsErrorObject;
|
|
|
|
#endif
|
1991-02-19 08:39:46 -04:00
|
|
|
|
1990-10-14 09:07:46 -03:00
|
|
|
/* Error handling definitions */
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
|
|
|
|
PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
|
|
|
|
PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
|
|
|
|
PyAPI_FUNC(void) PyErr_Clear(void);
|
|
|
|
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
|
|
|
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
1990-10-14 09:07:46 -03:00
|
|
|
|
2005-08-06 15:31:24 -03:00
|
|
|
#ifdef Py_DEBUG
|
|
|
|
#define _PyErr_OCCURRED() PyErr_Occurred()
|
|
|
|
#else
|
|
|
|
#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
|
|
|
|
#endif
|
|
|
|
|
Three new C API functions:
- int PyErr_GivenExceptionMatches(obj1, obj2)
Returns 1 if obj1 and obj2 are the same object, or if obj1 is an
instance of type obj2, or of a class derived from obj2
- int PyErr_ExceptionMatches(obj)
Higher level wrapper around PyErr_GivenExceptionMatches() which uses
PyErr_Occurred() as obj1. This will be the more commonly called
function.
- void PyErr_NormalizeException(typeptr, valptr, tbptr)
Normalizes exceptions, and places the normalized values in the
arguments. If type is not a class, this does nothing. If type is a
class, then it makes sure that value is an instance of the class by:
1. if instance is of the type, or a class derived from type, it does
nothing.
2. otherwise it instantiates the class, using the value as an
argument. If value is None, it uses an empty arg tuple, and if
the value is a tuple, it uses just that.
1997-08-22 18:22:58 -03:00
|
|
|
/* Error testing and normalization */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
|
|
|
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
|
|
|
|
PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
Three new C API functions:
- int PyErr_GivenExceptionMatches(obj1, obj2)
Returns 1 if obj1 and obj2 are the same object, or if obj1 is an
instance of type obj2, or of a class derived from obj2
- int PyErr_ExceptionMatches(obj)
Higher level wrapper around PyErr_GivenExceptionMatches() which uses
PyErr_Occurred() as obj1. This will be the more commonly called
function.
- void PyErr_NormalizeException(typeptr, valptr, tbptr)
Normalizes exceptions, and places the normalized values in the
arguments. If type is not a class, this does nothing. If type is a
class, then it makes sure that value is an instance of the class by:
1. if instance is of the type, or a class derived from type, it does
nothing.
2. otherwise it instantiates the class, using the value as an
argument. If value is None, it uses an empty arg tuple, and if
the value is a tuple, it uses just that.
1997-08-22 18:22:58 -03:00
|
|
|
|
2006-03-01 00:25:17 -04:00
|
|
|
/* */
|
Three new C API functions:
- int PyErr_GivenExceptionMatches(obj1, obj2)
Returns 1 if obj1 and obj2 are the same object, or if obj1 is an
instance of type obj2, or of a class derived from obj2
- int PyErr_ExceptionMatches(obj)
Higher level wrapper around PyErr_GivenExceptionMatches() which uses
PyErr_Occurred() as obj1. This will be the more commonly called
function.
- void PyErr_NormalizeException(typeptr, valptr, tbptr)
Normalizes exceptions, and places the normalized values in the
arguments. If type is not a class, this does nothing. If type is a
class, then it makes sure that value is an instance of the class by:
1. if instance is of the type, or a class derived from type, it does
nothing.
2. otherwise it instantiates the class, using the value as an
argument. If value is None, it uses an empty arg tuple, and if
the value is a tuple, it uses just that.
1997-08-22 18:22:58 -03:00
|
|
|
|
2006-03-01 00:25:17 -04:00
|
|
|
#define PyExceptionClass_Check(x) \
|
2007-02-25 15:44:48 -04:00
|
|
|
(PyClass_Check((x)) || (PyType_Check((x)) && \
|
|
|
|
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)))
|
2006-03-01 00:25:17 -04:00
|
|
|
|
|
|
|
#define PyExceptionInstance_Check(x) \
|
|
|
|
(PyInstance_Check((x)) || \
|
2007-02-25 15:44:48 -04:00
|
|
|
PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS))
|
2006-03-01 00:25:17 -04:00
|
|
|
|
|
|
|
#define PyExceptionClass_Name(x) \
|
|
|
|
(PyClass_Check((x)) \
|
|
|
|
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
|
|
|
|
: (char *)(((PyTypeObject*)(x))->tp_name))
|
|
|
|
|
|
|
|
#define PyExceptionInstance_Class(x) \
|
|
|
|
((PyInstance_Check((x)) \
|
|
|
|
? (PyObject*)((PyInstanceObject*)(x))->in_class \
|
|
|
|
: (PyObject*)((x)->ob_type)))
|
|
|
|
|
|
|
|
|
1990-12-20 11:06:42 -04:00
|
|
|
/* Predefined exceptions */
|
1990-10-14 17:00:25 -03:00
|
|
|
|
2006-03-01 00:25:17 -04:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_BaseException;
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_Exception;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_StopIteration;
|
2005-08-01 21:46:46 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_StandardError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_LookupError;
|
|
|
|
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_AssertionError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_AttributeError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_EOFError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_IOError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_OSError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_ImportError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_IndexError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_KeyError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_MemoryError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_NameError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_OverflowError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_RuntimeError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_IndentationError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_TabError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_SystemError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_SystemExit;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_TypeError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnicodeError;
|
2002-09-02 10:14:32 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_ValueError;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
|
2000-02-17 11:17:18 -04:00
|
|
|
#ifdef MS_WINDOWS
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_WindowsError;
|
2000-02-17 11:17:18 -04:00
|
|
|
#endif
|
2002-12-06 08:48:53 -04:00
|
|
|
#ifdef __VMS
|
2003-07-01 17:15:21 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_VMSError;
|
2002-12-06 08:48:53 -04:00
|
|
|
#endif
|
1990-10-21 19:09:30 -03:00
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst;
|
1997-08-29 18:56:07 -03:00
|
|
|
|
2000-12-15 17:57:34 -04:00
|
|
|
/* Predefined warning categories */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_Warning;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_UserWarning;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
|
|
|
|
PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
|
2002-08-14 12:51:29 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_FutureWarning;
|
2006-04-27 20:13:20 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_ImportWarning;
|
2006-08-14 07:55:19 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
|
2000-12-15 17:57:34 -04:00
|
|
|
|
1997-08-29 18:56:07 -03:00
|
|
|
|
1990-10-14 17:00:25 -03:00
|
|
|
/* Convenience functions */
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyErr_BadArgument(void);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
|
2002-10-03 02:10:39 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
|
|
|
|
PyObject *, PyObject *);
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *);
|
2002-10-03 02:10:39 -03:00
|
|
|
#ifdef Py_WIN_WIDE_FILENAMES
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
|
|
|
PyObject *, Py_UNICODE *);
|
|
|
|
#endif /* Py_WIN_WIDE_FILENAMES */
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...)
|
2002-09-15 11:09:54 -03:00
|
|
|
Py_GCC_ATTRIBUTE((format(printf, 2, 3)));
|
2002-10-03 02:10:39 -03:00
|
|
|
|
2000-02-17 11:17:18 -04:00
|
|
|
#ifdef MS_WINDOWS
|
2002-10-03 02:10:39 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
|
|
|
|
int, const char *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
|
|
|
|
int, const char *);
|
|
|
|
#ifdef Py_WIN_WIDE_FILENAMES
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
|
|
|
int, const Py_UNICODE *);
|
|
|
|
#endif /* Py_WIN_WIDE_FILENAMES */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
2002-10-03 02:10:39 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
|
|
|
PyObject *,int, PyObject *);
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
|
2002-07-29 11:27:41 -03:00
|
|
|
PyObject *,int, const char *);
|
2002-10-03 02:10:39 -03:00
|
|
|
#ifdef Py_WIN_WIDE_FILENAMES
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
|
|
|
PyObject *,int, const Py_UNICODE *);
|
|
|
|
#endif /* Py_WIN_WIDE_FILENAMES */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
2002-10-03 02:10:39 -03:00
|
|
|
#endif /* MS_WINDOWS */
|
1990-10-21 19:09:30 -03:00
|
|
|
|
2000-08-24 19:38:39 -03:00
|
|
|
/* Export the old function so that the existing API remains available: */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(void) PyErr_BadInternalCall(void);
|
|
|
|
PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno);
|
2000-08-24 19:38:39 -03:00
|
|
|
/* Mask the old API with a call to the new API for code compiled under
|
|
|
|
Python 2.0: */
|
|
|
|
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
|
1993-05-19 11:50:45 -03:00
|
|
|
|
1997-09-16 18:50:37 -03:00
|
|
|
/* Function to create a new exception */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_NewException(char *name, PyObject *base,
|
2000-07-08 14:25:55 -03:00
|
|
|
PyObject *dict);
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
1997-09-16 18:50:37 -03:00
|
|
|
|
2000-12-15 17:57:34 -04:00
|
|
|
/* Issue a warning or exception */
|
2006-07-30 03:55:48 -03:00
|
|
|
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
|
|
|
|
Py_ssize_t stack_level);
|
2002-12-11 10:04:59 -04:00
|
|
|
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
|
|
|
|
const char *, int,
|
|
|
|
const char *, PyObject *);
|
2006-07-30 03:55:48 -03:00
|
|
|
/* PyErr_Warn is only for backwards compatability and will be removed.
|
|
|
|
Use PyErr_WarnEx instead. */
|
|
|
|
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
|
2000-12-15 17:57:34 -04:00
|
|
|
|
1997-01-02 20:15:03 -04:00
|
|
|
/* In sigcheck.c or signalmodule.c */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
|
|
|
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
2001-02-28 13:47:12 -04:00
|
|
|
|
|
|
|
/* Support for adding program text to SyntaxErrors */
|
2002-12-11 10:04:59 -04:00
|
|
|
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
|
2001-11-28 12:51:49 -04:00
|
|
|
|
2002-11-21 16:08:33 -04:00
|
|
|
#ifdef Py_USING_UNICODE
|
2002-09-02 10:14:32 -03:00
|
|
|
/* The following functions are used to create and modify unicode
|
|
|
|
exceptions from C */
|
2002-11-21 16:08:33 -04:00
|
|
|
|
2002-09-02 10:14:32 -03:00
|
|
|
/* create a UnicodeDecodeError object */
|
|
|
|
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
2006-02-15 13:27:45 -04:00
|
|
|
const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* create a UnicodeEncodeError object */
|
|
|
|
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
|
2006-02-15 13:27:45 -04:00
|
|
|
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* create a UnicodeTranslateError object */
|
|
|
|
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
|
2006-02-15 13:27:45 -04:00
|
|
|
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* get the encoding attribute */
|
|
|
|
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_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 */
|
2006-02-15 13:27:45 -04:00
|
|
|
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* assign a new value to the start attribute
|
|
|
|
return 0 on success, -1 on failure */
|
2006-02-15 13:27:45 -04:00
|
|
|
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* get the value of the end attribute (the int *may not be NULL)
|
|
|
|
return 0 on success, -1 on failure */
|
2006-02-15 13:27:45 -04:00
|
|
|
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* assign a new value to the end attribute
|
|
|
|
return 0 on success, -1 on failure */
|
2006-02-15 13:27:45 -04:00
|
|
|
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
|
|
|
|
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
/* 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 *);
|
2002-11-21 16:08:33 -04:00
|
|
|
#endif
|
2002-09-02 10:14:32 -03:00
|
|
|
|
|
|
|
|
2001-07-31 10:24:44 -03:00
|
|
|
/* These APIs aren't really part of the error implementation, but
|
|
|
|
often needed to format error messages; the native C lib APIs are
|
|
|
|
not available on all platforms, which is why we provide emulations
|
2001-11-28 12:51:49 -04:00
|
|
|
for those platforms in Python/mysnprintf.c,
|
|
|
|
WARNING: The return value of snprintf varies across platforms; do
|
|
|
|
not rely on any particular behavior; eventually the C99 defn may
|
|
|
|
be reliable.
|
|
|
|
*/
|
2001-07-31 10:24:44 -03:00
|
|
|
#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
|
|
|
|
# define HAVE_SNPRINTF
|
|
|
|
# define snprintf _snprintf
|
|
|
|
# define vsnprintf _vsnprintf
|
|
|
|
#endif
|
2001-07-31 15:05:33 -03:00
|
|
|
|
2001-07-31 11:23:52 -03:00
|
|
|
#include <stdarg.h>
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
|
2002-09-15 11:09:54 -03:00
|
|
|
Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
|
2002-09-15 11:09:54 -03:00
|
|
|
Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
|
1994-08-01 08:34:53 -03:00
|
|
|
|
1993-07-28 06:05:47 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_ERRORS_H */
|