Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
f94f7ec8
Commit
f94f7ec8
authored
Apr 09, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Plain Diff
Merge issue21
parents
4dab3873
84390bc9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
CHANGES.rst
CHANGES.rst
+4
-0
persistent/tests/test_timestamp.py
persistent/tests/test_timestamp.py
+30
-0
persistent/timestamp.py
persistent/timestamp.py
+2
-2
No files found.
CHANGES.rst
View file @
f94f7ec8
...
...
@@ -4,10 +4,14 @@
4.0.10 (unreleased)
-------------------
- The Python implementation of ``Persistent`` and ``PickleCache`` now
behave more similarly to the C implementation. In particular, the
Python version can now run the complete ZODB unit test suite.
- Fix the hashcode of the Python ``TimeStamp`` on 32-bit platforms.
4.0.9 (2015-04-08)
------------------
...
...
persistent/tests/test_timestamp.py
View file @
f94f7ec8
...
...
@@ -253,6 +253,36 @@ class PyAndCComparisonTests(unittest.TestCase):
c
,
py
=
self
.
_make_C_and_Py
(
*
self
.
now_ts_args
)
self
.
assertEqual
(
hash
(
c
),
hash
(
py
))
def
test_py_hash_32_64_bit
(
self
):
# We happen to know that on a 32-bit platform, the hashcode
# of the c version should be exactly
# -1419374591
# and the 64-bit should be exactly:
# -3850693964765720575
# Fake out the python version to think it's on a 32-bit
# platform and test the same; also verify 64 bit
bit_32_hash
=
-
1419374591
bit_64_hash
=
-
3850693964765720575
import
persistent.timestamp
import
ctypes
orig_c_long
=
persistent
.
timestamp
.
c_long
try
:
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int32
py
=
self
.
_makePy
(
*
self
.
now_ts_args
)
self
.
assertEqual
(
hash
(
py
),
bit_32_hash
)
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int64
self
.
assertEqual
(
hash
(
py
),
bit_64_hash
)
finally
:
persistent
.
timestamp
.
c_long
=
orig_c_long
if
orig_c_long
is
ctypes
.
c_int32
:
self
.
assertEqual
(
py
.
__hash__
(),
bit_32_hash
)
elif
orig_c_long
is
ctypes
.
c_int64
:
self
.
assertEqual
(
py
.
__hash__
(),
bit_64_hash
)
else
:
self
.
fail
(
"Unknown bitness"
)
def
test_hash_equal_constants
(
self
):
# The simple constants make it easier to diagnose
# a difference in algorithms
...
...
persistent/timestamp.py
View file @
f94f7ec8
...
...
@@ -13,7 +13,7 @@
##############################################################################
__all__
=
(
'TimeStamp'
,)
from
ctypes
import
c_
int64
from
ctypes
import
c_
long
import
datetime
import
math
import
struct
...
...
@@ -158,7 +158,7 @@ class pyTimeStamp(object):
# Make sure to overflow and wraparound just
# like the C code does.
x
=
c_
int64
(
x
).
value
x
=
c_
long
(
x
).
value
if
x
==
-
1
:
#pragma: no cover
# The C version has this condition, but it's not clear
# why; it's also not immediately obvious what bytestring
...
...
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