Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
9e8c76de
Commit
9e8c76de
authored
Nov 05, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import struct pack and unpack at the top-level,
and eliminate default argument hack.
parent
973d486b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/ZODB/utils.py
src/ZODB/utils.py
+8
-6
No files found.
src/ZODB/utils.py
View file @
9e8c76de
...
@@ -13,18 +13,20 @@
...
@@ -13,18 +13,20 @@
##############################################################################
##############################################################################
import
sys
import
sys
import
TimeStamp
,
time
,
struct
import
TimeStamp
,
time
from
struct
import
pack
,
unpack
if
sys
.
version
>=
(
2
,
2
):
if
sys
.
version
>=
(
2
,
2
):
# Note that the distinction between ints and longs is blurred in
# Note that the distinction between ints and longs is blurred in
# Python 2.2. So make u64() and U64() the same.
# Python 2.2. So make u64() and U64() the same.
def
p64
(
v
,
pack
=
struct
.
pack
):
def
p64
(
v
):
"""Pack an integer or long into a 8-byte string"""
"""Pack an integer or long into a 8-byte string"""
return
pack
(
">Q"
,
v
)
return
pack
(
">Q"
,
v
)
def
u64
(
v
,
unpack
=
struct
.
unpack
):
def
u64
(
v
):
"""Unpack an 8-byte string into a 64-bit long integer."""
"""Unpack an 8-byte string into a 64-bit long integer."""
return
unpack
(
">Q"
,
v
)[
0
]
return
unpack
(
">Q"
,
v
)[
0
]
...
@@ -34,7 +36,7 @@ else:
...
@@ -34,7 +36,7 @@ else:
t32
=
1L
<<
32
t32
=
1L
<<
32
def
p64
(
v
,
pack
=
struct
.
pack
):
def
p64
(
v
):
"""Pack an integer or long into a 8-byte string"""
"""Pack an integer or long into a 8-byte string"""
if
v
<
t32
:
if
v
<
t32
:
h
=
0
h
=
0
...
@@ -42,7 +44,7 @@ else:
...
@@ -42,7 +44,7 @@ else:
h
,
v
=
divmod
(
v
,
t32
)
h
,
v
=
divmod
(
v
,
t32
)
return
pack
(
">II"
,
h
,
v
)
return
pack
(
">II"
,
h
,
v
)
def
u64
(
v
,
unpack
=
struct
.
unpack
):
def
u64
(
v
):
"""Unpack an 8-byte string into a 64-bit (or long) integer."""
"""Unpack an 8-byte string into a 64-bit (or long) integer."""
h
,
v
=
unpack
(
">ii"
,
v
)
h
,
v
=
unpack
(
">ii"
,
v
)
if
v
<
0
:
if
v
<
0
:
...
@@ -53,7 +55,7 @@ else:
...
@@ -53,7 +55,7 @@ else:
v
=
(
long
(
h
)
<<
32
)
+
v
v
=
(
long
(
h
)
<<
32
)
+
v
return
v
return
v
def
U64
(
v
,
unpack
=
struct
.
unpack
):
def
U64
(
v
):
"""Same as u64 but always returns a long."""
"""Same as u64 but always returns a long."""
h
,
v
=
unpack
(
">II"
,
v
)
h
,
v
=
unpack
(
">II"
,
v
)
if
h
:
if
h
:
...
...
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