Changeset 682 for trunk/zoo-project/zoo-kernel/service_internal_python.c
- Timestamp:
- Jun 26, 2015, 2:07:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal_python.c
r624 r682 523 523 maps* mapsFromPyDict(PyDictObject* t){ 524 524 maps* res=NULL; 525 maps* cursor= res;525 maps* cursor=NULL; 526 526 PyObject* list=PyDict_Keys((PyObject*)t); 527 527 int nb=PyList_Size(list); 528 528 int i; 529 PyObject* key; 530 PyObject* value; 529 531 for(i=0;i<nb;i++){ 530 532 #ifdef DEBUG 531 533 fprintf(stderr,">> parsing maps %d\n",i); 532 534 #endif 533 PyObject*key=PyList_GetItem(list,i);534 PyObject*value=PyDict_GetItem((PyObject*)t,key);535 key=PyList_GetItem(list,i); 536 value=PyDict_GetItem((PyObject*)t,key); 535 537 #ifdef DEBUG 536 538 fprintf(stderr,">> DEBUG VALUES : %s => %s\n", … … 538 540 #endif 539 541 cursor=(maps*)malloc(MAPS_SIZE); 540 cursor->name= PyString_AsString(key);542 cursor->name=zStrdup(PyString_AsString(key)); 541 543 cursor->content=mapFromPyDict((PyDictObject*)value); 542 544 #ifdef DEBUG … … 572 574 int nb=PyList_Size(list); 573 575 int i; 576 PyObject* key; 577 PyObject* value; 574 578 for(i=0;i<nb;i++){ 575 PyObject*key=PyList_GetItem(list,i);576 PyObject*value=PyDict_GetItem((PyObject*)t,key);579 key=PyList_GetItem(list,i); 580 value=PyDict_GetItem((PyObject*)t,key); 577 581 #ifdef DEBUG 578 582 fprintf(stderr,">> DEBUG VALUES : %s => %s\n", … … 584 588 Py_ssize_t size; 585 589 #if PY_MAJOR_VERSION >= 3 586 buffer=_PyUnicode_AsStringAndSize(value,&size); 590 if(PyBytes_Check(value)){ 591 size=PyBytes_Size(value); 592 buffer=PyBytes_AsString(value); 593 } 594 else 595 if(PyUnicode_Check(value) && PyUnicode_READY(value) == 0){ 596 buffer=PyUnicode_AsUTF8AndSize(value,&size); 597 } 598 else{ 599 fprintf(stderr,"Unsupported return value."); 600 return NULL; 601 } 587 602 #else 588 603 PyString_AsStringAndSize(value,&buffer,&size);
Note: See TracChangeset
for help on using the changeset viewer.