[ python-Bugs-902628 ] doctest confused by super-instances in
class-dicts
SourceForge.net
noreply at sourceforge.net
Fri Jul 16 17:12:16 CEST 2004
Bugs item #902628, was opened at 2004-02-23 07:10
Message generated for change (Comment added) made by edloper
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=902628&group_id=5470
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Christian Tanzer (tanzer)
Assigned to: Nobody/Anonymous (nobody)
Summary: doctest confused by super-instances in class-dicts
Initial Comment:
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/confuse_doctest.py",
line 14, in ?
import doctest, confuse_doctest
File
"/Node/tttprime/ttt/private/tanzer/temp/confuse_doctest.py",
line 15, in ?
doctest.testmod(confuse_doctest)
File "/usr/lib/python2.3/doctest.py", line 1148, in
testmod
f, t = tester.rundict(m.__dict__, name, m)
File "/usr/lib/python2.3/doctest.py", line 908, in
rundict
f2, t2 = self.__runone(value, name + "." + thisname)
File "/usr/lib/python2.3/doctest.py", line 1069, in
__runone
return self.rundoc(target, name)
File "/usr/lib/python2.3/doctest.py", line 828, in rundoc
f2, t2 = self.run__test__(d, name)
File "/usr/lib/python2.3/doctest.py", line 937, in
run__test__
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
----------------------------------------------------------------------
Comment By: Edward Loper (edloper)
Date: 2004-07-16 11:12
Message:
Logged In: YES
user_id=195958
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,
super)".
----------------------------------------------------------------------
Comment By: Christian Tanzer (tanzer)
Date: 2004-02-23 07:15
Message:
Logged In: YES
user_id=2402
I patched doctest.py 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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=902628&group_id=5470
More information about the Python-bugs-list
mailing list