2
0
mirror of https://github.com/boostorg/python.git synced 2026-02-05 22:12:16 +00:00

Toons of changes to improve error handling.

Added attributes function.__name__, function.__signature__, and
the dir(function) feature


[SVN r8313]
This commit is contained in:
Ullrich Köthe
2000-11-23 23:03:24 +00:00
parent f7ad50166d
commit e3fe2d02ee
19 changed files with 1423 additions and 1721 deletions

View File

@@ -67,7 +67,7 @@ namespace {
ref global_class_reduce()
{
static ref result(detail::new_wrapped_function(class_reduce));
static ref result(detail::new_wrapped_function(class_reduce, "__reduce__"));
return result;
}
@@ -111,7 +111,7 @@ namespace {
ref global_instance_reduce()
{
static ref result(detail::new_wrapped_function(instance_reduce));
static ref result(detail::new_wrapped_function(instance_reduce, "__reduce__"));
return result;
}
}
@@ -225,14 +225,21 @@ namespace detail {
// Mostly copied wholesale from Python's classobject.c
PyObject* class_base::repr() const
{
unsigned long address = reinterpret_cast<unsigned long>(this);
string result = string("<extension class %s at %lx>") % tuple(complete_class_name(), address);
return result.reference().release();
}
// Mostly copied wholesale from Python's classobject.c
string class_base::complete_class_name() const
{
PyObject *mod = PyDict_GetItemString(
m_name_space.get(), const_cast<char*>("__module__"));
unsigned long address = reinterpret_cast<unsigned long>(this);
string result = (mod == NULL || !PyString_Check(mod))
? string("<extension class %s at %lx>") % tuple(m_name, address)
: string("<extension class %s.%s at %lx>") % tuple(ref(mod, ref::increment_count), m_name, address);
return result.reference().release();
return (mod == NULL || !PyString_Check(mod))
? m_name
: string("%s.%s") % tuple(ref(mod, ref::increment_count), m_name);
}