Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f76e5ed4
Commit
f76e5ed4
authored
Nov 11, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for hashing of unaligned memory buffers (from issue #16427).
parent
55a5d246
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
Lib/test/test_hash.py
Lib/test/test_hash.py
+10
-0
No files found.
Lib/test/test_hash.py
View file @
f76e5ed4
...
...
@@ -45,6 +45,16 @@ class HashEqualityTestCase(unittest.TestCase):
self
.
same_hash
(
int
(
1.23e300
),
float
(
1.23e300
))
self
.
same_hash
(
float
(
0.5
),
complex
(
0.5
,
0.0
))
def
test_unaligned_buffers
(
self
):
# The hash function for bytes-like objects shouldn't have
# alignment-dependent results (example in issue #16427).
b
=
b"123456789abcdefghijklmnopqrstuvwxyz"
*
128
for
i
in
range
(
16
):
for
j
in
range
(
16
):
aligned
=
b
[
i
:
128
+
j
]
unaligned
=
memoryview
(
b
)[
i
:
128
+
j
]
self
.
assertEqual
(
hash
(
aligned
),
hash
(
unaligned
))
_default_hash
=
object
.
__hash__
class
DefaultHash
(
object
):
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment