Patch# 1258 by Christian Heimes: kill basestring.

I like this because it makes the code shorter! :-)
This commit is contained in:
Guido van Rossum 2007-10-16 18:12:55 +00:00
parent 60d241f135
commit 3172c5d263
77 changed files with 171 additions and 217 deletions

View file

@ -443,7 +443,7 @@ class DocTest:
Create a new DocTest containing the given examples. The
DocTest's globals are initialized with a copy of `globs`.
"""
assert not isinstance(examples, basestring), \
assert not isinstance(examples, str), \
"DocTest no longer accepts str; use DocTestParser instead"
self.examples = examples
self.docstring = docstring
@ -875,13 +875,13 @@ class DocTestFinder:
# Look for tests in a module's __test__ dictionary.
if inspect.ismodule(obj) and self._recurse:
for valname, val in getattr(obj, '__test__', {}).items():
if not isinstance(valname, basestring):
if not isinstance(valname, str):
raise ValueError("DocTestFinder.find: __test__ keys "
"must be strings: %r" %
(type(valname),))
if not (inspect.isfunction(val) or inspect.isclass(val) or
inspect.ismethod(val) or inspect.ismodule(val) or
isinstance(val, basestring)):
isinstance(val, str)):
raise ValueError("DocTestFinder.find: __test__ values "
"must be strings, functions, methods, "
"classes, or modules: %r" %
@ -914,7 +914,7 @@ class DocTestFinder:
"""
# Extract the object's docstring. If it doesn't have one,
# then return None (no test for this object).
if isinstance(obj, basestring):
if isinstance(obj, str):
docstring = obj
else:
try:
@ -922,7 +922,7 @@ class DocTestFinder:
docstring = ''
else:
docstring = obj.__doc__
if not isinstance(docstring, basestring):
if not isinstance(docstring, str):
docstring = str(docstring)
except (TypeError, AttributeError):
docstring = ''