@@ -5324,54 +5324,21 @@ static PyMethodDef DBSequence_methods[] = {
53245324};
53255325#endif
53265326
5327-
5328- static PyObject *
5329- DB_getattr (DBObject * self , char * name )
5330- {
5331- return Py_FindMethod (DB_methods , (PyObject * )self , name );
5332- }
5333-
5334-
53355327static PyObject *
5336- DBEnv_getattr (DBEnvObject * self , char * name )
5328+ DBEnv_db_home_get (DBEnvObject * self )
53375329{
5338- if (!strcmp (name , "db_home" )) {
5339- CHECK_ENV_NOT_CLOSED (self );
5340- if (self -> db_env -> db_home == NULL ) {
5341- RETURN_NONE ();
5342- }
5343- return PyUnicode_FromString (self -> db_env -> db_home );
5330+ CHECK_ENV_NOT_CLOSED (self );
5331+ if (self -> db_env -> db_home == NULL ) {
5332+ RETURN_NONE ();
53445333 }
5345-
5346- return Py_FindMethod (DBEnv_methods , (PyObject * )self , name );
5334+ return PyUnicode_FromString (self -> db_env -> db_home );
53475335}
53485336
5337+ static PyGetSetDef DBEnv_getsets [] = {
5338+ {"db_home" , (getter )DBEnv_db_home_get , NULL ,},
5339+ {NULL }
5340+ };
53495341
5350- static PyObject *
5351- DBCursor_getattr (DBCursorObject * self , char * name )
5352- {
5353- return Py_FindMethod (DBCursor_methods , (PyObject * )self , name );
5354- }
5355-
5356- static PyObject *
5357- DBTxn_getattr (DBTxnObject * self , char * name )
5358- {
5359- return Py_FindMethod (DBTxn_methods , (PyObject * )self , name );
5360- }
5361-
5362- static PyObject *
5363- DBLock_getattr (DBLockObject * self , char * name )
5364- {
5365- return NULL ;
5366- }
5367-
5368- #if (DBVER >= 43 )
5369- static PyObject *
5370- DBSequence_getattr (DBSequenceObject * self , char * name )
5371- {
5372- return Py_FindMethod (DBSequence_methods , (PyObject * )self , name );
5373- }
5374- #endif
53755342
53765343static PyTypeObject DB_Type = {
53775344 PyVarObject_HEAD_INIT (NULL , 0 )
@@ -5381,8 +5348,8 @@ static PyTypeObject DB_Type = {
53815348 /* methods */
53825349 (destructor )DB_dealloc , /*tp_dealloc*/
53835350 0 , /*tp_print*/
5384- ( getattrfunc ) DB_getattr , /*tp_getattr*/
5385- 0 , /*tp_setattr*/
5351+ 0 , /*tp_getattr*/
5352+ 0 , /*tp_setattr*/
53865353 0 , /*tp_compare*/
53875354 0 , /*tp_repr*/
53885355 0 , /*tp_as_number*/
@@ -5400,6 +5367,9 @@ static PyTypeObject DB_Type = {
54005367 0 , /* tp_clear */
54015368 0 , /* tp_richcompare */
54025369 offsetof(DBObject , in_weakreflist ), /* tp_weaklistoffset */
5370+ 0 , /* tp_iter */
5371+ 0 , /* tp_iternext */
5372+ DB_methods , /* tp_methods */
54035373};
54045374
54055375
@@ -5411,7 +5381,7 @@ static PyTypeObject DBCursor_Type = {
54115381 /* methods */
54125382 (destructor )DBCursor_dealloc ,/*tp_dealloc*/
54135383 0 , /*tp_print*/
5414- ( getattrfunc ) DBCursor_getattr , /*tp_getattr*/
5384+ 0 , /*tp_getattr*/
54155385 0 , /*tp_setattr*/
54165386 0 , /*tp_compare*/
54175387 0 , /*tp_repr*/
@@ -5430,6 +5400,9 @@ static PyTypeObject DBCursor_Type = {
54305400 0 , /* tp_clear */
54315401 0 , /* tp_richcompare */
54325402 offsetof(DBCursorObject , in_weakreflist ), /* tp_weaklistoffset */
5403+ 0 , /* tp_iter */
5404+ 0 , /* tp_iternext */
5405+ DBCursor_methods , /* tp_methods */
54335406};
54345407
54355408
@@ -5441,7 +5414,7 @@ static PyTypeObject DBEnv_Type = {
54415414 /* methods */
54425415 (destructor )DBEnv_dealloc , /*tp_dealloc*/
54435416 0 , /*tp_print*/
5444- ( getattrfunc ) DBEnv_getattr , /*tp_getattr*/
5417+ 0 , /*tp_getattr*/
54455418 0 , /*tp_setattr*/
54465419 0 , /*tp_compare*/
54475420 0 , /*tp_repr*/
@@ -5460,6 +5433,11 @@ static PyTypeObject DBEnv_Type = {
54605433 0 , /* tp_clear */
54615434 0 , /* tp_richcompare */
54625435 offsetof(DBEnvObject , in_weakreflist ), /* tp_weaklistoffset */
5436+ 0 , /* tp_iter */
5437+ 0 , /* tp_iternext */
5438+ DBEnv_methods , /* tp_methods */
5439+ 0 , /* tp_members */
5440+ DBEnv_getsets , /* tp_getsets */
54635441};
54645442
54655443static PyTypeObject DBTxn_Type = {
@@ -5470,8 +5448,8 @@ static PyTypeObject DBTxn_Type = {
54705448 /* methods */
54715449 (destructor )DBTxn_dealloc , /*tp_dealloc*/
54725450 0 , /*tp_print*/
5473- ( getattrfunc ) DBTxn_getattr , /*tp_getattr*/
5474- 0 , /*tp_setattr*/
5451+ 0 , /*tp_getattr*/
5452+ 0 , /*tp_setattr*/
54755453 0 , /*tp_compare*/
54765454 0 , /*tp_repr*/
54775455 0 , /*tp_as_number*/
@@ -5489,6 +5467,9 @@ static PyTypeObject DBTxn_Type = {
54895467 0 , /* tp_clear */
54905468 0 , /* tp_richcompare */
54915469 offsetof(DBTxnObject , in_weakreflist ), /* tp_weaklistoffset */
5470+ 0 , /* tp_iter */
5471+ 0 , /* tp_iternext */
5472+ DBTxn_methods , /* tp_methods */
54925473};
54935474
54945475
@@ -5500,8 +5481,8 @@ static PyTypeObject DBLock_Type = {
55005481 /* methods */
55015482 (destructor )DBLock_dealloc , /*tp_dealloc*/
55025483 0 , /*tp_print*/
5503- ( getattrfunc ) DBLock_getattr , /*tp_getattr*/
5504- 0 , /*tp_setattr*/
5484+ 0 , /*tp_getattr*/
5485+ 0 , /*tp_setattr*/
55055486 0 , /*tp_compare*/
55065487 0 , /*tp_repr*/
55075488 0 , /*tp_as_number*/
@@ -5530,7 +5511,7 @@ static PyTypeObject DBSequence_Type = {
55305511 /* methods */
55315512 (destructor )DBSequence_dealloc , /*tp_dealloc*/
55325513 0 , /*tp_print*/
5533- ( getattrfunc ) DBSequence_getattr , /*tp_getattr*/
5514+ 0 , /*tp_getattr*/
55345515 0 , /*tp_setattr*/
55355516 0 , /*tp_compare*/
55365517 0 , /*tp_repr*/
@@ -5549,6 +5530,9 @@ static PyTypeObject DBSequence_Type = {
55495530 0 , /* tp_clear */
55505531 0 , /* tp_richcompare */
55515532 offsetof(DBSequenceObject , in_weakreflist ), /* tp_weaklistoffset */
5533+ 0 , /* tp_iter */
5534+ 0 , /* tp_iternext */
5535+ DBSequence_methods , /* tp_methods */
55525536};
55535537#endif
55545538
@@ -5668,16 +5652,21 @@ PyMODINIT_FUNC PyInit__bsddb(void)
56685652 PyObject * svnid_s = PyUnicode_FromString (svn_id );
56695653 PyObject * py_api ;
56705654
5671- /* Initialize the type of the new type objects here; doing it here
5672- is required for portability to Windows without requiring C++. */
5673- Py_TYPE (& DB_Type ) = & PyType_Type ;
5674- Py_TYPE (& DBCursor_Type ) = & PyType_Type ;
5675- Py_TYPE (& DBEnv_Type ) = & PyType_Type ;
5676- Py_TYPE (& DBTxn_Type ) = & PyType_Type ;
5677- Py_TYPE (& DBLock_Type ) = & PyType_Type ;
5678- #if (DBVER >= 43 )
5679- Py_TYPE (& DBSequence_Type ) = & PyType_Type ;
5680- #endif
5655+ /* Initialize object types */
5656+ if (PyType_Ready (& DB_Type ) < 0 )
5657+ return NULL ;
5658+ if (PyType_Ready (& DBCursor_Type ) < 0 )
5659+ return NULL ;
5660+ if (PyType_Ready (& DBEnv_Type ) < 0 )
5661+ return NULL ;
5662+ if (PyType_Ready (& DBTxn_Type ) < 0 )
5663+ return NULL ;
5664+ if (PyType_Ready (& DBLock_Type ) < 0 )
5665+ return NULL ;
5666+ #if (DBVER >= 43 )
5667+ if (PyType_Ready (& DBSequence_Type ) < 0 )
5668+ return NULL ;
5669+ #endif
56815670
56825671
56835672#if defined(WITH_THREAD ) && !defined(MYDB_USE_GILSTATE )
0 commit comments