Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Objects/exceptions.c

    r2 r388  
    1010#include "osdefs.h"
    1111
    12 #define MAKE_IT_NONE(x) (x) = Py_None; Py_INCREF(Py_None);
    1312#define EXC_MODULE_NAME "exceptions."
    1413
     
    219218   {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS },
    220219   {"__setstate__", (PyCFunction)BaseException_setstate, METH_O },
    221 #ifdef Py_USING_UNICODE   
     220#ifdef Py_USING_UNICODE
    222221   {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS },
    223222#endif
     
    238237static PyObject *
    239238BaseException_getslice(PyBaseExceptionObject *self,
    240                         Py_ssize_t start, Py_ssize_t stop)
     239                        Py_ssize_t start, Py_ssize_t stop)
    241240{
    242241    if (PyErr_WarnPy3k("__getslice__ not supported for exception "
     
    308307    }
    309308    seq = PySequence_Tuple(val);
    310     if (!seq) return -1;
     309    if (!seq)
     310        return -1;
    311311    Py_CLEAR(self->args);
    312312    self->args = seq;
     
    318318{
    319319    PyObject *msg;
    320    
     320
    321321    /* if "message" is in self->dict, accessing a user-set message attribute */
    322322    if (self->dict &&
     
    350350                return -1;
    351351        }
    352         Py_XDECREF(self->message);
    353         self->message = NULL;
     352        Py_CLEAR(self->message);
    354353        return 0;
    355354    }
    356    
     355
    357356    /* else set it in __dict__, but may need to create the dict first */
    358357    if (self->dict == NULL) {
     
    368367    {"args", (getter)BaseException_get_args, (setter)BaseException_set_args},
    369368    {"message", (getter)BaseException_get_message,
    370             (setter)BaseException_set_message},
     369            (setter)BaseException_set_message},
    371370    {NULL},
    372371};
     
    395394    0,                          /*tp_as_buffer*/
    396395    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
    397         Py_TPFLAGS_BASE_EXC_SUBCLASS,  /*tp_flags*/
     396        Py_TPFLAGS_BASE_EXC_SUBCLASS,  /*tp_flags*/
    398397    PyDoc_STR("Common base class for all exceptions"), /* tp_doc */
    399398    (traverseproc)BaseException_traverse, /* tp_traverse */
     
    775774    if (PyTuple_GET_SIZE(args) == 2 && self->filename) {
    776775        args = PyTuple_New(3);
    777         if (!args) return NULL;
     776        if (!args)
     777            return NULL;
    778778
    779779        tmp = PyTuple_GET_ITEM(self->args, 0);
     
    10731073        info = PyTuple_GET_ITEM(args, 1);
    10741074        info = PySequence_Tuple(info);
    1075         if (!info) return -1;
     1075        if (!info)
     1076            return -1;
    10761077
    10771078        if (PyTuple_GET_SIZE(info) != 4) {
     
    11691170    else
    11701171        str = PyObject_Str(Py_None);
    1171     if (!str) return NULL;
     1172    if (!str)
     1173        return NULL;
    11721174    /* Don't fiddle with non-string return (shouldn't happen anyway) */
    1173     if (!PyString_Check(str)) return str;
     1175    if (!PyString_Check(str))
     1176        return str;
    11741177
    11751178    /* XXX -- do all the additional formatting with filename and
     
    17861789    Py_ssize_t start, Py_ssize_t end, const char *reason)
    17871790{
    1788     assert(length < INT_MAX);
    1789     assert(start < INT_MAX);
    1790     assert(end < INT_MAX);
    17911791    return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#nns",
    17921792                                 encoding, object, length, start, end, reason);
     
    20502050    if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \
    20512051        Py_FatalError("Module dictionary insertion problem.");
    2052 
    2053 #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
    2054 /* crt variable checking in VisualStudio .NET 2005 */
    2055 #include <crtdbg.h>
    2056 
    2057 static int      prevCrtReportMode;
    2058 static _invalid_parameter_handler       prevCrtHandler;
    2059 
    2060 /* Invalid parameter handler.  Sets a ValueError exception */
    2061 static void
    2062 InvalidParameterHandler(
    2063     const wchar_t * expression,
    2064     const wchar_t * function,
    2065     const wchar_t * file,
    2066     unsigned int line,
    2067     uintptr_t pReserved)
    2068 {
    2069     /* Do nothing, allow execution to continue.  Usually this
    2070      * means that the CRT will set errno to EINVAL
    2071      */
    2072 }
    2073 #endif
    20742052
    20752053
     
    21382116    m = Py_InitModule4("exceptions", functions, exceptions_doc,
    21392117        (PyObject *)NULL, PYTHON_API_VERSION);
    2140     if (m == NULL) return;
     2118    if (m == NULL)
     2119        return;
    21412120
    21422121    bltinmod = PyImport_ImportModule("__builtin__");
     
    22062185    PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
    22072186    if (!PyExc_MemoryErrorInst)
    2208         Py_FatalError("Cannot pre-allocate MemoryError instance\n");
     2187        Py_FatalError("Cannot pre-allocate MemoryError instance");
    22092188
    22102189    PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
    22112190    if (!PyExc_RecursionErrorInst)
    2212         Py_FatalError("Cannot pre-allocate RuntimeError instance for "
    2213                         "recursion errors");
     2191        Py_FatalError("Cannot pre-allocate RuntimeError instance for "
     2192                        "recursion errors");
    22142193    else {
    2215         PyBaseExceptionObject *err_inst =
    2216             (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
    2217         PyObject *args_tuple;
    2218         PyObject *exc_message;
    2219         exc_message = PyString_FromString("maximum recursion depth exceeded");
    2220         if (!exc_message)
    2221             Py_FatalError("cannot allocate argument for RuntimeError "
    2222                             "pre-allocation");
    2223         args_tuple = PyTuple_Pack(1, exc_message);
    2224         if (!args_tuple)
    2225             Py_FatalError("cannot allocate tuple for RuntimeError "
    2226                             "pre-allocation");
    2227         Py_DECREF(exc_message);
    2228         if (BaseException_init(err_inst, args_tuple, NULL))
    2229             Py_FatalError("init of pre-allocated RuntimeError failed");
    2230         Py_DECREF(args_tuple);
    2231     }
    2232 
     2194        PyBaseExceptionObject *err_inst =
     2195            (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
     2196        PyObject *args_tuple;
     2197        PyObject *exc_message;
     2198        exc_message = PyString_FromString("maximum recursion depth exceeded");
     2199        if (!exc_message)
     2200            Py_FatalError("cannot allocate argument for RuntimeError "
     2201                            "pre-allocation");
     2202        args_tuple = PyTuple_Pack(1, exc_message);
     2203        if (!args_tuple)
     2204            Py_FatalError("cannot allocate tuple for RuntimeError "
     2205                            "pre-allocation");
     2206        Py_DECREF(exc_message);
     2207        if (BaseException_init(err_inst, args_tuple, NULL))
     2208            Py_FatalError("init of pre-allocated RuntimeError failed");
     2209        Py_DECREF(args_tuple);
     2210    }
    22332211    Py_DECREF(bltinmod);
    2234 
    2235 #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
    2236     /* Set CRT argument error handler */
    2237     prevCrtHandler = _set_invalid_parameter_handler(InvalidParameterHandler);
    2238     /* turn off assertions in debug mode */
    2239     prevCrtReportMode = _CrtSetReportMode(_CRT_ASSERT, 0);
    2240 #endif
    22412212}
    22422213
     
    22442215_PyExc_Fini(void)
    22452216{
    2246     Py_XDECREF(PyExc_MemoryErrorInst);
    2247     PyExc_MemoryErrorInst = NULL;
    2248 #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
    2249     /* reset CRT error handling */
    2250     _set_invalid_parameter_handler(prevCrtHandler);
    2251     _CrtSetReportMode(_CRT_ASSERT, prevCrtReportMode);
    2252 #endif
    2253 }
     2217    Py_CLEAR(PyExc_MemoryErrorInst);
     2218    Py_CLEAR(PyExc_RecursionErrorInst);
     2219}
Note: See TracChangeset for help on using the changeset viewer.