Fix str.__str__ and PyRef::into_exact_or for int() or str() pattern#4732
Merged
Conversation
19a204e to
ae02814
Compare
ae02814 to
6b848f5
Compare
DimitrisJim
reviewed
Mar 27, 2023
| #[pymethod(magic)] | ||
| fn int(self, vm: &VirtualMachine) -> PyRefExact<PyInt> { | ||
| self.into_exact_or(&vm.ctx, |zelf| unsafe { | ||
| // TODO: this is actually safe. we need better interface |
Member
There was a problem hiding this comment.
we should definitely start documenting all the unsafe better at some point.
Contributor
There was a problem hiding this comment.
There's the allow-by-default undocumented_unsafe_blocks lint, in case we want to activate that.
Member
Author
There was a problem hiding this comment.
That clippy option looks very good for us because we use a lot of unsafe blocks.
For this function, I'd like to make the basic PyRef creation functions to return PyRefExact first and turn them to PyRef later. In that case, everything will be safe by both semantics and rust grammars.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
disallowing subclass is a repeatitive pattern