-
Notifications
You must be signed in to change notification settings - Fork 782
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
Add null-check for function's documents #1169
Conversation
I think this is a nice improvement, maybe we can also change the docs to take It might also make sense to change the E.g. something like impl PyMethodDef {
fn set_name(&mut self, name: &str) -> Result<()> {
let name = CString::new(name)?;
self.name = name;
Ok(())
}
} |
It must be static and we cannot do so. |
455687e
to
9e969c4
Compare
We can allocate a |
Probably we can, but it would require lots of refactoring. |
Now I want to investigate some other solutions. E.g., pub struct PyMethodDef {
pub ml_name: CString,
} So I leave this PR unmerged for two or three days (it looks that I did too much OSS work this week and I have to do some research works as a student...) |
UPDATED |
@davidhewitt |
And I'm sorry that this PR contains many changes to make fields of |
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.
LGTM; I think Vec
is fine here. Maybe slightly less optimal but it's one-time-setup anyway and the safety is a huge plus. Maybe one day it'll be possible to do this with const fn
🤷
I guess with the removal of public fields this is technically a breaking change, so maybe let's merge this and abandon the idea of making a 0.12.2
patch release? We can proceed with iterating on improvements for 0.13
.
(Also this could probably benefit from a CHANGELOG entry static that it fixes #1211 ) |
Hmm... I'm not sure we should treat this as public API 🤔 |
@@ -133,7 +133,9 @@ impl<'a> Container<'a> { | |||
"Cannot derive FromPyObject for empty structs and variants.", | |||
)); | |||
} | |||
let transparent = attrs.iter().any(ContainerAttribute::transparent); | |||
let transparent = attrs |
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.
Changes here are unrelated?
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.
I did for address clippy warnings.
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.
Although clippy only asked to replace the implementation with matches!()
, no?
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.
Yeah, but since we support MSRV(1.39), we cannot use macthes
.
@sebpuetz |
Should we maybe be marking |
I made them |
👍 anything else you want to change in this PR before it merges? I will release |
No, I think it's ready |
We have a feature that extracts Python's doc string from doc comments in proc-macro code.
In the related parts, I found all of the code assumes that the corresponding document is null-terminated and does not check that.
This can make it difficult to debug our proc-macro code when it produces not null-terminated doc by accident, so I added a check using
CStr
.