FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

I added the info parameter to the call to Bind() · chid/pythonnet@5d90263 · GitHub

Repository navigation

Commit 5d90263

Browse files
Barton Cline
committed
I added the info parameter to the call to Bind()
Binding binding = this.Bind(inst, args, kw, info); to take advantage of Bind()'s ability to use a single MethodBase (CI or MI).
1 parent 69cd539 commit 5d90263

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎pythonnet/src/runtime/constructorbinder.cs‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,27 @@ internal ConstructorBinder () : base() {}
3333
// Python type to use when wrapping the result (may be a subclass).
3434
//====================================================================
3535

36-
internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) {
36+
internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) {
3737
return this.InvokeRaw(inst, args, kw, null);
3838
}
39-
39+
/// <summary>
40+
/// Allows ctor selection to be limited to a single attempt at a
41+
/// match by providing the MethodBase to use instead of searching
42+
/// the entire MethodBinder.list (generic ArrayList)
43+
/// </summary>
44+
/// <param name="inst"> (possibly null) instance </param>
45+
/// <param name="args"> PyObject* to the arg tuple </param>
46+
/// <param name="kw"> PyObject* to the keyword args dict </param>
47+
/// <param name="info"> The sole ContructorInfo to use or null </param>
48+
/// <returns> The result of the constructor call with converted params </returns>
49+
/// <remarks>
50+
/// 2010-07-24 BC: I added the info parameter to the call to Bind()
51+
/// Binding binding = this.Bind(inst, args, kw, info);
52+
/// to take advantage of Bind()'s ability to use a single MethodBase (CI or MI).
53+
/// </remarks>
4054
internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw,
4155
MethodBase info) {
42-
Binding binding = this.Bind(inst, args, kw);
56+
Binding binding = this.Bind(inst, args, kw, info);
4357
Object result;
4458

4559
if (binding == null) {
@@ -55,17 +69,17 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw,
5569
Runtime.Decref(eargs);
5670

5771
if (binding == null) {
58-
Exceptions.SetError(Exceptions.TypeError,
72+
Exceptions.SetError(Exceptions.TypeError,
5973
"no constructor matches given arguments"
6074
);
6175
return null;
6276
}
6377
}
6478

79+
// Fire the selected ctor and catch errors...
80+
ConstructorInfo ci = (ConstructorInfo)binding.info;
6581
// Object construction is presumed to be non-blocking and fast
6682
// enough that we shouldn't really need to release the GIL.
67-
68-
ConstructorInfo ci = (ConstructorInfo)binding.info;
6983
try {
7084
result = ci.Invoke(binding.args);
7185
}
@@ -76,12 +90,7 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw,
7690
Exceptions.SetError(e);
7791
return null;
7892
}
79-
8093
return result;
8194
}
82-
83-
8495
}
85-
86-
8796
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL