]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34871: inspect: Don't pollute sys.modules (GH-9696)
authorINADA Naoki <methane@users.noreply.github.com>
Thu, 4 Oct 2018 16:47:09 +0000 (01:47 +0900)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 4 Oct 2018 16:47:09 +0000 (09:47 -0700)
https://bugs.python.org/issue34871

Lib/inspect.py
Misc/NEWS.d/next/Library/2018-10-04-18-46-54.bpo-34871.t3X-dB.rst [new file with mode: 0644]

index 5b7f526939b60ffe9ce76924520fa8c891892484..857892bc8144c563b5139286330a04452dbd4f0e 100644 (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)
diff --git a/Misc/NEWS.d/next/Library/2018-10-04-18-46-54.bpo-34871.t3X-dB.rst b/Misc/NEWS.d/next/Library/2018-10-04-18-46-54.bpo-34871.t3X-dB.rst
new file mode 100644 (file)
index 0000000..8cff156
--- /dev/null
@@ -0,0 +1,2 @@
+Fix inspect module polluted ``sys.modules`` when parsing
+``__text_signature__`` of callable.