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
1879a2af
Commit
1879a2af
authored
Apr 14, 2016
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of bare 'PyLong_AsLongLong()'.
Replace with 'PyLong_AsLongLongOverflow'. Toward a fix for #32.
parent
afa8c4eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
28 deletions
+9
-28
BTrees/BTreeModuleTemplate.c
BTrees/BTreeModuleTemplate.c
+5
-20
BTrees/intvaluemacros.h
BTrees/intvaluemacros.h
+4
-8
No files found.
BTrees/BTreeModuleTemplate.c
View file @
1879a2af
...
...
@@ -77,6 +77,7 @@ static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;}
#error "PY_LONG_LONG required but not defined"
#endif
#ifdef NEED_LONG_LONG_KEYS
static
int
longlong_check
(
PyObject
*
ob
)
{
...
...
@@ -84,25 +85,19 @@ longlong_check(PyObject *ob)
return
1
;
if
(
PyLong_Check
(
ob
))
{
#if PY_VERSION_HEX < 0x02070000
/* check magnitude */
PY_LONG_LONG
val
=
PyLong_AsLongLong
(
ob
);
if
(
val
==
-
1
&&
PyErr_Occurred
())
goto
overflow
;
#else
int
overflow
;
(
void
)
PyLong_AsLongLongAndOverflow
(
ob
,
&
overflow
);
if
(
overflow
)
goto
overflow
;
#endif
return
1
;
}
return
0
;
overflow:
PyErr_SetString
(
PyExc_ValueError
,
"long integer out of range"
);
PyErr_SetString
(
PyExc_ValueError
,
"longlong_check: long integer out of range"
);
return
0
;
}
#endif
static
PyObject
*
longlong_as_object
(
PY_LONG_LONG
val
)
...
...
@@ -111,10 +106,8 @@ longlong_as_object(PY_LONG_LONG val)
return
PyLong_FromLongLong
(
val
);
return
INT_FROM_LONG
((
long
)
val
);
}
#endif
#ifdef NEED_LONG_LONG_KEYS
static
int
longlong_convert
(
PyObject
*
ob
,
PY_LONG_LONG
*
value
)
{
...
...
@@ -134,18 +127,10 @@ longlong_convert(PyObject *ob, PY_LONG_LONG *value)
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
;
}
...
...
@@ -153,7 +138,7 @@ overflow:
PyErr_SetString
(
PyExc_ValueError
,
"long integer out of range"
);
return
0
;
}
#endif
#endif
/* NEED_LONG_LONG_SUPPORT */
/* Various kinds of BTree and Bucket structs are instances of
...
...
BTrees/intvaluemacros.h
View file @
1879a2af
...
...
@@ -7,14 +7,10 @@
#define VALUE_PARSE "L"
#define COPY_VALUE_TO_OBJECT(O, K) O=longlong_as_object(K)
#define COPY_VALUE_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 value"); \
(STATUS)=0; (TARGET)=0; }
if (!longlong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
#else
#define VALUE_TYPE int
#define VALUE_PARSE "i"
...
...
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