diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-05-10 19:18:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 19:18:58 +0200 |
commit | 8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d (patch) | |
tree | cded38835bde85bc8a1682303617f84bf2549f7e /runtime | |
parent | 1cd8517344c0d99ca6fb3246c70f78d271993cf6 (diff) | |
parent | 966e7abc4960746b4dde618807fb5516d162ae2d (diff) | |
download | rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.tar.gz rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.tar.bz2 rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.zip |
Merge #8371 'API: more reliable/descriptive VimL errors'
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/msgpack.vim | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim index a10ac32469..09c99c940d 100644 --- a/runtime/autoload/msgpack.vim +++ b/runtime/autoload/msgpack.vim @@ -40,9 +40,10 @@ function s:msgpack_init_python() abort return s:msgpack_python_type endif let s:msgpack_python_initialized = 1 - for suf in ['', '3'] + for suf in (has('win32') ? ['3'] : ['', '3']) try execute 'python' . suf + \. "\n" \. "def shada_dict_strftime():\n" \. " import datetime\n" \. " import vim\n" @@ -60,12 +61,15 @@ function s:msgpack_init_python() abort \. " fmt = vim.eval('a:format')\n" \. " timestr = vim.eval('a:string')\n" \. " timestamp = datetime.datetime.strptime(timestr, fmt)\n" - \. " timestamp = int(timestamp.timestamp())\n" + \. " try:\n" + \. " timestamp = int(timestamp.timestamp())\n" + \. " except:\n" + \. " timestamp = int(timestamp.strftime('%s'))\n" \. " if timestamp > 2 ** 31:\n" - \. " tsabs = abs(timestamp)" + \. " tsabs = abs(timestamp)\n" \. " return ('{\"_TYPE\": v:msgpack_types.integer,'\n" \. " + '\"_VAL\": [{sign},{v1},{v2},{v3}]}').format(\n" - \. " sign=1 if timestamp >= 0 else -1,\n" + \. " sign=(1 if timestamp >= 0 else -1),\n" \. " v1=((tsabs >> 62) & 0x3),\n" \. " v2=((tsabs >> 31) & (2 ** 31 - 1)),\n" \. " v3=(tsabs & (2 ** 31 - 1)))\n" |