bpo-34871: inspect: Don't pollute sys.modules (GH-9696)

https://bugs.python.org/issue34871
This commit is contained in:
INADA Naoki 2018-10-05 01:47:09 +09:00 committed by Miss Islington (bot)
parent c57eb9a336
commit 6f85b826b5
2 changed files with 3 additions and 1 deletions

View File

@ -1988,7 +1988,7 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
module = sys.modules.get(module_name, None)
if module:
module_dict = module.__dict__
sys_module_dict = sys.modules
sys_module_dict = sys.modules.copy()
def parse_name(node):
assert isinstance(node, ast.arg)

View File

@ -0,0 +1,2 @@
Fix inspect module polluted ``sys.modules`` when parsing
``__text_signature__`` of callable.