Skip to content

Commit 476c294

Browse files
miss-islingtonmethane
authored andcommitted
bpo-34871: inspect: Don't pollute sys.modules (GH-9696) (#9701)
https://bugs.python.org/issue34871 (cherry picked from commit 6f85b82) Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
1 parent a67bd53 commit 476c294

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
19881988
module = sys.modules.get(module_name, None)
19891989
if module:
19901990
module_dict = module.__dict__
1991-
sys_module_dict = sys.modules
1991+
sys_module_dict = sys.modules.copy()
19921992

19931993
def parse_name(node):
19941994
assert isinstance(node, ast.arg)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix inspect module polluted ``sys.modules`` when parsing
2+
``__text_signature__`` of callable.

0 commit comments

Comments
 (0)