| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 85db427 commit b68e7a1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,8 +281,10 @@ static IntPtr DoInstanceCheck(IntPtr tp, IntPtr args, bool checkType) | |||
| 281 | 281 | { | |
| 282 | 282 | ClassBase cb = GetManagedObject(tp) as ClassBase; | |
| 283 | 283 | ||
| 284 | - if (cb == null) | ||
| 284 | + if (cb == null) { | ||
| 285 | + Runtime.Incref(Runtime.PyFalse); | ||
| 285 | 286 | return Runtime.PyFalse; | |
| 287 | + } | ||
| 286 | 288 | ||
| 287 | 289 | using (PyList argsObj = new PyList(args)) | |
| 288 | 290 | { | |
@@ -296,12 +298,16 @@ static IntPtr DoInstanceCheck(IntPtr tp, IntPtr args, bool checkType) | |||
| 296 | 298 | else | |
| 297 | 299 | otherType = arg.GetPythonType(); | |
| 298 | 300 | ||
| 299 | - if (Runtime.PyObject_TYPE(otherType.Handle) != PyCLRMetaType) | ||
| 301 | + if (Runtime.PyObject_TYPE(otherType.Handle) != PyCLRMetaType) { | ||
| 302 | + Runtime.Incref(Runtime.PyFalse); | ||
| 300 | 303 | return Runtime.PyFalse; | |
| 304 | + } | ||
| 301 | 305 | ||
| 302 | 306 | ClassBase otherCb = GetManagedObject(otherType.Handle) as ClassBase; | |
| 303 | - if (otherCb == null) | ||
| 307 | + if (otherCb == null) { | ||
| 308 | + Runtime.Incref(Runtime.PyFalse); | ||
| 304 | 309 | return Runtime.PyFalse; | |
| 310 | + } | ||
| 305 | 311 | ||
| 306 | 312 | return Converter.ToPython(cb.type.IsAssignableFrom(otherCb.type)); | |
| 307 | 313 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,6 +147,21 @@ def handler(self, x, args): | |||
| 147 | 147 | self.assertEqual(event_handler.value, 3) | |
| 148 | 148 | self.assertEqual(len(d.event_handlers), 1) | |
| 149 | 149 | ||
| 150 | + def test_isinstance(self): | ||
| 151 | + from System import Object | ||
| 152 | + from System import String | ||
| 153 | + | ||
| 154 | + a = [str(x) for x in range(0, 1000)] | ||
| 155 | + b = [String(x) for x in a] | ||
| 156 | + | ||
| 157 | + for x in a: | ||
| 158 | + self.assertFalse(isinstance(x, Object)) | ||
| 159 | + self.assertFalse(isinstance(x, String)) | ||
| 160 | + | ||
| 161 | + for x in b: | ||
| 162 | + self.assertTrue(isinstance(x, Object)) | ||
| 163 | + self.assertTrue(isinstance(x, String)) | ||
| 164 | + | ||
| 150 | 165 | ||
| 151 | 166 | def test_suite(): | |
| 152 | 167 | return unittest.makeSuite(SubClassTests) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments