Skip to content

Commit 9a66b87

Browse files
authored
fix: segfault when creating tuple for slicing (denosaurs#37)
* fix: segfault when creating tuple for slicing * windows ci * x
1 parent c3ae19b commit 9a66b87

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
with:
4040
deno-version: v1.x
4141

42-
- name: Setup Python 3.10 (Windows)
42+
- name: Setup Python (Windows)
4343
uses: actions/setup-python@v2
4444
if: ${{ matrix.os == 'windows-latest' }}
4545
with:
46-
python-version: '3.10'
46+
python-version: '3.11'
4747

4848
- name: Install NumPy
4949
run: python3 -m pip install numpy

src/python.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -957,26 +957,8 @@ function isSlice(value: unknown): boolean {
957957
*/
958958
function toSlice(sliceList: string): PyObject {
959959
if (sliceList.includes(",")) {
960-
const pySlicesHandle = sliceList.split(",")
961-
.map(toSlice)
962-
.map((pyObject) => pyObject.handle);
963-
964-
const pyTuple_Pack = new Deno.UnsafeFnPointer(
965-
// TODO: this isn't really a `bigint`, but Deno's type definitions
966-
// haven't been updated to support `number` yet
967-
py.PyTuple_Pack!,
968-
{
969-
parameters: ["i32", ...pySlicesHandle.map(() => "pointer" as const)],
970-
result: "pointer",
971-
} as const,
972-
);
973-
974-
// SAFETY: idk how to make TS understand this sort of function
975-
const pyTupleHandle = (pyTuple_Pack as any).call(
976-
pySlicesHandle.length,
977-
...pySlicesHandle,
978-
);
979-
return new PyObject(pyTupleHandle);
960+
const pySlicesHandle = sliceList.split(",").map(toSlice);
961+
return python.tuple(pySlicesHandle)[ProxiedPyObject];
980962
} else if (/^\s*-?\d+\s*$/.test(sliceList)) {
981963
return PyObject.from(parseInt(sliceList));
982964
} else if (/^\s*\.\.\.\s*$/.test(sliceList)) {

0 commit comments

Comments
 (0)