Back to index

python3.2  3.2.2
Defines | Functions | Variables
exceptions.c File Reference
#include <Python.h>
#include "structmember.h"
#include "osdefs.h"

Go to the source code of this file.

Defines

#define PY_SSIZE_T_CLEAN
#define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC)
#define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC)
#define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC)
#define MEMERRORS_SAVE   16
#define PRE_INIT(TYPE)
#define POST_INIT(TYPE)

Functions

static PyObjectBaseException_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static int BaseException_init (PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
static int BaseException_clear (PyBaseExceptionObject *self)
static void BaseException_dealloc (PyBaseExceptionObject *self)
static int BaseException_traverse (PyBaseExceptionObject *self, visitproc visit, void *arg)
static PyObjectBaseException_str (PyBaseExceptionObject *self)
static PyObjectBaseException_repr (PyBaseExceptionObject *self)
static PyObjectBaseException_reduce (PyBaseExceptionObject *self)
static PyObjectBaseException_setstate (PyObject *self, PyObject *state)
static PyObjectBaseException_with_traceback (PyObject *self, PyObject *tb)
 PyDoc_STRVAR (with_traceback_doc,"Exception.with_traceback(tb) --\n\ set self.__traceback__ to tb and return self.")
static PyObjectBaseException_get_dict (PyBaseExceptionObject *self)
static int BaseException_set_dict (PyBaseExceptionObject *self, PyObject *val)
static PyObjectBaseException_get_args (PyBaseExceptionObject *self)
static int BaseException_set_args (PyBaseExceptionObject *self, PyObject *val)
static PyObjectBaseException_get_tb (PyBaseExceptionObject *self)
static int BaseException_set_tb (PyBaseExceptionObject *self, PyObject *tb)
static PyObjectBaseException_get_context (PyObject *self)
static int BaseException_set_context (PyObject *self, PyObject *arg)
static PyObjectBaseException_get_cause (PyObject *self)
static int BaseException_set_cause (PyObject *self, PyObject *arg)
PyObjectPyException_GetTraceback (PyObject *self)
int PyException_SetTraceback (PyObject *self, PyObject *tb)
PyObjectPyException_GetCause (PyObject *self)
void PyException_SetCause (PyObject *self, PyObject *cause)
PyObjectPyException_GetContext (PyObject *self)
void PyException_SetContext (PyObject *self, PyObject *context)
 SimpleExtendsException (PyExc_BaseException, Exception,"Common base class for all non-exit exceptions.")
 SimpleExtendsException (PyExc_Exception, TypeError,"Inappropriate argument type.")
 SimpleExtendsException (PyExc_Exception, StopIteration,"Signal the end from iterator.__next__().")
 SimpleExtendsException (PyExc_BaseException, GeneratorExit,"Request that a generator exit.")
static int SystemExit_init (PySystemExitObject *self, PyObject *args, PyObject *kwds)
static int SystemExit_clear (PySystemExitObject *self)
static void SystemExit_dealloc (PySystemExitObject *self)
static int SystemExit_traverse (PySystemExitObject *self, visitproc visit, void *arg)
 ComplexExtendsException (PyExc_BaseException, SystemExit, SystemExit, SystemExit_dealloc, 0, SystemExit_members, 0,"Request to exit from the interpreter.")
 SimpleExtendsException (PyExc_BaseException, KeyboardInterrupt,"Program interrupted by user.")
 SimpleExtendsException (PyExc_Exception, ImportError,"Import can't find module, or can't find name in module.")
static int EnvironmentError_init (PyEnvironmentErrorObject *self, PyObject *args, PyObject *kwds)
static int EnvironmentError_clear (PyEnvironmentErrorObject *self)
static void EnvironmentError_dealloc (PyEnvironmentErrorObject *self)
static int EnvironmentError_traverse (PyEnvironmentErrorObject *self, visitproc visit, void *arg)
static PyObjectEnvironmentError_str (PyEnvironmentErrorObject *self)
static PyObjectEnvironmentError_reduce (PyEnvironmentErrorObject *self)
 ComplexExtendsException (PyExc_Exception, EnvironmentError, EnvironmentError, EnvironmentError_dealloc, EnvironmentError_methods, EnvironmentError_members, EnvironmentError_str,"Base class for I/O related errors.")
 MiddlingExtendsException (PyExc_EnvironmentError, IOError, EnvironmentError,"I/O operation failed.")
 MiddlingExtendsException (PyExc_EnvironmentError, OSError, EnvironmentError,"OS system call failed.")
 SimpleExtendsException (PyExc_Exception, EOFError,"Read beyond end of file.")
 SimpleExtendsException (PyExc_Exception, RuntimeError,"Unspecified run-time error.")
 SimpleExtendsException (PyExc_RuntimeError, NotImplementedError,"Method or function hasn't been implemented yet.")
 SimpleExtendsException (PyExc_Exception, NameError,"Name not found globally.")
 SimpleExtendsException (PyExc_NameError, UnboundLocalError,"Local name referenced but not bound to a value.")
 SimpleExtendsException (PyExc_Exception, AttributeError,"Attribute not found.")
static int SyntaxError_init (PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
static int SyntaxError_clear (PySyntaxErrorObject *self)
static void SyntaxError_dealloc (PySyntaxErrorObject *self)
static int SyntaxError_traverse (PySyntaxErrorObject *self, visitproc visit, void *arg)
static PyObjectmy_basename (PyObject *name)
static PyObjectSyntaxError_str (PySyntaxErrorObject *self)
 ComplexExtendsException (PyExc_Exception, SyntaxError, SyntaxError, SyntaxError_dealloc, 0, SyntaxError_members, SyntaxError_str,"Invalid syntax.")
 MiddlingExtendsException (PyExc_SyntaxError, IndentationError, SyntaxError,"Improper indentation.")
 MiddlingExtendsException (PyExc_IndentationError, TabError, SyntaxError,"Improper mixture of spaces and tabs.")
 SimpleExtendsException (PyExc_Exception, LookupError,"Base class for lookup errors.")
 SimpleExtendsException (PyExc_LookupError, IndexError,"Sequence index out of range.")
static PyObjectKeyError_str (PyBaseExceptionObject *self)
 ComplexExtendsException (PyExc_LookupError, KeyError, BaseException, 0, 0, 0, KeyError_str,"Mapping key not found.")
 SimpleExtendsException (PyExc_Exception, ValueError,"Inappropriate argument value (of correct type).")
 SimpleExtendsException (PyExc_ValueError, UnicodeError,"Unicode related error.")
static PyObjectget_string (PyObject *attr, const char *name)
static PyObjectget_unicode (PyObject *attr, const char *name)
static int set_unicodefromstring (PyObject **attr, const char *value)
PyObjectPyUnicodeEncodeError_GetEncoding (PyObject *exc)
PyObjectPyUnicodeDecodeError_GetEncoding (PyObject *exc)
PyObjectPyUnicodeEncodeError_GetObject (PyObject *exc)
PyObjectPyUnicodeDecodeError_GetObject (PyObject *exc)
PyObjectPyUnicodeTranslateError_GetObject (PyObject *exc)
int PyUnicodeEncodeError_GetStart (PyObject *exc, Py_ssize_t *start)
int PyUnicodeDecodeError_GetStart (PyObject *exc, Py_ssize_t *start)
int PyUnicodeTranslateError_GetStart (PyObject *exc, Py_ssize_t *start)
int PyUnicodeEncodeError_SetStart (PyObject *exc, Py_ssize_t start)
int PyUnicodeDecodeError_SetStart (PyObject *exc, Py_ssize_t start)
int PyUnicodeTranslateError_SetStart (PyObject *exc, Py_ssize_t start)
int PyUnicodeEncodeError_GetEnd (PyObject *exc, Py_ssize_t *end)
int PyUnicodeDecodeError_GetEnd (PyObject *exc, Py_ssize_t *end)
int PyUnicodeTranslateError_GetEnd (PyObject *exc, Py_ssize_t *start)
int PyUnicodeEncodeError_SetEnd (PyObject *exc, Py_ssize_t end)
int PyUnicodeDecodeError_SetEnd (PyObject *exc, Py_ssize_t end)
int PyUnicodeTranslateError_SetEnd (PyObject *exc, Py_ssize_t end)
PyObjectPyUnicodeEncodeError_GetReason (PyObject *exc)
PyObjectPyUnicodeDecodeError_GetReason (PyObject *exc)
PyObjectPyUnicodeTranslateError_GetReason (PyObject *exc)
int PyUnicodeEncodeError_SetReason (PyObject *exc, const char *reason)
int PyUnicodeDecodeError_SetReason (PyObject *exc, const char *reason)
int PyUnicodeTranslateError_SetReason (PyObject *exc, const char *reason)
static int UnicodeError_clear (PyUnicodeErrorObject *self)
static void UnicodeError_dealloc (PyUnicodeErrorObject *self)
static int UnicodeError_traverse (PyUnicodeErrorObject *self, visitproc visit, void *arg)
static int UnicodeEncodeError_init (PyObject *self, PyObject *args, PyObject *kwds)
static PyObjectUnicodeEncodeError_str (PyObject *self)
PyObjectPyUnicodeEncodeError_Create (const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
static int UnicodeDecodeError_init (PyObject *self, PyObject *args, PyObject *kwds)
static PyObjectUnicodeDecodeError_str (PyObject *self)
PyObjectPyUnicodeDecodeError_Create (const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
static int UnicodeTranslateError_init (PyUnicodeErrorObject *self, PyObject *args, PyObject *kwds)
static PyObjectUnicodeTranslateError_str (PyObject *self)
PyObjectPyUnicodeTranslateError_Create (const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
 SimpleExtendsException (PyExc_Exception, AssertionError,"Assertion failed.")
 SimpleExtendsException (PyExc_Exception, ArithmeticError,"Base class for arithmetic errors.")
 SimpleExtendsException (PyExc_ArithmeticError, FloatingPointError,"Floating point operation failed.")
 SimpleExtendsException (PyExc_ArithmeticError, OverflowError,"Result too large to be represented.")
 SimpleExtendsException (PyExc_ArithmeticError, ZeroDivisionError,"Second argument to a division or modulo operation was zero.")
 SimpleExtendsException (PyExc_Exception, SystemError,"Internal error in the Python interpreter.\n""\n""Please report this to the Python maintainer, along with the traceback,\n""the Python version, and the hardware/OS platform and version.")
 SimpleExtendsException (PyExc_Exception, ReferenceError,"Weak ref proxy used after referent went away.")
static PyObjectMemoryError_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static void MemoryError_dealloc (PyBaseExceptionObject *self)
static void preallocate_memerrors (void)
static void free_preallocated_memerrors (void)
 SimpleExtendsException (PyExc_Exception, BufferError,"Buffer error.")
 SimpleExtendsException (PyExc_Exception, Warning,"Base class for warning categories.")
 SimpleExtendsException (PyExc_Warning, UserWarning,"Base class for warnings generated by user code.")
 SimpleExtendsException (PyExc_Warning, DeprecationWarning,"Base class for warnings about deprecated features.")
 SimpleExtendsException (PyExc_Warning, PendingDeprecationWarning,"Base class for warnings about features which will be deprecated\n""in the future.")
 SimpleExtendsException (PyExc_Warning, SyntaxWarning,"Base class for warnings about dubious syntax.")
 SimpleExtendsException (PyExc_Warning, RuntimeWarning,"Base class for warnings about dubious runtime behavior.")
 SimpleExtendsException (PyExc_Warning, FutureWarning,"Base class for warnings about constructs that will change semantically\n""in the future.")
 SimpleExtendsException (PyExc_Warning, ImportWarning,"Base class for warnings about probable mistakes in module imports")
 SimpleExtendsException (PyExc_Warning, UnicodeWarning,"Base class for warnings about Unicode related problems, mostly\n""related to conversion problems.")
 SimpleExtendsException (PyExc_Warning, BytesWarning,"Base class for warnings about bytes and buffer related problems, mostly\n""related to conversion from str or comparing to str.")
 SimpleExtendsException (PyExc_Warning, ResourceWarning,"Base class for warnings about resource usage.")
void _PyExc_Init (void)
void _PyExc_Fini (void)

Variables

static PyMethodDef BaseException_methods []
static PyGetSetDef BaseException_getset []
static PyTypeObject _PyExc_BaseException
PyObjectPyExc_BaseException = (PyObject *)&_PyExc_BaseException
static PyMemberDef SystemExit_members []
static PyMemberDef EnvironmentError_members []
static PyMethodDef EnvironmentError_methods []
static PyMemberDef SyntaxError_members []
static PyMemberDef UnicodeError_members []
static PyTypeObject _PyExc_UnicodeEncodeError
PyObjectPyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError
static PyTypeObject _PyExc_UnicodeDecodeError
PyObjectPyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError
static PyTypeObject _PyExc_UnicodeTranslateError
PyObjectPyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError
static PyBaseExceptionObjectmemerrors_freelist = NULL
static int memerrors_numfree = 0
static PyTypeObject _PyExc_MemoryError
PyObjectPyExc_MemoryError = (PyObject *) &_PyExc_MemoryError
PyObjectPyExc_RecursionErrorInst = NULL

Define Documentation

#define ComplexExtendsException (   EXCBASE,
  EXCNAME,
  EXCSTORE,
  EXCDEALLOC,
  EXCMETHODS,
  EXCMEMBERS,
  EXCSTR,
  EXCDOC 
)
Value:
static PyTypeObject _PyExc_ ## EXCNAME = { \
    PyVarObject_HEAD_INIT(NULL, 0) \
    # EXCNAME, \
    sizeof(Py ## EXCSTORE ## Object), 0, \
    (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
    (reprfunc)EXCSTR, 0, 0, 0, \
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
    PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \
    (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, EXCMETHODS, \
    EXCMEMBERS, 0, &_ ## EXCBASE, \
    0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \
    (initproc)EXCSTORE ## _init, 0, BaseException_new,\
}; \
PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME

Definition at line 440 of file exceptions.c.

#define MEMERRORS_SAVE   16

Definition at line 1781 of file exceptions.c.

#define MiddlingExtendsException (   EXCBASE,
  EXCNAME,
  EXCSTORE,
  EXCDOC 
)
Value:
static PyTypeObject _PyExc_ ## EXCNAME = { \
    PyVarObject_HEAD_INIT(NULL, 0) \
    # EXCNAME, \
    sizeof(Py ## EXCSTORE ## Object), \
    0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
    0, 0, 0, 0, 0, \
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
    PyDoc_STR(EXCDOC), (traverseproc)EXCSTORE ## _traverse, \
    (inquiry)EXCSTORE ## _clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
    0, 0, 0, offsetof(Py ## EXCSTORE ## Object, dict), \
    (initproc)EXCSTORE ## _init, 0, BaseException_new,\
}; \
PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME

Definition at line 425 of file exceptions.c.

#define POST_INIT (   TYPE)
Value:
Py_INCREF(PyExc_ ## TYPE); \
    if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \
        Py_FatalError("Module dictionary insertion problem.");

Definition at line 1965 of file exceptions.c.

#define PRE_INIT (   TYPE)
Value:
if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
    Py_FatalError("exceptions bootstrapping error.");

Definition at line 1962 of file exceptions.c.

Definition at line 7 of file exceptions.c.

#define SimpleExtendsException (   EXCBASE,
  EXCNAME,
  EXCDOC 
)
Value:
static PyTypeObject _PyExc_ ## EXCNAME = { \
    PyVarObject_HEAD_INIT(NULL, 0) \
    # EXCNAME, \
    sizeof(PyBaseExceptionObject), \
    0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \
    0, 0, 0, 0, 0, 0, 0, \
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
    PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \
    (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
    0, 0, 0, offsetof(PyBaseExceptionObject, dict), \
    (initproc)BaseException_init, 0, BaseException_new,\
}; \
PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME

Definition at line 410 of file exceptions.c.


Function Documentation

Definition at line 2123 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1971 of file exceptions.c.

{
    PyObject *bltinmod, *bdict;

    PRE_INIT(BaseException)
    PRE_INIT(Exception)
    PRE_INIT(TypeError)
    PRE_INIT(StopIteration)
    PRE_INIT(GeneratorExit)
    PRE_INIT(SystemExit)
    PRE_INIT(KeyboardInterrupt)
    PRE_INIT(ImportError)
    PRE_INIT(EnvironmentError)
    PRE_INIT(IOError)
    PRE_INIT(OSError)
#ifdef MS_WINDOWS
    PRE_INIT(WindowsError)
#endif
#ifdef __VMS
    PRE_INIT(VMSError)
#endif
    PRE_INIT(EOFError)
    PRE_INIT(RuntimeError)
    PRE_INIT(NotImplementedError)
    PRE_INIT(NameError)
    PRE_INIT(UnboundLocalError)
    PRE_INIT(AttributeError)
    PRE_INIT(SyntaxError)
    PRE_INIT(IndentationError)
    PRE_INIT(TabError)
    PRE_INIT(LookupError)
    PRE_INIT(IndexError)
    PRE_INIT(KeyError)
    PRE_INIT(ValueError)
    PRE_INIT(UnicodeError)
    PRE_INIT(UnicodeEncodeError)
    PRE_INIT(UnicodeDecodeError)
    PRE_INIT(UnicodeTranslateError)
    PRE_INIT(AssertionError)
    PRE_INIT(ArithmeticError)
    PRE_INIT(FloatingPointError)
    PRE_INIT(OverflowError)
    PRE_INIT(ZeroDivisionError)
    PRE_INIT(SystemError)
    PRE_INIT(ReferenceError)
    PRE_INIT(BufferError)
    PRE_INIT(MemoryError)
    PRE_INIT(BufferError)
    PRE_INIT(Warning)
    PRE_INIT(UserWarning)
    PRE_INIT(DeprecationWarning)
    PRE_INIT(PendingDeprecationWarning)
    PRE_INIT(SyntaxWarning)
    PRE_INIT(RuntimeWarning)
    PRE_INIT(FutureWarning)
    PRE_INIT(ImportWarning)
    PRE_INIT(UnicodeWarning)
    PRE_INIT(BytesWarning)
    PRE_INIT(ResourceWarning)

    bltinmod = PyImport_ImportModule("builtins");
    if (bltinmod == NULL)
        Py_FatalError("exceptions bootstrapping error.");
    bdict = PyModule_GetDict(bltinmod);
    if (bdict == NULL)
        Py_FatalError("exceptions bootstrapping error.");

    POST_INIT(BaseException)
    POST_INIT(Exception)
    POST_INIT(TypeError)
    POST_INIT(StopIteration)
    POST_INIT(GeneratorExit)
    POST_INIT(SystemExit)
    POST_INIT(KeyboardInterrupt)
    POST_INIT(ImportError)
    POST_INIT(EnvironmentError)
    POST_INIT(IOError)
    POST_INIT(OSError)
#ifdef MS_WINDOWS
    POST_INIT(WindowsError)
#endif
#ifdef __VMS
    POST_INIT(VMSError)
#endif
    POST_INIT(EOFError)
    POST_INIT(RuntimeError)
    POST_INIT(NotImplementedError)
    POST_INIT(NameError)
    POST_INIT(UnboundLocalError)
    POST_INIT(AttributeError)
    POST_INIT(SyntaxError)
    POST_INIT(IndentationError)
    POST_INIT(TabError)
    POST_INIT(LookupError)
    POST_INIT(IndexError)
    POST_INIT(KeyError)
    POST_INIT(ValueError)
    POST_INIT(UnicodeError)
    POST_INIT(UnicodeEncodeError)
    POST_INIT(UnicodeDecodeError)
    POST_INIT(UnicodeTranslateError)
    POST_INIT(AssertionError)
    POST_INIT(ArithmeticError)
    POST_INIT(FloatingPointError)
    POST_INIT(OverflowError)
    POST_INIT(ZeroDivisionError)
    POST_INIT(SystemError)
    POST_INIT(ReferenceError)
    POST_INIT(BufferError)
    POST_INIT(MemoryError)
    POST_INIT(BufferError)
    POST_INIT(Warning)
    POST_INIT(UserWarning)
    POST_INIT(DeprecationWarning)
    POST_INIT(PendingDeprecationWarning)
    POST_INIT(SyntaxWarning)
    POST_INIT(RuntimeWarning)
    POST_INIT(FutureWarning)
    POST_INIT(ImportWarning)
    POST_INIT(UnicodeWarning)
    POST_INIT(BytesWarning)
    POST_INIT(ResourceWarning)

    preallocate_memerrors();

    PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
    if (!PyExc_RecursionErrorInst)
        Py_FatalError("Cannot pre-allocate RuntimeError instance for "
                        "recursion errors");
    else {
        PyBaseExceptionObject *err_inst =
            (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
        PyObject *args_tuple;
        PyObject *exc_message;
        exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
        if (!exc_message)
            Py_FatalError("cannot allocate argument for RuntimeError "
                            "pre-allocation");
        args_tuple = PyTuple_Pack(1, exc_message);
        if (!args_tuple)
            Py_FatalError("cannot allocate tuple for RuntimeError "
                            "pre-allocation");
        Py_DECREF(exc_message);
        if (BaseException_init(err_inst, args_tuple, NULL))
            Py_FatalError("init of pre-allocated RuntimeError failed");
        Py_DECREF(args_tuple);
    }

    Py_DECREF(bltinmod);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int BaseException_clear ( PyBaseExceptionObject self) [static]

Definition at line 55 of file exceptions.c.

{
    Py_CLEAR(self->dict);
    Py_CLEAR(self->args);
    Py_CLEAR(self->traceback);
    Py_CLEAR(self->cause);
    Py_CLEAR(self->context);
    return 0;
}

Here is the caller graph for this function:

static void BaseException_dealloc ( PyBaseExceptionObject self) [static]

Definition at line 66 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    BaseException_clear(self);
    Py_TYPE(self)->tp_free((PyObject *)self);
}

Here is the call graph for this function:

Definition at line 197 of file exceptions.c.

{
    if (self->args == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    Py_INCREF(self->args);
    return self->args;
}
static PyObject* BaseException_get_cause ( PyObject self) [static]

Definition at line 279 of file exceptions.c.

                                        {
    PyObject *res = PyException_GetCause(self);
    if (res) return res;  /* new reference already returned above */
    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* BaseException_get_context ( PyObject self) [static]

Definition at line 253 of file exceptions.c.

                                          {
    PyObject *res = PyException_GetContext(self);
    if (res) return res;  /* new reference already returned above */
    Py_RETURN_NONE;
}

Here is the call graph for this function:

Definition at line 168 of file exceptions.c.

{
    if (self->dict == NULL) {
        self->dict = PyDict_New();
        if (!self->dict)
            return NULL;
    }
    Py_INCREF(self->dict);
    return self->dict;
}

Here is the call graph for this function:

static PyObject* BaseException_get_tb ( PyBaseExceptionObject self) [static]

Definition at line 223 of file exceptions.c.

{
    if (self->traceback == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    Py_INCREF(self->traceback);
    return self->traceback;
}
static int BaseException_init ( PyBaseExceptionObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 42 of file exceptions.c.

{
    if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
        return -1;

    Py_DECREF(self->args);
    self->args = args;
    Py_INCREF(self->args);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* BaseException_new ( PyTypeObject type,
PyObject args,
PyObject kwds 
) [static]

Definition at line 21 of file exceptions.c.

{
    PyBaseExceptionObject *self;

    self = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
    if (!self)
        return NULL;
    /* the dict is created on the fly in PyObject_GenericSetAttr */
    self->dict = NULL;
    self->traceback = self->cause = self->context = NULL;

    self->args = PyTuple_New(0);
    if (!self->args) {
        Py_DECREF(self);
        return NULL;
    }

    return (PyObject *)self;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* BaseException_reduce ( PyBaseExceptionObject self) [static]

Definition at line 112 of file exceptions.c.

{
    if (self->args && self->dict)
        return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
    else
        return PyTuple_Pack(2, Py_TYPE(self), self->args);
}

Here is the call graph for this function:

static PyObject* BaseException_repr ( PyBaseExceptionObject self) [static]

Definition at line 98 of file exceptions.c.

{
    char *name;
    char *dot;

    name = (char *)Py_TYPE(self)->tp_name;
    dot = strrchr(name, '.');
    if (dot != NULL) name = dot+1;

    return PyUnicode_FromFormat("%s%R", name, self->args);
}
static int BaseException_set_args ( PyBaseExceptionObject self,
PyObject val 
) [static]

Definition at line 208 of file exceptions.c.

{
    PyObject *seq;
    if (val == NULL) {
        PyErr_SetString(PyExc_TypeError, "args may not be deleted");
        return -1;
    }
    seq = PySequence_Tuple(val);
    if (!seq) return -1;
    Py_CLEAR(self->args);
    self->args = seq;
    return 0;
}

Here is the call graph for this function:

static int BaseException_set_cause ( PyObject self,
PyObject arg 
) [static]

Definition at line 286 of file exceptions.c.

                                                       {
    if (arg == NULL) {
        PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted");
        return -1;
    } else if (arg == Py_None) {
        arg = NULL;
    } else if (!PyExceptionInstance_Check(arg)) {
        PyErr_SetString(PyExc_TypeError, "exception cause must be None "
                        "or derive from BaseException");
        return -1;
    } else {
        /* PyException_SetCause steals this reference */
        Py_INCREF(arg);
    }
    PyException_SetCause(self, arg);
    return 0;
}

Here is the call graph for this function:

static int BaseException_set_context ( PyObject self,
PyObject arg 
) [static]

Definition at line 260 of file exceptions.c.

                                                         {
    if (arg == NULL) {
        PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted");
        return -1;
    } else if (arg == Py_None) {
        arg = NULL;
    } else if (!PyExceptionInstance_Check(arg)) {
        PyErr_SetString(PyExc_TypeError, "exception context must be None "
                        "or derive from BaseException");
        return -1;
    } else {
        /* PyException_SetContext steals this reference */
        Py_INCREF(arg);
    }
    PyException_SetContext(self, arg);
    return 0;
}

Here is the call graph for this function:

static int BaseException_set_dict ( PyBaseExceptionObject self,
PyObject val 
) [static]

Definition at line 180 of file exceptions.c.

{
    if (val == NULL) {
        PyErr_SetString(PyExc_TypeError, "__dict__ may not be deleted");
        return -1;
    }
    if (!PyDict_Check(val)) {
        PyErr_SetString(PyExc_TypeError, "__dict__ must be a dictionary");
        return -1;
    }
    Py_CLEAR(self->dict);
    Py_INCREF(val);
    self->dict = val;
    return 0;
}

Here is the call graph for this function:

static int BaseException_set_tb ( PyBaseExceptionObject self,
PyObject tb 
) [static]

Definition at line 234 of file exceptions.c.

{
    if (tb == NULL) {
        PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted");
        return -1;
    }
    else if (!(tb == Py_None || PyTraceBack_Check(tb))) {
        PyErr_SetString(PyExc_TypeError,
                        "__traceback__ must be a traceback or None");
        return -1;
    }

    Py_XINCREF(tb);
    Py_XDECREF(self->traceback);
    self->traceback = tb;
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* BaseException_setstate ( PyObject self,
PyObject state 
) [static]

Definition at line 126 of file exceptions.c.

{
    PyObject *d_key, *d_value;
    Py_ssize_t i = 0;

    if (state != Py_None) {
        if (!PyDict_Check(state)) {
            PyErr_SetString(PyExc_TypeError, "state is not a dictionary");
            return NULL;
        }
        while (PyDict_Next(state, &i, &d_key, &d_value)) {
            if (PyObject_SetAttr(self, d_key, d_value) < 0)
                return NULL;
        }
    }
    Py_RETURN_NONE;
}

Here is the call graph for this function:

static PyObject* BaseException_str ( PyBaseExceptionObject self) [static]

Definition at line 85 of file exceptions.c.

{
    switch (PyTuple_GET_SIZE(self->args)) {
    case 0:
        return PyUnicode_FromString("");
    case 1:
        return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
    default:
        return PyObject_Str(self->args);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int BaseException_traverse ( PyBaseExceptionObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 74 of file exceptions.c.

{
    Py_VISIT(self->dict);
    Py_VISIT(self->args);
    Py_VISIT(self->traceback);
    Py_VISIT(self->cause);
    Py_VISIT(self->context);
    return 0;
}

Here is the caller graph for this function:

static PyObject* BaseException_with_traceback ( PyObject self,
PyObject tb 
) [static]

Definition at line 145 of file exceptions.c.

                                                           {
    if (PyException_SetTraceback(self, tb))
        return NULL;

    Py_INCREF(self);
    return self;
}

Here is the call graph for this function:

ComplexExtendsException ( PyExc_BaseException  ,
SystemExit  ,
SystemExit  ,
SystemExit_dealloc  ,
,
SystemExit_members  ,
,
"Request to exit from the interpreter."   
)
ComplexExtendsException ( PyExc_Exception  ,
EnvironmentError  ,
EnvironmentError  ,
EnvironmentError_dealloc  ,
EnvironmentError_methods  ,
EnvironmentError_members  ,
EnvironmentError_str  ,
"Base class for I/O related errors."   
)
ComplexExtendsException ( PyExc_Exception  ,
SyntaxError  ,
SyntaxError  ,
SyntaxError_dealloc  ,
,
SyntaxError_members  ,
SyntaxError_str  ,
"Invalid syntax."   
)
ComplexExtendsException ( PyExc_LookupError  ,
KeyError  ,
BaseException  ,
,
,
,
KeyError_str  ,
"Mapping key not found."   
)

Definition at line 612 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 621 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    EnvironmentError_clear(self);
    Py_TYPE(self)->tp_free((PyObject *)self);
}

Here is the call graph for this function:

static int EnvironmentError_init ( PyEnvironmentErrorObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 570 of file exceptions.c.

{
    PyObject *myerrno = NULL, *strerror = NULL, *filename = NULL;
    PyObject *subslice = NULL;

    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) {
        return 0;
    }

    if (!PyArg_UnpackTuple(args, "EnvironmentError", 2, 3,
                           &myerrno, &strerror, &filename)) {
        return -1;
    }
    Py_CLEAR(self->myerrno);       /* replacing */
    self->myerrno = myerrno;
    Py_INCREF(self->myerrno);

    Py_CLEAR(self->strerror);      /* replacing */
    self->strerror = strerror;
    Py_INCREF(self->strerror);

    /* self->filename will remain Py_None otherwise */
    if (filename != NULL) {
        Py_CLEAR(self->filename);      /* replacing */
        self->filename = filename;
        Py_INCREF(self->filename);

        subslice = PyTuple_GetSlice(args, 0, 2);
        if (!subslice)
            return -1;

        Py_DECREF(self->args);  /* replacing args */
        self->args = subslice;
    }
    return 0;
}

Here is the call graph for this function:

Definition at line 666 of file exceptions.c.

{
    PyObject *args = self->args;
    PyObject *res = NULL, *tmp;

    /* self->args is only the first two real arguments if there was a
     * file name given to EnvironmentError. */
    if (PyTuple_GET_SIZE(args) == 2 && self->filename) {
        args = PyTuple_New(3);
        if (!args) return NULL;

        tmp = PyTuple_GET_ITEM(self->args, 0);
        Py_INCREF(tmp);
        PyTuple_SET_ITEM(args, 0, tmp);

        tmp = PyTuple_GET_ITEM(self->args, 1);
        Py_INCREF(tmp);
        PyTuple_SET_ITEM(args, 1, tmp);

        Py_INCREF(self->filename);
        PyTuple_SET_ITEM(args, 2, self->filename);
    } else
        Py_INCREF(args);

    if (self->dict)
        res = PyTuple_Pack(3, Py_TYPE(self), args, self->dict);
    else
        res = PyTuple_Pack(2, Py_TYPE(self), args);
    Py_DECREF(args);
    return res;
}

Here is the call graph for this function:

Definition at line 639 of file exceptions.c.

{
    if (self->filename)
        return PyUnicode_FromFormat("[Errno %S] %S: %R",
                                    self->myerrno ? self->myerrno: Py_None,
                                    self->strerror ? self->strerror: Py_None,
                                    self->filename);
    else if (self->myerrno && self->strerror)
        return PyUnicode_FromFormat("[Errno %S] %S",
                                    self->myerrno ? self->myerrno: Py_None,
                                    self->strerror ? self->strerror: Py_None);
    else
        return BaseException_str((PyBaseExceptionObject *)self);
}

Here is the call graph for this function:

static int EnvironmentError_traverse ( PyEnvironmentErrorObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 629 of file exceptions.c.

Here is the call graph for this function:

static void free_preallocated_memerrors ( void  ) [static]

Definition at line 1841 of file exceptions.c.

Here is the caller graph for this function:

static PyObject* get_string ( PyObject attr,
const char *  name 
) [static]

Definition at line 1118 of file exceptions.c.

{
    if (!attr) {
        PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name);
        return NULL;
    }

    if (!PyBytes_Check(attr)) {
        PyErr_Format(PyExc_TypeError, "%.200s attribute must be bytes", name);
        return NULL;
    }
    Py_INCREF(attr);
    return attr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* get_unicode ( PyObject attr,
const char *  name 
) [static]

Definition at line 1134 of file exceptions.c.

{
    if (!attr) {
        PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name);
        return NULL;
    }

    if (!PyUnicode_Check(attr)) {
        PyErr_Format(PyExc_TypeError,
                     "%.200s attribute must be unicode", name);
        return NULL;
    }
    Py_INCREF(attr);
    return attr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* KeyError_str ( PyBaseExceptionObject self) [static]

Definition at line 1083 of file exceptions.c.

{
    /* If args is a tuple of exactly one item, apply repr to args[0].
       This is done so that e.g. the exception raised by {}[''] prints
         KeyError: ''
       rather than the confusing
         KeyError
       alone.  The downside is that if KeyError is raised with an explanatory
       string, that string will be displayed in quotes.  Too bad.
       If args is anything else, use the default BaseException__str__().
    */
    if (PyTuple_GET_SIZE(self->args) == 1) {
        return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0));
    }
    return BaseException_str(self);
}

Here is the call graph for this function:

static void MemoryError_dealloc ( PyBaseExceptionObject self) [static]

Definition at line 1809 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    BaseException_clear(self);
    if (memerrors_numfree >= MEMERRORS_SAVE)
        Py_TYPE(self)->tp_free((PyObject *)self);
    else {
        self->dict = (PyObject *) memerrors_freelist;
        memerrors_freelist = self;
        memerrors_numfree++;
    }
}

Here is the call graph for this function:

static PyObject* MemoryError_new ( PyTypeObject type,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1786 of file exceptions.c.

{
    PyBaseExceptionObject *self;

    if (type != (PyTypeObject *) PyExc_MemoryError)
        return BaseException_new(type, args, kwds);
    if (memerrors_freelist == NULL)
        return BaseException_new(type, args, kwds);
    /* Fetch object from freelist and revive it */
    self = memerrors_freelist;
    self->args = PyTuple_New(0);
    /* This shouldn't happen since the empty tuple is persistent */
    if (self->args == NULL)
        return NULL;
    memerrors_freelist = (PyBaseExceptionObject *) self->dict;
    memerrors_numfree--;
    self->dict = NULL;
    _Py_NewReference((PyObject *)self);
    _PyObject_GC_TRACK(self);
    return (PyObject *)self;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MiddlingExtendsException ( PyExc_EnvironmentError  ,
IOError  ,
EnvironmentError  ,
"I/O operation failed."   
)
MiddlingExtendsException ( PyExc_EnvironmentError  ,
OSError  ,
EnvironmentError  ,
"OS system call failed."   
)
MiddlingExtendsException ( PyExc_SyntaxError  ,
IndentationError  ,
SyntaxError  ,
"Improper indentation."   
)
MiddlingExtendsException ( PyExc_IndentationError  ,
TabError  ,
SyntaxError  ,
"Improper mixture of spaces and tabs."   
)
static PyObject* my_basename ( PyObject name) [static]

Definition at line 963 of file exceptions.c.

{
    Py_UNICODE *unicode;
    Py_ssize_t i, size, offset;

    unicode = PyUnicode_AS_UNICODE(name);
    size = PyUnicode_GET_SIZE(name);
    offset = 0;
    for(i=0; i < size; i++) {
        if (unicode[i] == SEP)
            offset = i + 1;
    }
    if (offset != 0) {
        return PyUnicode_FromUnicode(
            PyUnicode_AS_UNICODE(name) + offset,
            size - offset);
    } else {
        Py_INCREF(name);
        return name;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void preallocate_memerrors ( void  ) [static]

Definition at line 1823 of file exceptions.c.

{
    /* We create enough MemoryErrors and then decref them, which will fill
       up the freelist. */
    int i;
    PyObject *errors[MEMERRORS_SAVE];
    for (i = 0; i < MEMERRORS_SAVE; i++) {
        errors[i] = MemoryError_new((PyTypeObject *) PyExc_MemoryError,
                                    NULL, NULL);
        if (!errors[i])
            Py_FatalError("Could not preallocate MemoryError object");
    }
    for (i = 0; i < MEMERRORS_SAVE; i++) {
        Py_DECREF(errors[i]);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyDoc_STRVAR ( with_traceback_doc  ,
"Exception.with_traceback(tb) --\n\ set self.__traceback__ to tb and return self."   
)

Definition at line 331 of file exceptions.c.

                                     {
    PyObject *cause = ((PyBaseExceptionObject *)self)->cause;
    Py_XINCREF(cause);
    return cause;
}

Here is the caller graph for this function:

Definition at line 346 of file exceptions.c.

                                       {
    PyObject *context = ((PyBaseExceptionObject *)self)->context;
    Py_XINCREF(context);
    return context;
}

Here is the caller graph for this function:

Definition at line 318 of file exceptions.c.

                                         {
    PyBaseExceptionObject *base_self = (PyBaseExceptionObject *)self;
    Py_XINCREF(base_self->traceback);
    return base_self->traceback;
}

Here is the caller graph for this function:

void PyException_SetCause ( PyObject self,
PyObject cause 
)

Definition at line 339 of file exceptions.c.

                                                      {
    PyObject *old_cause = ((PyBaseExceptionObject *)self)->cause;
    ((PyBaseExceptionObject *)self)->cause = cause;
    Py_XDECREF(old_cause);
}

Here is the caller graph for this function:

void PyException_SetContext ( PyObject self,
PyObject context 
)

Definition at line 354 of file exceptions.c.

                                                          {
    PyObject *old_context = ((PyBaseExceptionObject *)self)->context;
    ((PyBaseExceptionObject *)self)->context = context;
    Py_XDECREF(old_context);
}

Here is the caller graph for this function:

Definition at line 326 of file exceptions.c.

                                                       {
    return BaseException_set_tb((PyBaseExceptionObject *)self, tb);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyObject* PyUnicodeDecodeError_Create ( const char *  encoding,
const char *  object,
Py_ssize_t  length,
Py_ssize_t  start,
Py_ssize_t  end,
const char *  reason 
)

Definition at line 1621 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1168 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding");
}

Here is the call graph for this function:

Definition at line 1279 of file exceptions.c.

{
    Py_ssize_t size;
    PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
    if (!obj)
        return -1;
    size = PyBytes_GET_SIZE(obj);
    *end = ((PyUnicodeErrorObject *)exc)->end;
    if (*end<1)
        *end = 1;
    if (*end>size)
        *end = size;
    Py_DECREF(obj);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1180 of file exceptions.c.

{
    return get_string(((PyUnicodeErrorObject *)exc)->object, "object");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1334 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
}

Here is the call graph for this function:

Definition at line 1211 of file exceptions.c.

{
    Py_ssize_t size;
    PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
    if (!obj)
        return -1;
    size = PyBytes_GET_SIZE(obj);
    *start = ((PyUnicodeErrorObject *)exc)->start;
    if (*start<0)
        *start = 0;
    if (*start>=size)
        *start = size-1;
    Py_DECREF(obj);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1312 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->end = end;
    return 0;
}

Here is the caller graph for this function:

int PyUnicodeDecodeError_SetReason ( PyObject exc,
const char *  reason 
)

Definition at line 1356 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1244 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->start = start;
    return 0;
}

Here is the caller graph for this function:

PyObject* PyUnicodeEncodeError_Create ( const char *  encoding,
const Py_UNICODE object,
Py_ssize_t  length,
Py_ssize_t  start,
Py_ssize_t  end,
const char *  reason 
)

Definition at line 1509 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1162 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->encoding, "encoding");
}

Here is the call graph for this function:

Definition at line 1260 of file exceptions.c.

{
    Py_ssize_t size;
    PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object,
                                "object");
    if (!obj)
        return -1;
    *end = ((PyUnicodeErrorObject *)exc)->end;
    size = PyUnicode_GET_SIZE(obj);
    if (*end<1)
        *end = 1;
    if (*end>size)
        *end = size;
    Py_DECREF(obj);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1174 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1327 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
}

Here is the call graph for this function:

Definition at line 1192 of file exceptions.c.

{
    Py_ssize_t size;
    PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object,
                                "object");
    if (!obj)
        return -1;
    *start = ((PyUnicodeErrorObject *)exc)->start;
    size = PyUnicode_GET_SIZE(obj);
    if (*start<0)
        *start = 0; /*XXX check for values <0*/
    if (*start>=size)
        *start = size-1;
    Py_DECREF(obj);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1304 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->end = end;
    return 0;
}

Here is the caller graph for this function:

int PyUnicodeEncodeError_SetReason ( PyObject exc,
const char *  reason 
)

Definition at line 1348 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1236 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->start = start;
    return 0;
}

Here is the caller graph for this function:

PyObject* PyUnicodeTranslateError_Create ( const Py_UNICODE object,
Py_ssize_t  length,
Py_ssize_t  start,
Py_ssize_t  end,
const char *  reason 
)

Definition at line 1716 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1297 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1186 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->object, "object");
}

Here is the call graph for this function:

Definition at line 1341 of file exceptions.c.

{
    return get_unicode(((PyUnicodeErrorObject *)exc)->reason, "reason");
}

Here is the call graph for this function:

Definition at line 1229 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1320 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->end = end;
    return 0;
}

Here is the caller graph for this function:

int PyUnicodeTranslateError_SetReason ( PyObject exc,
const char *  reason 
)

Definition at line 1364 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1252 of file exceptions.c.

{
    ((PyUnicodeErrorObject *)exc)->start = start;
    return 0;
}

Here is the caller graph for this function:

static int set_unicodefromstring ( PyObject **  attr,
const char *  value 
) [static]

Definition at line 1151 of file exceptions.c.

{
    PyObject *obj = PyUnicode_FromString(value);
    if (!obj)
        return -1;
    Py_CLEAR(*attr);
    *attr = obj;
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SimpleExtendsException ( PyExc_BaseException  ,
Exception  ,
"Common base class for all non-exit exceptions."   
)
SimpleExtendsException ( PyExc_Exception  ,
TypeError  ,
"Inappropriate argument type."   
)
SimpleExtendsException ( PyExc_Exception  ,
StopIteration  ,
"Signal the end from iterator.__next__()."   
)
SimpleExtendsException ( PyExc_BaseException  ,
GeneratorExit  ,
"Request that a generator exit."   
)
SimpleExtendsException ( PyExc_BaseException  ,
KeyboardInterrupt  ,
"Program interrupted by user."   
)
SimpleExtendsException ( PyExc_Exception  ,
ImportError  ,
"Import can't find  module,
or can't find name in module."   
)
SimpleExtendsException ( PyExc_Exception  ,
EOFError  ,
"Read beyond end of file."   
)
SimpleExtendsException ( PyExc_Exception  ,
RuntimeError  ,
"Unspecified run-time error."   
)
SimpleExtendsException ( PyExc_RuntimeError  ,
NotImplementedError  ,
"Method or function hasn't been implemented yet."   
)
SimpleExtendsException ( PyExc_Exception  ,
NameError  ,
"Name not found globally."   
)
SimpleExtendsException ( PyExc_NameError  ,
UnboundLocalError  ,
"Local name referenced but not bound to a value."   
)
SimpleExtendsException ( PyExc_Exception  ,
AttributeError  ,
"Attribute not found."   
)
SimpleExtendsException ( PyExc_Exception  ,
LookupError  ,
"Base class for lookup errors."   
)
SimpleExtendsException ( PyExc_LookupError  ,
IndexError  ,
"Sequence index out of range."   
)
SimpleExtendsException ( PyExc_Exception  ,
ValueError  ,
"Inappropriate argument value (of correct type)."   
)
SimpleExtendsException ( PyExc_ValueError  ,
UnicodeError  ,
"Unicode related error."   
)
SimpleExtendsException ( PyExc_Exception  ,
AssertionError  ,
"Assertion failed."   
)
SimpleExtendsException ( PyExc_Exception  ,
ArithmeticError  ,
"Base class for arithmetic errors."   
)
SimpleExtendsException ( PyExc_ArithmeticError  ,
FloatingPointError  ,
"Floating point operation failed."   
)
SimpleExtendsException ( PyExc_ArithmeticError  ,
OverflowError  ,
"Result too large to be represented."   
)
SimpleExtendsException ( PyExc_ArithmeticError  ,
ZeroDivisionError  ,
"Second argument to a division or modulo operation was zero."   
)
SimpleExtendsException ( PyExc_Exception  ,
SystemError  ,
"Internal error in the Python interpreter.\n""\n""Please report this to the Python  maintainer,
along with the  traceback,
\n""the Python  version,
and the hardware/OS platform and version."   
)
SimpleExtendsException ( PyExc_Exception  ,
ReferenceError  ,
"Weak ref proxy used after referent went away."   
)
SimpleExtendsException ( PyExc_Exception  ,
BufferError  ,
"Buffer error."   
)
SimpleExtendsException ( PyExc_Exception  ,
Warning  ,
"Base class for warning categories."   
)
SimpleExtendsException ( PyExc_Warning  ,
UserWarning  ,
"Base class for warnings generated by user code."   
)
SimpleExtendsException ( PyExc_Warning  ,
DeprecationWarning  ,
"Base class for warnings about deprecated features."   
)
SimpleExtendsException ( PyExc_Warning  ,
PendingDeprecationWarning  ,
"Base class for warnings about features which will be deprecated\n""in the future."   
)
SimpleExtendsException ( PyExc_Warning  ,
SyntaxWarning  ,
"Base class for warnings about dubious syntax."   
)
SimpleExtendsException ( PyExc_Warning  ,
RuntimeWarning  ,
"Base class for warnings about dubious runtime behavior."   
)
SimpleExtendsException ( PyExc_Warning  ,
FutureWarning  ,
"Base class for warnings about constructs that will change semantically\n""in the future."   
)
SimpleExtendsException ( PyExc_Warning  ,
ImportWarning  ,
"Base class for warnings about probable mistakes in module imports"   
)
SimpleExtendsException ( PyExc_Warning  ,
UnicodeWarning  ,
"Base class for warnings about Unicode related  problems,
mostly\n""related to conversion problems."   
)
SimpleExtendsException ( PyExc_Warning  ,
BytesWarning  ,
"Base class for warnings about bytes and buffer related  problems,
mostly\n""related to conversion from str or comparing to str."   
)
SimpleExtendsException ( PyExc_Warning  ,
ResourceWarning  ,
"Base class for warnings about resource usage."   
)
static int SyntaxError_clear ( PySyntaxErrorObject self) [static]

Definition at line 928 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void SyntaxError_dealloc ( PySyntaxErrorObject self) [static]

Definition at line 940 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    SyntaxError_clear(self);
    Py_TYPE(self)->tp_free((PyObject *)self);
}

Here is the call graph for this function:

static int SyntaxError_init ( PySyntaxErrorObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 881 of file exceptions.c.

{
    PyObject *info = NULL;
    Py_ssize_t lenargs = PyTuple_GET_SIZE(args);

    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    if (lenargs >= 1) {
        Py_CLEAR(self->msg);
        self->msg = PyTuple_GET_ITEM(args, 0);
        Py_INCREF(self->msg);
    }
    if (lenargs == 2) {
        info = PyTuple_GET_ITEM(args, 1);
        info = PySequence_Tuple(info);
        if (!info) return -1;

        if (PyTuple_GET_SIZE(info) != 4) {
            /* not a very good error message, but it's what Python 2.4 gives */
            PyErr_SetString(PyExc_IndexError, "tuple index out of range");
            Py_DECREF(info);
            return -1;
        }

        Py_CLEAR(self->filename);
        self->filename = PyTuple_GET_ITEM(info, 0);
        Py_INCREF(self->filename);

        Py_CLEAR(self->lineno);
        self->lineno = PyTuple_GET_ITEM(info, 1);
        Py_INCREF(self->lineno);

        Py_CLEAR(self->offset);
        self->offset = PyTuple_GET_ITEM(info, 2);
        Py_INCREF(self->offset);

        Py_CLEAR(self->text);
        self->text = PyTuple_GET_ITEM(info, 3);
        Py_INCREF(self->text);

        Py_DECREF(info);
    }
    return 0;
}

Here is the call graph for this function:

static PyObject* SyntaxError_str ( PySyntaxErrorObject self) [static]

Definition at line 987 of file exceptions.c.

{
    int have_lineno = 0;
    PyObject *filename;
    PyObject *result;
    /* Below, we always ignore overflow errors, just printing -1.
       Still, we cannot allow an OverflowError to be raised, so
       we need to call PyLong_AsLongAndOverflow. */
    int overflow;

    /* XXX -- do all the additional formatting with filename and
       lineno here */

    if (self->filename && PyUnicode_Check(self->filename)) {
        filename = my_basename(self->filename);
        if (filename == NULL)
            return NULL;
    } else {
        filename = NULL;
    }
    have_lineno = (self->lineno != NULL) && PyLong_CheckExact(self->lineno);

    if (!filename && !have_lineno)
        return PyObject_Str(self->msg ? self->msg : Py_None);

    if (filename && have_lineno)
        result = PyUnicode_FromFormat("%S (%U, line %ld)",
                   self->msg ? self->msg : Py_None,
                   filename,
                   PyLong_AsLongAndOverflow(self->lineno, &overflow));
    else if (filename)
        result = PyUnicode_FromFormat("%S (%U)",
                   self->msg ? self->msg : Py_None,
                   filename);
    else /* only have_lineno */
        result = PyUnicode_FromFormat("%S (line %ld)",
                   self->msg ? self->msg : Py_None,
                   PyLong_AsLongAndOverflow(self->lineno, &overflow));
    Py_XDECREF(filename);
    return result;
}

Here is the call graph for this function:

static int SyntaxError_traverse ( PySyntaxErrorObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 948 of file exceptions.c.

Here is the call graph for this function:

static int SystemExit_clear ( PySystemExitObject self) [static]

Definition at line 509 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void SystemExit_dealloc ( PySystemExitObject self) [static]

Definition at line 516 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    SystemExit_clear(self);
    Py_TYPE(self)->tp_free((PyObject *)self);
}

Here is the call graph for this function:

static int SystemExit_init ( PySystemExitObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 490 of file exceptions.c.

{
    Py_ssize_t size = PyTuple_GET_SIZE(args);

    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    if (size == 0)
        return 0;
    Py_CLEAR(self->code);
    if (size == 1)
        self->code = PyTuple_GET_ITEM(args, 0);
    else if (size > 1)
        self->code = args;
    Py_INCREF(self->code);
    return 0;
}

Here is the call graph for this function:

static int SystemExit_traverse ( PySystemExitObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 524 of file exceptions.c.

Here is the call graph for this function:

static int UnicodeDecodeError_init ( PyObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1523 of file exceptions.c.

{
    PyUnicodeErrorObject *ude;
    const char *data;
    Py_ssize_t size;

    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    ude = (PyUnicodeErrorObject *)self;

    Py_CLEAR(ude->encoding);
    Py_CLEAR(ude->object);
    Py_CLEAR(ude->reason);

    if (!PyArg_ParseTuple(args, "O!OnnO!",
         &PyUnicode_Type, &ude->encoding,
         &ude->object,
         &ude->start,
         &ude->end,
         &PyUnicode_Type, &ude->reason)) {
             ude->encoding = ude->object = ude->reason = NULL;
             return -1;
    }

    if (!PyBytes_Check(ude->object)) {
        if (PyObject_AsReadBuffer(ude->object, (const void **)&data, &size)) {
            ude->encoding = ude->object = ude->reason = NULL;
            return -1;
        }
        ude->object = PyBytes_FromStringAndSize(data, size);
    }
    else {
        Py_INCREF(ude->object);
    }

    Py_INCREF(ude->encoding);
    Py_INCREF(ude->reason);

    return 0;
}

Here is the call graph for this function:

static PyObject* UnicodeDecodeError_str ( PyObject self) [static]

Definition at line 1566 of file exceptions.c.

{
    PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
    PyObject *result = NULL;
    PyObject *reason_str = NULL;
    PyObject *encoding_str = NULL;

    /* Get reason and encoding as strings, which they might not be if
       they've been modified after we were contructed. */
    reason_str = PyObject_Str(uself->reason);
    if (reason_str == NULL)
        goto done;
    encoding_str = PyObject_Str(uself->encoding);
    if (encoding_str == NULL)
        goto done;

    if (uself->start < PyBytes_GET_SIZE(uself->object) && uself->end == uself->start+1) {
        int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[uself->start]&0xff);
        result = PyUnicode_FromFormat(
            "'%U' codec can't decode byte 0x%02x in position %zd: %U",
            encoding_str,
            byte,
            uself->start,
            reason_str);
    }
    else {
        result = PyUnicode_FromFormat(
            "'%U' codec can't decode bytes in position %zd-%zd: %U",
            encoding_str,
            uself->start,
            uself->end-1,
            reason_str
            );
    }
done:
    Py_XDECREF(reason_str);
    Py_XDECREF(encoding_str);
    return result;
}

Here is the call graph for this function:

static int UnicodeEncodeError_init ( PyObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1417 of file exceptions.c.

{
    PyUnicodeErrorObject *err;

    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    err = (PyUnicodeErrorObject *)self;

    Py_CLEAR(err->encoding);
    Py_CLEAR(err->object);
    Py_CLEAR(err->reason);

    if (!PyArg_ParseTuple(args, "O!O!nnO!",
        &PyUnicode_Type, &err->encoding,
        &PyUnicode_Type, &err->object,
        &err->start,
        &err->end,
        &PyUnicode_Type, &err->reason)) {
          err->encoding = err->object = err->reason = NULL;
          return -1;
    }

    Py_INCREF(err->encoding);
    Py_INCREF(err->object);
    Py_INCREF(err->reason);

    return 0;
}

Here is the call graph for this function:

static PyObject* UnicodeEncodeError_str ( PyObject self) [static]

Definition at line 1448 of file exceptions.c.

{
    PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
    PyObject *result = NULL;
    PyObject *reason_str = NULL;
    PyObject *encoding_str = NULL;

    /* Get reason and encoding as strings, which they might not be if
       they've been modified after we were contructed. */
    reason_str = PyObject_Str(uself->reason);
    if (reason_str == NULL)
        goto done;
    encoding_str = PyObject_Str(uself->encoding);
    if (encoding_str == NULL)
        goto done;

    if (uself->start < PyUnicode_GET_SIZE(uself->object) && uself->end == uself->start+1) {
        int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start];
        const char *fmt;
        if (badchar <= 0xff)
            fmt = "'%U' codec can't encode character '\\x%02x' in position %zd: %U";
        else if (badchar <= 0xffff)
            fmt = "'%U' codec can't encode character '\\u%04x' in position %zd: %U";
        else
            fmt = "'%U' codec can't encode character '\\U%08x' in position %zd: %U";
        result = PyUnicode_FromFormat(
            fmt,
            encoding_str,
            badchar,
            uself->start,
            reason_str);
    }
    else {
        result = PyUnicode_FromFormat(
            "'%U' codec can't encode characters in position %zd-%zd: %U",
            encoding_str,
            uself->start,
            uself->end-1,
            reason_str);
    }
done:
    Py_XDECREF(reason_str);
    Py_XDECREF(encoding_str);
    return result;
}

Here is the call graph for this function:

static int UnicodeError_clear ( PyUnicodeErrorObject self) [static]

Definition at line 1372 of file exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void UnicodeError_dealloc ( PyUnicodeErrorObject self) [static]

Definition at line 1381 of file exceptions.c.

{
    _PyObject_GC_UNTRACK(self);
    UnicodeError_clear(self);
    Py_TYPE(self)->tp_free((PyObject *)self);
}

Here is the call graph for this function:

static int UnicodeError_traverse ( PyUnicodeErrorObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 1389 of file exceptions.c.

Here is the call graph for this function:

static int UnicodeTranslateError_init ( PyUnicodeErrorObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1635 of file exceptions.c.

{
    if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
        return -1;

    Py_CLEAR(self->object);
    Py_CLEAR(self->reason);

    if (!PyArg_ParseTuple(args, "O!nnO!",
        &PyUnicode_Type, &self->object,
        &self->start,
        &self->end,
        &PyUnicode_Type, &self->reason)) {
        self->object = self->reason = NULL;
        return -1;
    }

    Py_INCREF(self->object);
    Py_INCREF(self->reason);

    return 0;
}

Here is the call graph for this function:

static PyObject* UnicodeTranslateError_str ( PyObject self) [static]

Definition at line 1661 of file exceptions.c.

{
    PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
    PyObject *result = NULL;
    PyObject *reason_str = NULL;

    /* Get reason as a string, which it might not be if it's been
       modified after we were contructed. */
    reason_str = PyObject_Str(uself->reason);
    if (reason_str == NULL)
        goto done;

    if (uself->start < PyUnicode_GET_SIZE(uself->object) && uself->end == uself->start+1) {
        int badchar = (int)PyUnicode_AS_UNICODE(uself->object)[uself->start];
        const char *fmt;
        if (badchar <= 0xff)
            fmt = "can't translate character '\\x%02x' in position %zd: %U";
        else if (badchar <= 0xffff)
            fmt = "can't translate character '\\u%04x' in position %zd: %U";
        else
            fmt = "can't translate character '\\U%08x' in position %zd: %U";
        result = PyUnicode_FromFormat(
            fmt,
            badchar,
            uself->start,
            reason_str
        );
    } else {
        result = PyUnicode_FromFormat(
            "can't translate characters in position %zd-%zd: %U",
            uself->start,
            uself->end-1,
            reason_str
            );
    }
done:
    Py_XDECREF(reason_str);
    return result;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 361 of file exceptions.c.

Initial value:
 {
    PyVarObject_HEAD_INIT(NULL, 0)
    "MemoryError",
    sizeof(PyBaseExceptionObject),
    0, (destructor)MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
    PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse,
    (inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_PyExc_Exception,
    0, 0, 0, offsetof(PyBaseExceptionObject, dict),
    (initproc)BaseException_init, 0, MemoryError_new
}

Definition at line 1851 of file exceptions.c.

Initial value:

Definition at line 1606 of file exceptions.c.

Initial value:

Definition at line 1494 of file exceptions.c.

Initial value:

Definition at line 1701 of file exceptions.c.

Initial value:
 {
   {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS },
   {"__setstate__", (PyCFunction)BaseException_setstate, METH_O },
   {"with_traceback", (PyCFunction)BaseException_with_traceback, METH_O,
    with_traceback_doc},
   {NULL, NULL, 0, NULL},
}

Definition at line 158 of file exceptions.c.

Initial value:
 {
    {"errno", T_OBJECT, offsetof(PyEnvironmentErrorObject, myerrno), 0,
        PyDoc_STR("exception errno")},
    {"strerror", T_OBJECT, offsetof(PyEnvironmentErrorObject, strerror), 0,
        PyDoc_STR("exception strerror")},
    {"filename", T_OBJECT, offsetof(PyEnvironmentErrorObject, filename), 0,
        PyDoc_STR("exception filename")},
    {NULL}  
}

Definition at line 654 of file exceptions.c.

Initial value:

Definition at line 699 of file exceptions.c.

Definition at line 1782 of file exceptions.c.

int memerrors_numfree = 0 [static]

Definition at line 1783 of file exceptions.c.

Definition at line 405 of file exceptions.c.

Definition at line 1863 of file exceptions.c.

Definition at line 1960 of file exceptions.c.

Definition at line 1618 of file exceptions.c.

Definition at line 1506 of file exceptions.c.

Definition at line 1713 of file exceptions.c.

Initial value:
 {
    {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0,
        PyDoc_STR("exception msg")},
    {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0,
        PyDoc_STR("exception filename")},
    {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0,
        PyDoc_STR("exception lineno")},
    {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0,
        PyDoc_STR("exception offset")},
    {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), 0,
        PyDoc_STR("exception text")},
    {"print_file_and_line", T_OBJECT,
        offsetof(PySyntaxErrorObject, print_file_and_line), 0,
        PyDoc_STR("exception print_file_and_line")},
    {NULL}  
}

Definition at line 1029 of file exceptions.c.

Initial value:
 {
    {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0,
        PyDoc_STR("exception code")},
    {NULL}  
}

Definition at line 530 of file exceptions.c.

Initial value:
 {
    {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0,
        PyDoc_STR("exception encoding")},
    {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0,
        PyDoc_STR("exception object")},
    {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0,
        PyDoc_STR("exception start")},
    {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0,
        PyDoc_STR("exception end")},
    {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0,
        PyDoc_STR("exception reason")},
    {NULL}  
}

Definition at line 1397 of file exceptions.c.