8000 fix: NULL pointer not being recognized by tjosepo · Pull Request #26 · denosaurs/deno_python · GitHub
[go: up one dir, main page]

Skip to content

fix: NULL pointer not being recognized #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
< 8000 h5 data-view-component="true" class="mb-2"> Diff view
Diff view
1 change: 1 addition & 0 deletions src/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class PyObject {
*/
get isNone() {
return this.handle === 0 ||
this.handle === 0n ||
this.handle === python.None[ProxiedPyObject].handle;
}

Expand Down
14 changes: 13 additions & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, assertEquals } from "./deps.ts";
import { assert, assertEquals, assertThrows } from "./deps.ts";
import {
kw,
NamedArgument,
Expand Down Expand Up @@ -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]);
});
});
0