Title: doctest confused by super-instances in class-dicts
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: edloper, tanzer, tim.peters
Priority: normal Keywords:

Created on 2004-02-23 12:10 by tanzer, last changed 2004-08-08 06:14 by tim.peters. This issue is now closed.

File name Uploaded Description Edit tanzer, 2004-02-23 12:10
doctest_patch tanzer, 2004-02-23 12:15
Messages (4)
msg20120 - (view) Author: Christian Tanzer (tanzer) * Date: 2004-02-23 12:10
In Python 2.3.3, doctest chokes on classes which
contain an attribute of type super: 

Traceback (most recent call last):
  File "/ttt/private/tanzer/temp/",
line 14, in ?
    import doctest, confuse_doctest
line 15, in ?
  File "/usr/lib/python2.3/", line 1148, in
    f, t = tester.rundict(m.__dict__, name, m)
  File "/usr/lib/python2.3/", line 908, in
    f2, t2 = self.__runone(value, name + "." + thisname)
  File "/usr/lib/python2.3/", line 1069, in
    return self.rundoc(target, name)
  File "/usr/lib/python2.3/", line 828, in rundoc
    f2, t2 = self.run__test__(d, name)
  File "/usr/lib/python2.3/", line 937, in
    raise TypeError("Tester.run__test__: values in "
TypeError: Tester.run__test__: values in dict must be
strings, functions, methods, or classes; <super: <class
'A'>, NULL>

A simple example triggering the bug is attached.

Python 2.3.3 (#2, Jan 13 2004, 00:47:05) 
[GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2

msg20121 - (view) Author: Christian Tanzer (tanzer) * Date: 2004-02-23 12:15
Logged In: YES 

I patched to avoid the traceback (see attached
patch-file). I'm not sure if this is the right place to fix
the bug, though. Maybe inspect.classify_class_attrs should
be changed instead?

The second chunk of the patch improves the traceback given
by doctest by giving the name of the offending dict-item.
msg20122 - (view) Author: Edward Loper (edloper) * Date: 2004-07-16 15:12
Logged In: YES 

The problem is that inspect.get_class_attrs()'s "method" 
classification is a bit hetergeneous: it contains methods, 
and any method descriptors *except* classmethod and 
staticmethod.  The proposed patch will fix behavior for 
super(), but not for any other method descriptors.  So 
perhaps it would be better to explicitly test "_isfunction(v) 
or _ismethod(v)" rather than "not isinstance(value, 
msg20123 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-08-08 06:14
Logged In: YES 

This got fixed as part of the massive doctest refactoring for 
2.4.  I have no plan to backport any of that to the 2.3 line.
Date User Action Args
2004-02-23 12:10:08tanzercreate