summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/idlelib/run.py8
-rw-r--r--Lib/sgmllib.py2
-rw-r--r--Lib/test/test_dictcomps.py54
3 files changed, 60 insertions, 4 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index c1bc8eb..7914d20 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -193,14 +193,16 @@ def flush_stdout():
"""XXX How to do this now?"""
def exit():
- """Exit subprocess, possibly after first deleting sys.exitfunc
+ """Exit subprocess, possibly after first clearing exit functions.
If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
- sys.exitfunc will be removed before exiting. (VPython support)
+ functions registered with atexit will be removed before exiting.
+ (VPython support)
"""
if no_exitfunc:
- del sys.exitfunc
+ import atexit
+ atexit._clear()
sys.exit(0)
class MyRPCServer(rpc.RPCServer):
diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py
index 987b65ed..ce5807b 100644
--- a/Lib/sgmllib.py
+++ b/Lib/sgmllib.py
@@ -428,7 +428,7 @@ class SGMLParser(markupbase.ParserBase):
if replacement is None:
self.unknown_entityref(name)
else:
- self.handle_data(self.convert_entityref(name))
+ self.handle_data(replacement)
# Example -- handle data, should be overridden
def handle_data(self, data):
diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py
new file mode 100644
index 0000000..9af9e48
--- /dev/null
+++ b/Lib/test/test_dictcomps.py
@@ -0,0 +1,54 @@
+
+doctests = """
+
+ >>> k = "old value"
+ >>> { k: None for k in range(10) }
+ {0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}
+ >>> k
+ 'old value'
+
+ >>> { k: k+10 for k in range(10) }
+ {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19}
+
+ >>> g = "Global variable"
+ >>> { k: g for k in range(10) }
+ {0: 'Global variable', 1: 'Global variable', 2: 'Global variable', 3: 'Global variable', 4: 'Global variable', 5: 'Global variable', 6: 'Global variable', 7: 'Global variable', 8: 'Global variable', 9: 'Global variable'}
+
+ >>> { k: v for k in range(10) for v in range(10) if k == v }
+ {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
+
+ >>> { k: v for v in range(10) for k in range(v*9, v*10) }
+ {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4, 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6, 55: 6, 56: 6, 57: 6, 58: 6, 59: 6, 63: 7, 64: 7, 65: 7, 66: 7, 67: 7, 68: 7, 69: 7, 72: 8, 73: 8, 74: 8, 75: 8, 76: 8, 77: 8, 78: 8, 79: 8, 81: 9, 82: 9, 83: 9, 84: 9, 85: 9, 86: 9, 87: 9, 88: 9, 89: 9}
+
+ >>> { x: y for y, x in ((1, 2), (3, 4)) } = 5 # doctest: +IGNORE_EXCEPTION_DETAIL
+ Traceback (most recent call last):
+ ...
+ SyntaxError: ...
+
+ >>> { x: y for y, x in ((1, 2), (3, 4)) } += 5 # doctest: +IGNORE_EXCEPTION_DETAIL
+ Traceback (most recent call last):
+ ...
+ SyntaxError: ...
+
+"""
+
+__test__ = {'doctests' : doctests}
+
+def test_main(verbose=None):
+ import sys
+ from test import test_support
+ from test import test_dictcomps
+ test_support.run_doctest(test_dictcomps, verbose)
+
+ # verify reference counting
+ if verbose and hasattr(sys, "gettotalrefcount"):
+ import gc
+ counts = [None] * 5
+ for i in range(len(counts)):
+ test_support.run_doctest(test_dictcomps, verbose)
+ gc.collect()
+ counts[i] = sys.gettotalrefcount()
+ print(counts)
+
+if __name__ == "__main__":
+ test_main(verbose=True)