Skip to content
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

bpo-35636: remove redundant check in unicode_hash(PyObject *self) #11402

Merged
merged 5 commits into from Jan 2, 2019
Merged

bpo-35636: remove redundant check in unicode_hash(PyObject *self) #11402

merged 5 commits into from Jan 2, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jan 2, 2019

_Py_HashBytes() function already checks empty string:

Py_hash_t
_Py_HashBytes(const void *src, Py_ssize_t len)
{
    Py_hash_t x;
    /*
      We make the hash of the empty string be 0, rather than using
      (prefix ^ suffix), since this slightly obfuscates the hash secret
    */
    if (len == 0) {
        return 0;
    }
   ...

File /Lib/test/test_hash.py already has a test for empty str.

    @skip_unless_internalhash
    def test_empty_string(self):
        self.assertEqual(hash(""), 0)

https://bugs.python.org/issue35636

animalize and others added 3 commits January 2, 2019 14:50
@scoder
Copy link
Contributor

scoder commented Jan 2, 2019

LGTM

@scoder
Copy link
Contributor

scoder commented Jan 2, 2019

Doesn't need a News entry, IMHO.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

This change looks safe to me.

@serhiy-storchaka serhiy-storchaka merged commit a1d1425 into python:master Jan 2, 2019
@ghost ghost deleted the hash_empty_str branch January 2, 2019 12:17
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.

None yet

4 participants