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
2ce21f6b
Commit
2ce21f6b
authored
Dec 17, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix longlong keys edge-cases keys across supported Pythons.
parent
15da8c11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
8 deletions
+47
-8
BTrees/BTreeModuleTemplate.c
BTrees/BTreeModuleTemplate.c
+42
-0
BTrees/intkeymacros.h
BTrees/intkeymacros.h
+5
-8
No files found.
BTrees/BTreeModuleTemplate.c
View file @
2ce21f6b
...
...
@@ -110,6 +110,48 @@ longlong_as_object(PY_LONG_LONG val)
#endif
#ifdef NEED_LONG_LONG_KEYS
static
int
longlong_convert
(
PyObject
*
ob
,
PY_LONG_LONG
*
value
)
{
#ifndef PY3K
if
(
PyInt_Check
(
ob
))
{
(
*
value
)
=
(
PY_LONG_LONG
)
PyInt_AS_LONG
(
ob
);
return
1
;
}
#endif
if
(
!
PyLong_Check
(
ob
))
{
PyErr_SetString
(
PyExc_TypeError
,
"expected integer key"
);
return
0
;
}
else
{
PY_LONG_LONG
val
;
#if PY_VERSION_HEX < 0x02070000
/* check magnitude */
val
=
PyLong_AsLongLong
(
ob
);
if
(
val
==
-
1
&&
PyErr_Occurred
())
goto
overflow
;
#else
int
overflow
;
val
=
PyLong_AsLongLongAndOverflow
(
ob
,
&
overflow
);
if
(
overflow
)
goto
overflow
;
#endif
(
*
value
)
=
val
;
return
1
;
}
overflow:
PyErr_SetString
(
PyExc_ValueError
,
"long integer out of range"
);
return
0
;
}
#endif
/* Various kinds of BTree and Bucket structs are instances of
* "sized containers", and have a common initial layout:
* The stuff needed for all Python objects, or all Persistent objects.
...
...
BTrees/intkeymacros.h
View file @
2ce21f6b
...
...
@@ -4,18 +4,15 @@
#ifdef ZODB_64BIT_INTS
/* PY_LONG_LONG as key */
#define NEED_LONG_LONG_SUPPORT
#define NEED_LONG_LONG_KEYS
#define KEY_TYPE PY_LONG_LONG
#define KEY_CHECK longlong_check
#define COPY_KEY_TO_OBJECT(O, K) O=longlong_as_object(K)
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (INT_CHECK(ARG)) TARGET=INT_AS_LONG(ARG); else \
if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \
if (PyLong_Check(ARG)) { \
PyErr_SetString(PyExc_ValueError, "long integer out of range"); \
(STATUS)=0; (TARGET)=0; } \
else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
(STATUS)=0; (TARGET)=0; }
if (!longlong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
#else
/* C int as key */
#define KEY_TYPE int
...
...
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