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;
|
2007-06-13 13:57:12 -03:00
|
|
|
Py_ssize_t start;
|
|
|
|
Py_ssize_t end;
|
2006-05-27 09:29:24 -03:00
|
|
|
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)) \
|
2008-06-09 01:58:54 -03:00
|
|
|
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
|
2006-03-01 00:25:17 -04:00
|
|
|
: (char *)(((PyTypeObject*)(x))->tp_name))
|
|
|
|
|
|
|
|
#define PyExceptionInstance_Class(x) \
|
|
|
|
((PyInstance_Check((x)) \
|
|
|
|
? (PyObject*)((PyInstanceObject*)(x))->in_class \
|
|
|
|
: (PyObject*)((x)->ob_type)))
|
|
|
|
|
2009-05-16 23:52:09 -03:00
|
|
|
|
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
|
|
|
|
2008-03-17 14:36:12 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_BufferError;
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst;
|
2007-09-07 01:18:30 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
|
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;
|
Merged revisions 61750,61752,61754,61756,61760,61763,61768,61772,61775,61805,61809,61812,61819,61917,61920,61930,61933-61934 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61750 | christian.heimes | 2008-03-22 20:47:44 +0100 (Sat, 22 Mar 2008) | 1 line
Copied files from py3k w/o modifications
........
r61752 | christian.heimes | 2008-03-22 20:53:20 +0100 (Sat, 22 Mar 2008) | 7 lines
Take One
* Added initialization code, warnings, flags etc. to the appropriate places
* Added new buffer interface to string type
* Modified tests
* Modified Makefile.pre.in to compile the new files
* Added bytesobject.c to Python.h
........
r61754 | christian.heimes | 2008-03-22 21:22:19 +0100 (Sat, 22 Mar 2008) | 2 lines
Disabled bytearray.extend for now since it causes an infinite recursion
Fixed serveral unit tests
........
r61756 | christian.heimes | 2008-03-22 21:43:38 +0100 (Sat, 22 Mar 2008) | 5 lines
Added PyBytes support to several places:
str + bytearray
ord(bytearray)
bytearray(str, encoding)
........
r61760 | christian.heimes | 2008-03-22 21:56:32 +0100 (Sat, 22 Mar 2008) | 1 line
Fixed more unit tests related to type('') is not unicode
........
r61763 | christian.heimes | 2008-03-22 22:20:28 +0100 (Sat, 22 Mar 2008) | 2 lines
Fixed more unit tests
Fixed bytearray.extend
........
r61768 | christian.heimes | 2008-03-22 22:40:50 +0100 (Sat, 22 Mar 2008) | 1 line
Implemented old buffer interface for bytearray
........
r61772 | christian.heimes | 2008-03-22 23:24:52 +0100 (Sat, 22 Mar 2008) | 1 line
Added backport of the io module
........
r61775 | christian.heimes | 2008-03-23 03:50:49 +0100 (Sun, 23 Mar 2008) | 1 line
Fix str assignement to bytearray. Assignment of a str of size 1 is interpreted as a single byte
........
r61805 | christian.heimes | 2008-03-23 19:33:48 +0100 (Sun, 23 Mar 2008) | 3 lines
Fixed more tests
Fixed bytearray() comparsion with unicode()
Fixed iterator assignment of bytearray
........
r61809 | christian.heimes | 2008-03-23 21:02:21 +0100 (Sun, 23 Mar 2008) | 2 lines
str(bytesarray()) now returns the bytes and not the representation of the bytearray object
Enabled and fixed more unit tests
........
r61812 | christian.heimes | 2008-03-23 21:53:08 +0100 (Sun, 23 Mar 2008) | 3 lines
Clear error PyNumber_AsSsize_t() fails
Use CHARMASK for ob_svall access
disabled a test with memoryview again
........
r61819 | christian.heimes | 2008-03-23 23:05:57 +0100 (Sun, 23 Mar 2008) | 1 line
Untested updates to the PCBuild directory
........
r61917 | christian.heimes | 2008-03-26 00:57:06 +0100 (Wed, 26 Mar 2008) | 1 line
The type system of Python 2.6 has subtle differences to 3.0's. I've removed the Py_TPFLAGS_BASETYPE flags from bytearray for now. bytearray can't be subclasses until the issues with bytearray subclasses are fixed.
........
r61920 | christian.heimes | 2008-03-26 01:44:08 +0100 (Wed, 26 Mar 2008) | 2 lines
Disabled last failing test
I don't understand what the test is testing and how it suppose to work. Ka-Ping, please check it out.
........
r61930 | christian.heimes | 2008-03-26 12:46:18 +0100 (Wed, 26 Mar 2008) | 1 line
Re-enabled bytes warning code
........
r61933 | christian.heimes | 2008-03-26 13:20:46 +0100 (Wed, 26 Mar 2008) | 1 line
Fixed a bug in the new buffer protocol. The buffer slots weren't copied into a subclass.
........
r61934 | christian.heimes | 2008-03-26 13:25:09 +0100 (Wed, 26 Mar 2008) | 1 line
Re-enabled bytearray subclassing - all tests are passing.
........
2008-03-26 09:49:49 -03:00
|
|
|
PyAPI_DATA(PyObject *) PyExc_BytesWarning;
|
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 *);
|
2009-06-12 17:57:12 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
|
|
|
|
PyObject *, const char *);
|
2009-05-16 23:52:09 -03:00
|
|
|
#ifdef MS_WINDOWS
|
2002-10-03 02:10:39 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
2009-06-12 17:57:12 -03:00
|
|
|
PyObject *, const Py_UNICODE *);
|
2009-05-16 23:52:09 -03:00
|
|
|
#endif /* MS_WINDOWS */
|
2002-10-03 02:10:39 -03:00
|
|
|
|
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 *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
|
|
|
int, const Py_UNICODE *);
|
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
|
|
|
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
|
|
|
PyObject *,int, const Py_UNICODE *);
|
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 */
|
2009-12-28 04:34:58 -04:00
|
|
|
PyAPI_FUNC(PyObject *) PyErr_NewException(
|
|
|
|
char *name, PyObject *base, PyObject *dict);
|
|
|
|
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
|
|
|
|
char *name, char *doc, PyObject *base, PyObject *dict);
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
1997-09-16 18:50:37 -03: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
|
|
|
|
2007-12-19 15:41:06 -04:00
|
|
|
/* In signalmodule.c */
|
|
|
|
int PySignal_SetWakeupFd(int fd);
|
|
|
|
|
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 */
|