Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-74020: Raise ValueError for negative values converted to unsigned#121114
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ff4cfc81af789751c8b228701b4a76857810300d318526ac6d54127dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1377,8 +1377,8 @@ def equivalent_python(n, length, byteorder, signed=False): | ||
| self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=True) | ||
| self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=False) | ||
| self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=True) | ||
| self.assertRaises(OverflowError, (-1).to_bytes, 2, 'big', signed=False) | ||
| self.assertRaises(OverflowError, (-1).to_bytes, 2, 'little', signed=False) | ||
| self.assertRaises(ValueError, (-1).to_bytes, 2, 'big', signed=False) | ||
| self.assertRaises(ValueError, (-1).to_bytes, 2, 'little', signed=False) | ||
Comment on lines +1380 to +1381 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should adjust int.to_bytes() docs (both docstring and sphinx). BTW, I think there could be a test with a negative input and MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated docs. There is a test with a negative input and signed=True above. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe. I don't see it. | ||
| self.assertEqual((0).to_bytes(0, 'big'), b'') | ||
| self.assertEqual((1).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x01') | ||
| self.assertEqual((0).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x00') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Converting negative Python integer to a C unsigned integer type now raises | ||
| :exc:`ValueError`, not :exc:`OverflowError`. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be moved to 3.15 and marked as an incompatible change.