Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
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
BTrees
Commits
a81bf204
Commit
a81bf204
authored
Nov 11, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
100% coverage for BTrees.utils.
parent
2dbcd228
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
BTrees/utils.py
BTrees/utils.py
+21
-8
No files found.
BTrees/utils.py
View file @
a81bf204
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# Copied from ZODB/utils.py
# Copied from ZODB/utils.py
from
binascii
import
hexlify
from
binascii
import
hexlify
from
struct
import
calcsize
_ADDRESS_MASK
=
256
**
calcsize
(
'P'
)
def
non_negative
(
int_val
):
if
int_val
<
0
:
# Coerce to non-negative.
int_val
&=
0x7FFFFFFFFFFFFFFF
return
int_val
def
positive_id
(
obj
):
def
positive_id
(
obj
):
#pragma NO COVER
"""Return id(obj) as a non-negative integer."""
"""Return id(obj) as a non-negative integer."""
return
non_negative
(
id
(
obj
))
result
=
id
(
obj
)
if
result
<
0
:
result
+=
_ADDRESS_MASK
assert
result
>
0
return
result
def
oid_repr
(
oid
):
def
oid_repr
(
oid
):
if
isinstance
(
oid
,
str
)
and
len
(
oid
)
==
8
:
if
isinstance
(
oid
,
str
)
and
len
(
oid
)
==
8
:
...
...
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