Skip to content

bpo-33919: Expose hash_seed and use_hash_seed in sys.hash_info#7867

Closed
warsaw wants to merge 1 commit into
python:masterfrom
warsaw:bpo-33919
Closed

bpo-33919: Expose hash_seed and use_hash_seed in sys.hash_info#7867
warsaw wants to merge 1 commit into
python:masterfrom
warsaw:bpo-33919

Conversation

@warsaw

@warsaw warsaw commented Jun 23, 2018

Copy link
Copy Markdown
Member

Comment thread Doc/library/sys.rst
+------------------------+-----------------------------------------------+
| :const:`use_hash_seed` | Whether to use :envvar:`PYTHONHASHSEED` |
+------------------------+-----------------------------------------------+
| :const:`hash_seed` | The value from :envvar:`PYTHONHASHSEED` |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At the C level, we need two fields, since it's not possible to distinguish "value set" to "value unset". But at the Python level, we can use None when the hash seed is unset.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like the seed is always in the range [0; 4294967295], _Py_ReadHashSeed:

        if (*endptr != '\0'
            || seed > 4294967295UL
            || (errno == ERANGE && seed == ULONG_MAX))
        {
            return -1;
        }

It may be worth to document the value range.

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@warsaw

warsaw commented Jun 25, 2018

Copy link
Copy Markdown
Member Author

I wonder if it's worth pursuing this PR if all it's going to do is expose $PYTHONHASHSEED in a different format?

@warsaw

warsaw commented Jun 27, 2018

Copy link
Copy Markdown
Member Author

Discarding for now.

@warsaw warsaw closed this Jun 27, 2018
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.

4 participants