Backed out changeset af29d89083b3 (closes #25548) (closes #27498)

This commit is contained in:
Benjamin Peterson 2016-07-13 21:13:29 -07:00
parent fb4f8257bf
commit ab078e9ed1
20 changed files with 92 additions and 105 deletions

View file

@ -37,16 +37,16 @@ test_1 = """
Here's the new type at work:
>>> print(defaultdict) # show our type
<class 'test.test_descrtut.defaultdict' ...>
<class 'test.test_descrtut.defaultdict'>
>>> print(type(defaultdict)) # its metatype
<class 'type' ...>
<class 'type'>
>>> a = defaultdict(default=0.0) # create an instance
>>> print(a) # show the instance
{}
>>> print(type(a)) # show its type
<class 'test.test_descrtut.defaultdict' ...>
<class 'test.test_descrtut.defaultdict'>
>>> print(a.__class__) # show its class
<class 'test.test_descrtut.defaultdict' ...>
<class 'test.test_descrtut.defaultdict'>
>>> print(type(a) is a.__class__) # its type is its class
True
>>> a[1] = 3.25 # modify the instance
@ -149,11 +149,11 @@ Introspecting instances of built-in types
For instance of built-in types, x.__class__ is now the same as type(x):
>>> type([])
<class 'list' ...>
<class 'list'>
>>> [].__class__
<class 'list' ...>
<class 'list'>
>>> list
<class 'list' ...>
<class 'list'>
>>> isinstance([], list)
True
>>> isinstance([], dict)
@ -258,19 +258,19 @@ implicit first argument that is the *class* for which they are invoked.
... print("classmethod", cls, y)
>>> C.foo(1)
classmethod <class 'test.test_descrtut.C' ...> 1
classmethod <class 'test.test_descrtut.C'> 1
>>> c = C()
>>> c.foo(1)
classmethod <class 'test.test_descrtut.C' ...> 1
classmethod <class 'test.test_descrtut.C'> 1
>>> class D(C):
... pass
>>> D.foo(1)
classmethod <class 'test.test_descrtut.D' ...> 1
classmethod <class 'test.test_descrtut.D'> 1
>>> d = D()
>>> d.foo(1)
classmethod <class 'test.test_descrtut.D' ...> 1
classmethod <class 'test.test_descrtut.D'> 1
This prints "classmethod __main__.D 1" both times; in other words, the
class passed as the first argument of foo() is the class involved in the
@ -286,11 +286,11 @@ But notice this:
>>> E.foo(1)
E.foo() called
classmethod <class 'test.test_descrtut.C' ...> 1
classmethod <class 'test.test_descrtut.C'> 1
>>> e = E()
>>> e.foo(1)
E.foo() called
classmethod <class 'test.test_descrtut.C' ...> 1
classmethod <class 'test.test_descrtut.C'> 1
In this example, the call to C.foo() from E.foo() will see class C as its
first argument, not class E. This is to be expected, since the call
@ -350,7 +350,7 @@ Hmm -- property is builtin now, so let's try it that way too.
>>> del property # unmask the builtin
>>> property
<class 'property' ...>
<class 'property'>
>>> class C(object):
... def __init__(self):
@ -478,8 +478,7 @@ def test_main(verbose=None):
# business is used the name can change depending on how the test is
# invoked.
from test import support, test_descrtut
import doctest
support.run_doctest(test_descrtut, verbose, optionflags=doctest.ELLIPSIS)
support.run_doctest(test_descrtut, verbose)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":