A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-December/083809.html below:

[Python-Dev] Attribute error: providing type name

[Python-Dev] Attribute error: providing type nameNick Coghlan ncoghlan at gmail.com
Mon Dec 1 22:20:36 CET 2008
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   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4