Repository: RustPython/RustPython (language: rust)

Issue:
Cannot import `dns.name`: `index out of bounds: the len is 0 but the index is 0`
## Feature

I cannot pinpoint the exact feature, that triggers the panic, but if I remove [this line](https://github.com/rthalley/dnspython/blob/0a742b9658977175663dc30da902342a8c2bacac/dns/name.py#L357), it works. However, if I use `dns.immutable.immutable(dns.name.Name)` in REPL after deleting that line, everything also works perfectly.

## How to reproduce

```
❯ git log -1
commit b4bae8173be2e691a8a7234bab4baa2ffd4a116a (HEAD -> main, origin/main, origin/HEAD)
Merge: e142d655b 3c10888e3
Author: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Date:   Mon Jul 1 21:09:49 2024 +0900

    Merge pull request #5348 from JamesClarke7283/developer-experiance-tweaks
    
    DX improvements: Updated MSRV, added cargo deny toml file, and added lints to workspace
❯ cargo run --release --features ssl
    Finished `release` profile [optimized] target(s) in 0.64s
     Running `target/release/rustpython`
Welcome to the magnificent Rust Python 0.3.1 interpreter 😱 🖖
RustPython 3.12.0
Type "help", "copyright", "credits" or "license" for more information.
>>>>> import dns.name
set value to PackageNotFoundError ignored
thread 'main' panicked at vm/src/object/core.rs:838:10:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
❯
```

Here is gist with logs when I call it with `RUST_BACKTRACE=1` and `-vvv`: https://gist.github.com/PerchunPak/87c752674cdca0d460be327175531ae9


Discussion / hints:
@moreal do you have any clue?

Fix patch:
diff --git a/vm/src/builtins/descriptor.rs b/vm/src/builtins/descriptor.rs
index 16340c3a62..408b0efc84 100644
--- a/vm/src/builtins/descriptor.rs
+++ b/vm/src/builtins/descriptor.rs
@@ -320,10 +320,13 @@ fn set_slot_at_object(
                 PySetterValue::Delete => obj.set_slot(offset, None),
             };
         }
-        MemberKind::ObjectEx => match value {
-            PySetterValue::Assign(v) => obj.set_slot(offset, Some(v)),
-            PySetterValue::Delete => obj.set_slot(offset, None),
-        },
+        MemberKind::ObjectEx => {
+            let value = match value {
+                PySetterValue::Assign(v) => Some(v),
+                PySetterValue::Delete => None,
+            };
+            obj.set_slot(offset, value);
+        }
     }
 
     Ok(())
diff --git a/vm/src/builtins/type.rs b/vm/src/builtins/type.rs
index 296afff17c..15df5ff3c5 100644
--- a/vm/src/builtins/type.rs
+++ b/vm/src/builtins/type.rs
@@ -934,9 +934,14 @@ impl Constructor for PyType {
                 None
             };
 
-        let base_member_count = base.slots.member_count;
-        let member_count: usize =
-            base.slots.member_count + heaptype_slots.as_ref().map(|x| x.len()).unwrap_or(0);
+        // FIXME: this is a temporary fix. multi bases with multiple slots will break object
+        let base_member_count = bases
+            .iter()
+            .map(|base| base.slots.member_count)
+            .max()
+            .unwrap();
+        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 (slots, heaptype_ext) = {


Test patch: