| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,7 +87,7 @@ internal static ClassManagerState SaveRuntimeData() | |||
| 87 | 87 | if ((Runtime.PyDict_DelItemString(dict.Borrow(), member) == -1) && | |
| 88 | 88 | (Exceptions.ExceptionMatches(Exceptions.KeyError))) | |
| 89 | 89 | { | |
| 90 | - // Trying to remove a key that's not in the dictionary | ||
| 90 | + // Trying to remove a key that's not in the dictionary | ||
| 91 | 91 | // raises an error. We don't care about it. | |
| 92 | 92 | Runtime.PyErr_Clear(); | |
| 93 | 93 | } | |
@@ -215,7 +215,7 @@ internal static void InitClassBase(Type type, ClassBase impl, ReflectedClrType p | |||
| 215 | 215 | impl.indexer = info.indexer; | |
| 216 | 216 | impl.richcompare.Clear(); | |
| 217 | 217 | ||
| 218 | - | ||
| 218 | + | ||
| 219 | 219 | // Finally, initialize the class __dict__ and return the object. | |
| 220 | 220 | using var newDict = Runtime.PyObject_GenericGetDict(pyType.Reference); | |
| 221 | 221 | BorrowedReference dict = newDict.Borrow(); | |
@@ -271,6 +271,15 @@ internal static void InitClassBase(Type type, ClassBase impl, ReflectedClrType p | |||
| 271 | 271 | Runtime.PyDict_SetItem(dict, PyIdentifier.__doc__, doc.Borrow()); | |
| 272 | 272 | } | |
| 273 | 273 | } | |
| 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 | + } | ||
| 274 | 283 | } | |
| 275 | 284 | doc.Dispose(); | |
| 276 | 285 | ||
@@ -562,7 +571,7 @@ private static ClassInfo GetClassInfo(Type type, ClassBase impl) | |||
| 562 | 571 | ||
| 563 | 572 | return ci; | |
| 564 | 573 | } | |
| 565 | - | ||
| 574 | + | ||
| 566 | 575 | /// <summary> | |
| 567 | 576 | /// This class owns references to PyObjects in the `members` member. | |
| 568 | 577 | /// The caller has responsibility to DECREF them. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,3 +25,10 @@ def test_doc_without_ctor(): | |||
| 25 | 25 | assert DocWithoutCtorTest.__doc__ == 'DocWithoutCtorTest Class' | |
| 26 | 26 | assert DocWithoutCtorTest.TestMethod.__doc__ == 'DocWithoutCtorTest TestMethod' | |
| 27 | 27 | assert DocWithoutCtorTest.StaticTestMethod.__doc__ == 'DocWithoutCtorTest StaticTestMethod' | |
| 28 | + | ||
| 29 | + | ||
| 30 | + def test_doc_primitve(): | ||
| 31 | + from System import Int64, String | ||
| 32 | + | ||
| 33 | + assert Int64.__doc__ is not None | ||
| 34 | + assert String.__doc__ is not None | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,6 @@ def test_enum_standard_attrs(): | |||
| 15 | 15 | assert DayOfWeek.__name__ == 'DayOfWeek' | |
| 16 | 16 | assert DayOfWeek.__module__ == 'System' | |
| 17 | 17 | assert isinstance(DayOfWeek.__dict__, DictProxyType) | |
| 18 | - assert DayOfWeek.__doc__ is None | ||
| 19 | 18 | ||
| 20 | 19 | ||
| 21 | 20 | def test_enum_get_member(): | |
@@ -139,7 +138,7 @@ def test_enum_undefined_value(): | |||
| 139 | 138 | # This should fail because our test enum doesn't have it. | |
| 140 | 139 | with pytest.raises(ValueError): | |
| 141 | 140 | Test.FieldTest().EnumField = Test.ShortEnum(20) | |
| 142 | - | ||
| 141 | + | ||
| 143 | 142 | # explicitly permit undefined values | |
| 144 | 143 | Test.FieldTest().EnumField = Test.ShortEnum(20, True) | |
| 145 | 144 | ||
@@ -157,6 +156,6 @@ def test_enum_conversion(): | |||
| 157 | 156 | ||
| 158 | 157 | with pytest.raises(TypeError): | |
| 159 | 158 | Test.FieldTest().EnumField = "str" | |
| 160 | - | ||
| 159 | + | ||
| 161 | 160 | with pytest.raises(TypeError): | |
| 162 | 161 | Test.FieldTest().EnumField = 1 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments