Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] tracing some native values may throw #10440

Closed
clemos opened this issue Oct 20, 2021 · 0 comments
Closed

[python] tracing some native values may throw #10440

clemos opened this issue Oct 20, 2021 · 0 comments

Comments

@clemos
Copy link
Contributor

clemos commented Oct 20, 2021

Hi 馃憢

I'm working on a personal project with Haxe + Spacy and stumbled upon this "bug".

When calling trace on a native python Spacy Token object, the program will throw:

TypeError: Argument 'other' has incorrect type (expected spacy.tokens.token.Token, got type)

The error occurs in python.Boot.toString1, at the following line, which checks if the traced value is the python "str" type:
https://github.com/HaxeFoundation/haxe/blob/development/std/python/Boot.hx#L195
which in turn calls this method:
https://github.com/HaxeFoundation/haxe/blob/development/std/python/Boot.hx#L226

It seems Spacy has some kind of comparison overloading that throws an error when attempting to compare a Token (and other types) to an unrelated object.

To make python.Boot.toString1 (and trace) more resilient, I propose that isMetaType generates:

type(v) == type and v == t

instead of just

v == t

and also to type t as Class<T> just in case.

What do you think ?

clemos pushed a commit to clemos/haxe that referenced this issue Oct 20, 2021
clemos pushed a commit to clemos/haxe that referenced this issue Oct 20, 2021
@Simn Simn closed this as completed in b168bec Oct 20, 2021
RealyUniqueName added a commit that referenced this issue Oct 22, 2021
Co-authored-by: Cl茅ment Charmet <clement@viibe.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant