summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/subclass_native3.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/subclass_native3.py')
-rw-r--r--tests/basics/subclass_native3.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/basics/subclass_native3.py b/tests/basics/subclass_native3.py
new file mode 100644
index 0000000000..bd99ab0d6a
--- /dev/null
+++ b/tests/basics/subclass_native3.py
@@ -0,0 +1,22 @@
+class MyExc(Exception):
+ pass
+
+e = MyExc(100, "Some error")
+print(e)
+print(repr(e))
+print(e.args)
+
+try:
+ raise MyExc("Some error")
+except MyExc as e:
+ print("Caught exception:", repr(e))
+
+try:
+ raise MyExc("Some error2")
+except Exception as e:
+ print("Caught exception:", repr(e))
+
+try:
+ raise MyExc("Some error2")
+except:
+ print("Caught user exception")