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 ysj.ray
Recipients chris.jerdonek, ezio.melotti, ysj.ray
Date 2010-04-06.13:14:43
SpamBayes Score 2.6589841e-14
Marked as misclassified No
Message-id <1270559685.06.0.466778820975.issue8297@psf.upfronthosting.co.za>
In-reply-to
Content
This patch makes the AttributeError message generated from getting attributes from module object more helpful, that is, print the module name. Now the error message is:
  module object 'mod_name' has no attribute 'xxx'
Instead of:
  'module' object has no attribute 'xxx'

In this patch, I add a function PyObject_GenericFindAttr(), which is almost the same as PyObject_GenericGetAttr(), except that return NULL instead of setting the exception, and make PyObject_GenericGetAttr() call this function and setting exception in the case of NULL return value. Through this, each type can custom its own AttributeError message, while using the uniform process of getting the attribute in PyObject_GenericFindAttr(). For example, PyModuleType's tp_getattro is set to a new function PyModule_GetAttr(), which calls the PyObject_GenericFindAttr() can set the customed AttributeError message.

Besides, I think the super object's AttributeError message should also be improved, but I didn't include that in the patch. I don't know weather it is suitable.
History
Date User Action Args
2010-04-06 13:14:45ysj.raysetrecipients: + ysj.ray, ezio.melotti, chris.jerdonek
2010-04-06 13:14:45ysj.raysetmessageid: <1270559685.06.0.466778820975.issue8297@psf.upfronthosting.co.za>
2010-04-06 13:14:43ysj.raylinkissue8297 messages
2010-04-06 13:14:43ysj.raycreate