- Notifications
You must be signed in to change notification settings - Fork749
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lostmsu commentedFeb 22, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 along
, not anint32
.
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 usingUtil.ReadCLong
.
Surprisingly inPyType_Spec
flags are of typeunsigned int
, which implies they should never exceed2^32
.
typedefstruct{constchar*name;intbasicsize;intitemsize;unsignedintflags;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 useReadInt32
.tp_flags
is the only field, that is assumed to be declared aslong
. So we could removeReadCLong
andWriteCLong
helpers then.
982a4de
to73661fd
Comparelostmsu commentedFeb 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Damn Mono incorrectly marshaled [StructLayout(Sequential)]classByReference{SomeFields;} No idea why. Wasted whole day trying to figure it out. .NET Core and .NET Framework worked correctly on all platforms. According toMono docs it should have worked. After switching to [StructLayout(Sequential)]structByValue{SomeFields;} 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)
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