-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[stdlib] Add a new validate
parameter to the b64decode()
function
#3929
base: nightly
Are you sure you want to change the base?
Conversation
Signed-off-by: Manuel Saelices <msaelices@gmail.com>
validate
parameter to the b64decode()
function
Signed-off-by: Manuel Saelices <msaelices@gmail.com>
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, happy to sync it once the minor comments are addressed. Thanks!
stdlib/src/base64/base64.mojo
Outdated
@parameter | ||
if validate: | ||
if n % 4 != 0: | ||
raise Error("ValueError: Input length must be divisible by 4") |
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.
Suggestion Include the byte length value (n
) in the error message.
stdlib/src/base64/base64.mojo
Outdated
@parameter | ||
if validate: | ||
if a < 0 or b < 0 or c < 0 or d < 0: | ||
raise Error("ValueError: Unexpected character encountered") |
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.
Suggestion Include the unexpected character value in the error message.
This may mean pulling the snippet out into a local function and call it for each of the values a
, b
, c
, and d
.
Signed-off-by: Manuel Saelices <msaelices@gmail.com>
Thanks. I've fixed both of them here: msaelices@c1873d6 Could you please TAL? |
Nice improvement, thanks! Syncing now. |
!sync |
@msaelices do you mind rebasing with latest nightly so I can sync this? Thanks! |
done |
Matching the
validate
bool argument in Python's base64.b64decode but a using comp time parameter so it will not add CPU cycles if validation is not needed.