Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbaf2d91

Browse files
author
Guido van Rossum
committed
Backport fix for#192 to Python 2. Remove optimistic TODO about#196.
1 parent238502e commitbaf2d91

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

‎python2/test_typing.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ def foo(x):
673673
asserttype(a)isNode
674674
asserttype(b)isNode
675675
asserttype(c)isNode
676+
asserta.label==x
677+
assertb.label==x
678+
assertc.label==x
676679

677680
foo(42)
678681

‎python2/typing.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,11 @@ def __new__(cls, *args, **kwds):
10931093
fori,cinenumerate(cls.__mro__[:-1]):
10941094
ifisinstance(c,GenericMeta)and_gorg(c)isGeneric:
10951095
next_in_mro=cls.__mro__[i+1]
1096-
returnnext_in_mro.__new__(_gorg(cls))
1096+
origin=_gorg(cls)
1097+
obj=next_in_mro.__new__(origin)
1098+
iforiginisnotcls:
1099+
obj.__init__(*args,**kwds)
1100+
returnobj
10971101

10981102

10991103
defcast(typ,val):

‎src/typing.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,6 @@ def lookup_name(mapping: Mapping[X, Y], key: X, default: Y) -> Y:
10691069

10701070
__slots__= ()
10711071

1072-
# TODO: GenericMeta should compute next_in_mro and stuff its
1073-
# __new__ in the class dict, if origin is cls. Issue #196.
10741072
def__new__(cls,*args,**kwds):
10751073
next_in_mro=object
10761074
# Look for the last occurrence of Generic or Generic[...].

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp