-
Notifications
You must be signed in to change notification settings - Fork 750
Dotnetcore System.UInt32 conversion issues #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Well, this is problematic. We want to be platform-independent, but C's |
I was wondering if there’s a Python C API call that might give us the unsigned king size at runtime, so we could decide which PInvoke call to make?
… On 11 Sep 2019, at 07:39, Benedikt Reinartz ***@***.***> wrote:
Well, this is problematic. We want to be platform-independent, but C's unsigned long that is used in Python is 64bit on most 64bit Unices and 32bit on Windows, so the uint parameter is indeed wrong.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
As far as I can tell, Python is completely oblivious to this difference as it "lives" on the C platform, so all compiled modules will have the same idea of what |
Would this method get caught out if, for whatever reason, someone is using CPython compiled with 64bit longs on Win64 or CPython compiled with 32bit longs on 64bit Linux? |
What we really need is some hook or proxy into |
As per a discussion with Joe, It seems the correct way to do this would be with a call to |
If you managed to compile a program that messed up, it will not be able to reliably interact with anything else on the same system. This is an ABI thing, it's not something a user can just decide. /edit: Note, that this is a completely different question than asking for a 32bit vs 64bit program on a given system. All operating systems that I know of have separate variants of all relevant libraries compiled in the respective fashion, but |
This is not about a user decision, it’s about calling the correct PInvoke signature at runtime, based on the bitness of the interpreter being run.
… On 26 Sep 2019, at 07:53, Benedikt Reinartz ***@***.***> wrote:
As far as I can tell, Python is completely oblivious to this difference as it "lives" on the C platform, so all compiled modules will have the same idea of what long means. We can pretty reliably decide this by looking at the platform we are running on in .NET, though. We are already providing internally booleans for IsWindows and Is32Bit here https://github.com/pythonnet/pythonnet/blob/master/src/runtime/runtime.cs#L106-L109.
Would this method get caught out if, for whatever reason, someone is using CPython compiled with 64bit longs on Win64 or CPython compiled with 32bit longs on 64bit Linux?
If you managed to compile a program that messed up, it will not be able to reliably interact with anything else on the same system. This is an ABI thing, it's not something a user can just decide.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, and the correct P/Invoke signature can be decided by looking at the |
Fixed in PR #961 |
Environment
Details
uint
to a signed long (64 bits in size on my system) before calling the PyLong_FromUsignedLong function. Using GDB and breaking before the errornous overflow we can examine the created PyLongObject:The
PyLongObject
given to C# by the python interpretter that can be converted to auint
usingPyLong_AsUnsignedLong
Using
PyLong_FromUnsignedLong
on the resultinguint
gives this:I have raised an issue on the coreclr project: Issue 26444
FYI changing the function definition from
to
fixes the issue.
The text was updated successfully, but these errors were encountered: