суббота, 1 сентября 2012 г., 16:24:54 UTC+4 пользователь Marcin Szamotulski 
написал:
> I have some issues with the pyeval() function.  Let say I have a python
> dictionary where the keys are integers, for example:
> 
> :py x={1:''}
> 
> Then 
> 
> :echo pyeval("x")
> 
> Brings two errors:
> 
> E859: Failed to convert returned python object to vim value
> E685: Internal error: echo_string()
> 
> However if the keys are strings:
> 
> :py x={'1':''}
> > 
> everything works fine.

Internal error should not happen and is a bug, attached patch that fixes this.

E859 however is not a bug: vim dictionaries can have only string keys.

# HG changeset patch
# User ZyX <[email protected]>
# Date 1346507519 -14400
# Node ID 744a019963bcce46daa52f8dc61c79415c47bf45
# Parent  c0ac5ba6624303f459d0b24f5fe98b1269778213
Fixed internal error in case it failed to convert python object to vim value

diff -r c0ac5ba66243 -r 744a019963bc src/if_python.c
--- a/src/if_python.c   Wed Aug 29 18:50:29 2012 +0200
+++ b/src/if_python.c   Sat Sep 01 17:51:34 2012 +0400
@@ -1787,6 +1787,10 @@
        case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
        case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
        case VAR_FUNC: func_ref(rettv->vval.v_string);    break;
+       case VAR_UNKNOWN:
+           rettv->v_type = VAR_NUMBER;
+           rettv->vval.v_number = 0;
+           break;
     }
 }
 
diff -r c0ac5ba66243 -r 744a019963bc src/if_python3.c
--- a/src/if_python3.c  Wed Aug 29 18:50:29 2012 +0200
+++ b/src/if_python3.c  Sat Sep 01 17:51:34 2012 +0400
@@ -1817,6 +1817,10 @@
        case VAR_DICT: ++rettv->vval.v_dict->dv_refcount; break;
        case VAR_LIST: ++rettv->vval.v_list->lv_refcount; break;
        case VAR_FUNC: func_ref(rettv->vval.v_string);    break;
+       case VAR_UNKNOWN:
+           rettv->v_type = VAR_NUMBER;
+           rettv->vval.v_number = 0;
+           break;
     }
 }

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui