-
Notifications
You must be signed in to change notification settings - Fork 751
PyType class, wrapper for Python types #1395
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
Conversation
Hm, on non-Windows, utf8 decoding fails inside Python with a funky nÁmæ. This might be an existing problem with UTF-8 string marshaling. |
src/runtime/clrobject.cs
Outdated
@@ -14,7 +14,7 @@ internal CLRObject(object ob, IntPtr tp) | |||
System.Diagnostics.Debug.Assert(tp != IntPtr.Zero); | |||
IntPtr py = Runtime.PyType_GenericAlloc(tp, 0); | |||
|
|||
long flags = Util.ReadCLong(tp, TypeOffset.tp_flags); | |||
var flags = (TypeFlags)Marshal.ReadInt32(tp, TypeOffset.tp_flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tp_flags
is a long
, not an int32
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted back to using Util.ReadCLong
.
Surprisingly in PyType_Spec
flags are of type unsigned int
, which implies they should never exceed 2^32
.
typedef struct{
const char* name;
int basicsize;
int itemsize;
unsigned int flags;
PyType_Slot *slots; /* terminated by slot==0. */
} PyType_Spec;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Actually, because of the above we can probably use ReadInt32
.
tp_flags
is the only field, that is assumed to be declared as long
. So we could remove ReadCLong
and WriteCLong
helpers then.
982a4de
to
73661fd
Compare
Damn Mono incorrectly marshaled [StructLayout(Sequential)]
class ByReference
{
Some Fields;
} No idea why. Wasted whole day trying to figure it out. .NET Core and .NET Framework worked correctly on all platforms. According to Mono docs it should have worked. After switching to [StructLayout(Sequential)]
struct ByValue
{
Some Fields;
} and passing it as |
P.S. I tried to isolate commits, so best to rebase or merge. |
@filmor can you re-review this one? I am continuing to do cleanup, and in-progress work on |
…e construction from PyType_Spec (TypeSpec class)
73661fd
to
d3c5654
Compare
What does this implement/fix? Explain your changes.
This introduces a new
PyType
class (similar toPyInt
, but for types). It can:PyObject
, that points to a typeTypeSpec
class)Does this close any currently open issues?
It is WIP on #1033
It is related to #1196
Checklist
Check all those that are applicable and complete.
CHANGELOG