home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / PYERRORS.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-02  |  5.3 KB  |  136 lines

  1. #ifndef Py_ERRORS_H
  2. #define Py_ERRORS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7.  
  8. /* Error handling definitions */
  9.  
  10. DL_IMPORT(void) PyErr_SetNone(PyObject *);
  11. DL_IMPORT(void) PyErr_SetObject(PyObject *, PyObject *);
  12. DL_IMPORT(void) PyErr_SetString(PyObject *, const char *);
  13. DL_IMPORT(PyObject *) PyErr_Occurred(void);
  14. DL_IMPORT(void) PyErr_Clear(void);
  15. DL_IMPORT(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
  16. DL_IMPORT(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
  17.  
  18. /* Error testing and normalization */
  19. DL_IMPORT(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
  20. DL_IMPORT(int) PyErr_ExceptionMatches(PyObject *);
  21. DL_IMPORT(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
  22.  
  23.  
  24. /* Predefined exceptions */
  25.  
  26. extern DL_IMPORT(PyObject *) PyExc_Exception;
  27. extern DL_IMPORT(PyObject *) PyExc_StopIteration;
  28. extern DL_IMPORT(PyObject *) PyExc_StandardError;
  29. extern DL_IMPORT(PyObject *) PyExc_ArithmeticError;
  30. extern DL_IMPORT(PyObject *) PyExc_LookupError;
  31.  
  32. extern DL_IMPORT(PyObject *) PyExc_AssertionError;
  33. extern DL_IMPORT(PyObject *) PyExc_AttributeError;
  34. extern DL_IMPORT(PyObject *) PyExc_EOFError;
  35. extern DL_IMPORT(PyObject *) PyExc_FloatingPointError;
  36. extern DL_IMPORT(PyObject *) PyExc_EnvironmentError;
  37. extern DL_IMPORT(PyObject *) PyExc_IOError;
  38. extern DL_IMPORT(PyObject *) PyExc_OSError;
  39. extern DL_IMPORT(PyObject *) PyExc_ImportError;
  40. extern DL_IMPORT(PyObject *) PyExc_IndexError;
  41. extern DL_IMPORT(PyObject *) PyExc_KeyError;
  42. extern DL_IMPORT(PyObject *) PyExc_KeyboardInterrupt;
  43. extern DL_IMPORT(PyObject *) PyExc_MemoryError;
  44. extern DL_IMPORT(PyObject *) PyExc_NameError;
  45. extern DL_IMPORT(PyObject *) PyExc_OverflowError;
  46. extern DL_IMPORT(PyObject *) PyExc_RuntimeError;
  47. extern DL_IMPORT(PyObject *) PyExc_NotImplementedError;
  48. extern DL_IMPORT(PyObject *) PyExc_SyntaxError;
  49. extern DL_IMPORT(PyObject *) PyExc_IndentationError;
  50. extern DL_IMPORT(PyObject *) PyExc_TabError;
  51. extern DL_IMPORT(PyObject *) PyExc_ReferenceError;
  52. extern DL_IMPORT(PyObject *) PyExc_SystemError;
  53. extern DL_IMPORT(PyObject *) PyExc_SystemExit;
  54. extern DL_IMPORT(PyObject *) PyExc_TypeError;
  55. extern DL_IMPORT(PyObject *) PyExc_UnboundLocalError;
  56. extern DL_IMPORT(PyObject *) PyExc_UnicodeError;
  57. extern DL_IMPORT(PyObject *) PyExc_ValueError;
  58. extern DL_IMPORT(PyObject *) PyExc_ZeroDivisionError;
  59. #ifdef MS_WINDOWS
  60. extern DL_IMPORT(PyObject *) PyExc_WindowsError;
  61. #endif
  62.  
  63. extern DL_IMPORT(PyObject *) PyExc_MemoryErrorInst;
  64.  
  65. /* Predefined warning categories */
  66. extern DL_IMPORT(PyObject *) PyExc_Warning;
  67. extern DL_IMPORT(PyObject *) PyExc_UserWarning;
  68. extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning;
  69. extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning;
  70. extern DL_IMPORT(PyObject *) PyExc_OverflowWarning;
  71. extern DL_IMPORT(PyObject *) PyExc_RuntimeWarning;
  72.  
  73.  
  74. /* Convenience functions */
  75.  
  76. extern DL_IMPORT(int) PyErr_BadArgument(void);
  77. extern DL_IMPORT(PyObject *) PyErr_NoMemory(void);
  78. extern DL_IMPORT(PyObject *) PyErr_SetFromErrno(PyObject *);
  79. extern DL_IMPORT(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *);
  80. extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...)
  81.             __attribute__((format(printf, 2, 3)));
  82. #ifdef MS_WINDOWS
  83. extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char *);
  84. extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int);
  85. #endif
  86.  
  87. /* Export the old function so that the existing API remains available: */
  88. extern DL_IMPORT(void) PyErr_BadInternalCall(void);
  89. extern DL_IMPORT(void) _PyErr_BadInternalCall(char *filename, int lineno);
  90. /* Mask the old API with a call to the new API for code compiled under
  91.    Python 2.0: */
  92. #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
  93.  
  94. /* Function to create a new exception */
  95. DL_IMPORT(PyObject *) PyErr_NewException(char *name, PyObject *base,
  96.                                          PyObject *dict);
  97. extern DL_IMPORT(void) PyErr_WriteUnraisable(PyObject *);
  98.  
  99. /* Issue a warning or exception */
  100. extern DL_IMPORT(int) PyErr_Warn(PyObject *, char *);
  101. extern DL_IMPORT(int) PyErr_WarnExplicit(PyObject *, char *,
  102.                      char *, int, char *, PyObject *);
  103.  
  104. /* In sigcheck.c or signalmodule.c */
  105. extern DL_IMPORT(int) PyErr_CheckSignals(void);
  106. extern DL_IMPORT(void) PyErr_SetInterrupt(void);
  107.  
  108. /* Support for adding program text to SyntaxErrors */
  109. extern DL_IMPORT(void) PyErr_SyntaxLocation(char *, int);
  110. extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
  111.  
  112. /* These APIs aren't really part of the error implementation, but
  113.    often needed to format error messages; the native C lib APIs are
  114.    not available on all platforms, which is why we provide emulations
  115.    for those platforms in Python/mysnprintf.c,
  116.    WARNING:  The return value of snprintf varies across platforms; do
  117.    not rely on any particular behavior; eventually the C99 defn may
  118.    be reliable.
  119. */
  120. #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
  121. # define HAVE_SNPRINTF
  122. # define snprintf _snprintf
  123. # define vsnprintf _vsnprintf
  124. #endif
  125.  
  126. #include <stdarg.h>
  127. extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)
  128.             __attribute__((format(printf, 3, 4)));
  129. extern DL_IMPORT(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
  130.             __attribute__((format(printf, 3, 0)));
  131.  
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* !Py_ERRORS_H */
  136.