This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2010-04-03.05:30:03
SpamBayes Score 2.1400026e-10
Marked as misclassified No
Message-id <1270272607.93.0.943961280816.issue8297@psf.upfronthosting.co.za>
In-reply-to
Content
It would be nice if the error message for an AttributeError could include the module name when getting from a module -- just like it does for getting from a class.

This would make the message more helpful.  For example, it would help in diagnosing issues like the ones mentioned in this report:

http://bugs.python.org/issue7559

EXAMPLE (using latest from trunk Python 2.7a4+):

import sys

class TestClass(object):
    pass

m = sys
c = TestClass

print "CLASS: %s" % c

try:
    c.asdf
except AttributeError, err:
    print err

print "\nMODULE: %s" % m

try:
    m.adsf
except AttributeError, err:
    print err

***
OUTPUT:

CLASS: <class '__main__.TestClass'>
type object 'TestClass' has no attribute 'asdf'

MODULE: <module 'sys' (built-in)>
'module' object has no attribute 'adsf'

***
The latter message could instead be (paralleling the text in the case of a class)--

module object 'sys' has no attribute 'adsf'
History
Date User Action Args
2010-04-03 05:30:08chris.jerdoneksetrecipients: + chris.jerdonek
2010-04-03 05:30:07chris.jerdoneksetmessageid: <1270272607.93.0.943961280816.issue8297@psf.upfronthosting.co.za>
2010-04-03 05:30:05chris.jerdoneklinkissue8297 messages
2010-04-03 05:30:04chris.jerdonekcreate