Commit 806a6572 authored by Kevin Modzelewski's avatar Kevin Modzelewski

_PyInstance_Lookup returns a borrowed reference

parent 183aa5f7
......@@ -81,7 +81,7 @@ PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *) PYSTON_NOEXCEPT;
* can't fail, never sets an exception, and NULL is not an error (it just
* means "not found").
*/
PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name) PYSTON_NOEXCEPT;
PyAPI_FUNC(BORROWED(PyObject *)) _PyInstance_Lookup(PyObject *pinst, PyObject *name) PYSTON_NOEXCEPT;
// Pyston change: no longer macros
#if 0
......
# expected: reffail
# - leaked refs, some test failures?
# Copyright (C) 2003 Python Software Foundation
import unittest
......
......@@ -77,7 +77,7 @@ static BORROWED(Box*) classLookup(BoxedClassobj* cls, BoxedString* attr) {
return classLookup<NOT_REWRITABLE>(cls, attr, NULL);
}
extern "C" PyObject* _PyInstance_Lookup(PyObject* pinst, PyObject* pname) noexcept {
extern "C" BORROWED(PyObject*) _PyInstance_Lookup(PyObject* pinst, PyObject* pname) noexcept {
RELEASE_ASSERT(PyInstance_Check(pinst), "");
BoxedInstance* inst = (BoxedInstance*)pinst;
......@@ -92,7 +92,7 @@ extern "C" PyObject* _PyInstance_Lookup(PyObject* pinst, PyObject* pname) noexce
Box* v = inst->getattr(name);
if (v == NULL)
v = classLookup(inst->inst_cls, name);
return xincref(v);
return v;
} catch (ExcInfo e) {
setCAPIException(e);
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment