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/weakrefobject.c

    r2 r388  
    5353    PyObject *callback = self->wr_callback;
    5454
    55     if (PyWeakref_GET_OBJECT(self) != Py_None) {
    56         PyWeakReference **list = GET_WEAKREFS_LISTPTR(
    57             PyWeakref_GET_OBJECT(self));
     55    if (self->wr_object != Py_None) {
     56        PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
    5857
    5958        if (*list == self)
    60             /* If 'self' is the end of the list (and thus self->wr_next == NULL)
    61                then the weakref list itself (and thus the value of *list) will
    62                end up being set to NULL. */
     59            /* If 'self' is the end of the list (and thus self->wr_next == NULL)
     60               then the weakref list itself (and thus the value of *list) will
     61               end up being set to NULL. */
    6362            *list = self->wr_next;
    6463        self->wr_object = Py_None;
     
    162161    }
    163162    else {
    164         char *name = NULL;
    165         PyObject *nameobj = PyObject_GetAttrString(PyWeakref_GET_OBJECT(self),
    166                                                    "__name__");
    167         if (nameobj == NULL)
    168                 PyErr_Clear();
    169         else if (PyString_Check(nameobj))
    170                 name = PyString_AS_STRING(nameobj);
    171         PyOS_snprintf(buffer, sizeof(buffer),
    172                       name ? "<weakref at %p; to '%.50s' at %p (%s)>"
    173                            : "<weakref at %p; to '%.50s' at %p>",
    174                       self,
    175                       Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
    176                       PyWeakref_GET_OBJECT(self),
    177                       name);
    178         Py_XDECREF(nameobj);
     163        char *name = NULL;
     164        PyObject *nameobj = PyObject_GetAttrString(PyWeakref_GET_OBJECT(self),
     165                                                   "__name__");
     166        if (nameobj == NULL)
     167                PyErr_Clear();
     168        else if (PyString_Check(nameobj))
     169                name = PyString_AS_STRING(nameobj);
     170        if (name != NULL) {
     171            PyOS_snprintf(buffer, sizeof(buffer),
     172                          "<weakref at %p; to '%.50s' at %p (%s)>",
     173                          self,
     174                          Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
     175                          PyWeakref_GET_OBJECT(self),
     176                          name);
     177        }
     178        else {
     179            PyOS_snprintf(buffer, sizeof(buffer),
     180                          "<weakref at %p; to '%.50s' at %p>",
     181                          self,
     182                          Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
     183                          PyWeakref_GET_OBJECT(self));
     184        }
     185        Py_XDECREF(nameobj);
    179186    }
    180187    return PyString_FromString(buffer);
     
    188195weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op)
    189196{
    190     if (op != Py_EQ || self->ob_type != other->ob_type) {
     197    if ((op != Py_EQ && op != Py_NE) || self->ob_type != other->ob_type) {
    191198        Py_INCREF(Py_NotImplemented);
    192199        return Py_NotImplemented;
     
    194201    if (PyWeakref_GET_OBJECT(self) == Py_None
    195202        || PyWeakref_GET_OBJECT(other) == Py_None) {
    196         PyObject *res = self==other ? Py_True : Py_False;
    197         Py_INCREF(res);
    198         return res;
     203        int res = (self == other);
     204        if (op == Py_NE)
     205            res = !res;
     206        if (res)
     207            Py_RETURN_TRUE;
     208        else
     209            Py_RETURN_FALSE;
    199210    }
    200211    return PyObject_RichCompare(PyWeakref_GET_OBJECT(self),
     
    338349    0,
    339350    weakref_dealloc,            /*tp_dealloc*/
    340     0,                          /*tp_print*/
     351    0,                          /*tp_print*/
    341352    0,                          /*tp_getattr*/
    342353    0,                          /*tp_setattr*/
    343     0,                          /*tp_compare*/
     354    0,                          /*tp_compare*/
    344355    (reprfunc)weakref_repr,     /*tp_repr*/
    345356    0,                          /*tp_as_number*/
     
    357368    (traverseproc)gc_traverse,  /*tp_traverse*/
    358369    (inquiry)gc_clear,          /*tp_clear*/
    359     (richcmpfunc)weakref_richcompare,   /*tp_richcompare*/
     370    (richcmpfunc)weakref_richcompare,   /*tp_richcompare*/
    360371    0,                          /*tp_weaklistoffset*/
    361372    0,                          /*tp_iter*/
     
    437448    static PyObject * \
    438449    method(PyObject *proxy) { \
    439             UNWRAP(proxy); \
    440                 return PyObject_CallMethod(proxy, special, ""); \
    441         }
     450            UNWRAP(proxy); \
     451                return PyObject_CallMethod(proxy, special, ""); \
     452        }
    442453
    443454
     
    453464    char buf[160];
    454465    PyOS_snprintf(buf, sizeof(buf),
    455                   "<weakproxy at %p to %.100s at %p>", proxy,
    456                   Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name,
    457                   PyWeakref_GET_OBJECT(proxy));
     466                  "<weakproxy at %p to %.100s at %p>", proxy,
     467                  Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name,
     468                  PyWeakref_GET_OBJECT(proxy));
    458469    return PyString_FromString(buf);
    459470}
     
    605616
    606617static PyMethodDef proxy_methods[] = {
    607         {"__unicode__", (PyCFunction)proxy_unicode, METH_NOARGS},
    608         {NULL, NULL}
     618        {"__unicode__", (PyCFunction)proxy_unicode, METH_NOARGS},
     619        {NULL, NULL}
    609620};
    610621
     
    678689    /* methods */
    679690    (destructor)proxy_dealloc,          /* tp_dealloc */
    680     0,                                  /* tp_print */
    681     0,                                  /* tp_getattr */
    682     0,                                  /* tp_setattr */
    683     proxy_compare,                      /* tp_compare */
    684     (reprfunc)proxy_repr,               /* tp_repr */
    685     &proxy_as_number,                   /* tp_as_number */
    686     &proxy_as_sequence,                 /* tp_as_sequence */
    687     &proxy_as_mapping,                  /* tp_as_mapping */
    688     0,                                  /* tp_hash */
    689     0,                                  /* tp_call */
     691    0,                                  /* tp_print */
     692    0,                                  /* tp_getattr */
     693    0,                                  /* tp_setattr */
     694    proxy_compare,                      /* tp_compare */
     695    (reprfunc)proxy_repr,               /* tp_repr */
     696    &proxy_as_number,                   /* tp_as_number */
     697    &proxy_as_sequence,                 /* tp_as_sequence */
     698    &proxy_as_mapping,                  /* tp_as_mapping */
     699    0,                                  /* tp_hash */
     700    0,                                  /* tp_call */
    690701    proxy_str,                          /* tp_str */
    691702    proxy_getattr,                      /* tp_getattro */
    692703    (setattrofunc)proxy_setattr,        /* tp_setattro */
    693     0,                                  /* tp_as_buffer */
     704    0,                                  /* tp_as_buffer */
    694705    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC
    695706    | Py_TPFLAGS_CHECKTYPES,            /* tp_flags */
     
    701712    (getiterfunc)proxy_iter,            /* tp_iter */
    702713    (iternextfunc)proxy_iternext,       /* tp_iternext */
    703         proxy_methods,                      /* tp_methods */
     714        proxy_methods,                      /* tp_methods */
    704715};
    705716
     
    713724    /* methods */
    714725    (destructor)proxy_dealloc,          /* tp_dealloc */
    715     0,                                  /* tp_print */
    716     0,                                  /* tp_getattr */
    717     0,                                  /* tp_setattr */
    718     proxy_compare,                      /* tp_compare */
    719     (unaryfunc)proxy_repr,              /* tp_repr */
    720     &proxy_as_number,                   /* tp_as_number */
    721     &proxy_as_sequence,                 /* tp_as_sequence */
    722     &proxy_as_mapping,                  /* tp_as_mapping */
    723     0,                                  /* tp_hash */
    724     proxy_call,                         /* tp_call */
    725     proxy_str,                          /* tp_str */
     726    0,                                  /* tp_print */
     727    0,                                  /* tp_getattr */
     728    0,                                  /* tp_setattr */
     729    proxy_compare,                      /* tp_compare */
     730    (unaryfunc)proxy_repr,              /* tp_repr */
     731    &proxy_as_number,                   /* tp_as_number */
     732    &proxy_as_sequence,                 /* tp_as_sequence */
     733    &proxy_as_mapping,                  /* tp_as_mapping */
     734    0,                                  /* tp_hash */
     735    proxy_call,                         /* tp_call */
     736    proxy_str,                          /* tp_str */
    726737    proxy_getattr,                      /* tp_getattro */
    727738    (setattrofunc)proxy_setattr,        /* tp_setattro */
    728     0,                                  /* tp_as_buffer */
     739    0,                                  /* tp_as_buffer */
    729740    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC
    730741    | Py_TPFLAGS_CHECKTYPES,            /* tp_flags */
     
    749760    if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
    750761        PyErr_Format(PyExc_TypeError,
    751                      "cannot create weak reference to '%s' object",
     762                     "cannot create weak reference to '%s' object",
    752763                     Py_TYPE(ob)->tp_name);
    753764        return NULL;
     
    808819    if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
    809820        PyErr_Format(PyExc_TypeError,
    810                      "cannot create weak reference to '%s' object",
     821                     "cannot create weak reference to '%s' object",
    811822                     Py_TYPE(ob)->tp_name);
    812823        return NULL;
     
    933944            PyObject *tuple;
    934945            Py_ssize_t i = 0;
    935    
     946
    936947            tuple = PyTuple_New(count * 2);
    937948            if (tuple == NULL) {
Note: See TracChangeset for help on using the changeset viewer.