| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…hod (QuantConnect#132) Calling an overloaded method with an empty kwargs mapping (e.g. obj.Method(arg, **{}), common when forwarding *args/**kwargs from a wrapper) crashed with an unhandled IndexOutOfRangeException in MethodBinder.CheckMethodArgumentsMatch. Since 10e721b (PR QuantConnect#83), the parameter names array is only populated when there are named arguments, but the kwargs code paths only checked the kwargs dictionary for null, so a non-null empty dict indexed into an empty names array. Treat an empty kwargs dict as no keyword arguments, matching Python semantics where f(x, **{}) is equivalent to f(x). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bump package <Version>, AssemblyVersion/AssemblyFileVersion and the perf-test baseline reference to 2.0.60. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Description
Calling an overloaded .NET method from Python with an empty **kwargs mapping (e.g. obj.Method(arg, **{}), common when forwarding *args/**kwargs from a wrapper or decorator) crashed with an unhandled System.IndexOutOfRangeException in MethodBinder.CheckMethodArgumentsMatch. The exception escapes through tp_call as a CLR exception, so it cannot be caught from Python and tears down the host process (crashes LEAN during Initialize()).
Closes #132
Also bumps the package version to 2.0.60 (package <Version>, AssemblyVersion/AssemblyFileVersion and the perf-test baseline reference, following the same pattern as #131).
Root cause
Since 10e721b (#83), the parameter names array is only populated when there are named arguments (hasNamedArgs ? methodInformation.ParameterNames : Array.Empty<string>()), but the kwargs code paths in CheckMethodArgumentsMatch and Bind only checked the kwargs dictionary for null. A non-null but empty kwargs dict therefore routed binding through the kwargs path while paramNames was empty, indexing out of range for any overload with more CLR parameters than positional Python arguments. Bisect-confirmed: 10e721b~1 binds fine, 10e721b crashes.
Fix
Treat an empty kwargs dict as no keyword arguments: MethodBinder.Bind only builds kwArgDict when PyDict_Size(kw) > 0, so **{} follows the exact same code path as a plain positional call. This matches pure Python semantics, where f(x, **{}) is equivalent to f(x), and restores the invariant that a non-null kwArgDict implies populated parameter names.
Testing