summaryrefslogtreecommitdiff
path: root/tests/basics/builtin_super.py
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2023-11-08 16:42:56 +0100
committerDamien George <damien@micropython.org>2024-07-25 12:27:33 +1000
commit093d0c0a17751c11c24f82594bb8208ca1ea9744 (patch)
tree02dd7781a8de5bcaf85eaf3bb1517f723483a427 /tests/basics/builtin_super.py
parentd1bf0eeb0fb0c485da076075a15ffdfd5fb68303 (diff)
py/objtype: Validate super() arguments.
This fixes various null dereferencing and out-of-bounds access because super_attr assumes the held obj is effectively an object of the held type, which is now verified. Fixes issue #12830. Signed-off-by: stijn <stijn@ignitron.net>
Diffstat (limited to 'tests/basics/builtin_super.py')
-rw-r--r--tests/basics/builtin_super.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/basics/builtin_super.py b/tests/basics/builtin_super.py
new file mode 100644
index 000000000..5f7c3ae01
--- /dev/null
+++ b/tests/basics/builtin_super.py
@@ -0,0 +1,15 @@
+# Check that super rejects invalid arguments.
+try:
+ super(str, 0)
+except TypeError:
+ print("TypeError")
+
+try:
+ super(str, int)
+except TypeError:
+ print("TypeError")
+
+try:
+ super(0, int)
+except TypeError:
+ print("TypeError")