summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-03 19:47:54 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-03 19:47:54 (GMT)
commite69c320d48a5708c900cc6c78bf006fef68c62bd (patch)
tree04e85c6cfaf9f5b6eb1a79a263e5cf6e51cc1ae9 /Lib/test
parent6554cb94ba328939366ac6f12104d70d52d57cdd (diff)
downloadcpython-e69c320d48a5708c900cc6c78bf006fef68c62bd.zip
cpython-e69c320d48a5708c900cc6c78bf006fef68c62bd.tar.gz
cpython-e69c320d48a5708c900cc6c78bf006fef68c62bd.tar.bz2
Patch #1537 from Chad Austin
Change GeneratorExit's base class from Exception to BaseException
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/exception_hierarchy.txt2
-rw-r--r--Lib/test/test_generators.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt
index 965252c..73ccb66 100644
--- a/Lib/test/exception_hierarchy.txt
+++ b/Lib/test/exception_hierarchy.txt
@@ -1,8 +1,8 @@
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+ +-- GeneratorExit
+-- Exception
- +-- GeneratorExit
+-- StopIteration
+-- ArithmeticError
| +-- FloatingPointError
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 4710c8c..0d6908d 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -1668,6 +1668,19 @@ And finalization:
exiting
+GeneratorExit is not caught by except Exception:
+
+>>> def f():
+... try: yield
+... except Exception: print 'except'
+... finally: print 'finally'
+
+>>> g = f()
+>>> g.next()
+>>> del g
+finally
+
+
Now let's try some ill-behaved generators:
>>> def f():