| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b165605 commit eb27f97
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,19 +106,7 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw) { | |||
| 106 | 106 | ||
| 107 | 107 | Object obj = self.binder.InvokeRaw(IntPtr.Zero, args, kw); | |
| 108 | 108 | if (obj == null) { | |
| 109 | - // It is possible for __new__ to be invoked on construction | ||
| 110 | - // of a Python subclass of a managed class, so args may | ||
| 111 | - // reflect more args than are required to instantiate the | ||
| 112 | - // class. So if we cant find a ctor that matches, we'll see | ||
| 113 | - // if there is a default constructor and, if so, assume that | ||
| 114 | - // any extra args are intended for the subclass' __init__. | ||
| 115 | - | ||
| 116 | - IntPtr eargs = Runtime.PyTuple_New(0); | ||
| 117 | - obj = self.binder.InvokeRaw(IntPtr.Zero, eargs, kw); | ||
| 118 | - Runtime.Decref(eargs); | ||
| 119 | - if (obj == null) { | ||
| 120 | - return IntPtr.Zero; | ||
| 121 | - } | ||
| 109 | + return IntPtr.Zero; | ||
| 122 | 110 | } | |
| 123 | 111 | ||
| 124 | 112 | return CLRObject.GetInstHandle(obj, tp); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,10 +43,23 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 43 | 43 | Object result; | |
| 44 | 44 | ||
| 45 | 45 | if (binding == null) { | |
| 46 | - Exceptions.SetError(Exceptions.TypeError, | ||
| 47 | - "no constructor matches given arguments" | ||
| 48 | - ); | ||
| 49 | - return null; | ||
| 46 | + // It is possible for __new__ to be invoked on construction | ||
| 47 | + // of a Python subclass of a managed class, so args may | ||
| 48 | + // reflect more args than are required to instantiate the | ||
| 49 | + // class. So if we cant find a ctor that matches, we'll see | ||
| 50 | + // if there is a default constructor and, if so, assume that | ||
| 51 | + // any extra args are intended for the subclass' __init__. | ||
| 52 | + | ||
| 53 | + IntPtr eargs = Runtime.PyTuple_New(0); | ||
| 54 | + binding = this.Bind(inst, eargs, kw); | ||
| 55 | + Runtime.Decref(eargs); | ||
| 56 | + | ||
| 57 | + if (binding == null) { | ||
| 58 | + Exceptions.SetError(Exceptions.TypeError, | ||
| 59 | + "no constructor matches given arguments" | ||
| 60 | + ); | ||
| 61 | + return null; | ||
| 62 | + } | ||
| 50 | 63 | } | |
| 51 | 64 | ||
| 52 | 65 | // Object construction is presumed to be non-blocking and fast | |
| Back | FazBrowse Home | New Git URL |
0 commit comments