Open
Conversation
elicn
reviewed
May 9, 2022
LukeSerne
reviewed
May 15, 2022
|
|
||
| return self.ql.mem.read(start, max(0, stop - start)) | ||
| elif isinstance(key, int): | ||
| return self.ql.mem.read(key, 1)[0] |
There was a problem hiding this comment.
This line returns an int, not bytearray, which is somewhat counterintuitive, inconsistent with the case where a slice is given as argument, and goes against the type annotation. I think you should remove the [0]. Also, I'm not sure why this code uses self.ql.mem instead of self. In this class, they reference / point to the same thing, right?
Suggested change
| return self.ql.mem.read(key, 1)[0] | |
| return self.read(key, 1) |
Member
Author
There was a problem hiding this comment.
This line returns an
int, notbytearray, which is somewhat counterintuitive. I think you should remove the[0].
Because we (try to) provide the same interface as bytearray, e.g.:
In [1]: a = bytearray(b"\x01\x02")
In [2]: type(a[0])
Out[2]: int
In [3]:
Also, I'm not sure why this code uses
self.ql.meminstead ofself. In this class, they reference / point to the same thing, right?
Good point.
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.
Checklist
Which kind of PR do you create?
Coding convention?
Extra tests?
Changelog?
Target branch?
One last thing
This is one of several efforts to make the current wrapper more pythonic to fix unicorn-engine/unicorn#201.
This PR makes
ql.memsupport slicing.