2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 06:42:27 +00:00

merging current boost/python and libs/python from trunk into release branch

[SVN r74931]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2011-10-12 21:38:53 +00:00
parent cfa2baf8c9
commit 49e8699b9f
10 changed files with 44 additions and 33 deletions

View File

@@ -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)
{