[Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless prickelpit.c, 1.60, 1.61 stacklessmodule.c, 1.162, 1.163
Christian Tismer
tismer at centera.de
Mon Apr 19 21:15:20 CEST 2004
Update of /home/cvs/slpdev/src/2.3/dev/Stackless
In directory centera.de:/tmp/cvs-serv23468/dev/Stackless
Modified Files:
prickelpit.c stacklessmodule.c
Log Message:
moved the patched types for pickling into builtins.
This should generate less incompatibilites.
I tried to use copy_reg, but this still requires some location
for the global types, and still would mean to change the type names.
Index: prickelpit.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/prickelpit.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** prickelpit.c 18 Apr 2004 16:45:25 -0000 1.60
--- prickelpit.c 19 Apr 2004 19:15:18 -0000 1.61
***************
*** 16,19 ****
--- 16,21 ----
*******************************************************/
+ static PyObject *_builtin_dict = NULL;
+
static int meth_table_len(PyMethodDef *ml)
{
***************
*** 45,50 ****
static int init_type(PyTypeObject *t, PyMethodDef *ml, newfunc _new)
{
! static char stackless[] = "stackless.";
! char *new_name;
if (_new)
--- 47,53 ----
static int init_type(PyTypeObject *t, PyMethodDef *ml, newfunc _new)
{
! if (PyDict_GetItemString(_builtin_dict, t->tp_name) == NULL) {
! if (PyDict_SetItemString(_builtin_dict, t->tp_name, (PyObject *)t)) return -1;
! }
if (_new)
***************
*** 60,71 ****
t->tp_methods = ml;
}
- /* we cannot use the __module__ attribute, since this is no heap type */
- if (strncmp(stackless, t->tp_name, strlen(stackless))) {
- new_name = malloc(strlen(stackless)+strlen(t->tp_name)+1);
- if (new_name == NULL) return -1;
- strcpy(new_name, stackless);
- strcat(new_name, t->tp_name);
- t->tp_name = new_name;
- }
/* enforce the dict and type to be initialized */
if (PyType_Ready(t))
--- 63,66 ----
***************
*** 1568,1571 ****
--- 1563,1570 ----
int init_prickelpit(void)
{
+ PyObject *builtin = PyImport_ImportModule("__builtin__");
+ PyObject *dict;
+ if (builtin == NULL) return -1;
+ dict = PyModule_GetDict(builtin);
if (0
|| init_codetype()
***************
*** 1586,1591 ****
--- 1585,1592 ----
|| init_rangetype()
) return -1;
+ Py_DECREF(builtin);
return 0;
}
+
#endif
Index: stacklessmodule.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/stacklessmodule.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -C2 -d -r1.162 -r1.163
*** stacklessmodule.c 18 Apr 2004 15:14:37 -0000 1.162
--- stacklessmodule.c 19 Apr 2004 19:15:18 -0000 1.163
***************
*** 861,864 ****
--- 861,867 ----
|| init_cframetype()
|| init_prickelpit()
+ || init_flextype()
+ || init_tasklettype()
+ || init_channeltype()
)
return 0;
***************
*** 875,880 ****
PySlpModuleObject *m;
- if (init_flextype())
- return;
if (init_slpmoduletype())
return;
--- 878,881 ----
***************
*** 901,909 ****
if (PyDict_SetItemString(dict, name, (PyObject*)object) < 0) return
- if (0
- || init_tasklettype()
- || init_channeltype()
- )
- return;
INSERT("slpmodule", PySlpModule_TypePtr);
INSERT("cframe", &PyCFrame_Type);
--- 902,905 ----
***************
*** 914,936 ****
INSERT("stackless", slp_module);
- /* patched types */
- INSERT("cell", &PyCell_Type);
- INSERT("code", &PyCode_Type);
- INSERT("traceback", &PyTraceBack_Type);
- INSERT("function", &PyFunction_Type);
- INSERT("frame", &PyFrame_Type);
- INSERT("module", &PyModule_Type);
- INSERT("iterator", &PySeqIter_Type);
- INSERT("callable-iterator", &PyCallIter_Type);
- INSERT("instancemethod", &PyMethod_Type);
-
- INSERT("dictionary-iterator", &PyDictIter_Type);
- INSERT("enumerate", &PyEnum_Type);
- INSERT("enumerate-factory", &PyEnumFactory_Type);
- INSERT("listiterator", &PyListIter_Type);
- INSERT("rangeiterator", &Pyrangeiter_Type);
- INSERT("tupleiterator", &PyTupleIter_Type);
- INSERT("xrange", &PyRange_Type);
-
/* module dicts */
INSERT("modict", &PyModuleDict_Type);
--- 910,913 ----
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list