Skip to content

Commit 8449c34

Browse files
author
Ralf W. Grosse-Kunstleve
committed
libs/python/src/object/function.cpp: apply patch by Matthew Bradbury (trac #4259)
[SVN r74321]
1 parent 838f44c commit 8449c34

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/object/function.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,23 +433,23 @@ void function::add_to_namespace(
433433
if (attribute.ptr()->ob_type == &function_type)
434434
{
435435
function* new_func = downcast<function>(attribute.ptr());
436-
PyObject* dict = 0;
436+
handle<> dict;
437437

438438
#if PY_VERSION_HEX < 0x03000000
439439
// Old-style class gone in Python 3
440440
if (PyClass_Check(ns))
441-
dict = ((PyClassObject*)ns)->cl_dict;
441+
dict = handle<>(borrowed(((PyClassObject*)ns)->cl_dict));
442442
else
443443
#endif
444444
if (PyType_Check(ns))
445-
dict = ((PyTypeObject*)ns)->tp_dict;
445+
dict = handle<>(borrowed(((PyTypeObject*)ns)->tp_dict));
446446
else
447-
dict = PyObject_GetAttrString(ns, const_cast<char*>("__dict__"));
447+
dict = handle<>(PyObject_GetAttrString(ns, const_cast<char*>("__dict__")));
448448

449449
if (dict == 0)
450450
throw_error_already_set();
451451

452-
handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr())));
452+
handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr())));
453453

454454
if (existing)
455455
{

0 commit comments

Comments
 (0)