[Python-Dev] PyExc_UnicodeDecodeError (original) (raw)
M.-A. Lemburg mal at egenix.com
Wed Sep 15 17:35:36 CEST 2004
- Previous message: [Python-Dev] PyExc_UnicodeDecodeError
- Next message: [Python-Dev] PyExc_UnicodeDecodeError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thomas Heller wrote:
Can anyone explain why calling this code in a C extension
static PyObject * test(PyObject *self, PyObject *arg) { PyErrSetString(PyExcUnicodeDecodeError, "blah blah"); return NULL; } PyMethodDef modulemethods[] = { {"test", test, METHNOARGS}, {NULL, NULL} };
does this (same in 2.3.4, and 2.4 current CVS):
from somewhere import test test() Traceback (most recent call last): File "", line 1, in ? TypeError: function takes exactly 5 arguments (1 given)
See Python/exceptions.c:
PyObject * PyUnicodeDecodeError_Create( const char *encoding, const char *object, int length, int start, int end, const char *reason) { return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#iis", encoding, object, length, start, end, reason); }
This exception is thrown by codecs that want to signal a decoding error. It includes the context of the problem as well as the reason string.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Sep 15 2004)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
- Previous message: [Python-Dev] PyExc_UnicodeDecodeError
- Next message: [Python-Dev] PyExc_UnicodeDecodeError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]