Skip to content

Commit 6f85b82

Browse files
methanemiss-islington
authored andcommitted
bpo-34871: inspect: Don't pollute sys.modules (GH-9696)
https://bugs.python.org/issue34871
1 parent c57eb9a commit 6f85b82

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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)