From 86de623fde49cb03d5096872e5766380579cf3d8 Mon Sep 17 00:00:00 2001 From: tjosepo Date: Tue, 30 Aug 2022 01:33:15 +0200 Subject: [PATCH 1/2] fix: NULL pointer not being recognized --- src/python.ts | 1 + test/test.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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..f79a9ed 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]); + }); +}); From aa25317d8a31db7d3c536ca532a382e2a7a8fe07 Mon Sep 17 00:00:00 2001 From: tjosepo Date: Tue, 30 Aug 2022 01:44:43 +0200 Subject: [PATCH 2/2] fmt --- test/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.ts b/test/test.ts index f79a9ed..99ce34a 100644 --- a/test/test.ts +++ b/test/test.ts @@ -297,7 +297,7 @@ def call(cb): Deno.test("exceptions", async (t) => { await t.step("simple exception", () => { - assertThrows(() => python.runModule("1 / 0")); + assertThrows(() => python.runModule("1 / 0")); }); await t.step("exception with traceback", () => {