Skip to content

[2.7] bpo-31478: Prevent unwanted behavior in _random.Random.seed() in case the arg has a bad __abs__() method (GH-3596) #3845

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

Merged
merged 5 commits into from
Oct 2, 2017

Conversation

orenmn
Copy link
Contributor

@orenmn orenmn commented Oct 1, 2017

  • In case the argument of _random.Random.seed() is a long/int subclass, ignore its __abs__() method.
  • Add a test to test_random to verify that such __abs__() methods are indeed ignored.

https://bugs.python.org/issue31478

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.

Add a NEWS entry.

expected_value = self.gen.random()
for seed_arg in [42L, BadInt(42), BadLong(42)]:
self.gen.seed(seed_arg)
self.assertEqual(expected_value, self.gen.random())
Copy link
Member

Choose a reason for hiding this comment

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

Use the actual value at left and the expected value at right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants