mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
feat(vm/slot): implement Py_TPFLAGS_MANAGED_DICT for class objects (#5949)
This commit is contained in:
2
Lib/test/test_array.py
vendored
2
Lib/test/test_array.py
vendored
@@ -1285,8 +1285,6 @@ class NumberTest(BaseTest):
|
||||
self.assertRaises(OverflowError, array.array, self.typecode, [upper+1])
|
||||
self.assertRaises(OverflowError, a.__setitem__, 0, upper+1)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_subclassing(self):
|
||||
typecode = self.typecode
|
||||
class ExaggeratingArray(array.array):
|
||||
|
||||
2
Lib/test/test_importlib/test_metadata_api.py
vendored
2
Lib/test/test_importlib/test_metadata_api.py
vendored
@@ -139,8 +139,6 @@ class APITests(
|
||||
def test_entry_points_missing_group(self):
|
||||
assert entry_points(group='missing') == ()
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_entry_points_allows_no_attributes(self):
|
||||
ep = entry_points().select(group='entries', name='main')
|
||||
with self.assertRaises(AttributeError):
|
||||
|
||||
2
Lib/test/test_property.py
vendored
2
Lib/test/test_property.py
vendored
@@ -242,8 +242,6 @@ class PropertySubSlots(property):
|
||||
|
||||
class PropertySubclassTests(unittest.TestCase):
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_slots_docstring_copy_exception(self):
|
||||
try:
|
||||
class Foo(object):
|
||||
|
||||
2
Lib/test/test_weakref.py
vendored
2
Lib/test/test_weakref.py
vendored
@@ -1132,8 +1132,6 @@ class SubclassableWeakrefTestCase(TestBase):
|
||||
self.assertIn(r1, refs)
|
||||
self.assertIn(r2, refs)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_subclass_refs_with_slots(self):
|
||||
class MyRef(weakref.ref):
|
||||
__slots__ = "slot1", "slot2"
|
||||
|
||||
@@ -1038,9 +1038,6 @@ impl Constructor for PyType {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Flags is currently initialized with HAS_DICT. Should be
|
||||
// updated when __slots__ are supported (toggling the flag off if
|
||||
// a class has __slots__ defined).
|
||||
let heaptype_slots: Option<PyRef<PyTuple<PyStrRef>>> =
|
||||
if let Some(x) = attributes.get(identifier!(vm, __slots__)) {
|
||||
let slots = if x.class().is(vm.ctx.types.str_type) {
|
||||
@@ -1072,7 +1069,12 @@ impl Constructor for PyType {
|
||||
let heaptype_member_count = heaptype_slots.as_ref().map(|x| x.len()).unwrap_or(0);
|
||||
let member_count: usize = base_member_count + heaptype_member_count;
|
||||
|
||||
let flags = PyTypeFlags::heap_type_flags() | PyTypeFlags::HAS_DICT;
|
||||
let mut flags = PyTypeFlags::heap_type_flags();
|
||||
// Only add HAS_DICT and MANAGED_DICT if __slots__ is not defined.
|
||||
if heaptype_slots.is_none() {
|
||||
flags |= PyTypeFlags::HAS_DICT | PyTypeFlags::MANAGED_DICT;
|
||||
}
|
||||
|
||||
let (slots, heaptype_ext) = {
|
||||
let slots = PyTypeSlots {
|
||||
flags,
|
||||
|
||||
@@ -122,6 +122,7 @@ bitflags! {
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct PyTypeFlags: u64 {
|
||||
const MANAGED_DICT = 1 << 4;
|
||||
const IMMUTABLETYPE = 1 << 8;
|
||||
const HEAPTYPE = 1 << 9;
|
||||
const BASETYPE = 1 << 10;
|
||||
|
||||
Reference in New Issue
Block a user