mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Fix SF bug #472234: type(obj) calls type->tp_init (Roeland Rengelink)
The fix is a band-aid: type_call() now makes the same exception for a single-argument call to type() as type_new() was already making.
This commit is contained in:
parent
b7da67a873
commit
f76de62f7d
3 changed files with 20 additions and 0 deletions
|
@ -716,6 +716,18 @@ def metaclass():
|
|||
return "D" + self.__super._get_x()
|
||||
vereq(D().x, "DCBA")
|
||||
|
||||
# Make sure type(x) doesn't call x.__class__.__init__
|
||||
class T(type):
|
||||
counter = 0
|
||||
def __init__(self, *args):
|
||||
T.counter += 1
|
||||
class C:
|
||||
__metaclass__ = T
|
||||
vereq(T.counter, 1)
|
||||
a = C()
|
||||
vereq(type(a), C)
|
||||
vereq(T.counter, 1)
|
||||
|
||||
def pymods():
|
||||
if verbose: print "Testing Python subclass of module..."
|
||||
log = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue