-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
HPyBytes_AsString should return const char pointer. #383
HPyBytes_AsString should return const char pointer. #383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small nits, but looks good to me, thanks
@@ -145,7 +145,7 @@ typedef struct { | |||
|
|||
#define HPyDef_METH_IMPL(SYM, NAME, IMPL, SIG, ...) \ | |||
HPyFunc_DECLARE(IMPL, SIG); \ | |||
HPyFunc_TRAMPOLINE(SYM##_trampoline, IMPL, SIG); \ | |||
HPyFunc_TRAMPOLINE(SYM##_trampoline, IMPL, SIG) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this on purpose? Even though it is not needed, I think it improves code readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's on purpose. I sometimes add -pedantic
to tests compilation to spot possible problems and this was one of the warnings since the macro expands to several statements and this semicolon is not necessary.
But I don't have a strong opinion. If you want to keep it, I can re-introduce it but I would like to do it in a follow-up PR to save CI time.
assert b"UnicodeDecodeError" in result.stderr | ||
content = "'use after close me!'" | ||
bcontent = "b" + content | ||
for mode, msg in enumerate((content, bcontent, bcontent)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a paramterize()
decorator, but then the test would compile the module three times, so better as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was basically the intention. Whenever I write new tests, I try to group conceptually equal tests to reduce compilation since that seems to increase test time significantly.
It would be nice if we could use parameterize
. Maybe we can have a fixture or closure such that the module is compiled just once per session.
@@ -64,6 +64,7 @@ static DHPy _DHPy_open(HPyContext *dctx, UHPy uh, bool is_immortal) | |||
handle->is_closed = 0; | |||
handle->is_immortal = is_immortal; | |||
handle->associated_data = NULL; | |||
handle->associated_data_size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't zeroed out before? Good catch.
nice |
Resolves #183 .
I've also implemented data pointer usage verification in debug mode. If the data pointer is written or used after the handle was closed, the process will crash because we protect the pages appropriately (just line we do for
HPyUnicode_AsUTF8AndSize
.I also took the opportunity to implement the functionality on Windows as well.