Open soraros opened 2 weeks ago
hi @JoeLoser , here is the code that will act patch for this bug : https://github.com/dhruvmalik007/mojo/commit/bf8d434b67f196437adc91e9b1f28e0fdf6f1e01 , let me know if you need more tests / changes required and I will do the needful in order to create PR and merge .
Thanks
Hi @dhruvmalik007, thanks for your interest! Feel free to make a PR and we can iterate there.
Hey i have created the PR , with the merging the nighly branch as described in the mojo.
@dhruvmalik007 We should probably switch to PyLong_FromSsize_t
and PyLong_FromSize_t
for ABI compatibility.
thanks for first review and sure will do.
just to clarify then what the condition we should define for the branch
fn __init__[dt: DType](inout self, value: SIMD[dt, 1]):
## ...... other implementations
elif dt == DType.size_t:
## equating the PyLong_FromSsize_t to the pyobject.
elif dt == DType.ssize_t:
## implementation of the PyLong_FromSize_t to the pyobject.
but the issue is that the definition of the Dtypes depends on the MLIR attr as defined here , and these had to be defined for the unsigned int and int of arbitrary lengths size_t
and ssize_t
.
@soraros maybe you can check my recent commit and guide how to implement it. thanks
Bug description
As title.
A Mojo
UInt64
value went through the following to reach Python runtime:PythonObject.__init__[dt: DType](Self, SIMD[dt, 1])
https://github.com/modularml/mojo/blob/61d8208e3beedb4ec4a35b73c91cc9169fa46591/stdlib/src/python/python_object.mojo#L294-L296CPython.toPython(Self, Int)
https://github.com/modularml/mojo/blob/61d8208e3beedb4ec4a35b73c91cc9169fa46591/stdlib/src/python/_cpython.mojo#L966-L967CPython.PyLong_FromLong(Self, Int)
https://github.com/modularml/mojo/blob/61d8208e3beedb4ec4a35b73c91cc9169fa46591/stdlib/src/python/_cpython.mojo#L889-L902PyLong_FromLong
has the signaturePyObject *PyLong_FromLong(long v)
An unwanted bit cast happened on CPython's API boundary.
We should
PythonObject.__init__
PyLong_FromUnsignedLong
PyLong_FromSize_t
onstruct CPython
Steps to reproduce
A more peculiar repro:
System information