8000 fix: NULL pointer not being recognized (#26) · denosaurs/deno_python@54c02b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54c02b4

Browse files
authored
fix: NULL pointer not being recognized (#26)
1 parent 7f69246 commit 54c02b4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/python.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export class PyObject {
194194
*/
195195
get isNone() {
196196
return this.handle === 0 ||
197+
this.handle === 0n ||
197198
this.handle === python.None[ProxiedPyObject].handle;
198199
}
199200

test/test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert, assertEquals } from "./deps.ts";
1+
import { assert, assertEquals, assertThrows } from "./deps.ts";
22
import {
33
kw,
44
NamedArgument,
@@ -294,3 +294,15 @@ def call(cb):
294294
);
295295
cb.destroy();
296296
});
297+
298+
Deno.test("exceptions", async (t) => {
299+
await t.step("simple exception", () => {
300+
assertThrows(() => python.runModule("1 / 0"));
301+
});
302+
303+
await t.step("exception with traceback", () => {
304+
const np = python.import("numpy");
305+
const array = np.zeros([2, 3, 4]);
306+
assertThrows(() => array.shape = [3, 6]);
307+
});
308+
});

0 commit comments

Comments
 (0)
0