Message102224
| 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:08 | chris.jerdonek | set | recipients:
+ chris.jerdonek |
| 2010年04月03日 05:30:07 | chris.jerdonek | set | messageid: <1270272607.93.0.943961280816.issue8297@psf.upfronthosting.co.za> |
| 2010年04月03日 05:30:05 | chris.jerdonek | link | issue8297 messages |
| 2010年04月03日 05:30:04 | chris.jerdonek | create |
|