Loading ...
Sorry, an error occurred while loading the content.

66280Re: pyeval() error

Expand Messages
  • ZyX
    Sep 1, 2012
    • 0 Attachment
      > Prior to pyeval() function I was using
      > vim.command("let dict=%s" % python_dict)

      I used json.dumps and a self-written dumper for this job. The above code is one of the worst ideas that could go into your head:

      1. (string % tuple_or_value) notation is deprecated.
      2. “"%s" % {u'«»': 1}” produces “{u'\xab\xbb': 1}” which can’t be handled in vim.
      3. “"%s" % {'«»': 1}” produces “{'\xc2\xab\xc2\xbb': 1}” which is not handled by vim in a proper way.
      4. There is a bunch of other things calling __repl__ on which will result in something vim won’t understand, but in this case vim won’t even understand simple unicode or utf-8 encoded strings as shown above.

      json.dumps minimizes the amount of problematic things (including converting keys to strings) and throws an exception if it can’t handle something, my interface does this as well. I do not do some type conversions that json.dumps does, json.dumps fails to handle some things which I handle (“pyeval('vim.current.buffer')” produces same output as “getline(1, '$')”, but “json.dumps(vim.current.buffer)” fails).

      Self-written dumper was used to get binary data: “json.dumps('\x80')” throws an exception while vim is fine with just having it embedded inside a string.

      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
    • Show all 11 messages in this topic