[issue8297] AttributeError message text should include module name
Chris Jerdonek
report at bugs.python.org
Sat Apr 3 07:30:08 CEST 2010
New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:
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'
----------
components: Library (Lib)
messages: 102224
nosy: cjerdonek
severity: normal
status: open
title: AttributeError message text should include module name
type: feature request
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8297>
_______________________________________
More information about the Python-bugs-list
mailing list