2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 17:52:17 +00:00

Tons of changes to improve error reporting

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


[SVN r8311]
This commit is contained in:
Ullrich Köthe
2000-11-23 22:48:51 +00:00
parent 4d7b6fe92a
commit ec4bc0382f
18 changed files with 1153 additions and 1134 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);
}