| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 50d947f commit 03cf4ac
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,3 +77,4 @@ | |||
| 77 | 77 | - ([@stonebig](https://github.com/stonebig)) | |
| 78 | 78 | - ([@testrunner123](https://github.com/testrunner123)) | |
| 79 | 79 | - ([@DanBarzilian](https://github.com/DanBarzilian)) | |
| 80 | + - ([@alxnull](https://github.com/alxnull)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,7 @@ details about the cause of the failure | |||
| 28 | 28 | - Fix `object[]` parameters taking precedence when should not in overload resolution | |
| 29 | 29 | - Fixed a bug where all .NET class instances were considered Iterable | |
| 30 | 30 | - Fix incorrect choice of method to invoke when using keyword arguments. | |
| 31 | + - Fix non-delegate types incorrectly appearing as callable. | ||
| 31 | 32 | ||
| 32 | 33 | ## [2.5.0][] - 2020-06-14 | |
| 33 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -278,36 +278,5 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) | |||
| 278 | 278 | ||
| 279 | 279 | return 0; | |
| 280 | 280 | } | |
| 281 | - | ||
| 282 | - | ||
| 283 | - /// <summary> | ||
| 284 | - /// This is a hack. Generally, no managed class is considered callable | ||
| 285 | - /// from Python - with the exception of System.Delegate. It is useful | ||
| 286 | - /// to be able to call a System.Delegate instance directly, especially | ||
| 287 | - /// when working with multicast delegates. | ||
| 288 | - /// </summary> | ||
| 289 | - public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) | ||
| 290 | - { | ||
| 291 | - //ManagedType self = GetManagedObject(ob); | ||
| 292 | - IntPtr tp = Runtime.PyObject_TYPE(ob); | ||
| 293 | - var cb = (ClassBase)GetManagedObject(tp); | ||
| 294 | - | ||
| 295 | - if (cb.type != typeof(Delegate)) | ||
| 296 | - { | ||
| 297 | - Exceptions.SetError(Exceptions.TypeError, "object is not callable"); | ||
| 298 | - return IntPtr.Zero; | ||
| 299 | - } | ||
| 300 | - | ||
| 301 | - var co = (CLRObject)GetManagedObject(ob); | ||
| 302 | - var d = co.inst as Delegate; | ||
| 303 | - BindingFlags flags = BindingFlags.Public | | ||
| 304 | - BindingFlags.NonPublic | | ||
| 305 | - BindingFlags.Instance | | ||
| 306 | - BindingFlags.Static; | ||
| 307 | - | ||
| 308 | - MethodInfo method = d.GetType().GetMethod("Invoke", flags); | ||
| 309 | - var binder = new MethodBinder(method); | ||
| 310 | - return binder.Invoke(ob, args, kw); | ||
| 311 | - } | ||
| 312 | 281 | } | |
| 313 | 282 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -315,3 +315,13 @@ def test_method_inheritance(): | |||
| 315 | 315 | ||
| 316 | 316 | assert base.IsBase() == True | |
| 317 | 317 | assert derived.IsBase() == False | |
| 318 | + | ||
| 319 | + | ||
| 320 | + def test_callable(): | ||
| 321 | + """Test that only delegate subtypes are callable""" | ||
| 322 | + | ||
| 323 | + def foo(): | ||
| 324 | + pass | ||
| 325 | + | ||
| 326 | + assert callable(System.String("foo")) == False | ||
| 327 | + assert callable(System.Action(foo)) == True | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments