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
b4cda4da
Commit
b4cda4da
authored
Dec 14, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix module initialization dance under Py3k.
parent
f108be3a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
144 additions
and
59 deletions
+144
-59
BTrees/BTreeModuleTemplate.c
BTrees/BTreeModuleTemplate.c
+61
-48
BTrees/_IFBTree.c
BTrees/_IFBTree.c
+8
-1
BTrees/_IIBTree.c
BTrees/_IIBTree.c
+8
-1
BTrees/_IOBTree.c
BTrees/_IOBTree.c
+8
-1
BTrees/_LFBTree.c
BTrees/_LFBTree.c
+8
-1
BTrees/_LLBTree.c
BTrees/_LLBTree.c
+8
-1
BTrees/_LOBTree.c
BTrees/_LOBTree.c
+8
-1
BTrees/_OIBTree.c
BTrees/_OIBTree.c
+8
-1
BTrees/_OLBTree.c
BTrees/_OLBTree.c
+8
-1
BTrees/_OOBTree.c
BTrees/_OOBTree.c
+8
-1
BTrees/_compat.h
BTrees/_compat.h
+4
-1
BTrees/_fsBTree.c
BTrees/_fsBTree.c
+7
-1
No files found.
BTrees/BTreeModuleTemplate.c
View file @
b4cda4da
...
...
@@ -480,38 +480,38 @@ static struct PyModuleDef moduledef = {
#endif
void
INITMODULE
(
void
)
static
PyObject
*
module_init
(
void
)
{
PyObject
*
m
,
*
d
,
*
c
;
PyObject
*
m
odule
,
*
mod_dict
,
*
interfaces
,
*
conflicterr
;
#ifdef KEY_TYPE_IS_PYOBJECT
object_
=
PyTuple_GetItem
(
Py_
None
->
ob_type
->
tp_bases
,
0
);
object_
=
PyTuple_GetItem
(
Py_
TYPE
(
Py_None
)
->
tp_bases
,
0
);
if
(
object_
==
NULL
)
return
;
return
NULL
;
#endif
sort_str
=
INTERN
(
"sort"
);
if
(
!
sort_str
)
return
;
return
NULL
;
reverse_str
=
INTERN
(
"reverse"
);
if
(
!
reverse_str
)
return
;
return
NULL
;
__setstate___str
=
INTERN
(
"__setstate__"
);
if
(
!
__setstate___str
)
return
;
return
NULL
;
_bucket_type_str
=
INTERN
(
"_bucket_type"
);
if
(
!
_bucket_type_str
)
return
;
return
NULL
;
/* Grab the ConflictError class */
m
=
PyImport_ImportModule
(
"BTrees.Interfaces"
);
if
(
m
!=
NULL
)
interfaces
=
PyImport_ImportModule
(
"BTrees.Interfaces"
);
if
(
interfaces
!=
NULL
)
{
c
=
PyObject_GetAttrString
(
m
,
"BTreesConflictError"
);
if
(
c
!=
NULL
)
ConflictError
=
c
;
Py_DECREF
(
m
);
c
onflicterr
=
PyObject_GetAttrString
(
interfaces
,
"BTreesConflictError"
);
if
(
c
onflicterr
!=
NULL
)
ConflictError
=
c
onflicterr
;
Py_DECREF
(
interfaces
);
}
if
(
ConflictError
==
NULL
)
...
...
@@ -529,7 +529,7 @@ INITMODULE (void)
"persistent.cPersistence"
,
"CAPI"
);
#endif
if
(
cPersistenceCAPI
==
NULL
)
return
;
return
NULL
;
#ifdef PY3K
#define _SET_TYPE(typ) ((PyObject*)(&typ))->ob_type = &PyType_Type
...
...
@@ -544,75 +544,88 @@ INITMODULE (void)
BTreeType
.
tp_new
=
PyType_GenericNew
;
TreeSetType
.
tp_new
=
PyType_GenericNew
;
if
(
!
init_persist_type
(
&
BucketType
))
return
;
return
NULL
;
if
(
!
init_persist_type
(
&
BTreeType
))
return
;
return
NULL
;
if
(
!
init_persist_type
(
&
SetType
))
return
;
return
NULL
;
if
(
!
init_persist_type
(
&
TreeSetType
))
return
;
return
NULL
;
if
(
PyDict_SetItem
(
BTreeType
.
tp_dict
,
_bucket_type_str
,
(
PyObject
*
)
&
BucketType
)
<
0
)
{
fprintf
(
stderr
,
"btree failed
\n
"
);
return
;
return
NULL
;
}
if
(
PyDict_SetItem
(
TreeSetType
.
tp_dict
,
_bucket_type_str
,
(
PyObject
*
)
&
SetType
)
<
0
)
{
fprintf
(
stderr
,
"bucket failed
\n
"
);
return
;
return
NULL
;
}
/* Create the module and add the functions */
#ifdef PY3K
m
=
PyModule_Create
(
&
moduledef
);
module
=
PyModule_Create
(
&
moduledef
);
#else
/* Create the module and add the functions */
m
=
Py_InitModule4
(
"_"
MOD_NAME_PREFIX
"BTree"
,
module
=
Py_InitModule4
(
"_"
MOD_NAME_PREFIX
"BTree"
,
module_methods
,
BTree_module_documentation
,
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
#endif
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"Bucket"
,
mod_dict
=
PyModule_GetDict
(
module
);
if
(
PyDict_SetItemString
(
mod_dict
,
MOD_NAME_PREFIX
"Bucket"
,
(
PyObject
*
)
&
BucketType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"BTree"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
MOD_NAME_PREFIX
"BTree"
,
(
PyObject
*
)
&
BTreeType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"Set"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
MOD_NAME_PREFIX
"Set"
,
(
PyObject
*
)
&
SetType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"TreeSet"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
MOD_NAME_PREFIX
"TreeSet"
,
(
PyObject
*
)
&
TreeSetType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
MOD_NAME_PREFIX
"TreeIterator"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
MOD_NAME_PREFIX
"TreeIterator"
,
(
PyObject
*
)
&
BTreeIter_Type
)
<
0
)
return
;
return
NULL
;
/* We also want to be able to access these constants without the prefix
* so that code can more easily exchange modules (particularly the integer
* and long modules, but also others). The TreeIterator is only internal,
* so we don't bother to expose that.
*/
if
(
PyDict_SetItemString
(
d
,
"Bucket"
,
if
(
PyDict_SetItemString
(
mod_dict
,
"Bucket"
,
(
PyObject
*
)
&
BucketType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"BTree"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
"BTree"
,
(
PyObject
*
)
&
BTreeType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Set"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
"Set"
,
(
PyObject
*
)
&
SetType
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"TreeSet"
,
return
NULL
;
if
(
PyDict_SetItemString
(
mod_dict
,
"TreeSet"
,
(
PyObject
*
)
&
TreeSetType
)
<
0
)
return
;
return
NULL
;
#if defined(ZODB_64BIT_INTS) && defined(NEED_LONG_LONG_SUPPORT)
if
(
PyDict_SetItemString
(
d
,
"using64bits"
,
Py_True
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
mod_dict
,
"using64bits"
,
Py_True
)
<
0
)
return
NULL
;
#else
if
(
PyDict_SetItemString
(
d
,
"using64bits"
,
Py_False
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
mod_dict
,
"using64bits"
,
Py_False
)
<
0
)
return
NULL
;
#endif
return
module
;
}
#ifdef PY3K
PyMODINIT_FUNC
INITMODULE
(
void
)
{
return
module_init
();
}
#else
PyMODINIT_FUNC
INITMODULE
(
void
)
{
module_init
();
}
#endif
BTrees/_IFBTree.c
View file @
b4cda4da
...
...
@@ -25,10 +25,17 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "IF"
#define INITMODULE init_IFBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#include "_compat.h"
#include "intkeymacros.h"
#include "floatvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__IFBTree
#else
#define INITMODULE init_IFBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_IIBTree.c
View file @
b4cda4da
...
...
@@ -25,10 +25,17 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "II"
#define INITMODULE init_IIBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__IIBTree
#else
#define INITMODULE init_IIBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_IOBTree.c
View file @
b4cda4da
...
...
@@ -23,10 +23,17 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "IO"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 500
#define INITMODULE init_IOBTree
#include "_compat.h"
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__IOBTree
#else
#define INITMODULE init_IOBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_LFBTree.c
View file @
b4cda4da
...
...
@@ -25,12 +25,19 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "LF"
#define INITMODULE init_LFBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "floatvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__LFBTree
#else
#define INITMODULE init_LFBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_LLBTree.c
View file @
b4cda4da
...
...
@@ -25,12 +25,19 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "LL"
#define INITMODULE init_LLBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__LLBTree
#else
#define INITMODULE init_LLBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_LOBTree.c
View file @
b4cda4da
...
...
@@ -23,12 +23,19 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "LO"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 500
#define INITMODULE init_LOBTree
#define ZODB_64BIT_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__LOBTree
#else
#define INITMODULE init_LOBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_OIBTree.c
View file @
b4cda4da
...
...
@@ -23,10 +23,17 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "OI"
#define INITMODULE init_OIBTree
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 250
#include "_compat.h"
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__OIBTree
#else
#define INITMODULE init_OIBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_OLBTree.c
View file @
b4cda4da
...
...
@@ -23,12 +23,19 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "OL"
#define INITMODULE init_OLBTree
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 250
#define ZODB_64BIT_INTS
#include "_compat.h"
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__OLBTree
#else
#define INITMODULE init_OLBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_OOBTree.c
View file @
b4cda4da
...
...
@@ -23,10 +23,17 @@
#define PERSISTENT
#define MOD_NAME_PREFIX "OO"
#define INITMODULE init_OOBTree
#define DEFAULT_MAX_BUCKET_SIZE 30
#define DEFAULT_MAX_BTREE_SIZE 250
#include "_compat.h"
#include "objectkeymacros.h"
#include "objectvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__OOBTree
#else
#define INITMODULE init_OOBTree
#endif
#include "BTreeModuleTemplate.c"
BTrees/_compat.h
View file @
b4cda4da
...
...
@@ -2,7 +2,7 @@
#ifndef BTREES__COMPAT_H
#define BTREES__COMPAT_H
#i
f PY_MAJOR_VERSION >= 3
#i
nclude "Python.h"
#ifdef INTERN
#undef INTERN
...
...
@@ -16,6 +16,8 @@
#undef INT_CHECK
#endif
#if PY_MAJOR_VERSION >= 3
#define PY3K
#define INTERN PyUnicode_InternFromString
...
...
@@ -30,6 +32,7 @@
PyObject_RichCompareBool((lhs), (rhs), Py_LT) > 0 ? -1 : \
(PyObject_RichCompareBool((lhs), (rhs), Py_EQ) > 0 ? 0 : 1)
#else
#define INTERN PyString_InternFromString
...
...
BTrees/_fsBTree.c
View file @
b4cda4da
...
...
@@ -31,10 +31,11 @@ typedef unsigned char char6[6];
#define PERSISTENT
#define MOD_NAME_PREFIX "fs"
#define INITMODULE init_fsBTree
#define DEFAULT_MAX_BUCKET_SIZE 500
#define DEFAULT_MAX_BTREE_SIZE 500
#include "_compat.h"
/*#include "intkeymacros.h"*/
#define KEYMACROS_H "$Id$\n"
...
...
@@ -80,6 +81,11 @@ static PyObject *bucket_fromString(PyObject *self, PyObject *state);
{"fromString", (PyCFunction) bucket_fromString, METH_O, \
"fromString(s) -- Set the state of the object from a string"}, \
#ifdef PY3K
#define INITMODULE PyInit__fsBTree
#else
#define INITMODULE init_fsBTree
#endif
#include "BTreeModuleTemplate.c"
static
PyObject
*
...
...
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