cpython: 27cc5cce0292 (original) (raw)

Mercurial > cpython

changeset 97683:27cc5cce0292 3.5

Issue #24912: Prevent __class__ assignment to immutable built-in objects. [#24912]

Guido van Rossum guido@dropbox.com
date Fri, 04 Sep 2015 20:54:07 -0700
parents 438dde69871d
children 1c55f169f4ee 09b62202d9b7
files Lib/test/test_descr.py Misc/NEWS Objects/typeobject.c
diffstat 3 files changed, 106 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_descr.py 45 Misc/NEWS 2 Objects/typeobject.c 59

line wrap: on

line diff

--- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1036,6 +1036,51 @@ order (MRO) for bases """ self.assertTrue(m.class is types.ModuleType) self.assertFalse(hasattr(m, "a"))

+

+

+

+

+

+

+

+

+ def test_slots(self): # Testing slots... class C0(object):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Release date: 2015-09-06 Core and Builtins ----------------- +- Issue #24912: Prevent class assignment to immutable built-in objects. +

--- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3666,6 +3666,65 @@ object_set_class(PyObject *self, PyObjec return -1; } newto = (PyTypeObject *)value;

+

+

+

+

+

+

+ if (compatible_for_assignment(oldto, newto, "class")) { if (newto->tp_flags & Py_TPFLAGS_HEAPTYPE) Py_INCREF(newto);