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

https://bugs.python.org/issue34871
(cherry picked from commit 6f85b826b5)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2018-10-04 12:26:33 -07:00 committed by Yury Selivanov
parent a67bd53d3f
commit 476c294f26
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.