On 17:18 Sat 01 Sep , Marcin Szamotulski wrote:
> On 07:00 Sat 01 Sep , ZyX wrote:
> > суббота, 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.
>
> Prior to pyeval() function I was using
> vim.command("let dict=%s" % python_dict)
> inside python code. I think this was a standard solution to translate
> python objects like dictionaries into vim language. I think it would be
> nice if pyeval did the translation of keys into strings it self. This
> error might occur in quite a few plugins. Otherwise it is nice to add
> a comment in the documentation of pyeval().
>
> Best,
> Marcin
I looked into the documentation in the mercurial (I should check it
before but my vim has bit old runtime tree) and it suggests that the
keys are converted to strings:
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
So or E859 is a bug or the documentation should be changed.
Best,
Marcin
--
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