[Zope-Checkins] SVN: Zope/trunk/lib/python/ExtensionClass/ Changed
the way __doc__ is managed to get backward compatible behavior.
Jim Fulton
jim at zope.com
Thu Sep 30 17:18:51 EDT 2004
Log message for revision 27725:
Changed the way __doc__ is managed to get backward compatible behavior.
Changed:
U Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c
U Zope/trunk/lib/python/ExtensionClass/tests.py
-=-
Modified: Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c 2004-09-30 21:02:07 UTC (rev 27724)
+++ Zope/trunk/lib/python/ExtensionClass/_ExtensionClass.c 2004-09-30 21:18:50 UTC (rev 27725)
@@ -308,6 +308,15 @@
if (PyType_Type.tp_init(OBJECT(self), args, kw) < 0)
return -1;
+ if (self->tp_dict != NULL)
+ {
+ r = PyDict_GetItemString(self->tp_dict, "__doc__");
+ if ((r == Py_None) &&
+ (PyDict_DelItemString(self->tp_dict, "__doc__") < 0)
+ )
+ return -1;
+ }
+
/* set up __get__, if necessary */
if (self->tp_descr_get != of_get)
{
Modified: Zope/trunk/lib/python/ExtensionClass/tests.py
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/tests.py 2004-09-30 21:02:07 UTC (rev 27724)
+++ Zope/trunk/lib/python/ExtensionClass/tests.py 2004-09-30 21:18:50 UTC (rev 27725)
@@ -170,6 +170,8 @@
{}
"""
+
+
def cmpattrs(self, other, *attrs):
for attr in attrs:
if attr[:3] in ('_v_', '_p_'):
@@ -690,6 +692,23 @@
"""
+def test_inheriting___doc__():
+ """Old-style ExtensionClass inherited __doc__ from base classes.
+
+ >>> class E(Base):
+ ... "eek"
+
+ >>> class EE(E):
+ ... pass
+
+ >>> EE.__doc__
+ 'eek'
+
+ >>> EE().__doc__
+ 'eek'
+
+ """
+
from doctest import DocTestSuite
import unittest
More information about the Zope-Checkins
mailing list