Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3677,7 +3677,11 @@ fn mro_internal(typ: &Py<PyType>, vm: &VirtualMachine) -> PyResult<i32> {

/// Returns true if the two types have different instance layouts.
fn shape_differs(t1: &Py<PyType>, t2: &Py<PyType>) -> bool {
t1.slots.basicsize != t2.slots.basicsize || t1.slots.itemsize != t2.slots.itemsize
// Prefix member cells do not change basicsize, but still make a base
// solid: unrelated slotted bases cannot share the same member indexes.
t1.slots.basicsize != t2.slots.basicsize
|| t1.slots.itemsize != t2.slots.itemsize
|| t1.slots.member_count != t2.slots.member_count
}

fn solid_base<'a>(typ: &'a Py<PyType>, vm: &VirtualMachine) -> &'a Py<PyType> {
Expand Down
50 changes: 50 additions & 0 deletions extra_tests/snippets/builtin_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,53 @@ class StrKey(str):
warnings.simplefilter("error")
with assert_raises(RuntimeWarning):
type("NonStringKeyRaises", (), {6: 7})


class Left:
__slots__ = ("left",)


class Right:
__slots__ = ("right",)


with assert_raises(TypeError):

class Conflict(Left, Right):
pass
Comment on lines +761 to +764

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the disallowed test-logic block

This appended scenario changes test logic and assertions in extra_tests/snippets/builtin_type.py, but the root AGENTS policy explicitly limits test-file modifications to adding or removing expected-failure decorators and related TODO comments. Remove this block or obtain an explicit policy exception before landing it.

AGENTS.md reference: AGENTS.md:L273-L279

Useful? React with 👍 / 👎.



with assert_raises(TypeError):

class ReverseConflict(Right, Left):
pass


class Empty:
__slots__ = ()


class Compatible(Left, Empty):
pass


value = Compatible()
value.left = 42
assert value.left == 42


class FirstChild(Left):
__slots__ = ()


class SecondChild(Left):
__slots__ = ()


class Diamond(FirstChild, SecondChild):
pass


value = Diamond()
value.left = 43
assert value.left == 43
Loading