mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 05:22:45 +00:00
libs/python/src/object/function.cpp: apply patch by Matthew Bradbury (trac #4259)
[SVN r74321]
This commit is contained in:
@@ -433,23 +433,23 @@ void function::add_to_namespace(
|
||||
if (attribute.ptr()->ob_type == &function_type)
|
||||
{
|
||||
function* new_func = downcast<function>(attribute.ptr());
|
||||
PyObject* dict = 0;
|
||||
handle<> dict;
|
||||
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
// Old-style class gone in Python 3
|
||||
if (PyClass_Check(ns))
|
||||
dict = ((PyClassObject*)ns)->cl_dict;
|
||||
dict = handle<>(borrowed(((PyClassObject*)ns)->cl_dict));
|
||||
else
|
||||
#endif
|
||||
if (PyType_Check(ns))
|
||||
dict = ((PyTypeObject*)ns)->tp_dict;
|
||||
dict = handle<>(borrowed(((PyTypeObject*)ns)->tp_dict));
|
||||
else
|
||||
dict = PyObject_GetAttrString(ns, const_cast<char*>("__dict__"));
|
||||
dict = handle<>(PyObject_GetAttrString(ns, const_cast<char*>("__dict__")));
|
||||
|
||||
if (dict == 0)
|
||||
throw_error_already_set();
|
||||
|
||||
handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr())));
|
||||
handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr())));
|
||||
|
||||
if (existing)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user