Skip to content

Commit 37a3dd5

Browse files
author
Guido van Rossum
committed
Backport fix for #192 to Python 2. Remove optimistic TODO about #196.
1 parent 238502e commit 37a3dd5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

python2/test_typing.py

+3
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ def foo(x):
673673
assert type(a) is Node
674674
assert type(b) is Node
675675
assert type(c) is Node
676+
assert a.label == x
677+
assert b.label == x
678+
assert c.label == x
676679

677680
foo(42)
678681

python2/typing.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,11 @@ def __new__(cls, *args, **kwds):
10931093
for i, c in enumerate(cls.__mro__[:-1]):
10941094
if isinstance(c, GenericMeta) and _gorg(c) is Generic:
10951095
next_in_mro = cls.__mro__[i+1]
1096-
return next_in_mro.__new__(_gorg(cls))
1096+
origin = _gorg(cls)
1097+
obj = next_in_mro.__new__(origin)
1098+
if origin is not cls:
1099+
obj.__init__(*args, **kwds)
1100+
return obj
10971101

10981102

10991103
def cast(typ, val):

0 commit comments

Comments
 (0)