Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-35557 - Allow base64.b16decode() to accept lowercase hexadecimal characters by default #11285

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

Closed
wants to merge 6 commits into from
Closed

bpo-35557 - Allow base64.b16decode() to accept lowercase hexadecimal characters by default #11285

wants to merge 6 commits into from

Conversation

fractionalhare
Copy link

@fractionalhare fractionalhare commented Dec 22, 2018

Hello,

This pull request addresses the proposed changes in issue 35557. Namely, it refactors base64.b16decode() to accept both lowercase and uppercase hexadecimal strings without requiring the use of the casefold parameter. The motivating reasons for this change are outlined in the corresponding issue.

Specifically, the code changes to the two files are as follows:

  1. Expand the regular expression matching string from 0-9A-F to 0-9A-Fa-f;

  2. Remove the casefold argument, its default value, and the conditional check for its value within the method;

  3. Remove the tests under test_base64.py which check the casefold conditional checking behavior (and only those tests!).

This change passes all other tests for base64.py. I also attached a file on the corresponding issue which demonstrates a ~9.4% performance improvement on decoding hexadecimal strings due to the removal of the casefold parameter.

https://bugs.python.org/issue35557

djhoulihan added 2 commits December 21, 2018 15:02
…ase characters by default, and eliminate the consequently unnecessary second argument casefold
…ment to base64.b16decode() (casefold) and the function accepts hexadecimal strings with lowercase characters by default
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@fractionalhare
Copy link
Author

With regards to the CLA - I've only just signed it 15 minutes ago or so, so that's likely why the check is failing :)

Dylan Houlihan added 2 commits December 21, 2018 22:07
Since the `casefold` argument is removed, alter the docstring to reflect that and get rid of the reference to a second argument
Assuming the change isn't met with resistance from a security perspective, there is probably no need to keep a stale RFC reference around that mentions an outdated security consideration
@eamanu
Copy link
Contributor

eamanu commented Dec 22, 2018

@DJHoulihan Please complete the title of the PR

@fractionalhare fractionalhare changed the title bpo-35557 bpo-35557 - Allow base64.b16decode() to accept lowercase hexadecimal characters by default Dec 23, 2018
Copy link
Contributor

@BoboTiG BoboTiG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch @DJHoulihan!

Changes LGTM, but it still need more work to be accepted:

And even more, why not updating other functions to remove completely the casefold argument?

@BoboTiG
Copy link
Contributor

BoboTiG commented Jan 14, 2019

(I requested changes only, the labels update is wrong as there still need work)

@BoboTiG
Copy link
Contributor

BoboTiG commented Jan 14, 2019

And I just read the BPO. The patch will unlikely be merged as it breaks the compatibility with old Python versions.
The possible option would be to keep the argument and fire a DeprecationWarning until Python 4.0 where you will then be able to delete the argument.

@vstinner vstinner closed this May 3, 2021
@vstinner vstinner deleted the branch python:master May 3, 2021 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants