diff --git a/src/python.ts b/src/python.ts index 5431681..949064e 100644 --- a/src/python.ts +++ b/src/python.ts @@ -194,6 +194,7 @@ export class PyObject { */ get isNone() { return this.handle === 0 || + this.handle === 0n || this.handle === python.None[ProxiedPyObject].handle; } diff --git a/test/test.ts b/test/test.ts index 6756f36..99ce34a 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "./deps.ts"; +import { assert, assertEquals, assertThrows } from "./deps.ts"; import { kw, NamedArgument, @@ -294,3 +294,15 @@ def call(cb): ); cb.destroy(); }); + +Deno.test("exceptions", async (t) => { + await t.step("simple exception", () => { + assertThrows(() => python.runModule("1 / 0")); + }); + + await t.step("exception with traceback", () => { + const np = python.import("numpy"); + const array = np.zeros([2, 3, 4]); + assertThrows(() => array.shape = [3, 6]); + }); +});