[Python-3000] Help replacing Py_FindMethod
Jesus Cea
jcea at jcea.es
Sat Jul 19 06:47:14 CEST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Good night everybody!.
Working on the Python3.0 support for bsddb I see that "Py_FindMethod"
was just removed in Python last beta.
Most uses of "Py_FindMethod" can be resolved as (as far as I know):
1. Delete the getattr routine.
2. Put a "0" in the getattr slot in the type object.
3. Use the "methods" slot. [*]
This is not documented anywhere, so I needed to "diff" modules between
2.6 and 3.0 trees :-(
But I have some code I don't know how to "upgrade". Can you possibly
help me?
The full sourcecode:
"""
static PyObject*
DBEnv_getattr(DBEnvObject* self, char *name)
{
~ if (!strcmp(name, "db_home")) {
~ const char *home = NULL;
~ CHECK_ENV_NOT_CLOSED(self);
#if (DBVER >= 42)
~ self->db_env->get_home(self->db_env, &home);
#else
~ home=self->db_env->db_home;
#endif
~ if (home == NULL) {
~ RETURN_NONE();
~ }
~ return PyBytes_FromString(home);
~ }
~ return Py_FindMethod(DBEnv_methods, (PyObject* )self, name);
}
"""
What can I do?.
Moreover, is this "Py_FindMethod" removal strategy valid for old Python
releases?. I need to support Python 2.3 and up.
[*] Using this change, the code doesn't work :-(. Compiling under
Python2.6 I get a lot of errors: "AttributeError: 'DB' object has no
attribute 'XXX'."
Example of "diff" I'm doing:
1. Delete the "DBSequence_getattr" routine.
2. Change the DBSequence_Type as:
"""
@@ -6800,7 +6785,7 @@
~ /* methods */
~ (destructor)DBSequence_dealloc, /*tp_dealloc*/
~ 0, /*tp_print*/
- - (getattrfunc)DBSequence_getattr,/*tp_getattr*/
+ 0, /*tp_getattr*/
~ 0, /*tp_setattr*/
~ 0, /*tp_compare*/
~ 0, /*tp_repr*/
@@ -6823,6 +6808,10 @@
~ 0, /* tp_clear */
~ 0, /* tp_richcompare */
~ offsetof(DBSequenceObject, in_weakreflist),/*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ DBSequence_methods, /*tp_methods*/
+ 0, /*tp_members*/
~ };
~ #endif
"""
What am I doing wrong?.
Thanks in advance.
PS: Four hours of hard working and bsddb "almost" compiles under
Python3.0b2!.
- --
Jesus Cea Avion _/_/ _/_/_/ _/_/_/
jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/
. _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iQCVAwUBSIFxyplgi5GaxT1NAQKBgAP+MWBeOOzNypzLNyG7UX7ZHZ4bMSn8t/Oh
fnR8UeRQoSCBuhvqfi6Vl6o06cc/v9bnsZ25Shhy73bn+KRm+HE6x6HXnFFO8e6W
XPLgi2l7xd/wIp6IA8M9r0NSpwn8nE4qJz44lhzRFPV54DsxwhbEkmCRyzpeJppb
DGu75Yw5cww=
=nte2
-----END PGP SIGNATURE-----
More information about the Python-3000
mailing list