summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilkes <git@matthewwilkes.name>2013-03-19 15:40:17 +0000
committerMatthew Wilkes <git@matthewwilkes.name>2013-03-19 15:40:17 +0000
commitc44d002775265ea9c9204fb86304da3136485dbc (patch)
treedac2ee7f990dee7a9e85c6119da38ff4f2777060
parenta3c38f9a91f8e3f67cd27577838a457056c6e629 (diff)
downloadzope-i18nmessageid-3.5.3-experimental-pypy.tar.gz
The PyPy and Python people on freenode think that the original way of 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.3.5.3-experimental-pypy
-rw-r--r--src/zope/i18nmessageid/_zope_i18nmessageid_message.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/zope/i18nmessageid/_zope_i18nmessageid_message.c b/src/zope/i18nmessageid/_zope_i18nmessageid_message.c
index 98e2d06..b932ace 100644
--- a/src/zope/i18nmessageid/_zope_i18nmessageid_message.c
+++ b/src/zope/i18nmessageid/_zope_i18nmessageid_message.c
@@ -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,
@@ -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;