Skip to content

Commit 78ff936

Browse files
committed
Load docstring from slots
1 parent 0b6de47 commit 78ff936

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎vm/src/builtins/pytype.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ impl PyType {
520520

521521
#[pyproperty(magic)]
522522
fn text_signature(&self) -> Option<String> {
523-
let doc_string = self.get_attr("__doc__");
524-
let doc: PyStrRef = doc_string.and_then(|o| o.downcast().ok())?;
525-
get_text_signature_from_internal_doc(self.name().as_str(), doc.as_str())
523+
self.slots
524+
.doc
525+
.and_then(|doc| get_text_signature_from_internal_doc(self.name().as_str(), doc))
526526
.map(|signature| signature.to_string())
527527
}
528528
}

‎vm/src/pyobject.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ pub trait PyClassImpl: PyClassDef {
11261126
let mut slots = PyTypeSlots {
11271127
flags: Self::TP_FLAGS,
11281128
name: PyRwLock::new(Some(Self::TP_NAME.to_owned())),
1129+
doc: Self::DOC,
11291130
..Default::default()
11301131
};
11311132
Self::extend_slots(&mut slots);

‎vm/src/slots.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ pub struct PyTypeSlots {
9696

9797
// Flags to define presence of optional/expanded features
9898
pub flags: PyTpFlags,
99+
99100
// tp_doc
101+
pub doc: Option<&'static str>,
100102

101103
// Strong reference on a heap type, borrowed reference on a static type
102104
// tp_base

0 commit comments

Comments
 (0)