Author ysj.ray
Recipients chris.jerdonek, ezio.melotti, ysj.ray
Date 2010-04-06.13:14:43
SpamBayes Score 2.65898e-14
Marked as misclassified No
Message-id <>
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.
Date User Action Args
2010-04-06 13:14:45ysj.raysetrecipients: + ysj.ray, ezio.melotti, chris.jerdonek
2010-04-06 13:14:45ysj.raysetmessageid: <>
2010-04-06 13:14:43ysj.raylinkissue8297 messages
2010-04-06 13:14:43ysj.raycreate