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
9f08f97f
Commit
9f08f97f
authored
Aug 10, 2016
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/zerodb/persistent
into zerodb-master
parents
ed211197
533908c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
persistent/tests/test_timestamp.py
persistent/tests/test_timestamp.py
+8
-10
persistent/timestamp.py
persistent/timestamp.py
+1
-2
No files found.
persistent/tests/test_timestamp.py
View file @
9f08f97f
...
...
@@ -269,16 +269,14 @@ class PyAndCComparisonTests(unittest.TestCase):
# 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
import
sys
orig_maxint
=
sys
.
maxint
try
:
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int32
sys
.
maxint
=
int
(
2
**
31
-
1
)
py
=
self
.
_makePy
(
*
self
.
now_ts_args
)
self
.
assertEqual
(
hash
(
py
),
bit_32_hash
)
persistent
.
timestamp
.
c_long
=
ctypes
.
c_int64
sys
.
maxint
=
int
(
2
**
63
-
1
)
# call __hash__ directly to avoid interpreter truncation
# in hash() on 32-bit platforms
if
not
_is_jython
:
...
...
@@ -292,13 +290,13 @@ class PyAndCComparisonTests(unittest.TestCase):
# 32-bit ints for its hashCode methods.
self
.
assertEqual
(
py
.
__hash__
(),
384009219096809580920179179233996861765753210540033
)
finally
:
persistent
.
timestamp
.
c_long
=
orig_c_long
sys
.
maxint
=
orig_maxint
# These are *usually* aliases, but aren't required
# to be (and aren't under Jython 2.7).
if
orig_
c_long
is
ctypes
.
c_int32
:
if
orig_
maxint
==
2
**
31
-
1
:
self
.
assertEqual
(
py
.
__hash__
(),
bit_32_hash
)
elif
orig_
c_long
is
ctypes
.
c_int64
:
elif
orig_
maxint
==
2
**
63
-
1
:
self
.
assertEqual
(
py
.
__hash__
(),
bit_64_hash
)
def
test_hash_equal_constants
(
self
):
...
...
@@ -307,7 +305,7 @@ class PyAndCComparisonTests(unittest.TestCase):
import
persistent.timestamp
import
ctypes
# We get 32-bit hash values of 32-bit platforms, or on the JVM
is_32_bit
=
persistent
.
timestamp
.
c_long
==
ctypes
.
c_int32
or
_is_jython
is_32_bit
=
persistent
.
timestamp
.
sys
.
maxint
==
(
2
**
31
-
1
)
or
_is_jython
c
,
py
=
self
.
_make_C_and_Py
(
b'
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
\
x00
'
)
self
.
assertEqual
(
hash
(
c
),
8
)
...
...
persistent/timestamp.py
View file @
9f08f97f
...
...
@@ -13,7 +13,6 @@
##############################################################################
__all__
=
(
'TimeStamp'
,)
from
ctypes
import
c_long
import
datetime
import
math
import
struct
...
...
@@ -158,7 +157,7 @@ class pyTimeStamp(object):
# Make sure to overflow and wraparound just
# like the C code does.
x
=
c_long
(
x
).
value
x
=
int
(((
x
+
(
sys
.
maxint
+
1
))
&
((
sys
.
maxint
<<
1
)
+
1
))
-
(
sys
.
maxint
+
1
))
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