Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-110932: Fix regrtest for SOURCE_DATE_EPOCH#111143

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:regrtest_epoch
Oct 21, 2023

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commentedOct 20, 2023
edited by bedevere-appbot
Loading

If the SOURCE_DATE_EPOCH environment variable is defined, use its value as the random seed.

If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.
@vstinner
Copy link
MemberAuthor

vstinner commentedOct 20, 2023
edited
Loading

SOURCE_DATE_EPOCH intent is tomake programsreproducible. Without this change, if SOURCE_DATE_EPOCH is set, regrtest uses arandom seed which makes testsless reproducible.

With this change, the randomseed is constant and so the behavior should bemore reproducible.

--randseed=custom_string command line option is invalid: the option value must be an integer. Only SOURCE_DATE_EPOCH is used to use a string as the random seed.

@vstinner
Copy link
MemberAuthor

@sobolevn: Would you mind to review this change?

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Generally looks good to me, just one idea.

elserandom.getrandbits(32)
)
if'SOURCE_DATE_EPOCH'inos.environ:
if ('SOURCE_DATE_EPOCH'inos.environ
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
if ('SOURCE_DATE_EPOCH'inos.environ
if (
'SOURCE_DATE_EPOCH'inos.environ

# SOURCE_DATE_EPOCH should be an integer, but use a string to not
# fail if it's not integer. random.seed() accepts a string.
# https://reproducible-builds.org/docs/source-date-epoch/
self.random_seed:int|str=os.environ['SOURCE_DATE_EPOCH']
Copy link
Member

Choose a reason for hiding this comment

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

Myabe we should always usestr? There's no real reason to useint here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The reason is subtle. It avoids to import hashlib to convert a string to an integer in Random.seed(). Right now, hashlib is always imported, but I have a local branch to reduce the number of imports at Python startup.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm talking about the second code path, where we create a random seed as an integer.

# https://reproducible-builds.org/docs/source-date-epoch/
self.random_seed:int|str=os.environ['SOURCE_DATE_EPOCH']
elifns.random_seedisNone:
self.random_seed=random.getrandbits(32)
Copy link
Member

Choose a reason for hiding this comment

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

If so, it would become:

Suggested change
self.random_seed=random.getrandbits(32)
self.random_seed=str(random.getrandbits(32))

@vstinnervstinner merged commit7237fb5 intopython:mainOct 21, 2023
@vstinnervstinner deleted the regrtest_epoch branchOctober 21, 2023 08:37
@vstinnervstinner added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsOct 21, 2023
@miss-islington-app
Copy link

Thanks@vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks@vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 21, 2023
If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.(cherry picked from commit7237fb5)Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 21, 2023
If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.(cherry picked from commit7237fb5)Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

GH-111153 is a backport of this pull request to the3.11 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.11only security fixes labelOct 21, 2023
@bedevere-app
Copy link

GH-111154 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelOct 21, 2023
@vstinner
Copy link
MemberAuthor

Merged, thanks to reviewing the change@sobolevn.

vstinner added a commit that referenced this pull requestOct 21, 2023
…1153)gh-110932: Fix regrtest for SOURCE_DATE_EPOCH (GH-111143)If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.(cherry picked from commit7237fb5)Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull requestOct 21, 2023
…1154)gh-110932: Fix regrtest for SOURCE_DATE_EPOCH (GH-111143)If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.(cherry picked from commit7237fb5)Co-authored-by: Victor Stinner <vstinner@python.org>
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
If the SOURCE_DATE_EPOCH environment variable is defined, use itsvalue as the random seed.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sobolevnsobolevnsobolevn left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@vstinner@sobolevn

[8]ページ先頭

©2009-2025 Movatter.jp