Skip to content

Commit

Permalink
The PyPy and Python people on freenode think that the original way of…
Browse files Browse the repository at this point in the history
… doing this is dangerous. This workaround *appears* to work, but I'd rather provide a pure python implementation of message. It works by getting a reference to __new__ and calling that with the arguments given as a tuple, rather than calling the C implementation directly. There is, as expected, no C implementation of unicode.__new__ in Python.
  • Loading branch information
MatthewWilkes committed Mar 19, 2013
1 parent a3c38f9 commit c44d002
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/zope/i18nmessageid/_zope_i18nmessageid_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static PyObject *
Message_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"value", "domain", "default", "mapping", NULL};
PyObject *value, *domain=NULL, *default_=NULL, *mapping=NULL, *s;
PyObject *value, *domain=NULL, *default_=NULL, *mapping=NULL, *s, *newfunc, *newargs;
Message *self;

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist,
Expand All @@ -65,8 +65,16 @@ Message_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (args == NULL)
return NULL;

s = PyUnicode_Type.tp_new(type, args, NULL);
Py_DECREF(args);
s =
new_func = PyObject_GetAttrString((PyObject *)&PyUnicode_Type, "__new__");
Py_INCREF(new_func);
new_args = PyTuple_New(3);
Py_INCREF(new_args);
PyObject_CallMethod(PyUnicode_Type, "__new__", args);
//PyTuple_SetItem(new_args, 0, type);
//
//(type, args, NULL);
//Py_DECREF(args);
if (s == NULL)
return NULL;

Expand Down

0 comments on commit c44d002

Please sign in to comment.