summaryrefslogtreecommitdiffstats
path: root/Lib/test/crashers
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2007-02-27 18:29:45 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2007-02-27 18:29:45 (GMT)
commitfa955697fa0986b19abac7b026c8f00b4393adf9 (patch)
tree33731c5bb7b7e6fee121763b7c29439f1cc97779 /Lib/test/crashers
parent2d1f5c93bbe3ed6202e14e9d3c3708174b62f8e6 (diff)
downloadcpython-fa955697fa0986b19abac7b026c8f00b4393adf9.zip
cpython-fa955697fa0986b19abac7b026c8f00b4393adf9.tar.gz
cpython-fa955697fa0986b19abac7b026c8f00b4393adf9.tar.bz2
Add checking for a number of metaclass error conditions.
We add some new rules that are required for preserving internal invariants of types. 1. If type (or a subclass of type) appears in bases, it must appear before any non-type bases. If a non-type base (like a regular new-style class) occurred first, it could trick type into allocating the new class an __dict__ which must be impossible. 2. There are several checks that are made of bases when creating a type. Those checks are now repeated when assigning to __bases__. We also add the restriction that assignment to __bases__ may not change the metaclass of the type. Add new tests for these cases and for a few other oddball errors that were no previously tested. Remove a crasher test that was fixed. Also some internal refactoring: Extract the code to find the most derived metaclass of a type and its bases. It is now needed in two places. Rewrite the TypeError checks in test_descr to use doctest. The tests now clearly show what exception they expect to see.
Diffstat (limited to 'Lib/test/crashers')
-rw-r--r--Lib/test/crashers/modify_dict_attr.py19
1 files changed, 0 insertions, 19 deletions
diff --git a/Lib/test/crashers/modify_dict_attr.py b/Lib/test/crashers/modify_dict_attr.py
deleted file mode 100644
index dfce467..0000000
--- a/Lib/test/crashers/modify_dict_attr.py
+++ /dev/null
@@ -1,19 +0,0 @@
-
-# http://python.org/sf/1303614
-
-class Y(object):
- pass
-
-class type_with_modifiable_dict(Y, type):
- pass
-
-class MyClass(object):
- """This class has its __dict__ attribute completely exposed:
- user code can read, reassign and even delete it.
- """
- __metaclass__ = type_with_modifiable_dict
-
-
-if __name__ == '__main__':
- del MyClass.__dict__ # if we set tp_dict to NULL,
- print MyClass # doing anything with MyClass segfaults