@@ -87,7 +87,7 @@ internal static ClassManagerState SaveRuntimeData()
8787 if ( ( Runtime . PyDict_DelItemString ( dict . Borrow ( ) , member ) == - 1 ) &&
8888 ( Exceptions . ExceptionMatches ( Exceptions . KeyError ) ) )
8989 {
90- // Trying to remove a key that's not in the dictionary
90+ // Trying to remove a key that's not in the dictionary
9191 // raises an error. We don't care about it.
9292 Runtime . PyErr_Clear ( ) ;
9393 }
@@ -215,7 +215,7 @@ internal static void InitClassBase(Type type, ClassBase impl, ReflectedClrType p
215215 impl . indexer = info . indexer ;
216216 impl . richcompare . Clear ( ) ;
217217
218-
218+
219219 // Finally, initialize the class __dict__ and return the object.
220220 using var newDict = Runtime . PyObject_GenericGetDict ( pyType . Reference ) ;
221221 BorrowedReference dict = newDict . Borrow ( ) ;
@@ -271,6 +271,15 @@ internal static void InitClassBase(Type type, ClassBase impl, ReflectedClrType p
271271 Runtime . PyDict_SetItem ( dict , PyIdentifier . __doc__ , doc . Borrow ( ) ) ;
272272 }
273273 }
274+
275+ if ( Runtime . PySequence_Contains ( dict , PyIdentifier . __doc__ ) != 1 )
276+ {
277+ // Ensure that at least some doc string is set
278+ using var fallbackDoc = Runtime . PyString_FromString (
279+ $ "Python wrapper for .NET type { type } "
280+ ) ;
281+ Runtime . PyDict_SetItem ( dict , PyIdentifier . __doc__ , fallbackDoc . Borrow ( ) ) ;
282+ }
274283 }
275284 doc . Dispose ( ) ;
276285
@@ -562,7 +571,7 @@ private static ClassInfo GetClassInfo(Type type, ClassBase impl)
562571
563572 return ci ;
564573 }
565-
574+
566575 /// <summary>
567576 /// This class owns references to PyObjects in the `members` member.
568577 /// The caller has responsibility to DECREF them.
0 commit comments