| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I'm not entirely happy with this, yet. I think we might want to do the special-casing in ClassObject instead, like it's done for enums and bigints. Thoughts? |
Sorry, something went wrong.
|
Re: IntPtr Why can't we just treat IntPtr as non-primitive type? Then its constructor will be invoked by normal means. |
Sorry, something went wrong.
|
Maybe we should have an explicit set of types for which this constructor masking behavior should be used, instead of relying on IsPrimitive which was created for a totally different purpose. |
Sorry, something went wrong.
Because then it's always default constructed, apparently calling a cobstructor on a primitive type after it has been created "uninitialised" is a no-op. I can check again, though I'm quite certain that that was among the first things I've tried. |
Sorry, something went wrong.
@filmor this would be highly problematic depending on what types this behavior applies to. If it is just IsPrimitive types, then we just need to adjust handling explicitly. However, if it is the case for any value types, we are in trouble. UPD. Just checked rc2 for the record, values types in general seem fine: TimeSpan(3, 2, 1).ToString() prints '03:02:01'. IntPtr gives "TypeError: No match found for given type params" |
Sorry, something went wrong.
|
@filmor this PR was rushed. There are few artifacts of development left in the final code, the latest commits never reviewed, and the earliest not reviewed completely. This would be OK if there was no active response for a few days, but simply bypassing review on new code is not a good idea. |
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| if (result == null && !Converter.ToManaged(op, type, out result, true)) |
There was a problem hiding this comment.
I think we need a test for IntPtr constructor call with this path (e.g. parameter is neither CLR object nor Python int)
Sorry, something went wrong.
There was a problem hiding this comment.
What do you expect to happen? It fails to convert, this is essentially the "old" code path. I'll add the test, though.
Sorry, something went wrong.
There was a problem hiding this comment.
@filmor actually, nothing specific. Just want to ensure it does not error in a weird way and the error is actually helpful.
Sorry, something went wrong.
| /// <param name="args">Constructor arguments</param> | ||
| private static NewReference NewPrimitive(BorrowedReference tp, BorrowedReference args, Type type) | ||
| { | ||
| // TODO: Handle IntPtr |
There was a problem hiding this comment.
dead TODO?
Sorry, something went wrong.
There was a problem hiding this comment.
True, I'll remove it.
Sorry, something went wrong.
It might have been a bit rushed, but that was mostly because I wanted to tackle the other remaining issues (regressions from the constructor refactor) and get a new rc out soon for people to test with. This one would have actually bitten myself for a change if we had released this as stable. :) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What does this implement/fix? Explain your changes.
Allows creating an IntPtr from Python. This is currently impossible, because we rely on automatic conversion (as IntPtr is a primitive type) while we don't actually implement one for this type (rightly so!).
The relevant code section is:
pythonnet/src/runtime/Types/ClassObject.cs
Lines 73 to 89 in 87d4db9
Does this close any currently open issues?
#1116
Any other comments?
...
Checklist
Check all those that are applicable and complete.