summaryrefslogtreecommitdiffstats
path: root/Lib/rlcompleter.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-07-31 21:14:08 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-07-31 21:14:08 (GMT)
commitdcedaf6e53fcba48aa8185d0dc27d832da2615aa (patch)
tree1dec81865462dd482c792e3790280a1c8393e18f /Lib/rlcompleter.py
parentc27cd71cd71e5b3f464f6994e2a73f201eb430ca (diff)
downloadcpython-dcedaf6e53fcba48aa8185d0dc27d832da2615aa.zip
cpython-dcedaf6e53fcba48aa8185d0dc27d832da2615aa.tar.gz
cpython-dcedaf6e53fcba48aa8185d0dc27d832da2615aa.tar.bz2
Issue #18214: Improve finalization of Python modules to avoid setting their globals to None, in most cases.
Diffstat (limited to 'Lib/rlcompleter.py')
-rw-r--r--Lib/rlcompleter.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index d3a4437..8775730 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -29,6 +29,7 @@ Notes:
"""
+import atexit
import builtins
import __main__
@@ -158,3 +159,8 @@ except ImportError:
pass
else:
readline.set_completer(Completer().complete)
+ # Release references early at shutdown (the readline module's
+ # contents are quasi-immortal, and the completer function holds a
+ # reference to globals).
+ atexit.register(lambda: readline.set_completer(None))
+