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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error not raised when type from another file is missing #177

Open
aisk opened this issue Jul 16, 2021 · 0 comments · May be fixed by #178
Open

error not raised when type from another file is missing #177

aisk opened this issue Jul 16, 2021 · 0 comments · May be fixed by #178

Comments

@aisk
Copy link
Member

aisk commented Jul 16, 2021

cat b.thrift:

enum Status {
    OK = 1
    ERROR = 2
}

cat a.thrift:

include "b.thrift"

struct A {
    1: b.Status status
    2: b.InvalidType type  // notice that this type is not defined in b.
}

parse the files and dump the thrift_spec for struct A:

import thriftpy2


a = thriftpy2.load("a.thrift")
print(a.A.thrift_spec)

And got the result:

{1: (8, 'status', <class 'b.Status'>, False), 2: (<module 'b'>, 'type', False)}

As we can see, the field with number 2 have incomplete type, and there is no error been raised, and until someone called a function which returns a struct A, we got a missleading error message:

TypeError: an integer is required
@aisk aisk linked a pull request Jul 16, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant