Skip to content

Commit 7f94c10

Browse files
committed
patch typing not to reqiure contextlib
This will be correctly fixed in future CPython
1 parent 549cce2 commit 7f94c10

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎Lib/typing.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from abc import abstractmethod, ABCMeta
2323
import collections
2424
import collections.abc
25-
import contextlib
2625
import functools
2726
import operator
2827
import re as stdlib_re # Avoid confusion with the re we export.
@@ -2138,8 +2137,13 @@ class Other(Leaf): # Error reported by type checker
21382137
KeysView = _alias(collections.abc.KeysView, 1)
21392138
ItemsView = _alias(collections.abc.ItemsView, 2)
21402139
ValuesView = _alias(collections.abc.ValuesView, 1)
2141-
ContextManager = _alias(contextlib.AbstractContextManager, 1, name='ContextManager')
2142-
AsyncContextManager = _alias(contextlib.AbstractAsyncContextManager, 1, name='AsyncContextManager')
2140+
try:
2141+
# XXX: RUSTPYTHON; contextlib support for wasm
2142+
import contextlib
2143+
ContextManager = _alias(contextlib.AbstractContextManager, 1, name='ContextManager')
2144+
AsyncContextManager = _alias(contextlib.AbstractAsyncContextManager, 1, name='AsyncContextManager')
2145+
except ImportError:
2146+
pass
21432147
Dict = _alias(dict, 2, inst=False, name='Dict')
21442148
DefaultDict = _alias(collections.defaultdict, 2, name='DefaultDict')
21452149
OrderedDict = _alias(collections.OrderedDict, 2)

0 commit comments

Comments
 (0)