Alex Martelli wrote:
> I wonder if there's some desiderata left for future Python versions to
> make this standard behavior easier (for C-coded, Python-coded, and
> Cython-coded classes, ones made by SWIG, etc) without too much black
> magic...

Perhaps adding something like the following to the C API:

void PyErr_FormatAttributeError(PyObject* type, char *attr)
{
  PyErr_Format(PyExc_AttributeError,
    "object of type %.100s has no attribute '%.200s'",
    type->tp_name, attr);
}

This could also be exposed as a class method of AttributeError itself
for use in Python code.

(Interestingly, I noticed that there are still quite a few attribute
errors at least in typeobject.c that don't provide any information on
the type of the object that is missing an attribute - they appeared to
mostly be obscure errors that will only turn up if something has gone
very strange, but they're there)

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to