diff options
author | Bram Moolenaar <Bram@vim.org> | 2009-01-13 17:11:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2009-01-13 17:11:05 +0000 |
commit | d72b386a636aa7b56e5eb34498a6efae4d8ce7c5 (patch) | |
tree | a511c5ab0f399ce2a7d9b58d85ab61bf17fed7af /src/if_python.c | |
parent | 51460cd634d29b3612e7443c34bec5c20207ddad (diff) | |
download | vim-git-d72b386a636aa7b56e5eb34498a6efae4d8ce7c5.tar.gz |
updated for version 7.2-084v7.2.084
Diffstat (limited to 'src/if_python.c')
-rw-r--r-- | src/if_python.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/if_python.c b/src/if_python.c index 4a148840b..9a49dd29f 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -1151,14 +1151,23 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) /* Check if we run into a recursive loop. The item must be in lookupDict * then and we can use it again. */ - sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, (long_u)our_tv); - result = PyDict_GetItemString(lookupDict, ptrBuf); - if (result != NULL) - Py_INCREF(result); - else if (our_tv->v_type == VAR_STRING) + if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL) + || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL)) + { + sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, + our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list + : (long_u)our_tv->vval.v_dict); + result = PyDict_GetItemString(lookupDict, ptrBuf); + if (result != NULL) + { + Py_INCREF(result); + return result; + } + } + + if (our_tv->v_type == VAR_STRING) { result = Py_BuildValue("s", our_tv->vval.v_string); - PyDict_SetItemString(lookupDict, ptrBuf, result); } else if (our_tv->v_type == VAR_NUMBER) { @@ -1167,7 +1176,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) /* For backwards compatibility numbers are stored as strings. */ sprintf(buf, "%ld", (long)our_tv->vval.v_number); result = Py_BuildValue("s", buf); - PyDict_SetItemString(lookupDict, ptrBuf, result); } # ifdef FEAT_FLOAT else if (our_tv->v_type == VAR_FLOAT) @@ -1176,7 +1184,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) sprintf(buf, "%f", our_tv->vval.v_float); result = Py_BuildValue("s", buf); - PyDict_SetItemString(lookupDict, ptrBuf, result); } # endif else if (our_tv->v_type == VAR_LIST) @@ -1185,10 +1192,11 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) listitem_T *curr; result = PyList_New(0); - PyDict_SetItemString(lookupDict, ptrBuf, result); if (list != NULL) { + PyDict_SetItemString(lookupDict, ptrBuf, result); + for (curr = list->lv_first; curr != NULL; curr = curr->li_next) { newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict); @@ -1200,7 +1208,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) else if (our_tv->v_type == VAR_DICT) { result = PyDict_New(); - PyDict_SetItemString(lookupDict, ptrBuf, result); if (our_tv->vval.v_dict != NULL) { @@ -1209,6 +1216,8 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) hashitem_T *hi; dictitem_T *di; + PyDict_SetItemString(lookupDict, ptrBuf, result); + for (hi = ht->ht_array; todo > 0; ++hi) { if (!HASHITEM_EMPTY(hi)) |