Embedded Python and MySQLdb (was Re: PyApache and MySQLdb (was Re: anyone get one of the python apache modules to work with 2.1?))
Brandon Long
blong at fiction.net
Thu Aug 30 00:30:51 EDT 2001
On 08/29/01 Skip Montanaro uttered the following other thing:
>
> >> Sounds like something's fishy in your os module.
> ...
> Brandon> No, the module is unmodified and does contain the
> Brandon> AttributeError clause... but for some reason, it doesn't match
> Brandon> the AttributeError exception that is thrown. If I replace it
> Brandon> with just except: to catch all exceptions, it passes until
> Brandon> further down where something else in os.py expects an
> Brandon> exception.
>
> This sounds very odd. If you print out sys.exc_info() inside the except:
> clause what do you see as an error? Is there anything unusual about your
> install? Does "make test" from your build directory run pretty cleanly?
The first time through (when it doesn't fail):
(<class exceptions.AttributeError at 0x80c807c>,
<exceptions.AttributeError instance at 0x8151dc4>, <traceback object at
0x81506e0>)
The second time through:
(<class exceptions.AttributeError at 0x81635e4>,
<exceptions.AttributeError instance at 0x8178f04>, <traceback object at
0x80d01c0>)
The system is Redhat 6.1, the only argument to configure was to change
the installation prefix. 'make test' passed.
The culprit appears to be the following code in MySQLdb/_mysql.c:
if (!(emod = PyImport_ImportModule("_mysql_exceptions")))
goto error;
if (!(edict = PyModule_GetDict(emod))) goto error;
if (!(_mysql_MySQLError =
_mysql_NewException(dict, edict, "MySQLError")))
goto error;
/* continues through all the other exceptions defined in _mysql_exceptions.py */
Where _mysql_NewException is defined as:
static PyObject *
_mysql_NewException(
PyObject *dict,
PyObject *edict,
char *name)
{
PyObject *e;
if (!(e = PyDict_GetItemString(edict, name)))
return NULL;
if (PyDict_SetItemString(dict, name, e)) return NULL;
return e;
}
commenting out that entire code fragment in the init_mysql(), and the
test passes. It seems really weird to be doing the above, but I don't
know what its actually violating.
Brandon
--
"No man really knows about other human beings. The best he can do is
to suppose that they are like himself."
-- John Steinbeck, "The Winter of Our Discontent"
http://www.fiction.net/blong/
More information about the Python-list
mailing list