ultisnips 2.1 on windows throws constantly an error

Bug #937605 reported by Serge Ratke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UltiSnips
Fix Released
Undecided
Unassigned

Bug Description

error appears as soon as i start using vim

here's the sys.version

2.7.1 (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 bit (Intel)]

i have deleted all my previously defined snippets. in this case the error was thrown as soon
as i started creating a new snippet (ft=cf) with :UltiSnipsEdit

here's the full tb

Following is the full stack trace:
Traceback (most recent call last):
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 23, in wrapper
    return f(self, *args, **kwds)
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 566, in expand_or_jump
    rv = self._try_expand()
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 866, in _try_expand
    self._do_snippet(snippet, before, after)
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 848, in _do_snippet
    self._jump()
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 731, in _jump
    _vim.select(self._ctab.start, self._ctab.end)
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 119, in select
    _unmap_select_mode_mapping()
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 207, in _unmap_select_mode_mapping
    all_maps = list(filter(len, eval(r"_tmp_smaps").splitlines()))
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 101, in eval
    return as_unicode(rv)
  File "C:\Users\srr\vimfiles\plugin\UltiSnips\compatibility.py", line 69, in as_unicode
    return s.decode("utf-8")
  File "C:\Python27\Lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xea in position 1011: invalid continuation byte

Revision history for this message
SirVer (sirver) wrote : Re: [Bug 937605] [NEW] ultisnips 2.1 on windows throws constantly an error

Please provide the snippet file for this file type. Also &encoding.

  status incomplete

Changed in ultisnips:
status: New → Incomplete
Revision history for this message
Serge Ratke (serge-ratke) wrote :

the file is empty, hence no snippet definitions. encoding is latin1.

Revision history for this message
SirVer (sirver) wrote : Re: [Bug 937605] Re: ultisnips 2.1 on windows throws constantly an error

Does this also happen with other filetypes? e.g. ft=blahblub. And what
happens when there is already a snippet file available e.g. ft=tex.

Can you also try setting your system language/vim language to english
and see if this changes anything?

Revision history for this message
Serge Ratke (serge-ratke) wrote :

yea, it seems to be independent on what filetype is currently active, it even happens if no filetype is set at all. switching to english doesn't change anything.

Revision history for this message
SirVer (sirver) wrote :

Could you provide me with the output of :verbose smap, please?

On Wed, Feb 22, 2012 at 12:04:49PM -0000, Serge Ratke wrote:
>yea, it seems to be independent on what filetype is currently active, it
>even happens if no filetype is set at all. switching to english doesn't
>change anything.
>
>--
>You received this bug notification because you are subscribed to
>UltiSnips.
>https://bugs.launchpad.net/bugs/937605
>
>Title:
> ultisnips 2.1 on windows throws constantly an error
>
>Status in UltiSnips - The Ultimate Snippet Solution for Vim:
> Incomplete
>
>Bug description:
> error appears as soon as i start using vim
>
> here's the sys.version
>
> 2.7.1 (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 bit (Intel)]
>
> i have deleted all my previously defined snippets. in this case the error was thrown as soon
> as i started creating a new snippet (ft=cf) with :UltiSnipsEdit
>
> here's the full tb
>
> Following is the full stack trace:
> Traceback (most recent call last):
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 23, in wrapper
> return f(self, *args, **kwds)
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 566, in expand_or_jump
> rv = self._try_expand()
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 866, in _try_expand
> self._do_snippet(snippet, before, after)
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 848, in _do_snippet
> self._jump()
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\__init__.py", line 731, in _jump
> _vim.select(self._ctab.start, self._ctab.end)
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 119, in select
> _unmap_select_mode_mapping()
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 207, in _unmap_select_mode_mapping
> all_maps = list(filter(len, eval(r"_tmp_smaps").splitlines()))
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\_vim.py", line 101, in eval
> return as_unicode(rv)
> File "C:\Users\srr\vimfiles\plugin\UltiSnips\compatibility.py", line 69, in as_unicode
> return s.decode("utf-8")
> File "C:\Python27\Lib\encodings\utf_8.py", line 16, in decode
> return codecs.utf_8_decode(input, errors, True)
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xea in position 1011: invalid continuation byte
>
>To manage notifications about this bug go to:
>https://bugs.launchpad.net/ultisnips/+bug/937605/+subscriptions

Revision history for this message
Serge Ratke (serge-ratke) wrote :

sure thing, there you go:

s <Tab> * <Esc>:call UltiSnips_ExpandSnippetOrJump()<CR>
 Zuletzt gesetzt von ~\vimfiles\plugin\UltiSnips.vim
v <C-X> "*d
v % * :<C-U>call <SNR>17_Match_wrapper('',1,'v') <CR>m'gv``
 Zuletzt gesetzt von ~\vimfiles\plugin\matchit.vim
   ,mi <C-W>=|
 Zuletzt gesetzt von ~\_vimrc
   ,ma <C-W>_<C-W>|
 Zuletzt gesetzt von ~\_vimrc
   ,s? z=
 Zuletzt gesetzt von ~\_vimrc
   ,sa zg
 Zuletzt gesetzt von ~\_vimrc
   ,sp [s
 Zuletzt gesetzt von ~\_vimrc
   ,sn ]s
 Zuletzt gesetzt von ~\_vimrc
   ,ss :setlocal spell!<CR>
 Zuletzt gesetzt von ~\_vimrc
   ,e :tabnew! ~\_vimrc<CR>
 Zuletzt gesetzt von ~\_vimrc
   ,tm :tabmove
 Zuletzt gesetzt von ~\_vimrc
   ,te :tabedit
 Zuletzt gesetzt von ~\_vimrc
   ,tn :tabnew<CR>
 Zuletzt gesetzt von ~\_vimrc
v [% <Esc>[%m'gv``
 Zuletzt gesetzt von ~\vimfiles\plugin\matchit.vim
v ]% <Esc>]%m'gv``
 Zuletzt gesetzt von ~\vimfiles\plugin\matchit.vim
v a% <Esc>[%v]%
 Zuletzt gesetzt von ~\vimfiles\plugin\matchit.vim
v g% * :<C-U>call <SNR>17_Match_wrapper('',0,'v') <CR>m'gv``
 Zuletzt gesetzt von ~\vimfiles\plugin\matchit.vim
v <Plug>VSurround * :<C-U>call <SNR>19_opfunc2(visualmode())<CR>
 Zuletzt gesetzt von ~\vimfiles\plugin\surround.vim
v <Plug>Vsurround * :<C-U>call <SNR>19_opfunc(visualmode())<CR>
 Zuletzt gesetzt von ~\vimfiles\plugin\surround.vim
s <BS> * <C-G>c
 Zuletzt gesetzt von ~\vimfiles\plugin\UltiSnips.vim
s <C-Tab> * <Esc>:call UltiSnips_ListSnippets()<CR>
 Zuletzt gesetzt von ~\vimfiles\plugin\UltiSnips.vim
s <S-Tab> * <Esc>:call UltiSnips_JumpBackwards()<CR>
 Zuletzt gesetzt von ~\vimfiles\plugin\UltiSnips.vim
v <C-Del> "*d
v <S-Del> "*d
v <C-Insert> "*y
v <S-Insert> "-d"*P
v ê :m'>+<CR>gv=`<my`>mzgv`yo`z
 Zuletzt gesetzt von ~\_vimrc
v ë :m'<-2<CR>gv=`>my`<mzgv`yo`z
 Zuletzt gesetzt von ~\_vimrc

Revision history for this message
SirVer (sirver) wrote :

Please unmap
ê
ë

using sunmap.

and see if this solves the problem. I guess so, it is unlikely that you
will need them in select map anyways.

Revision history for this message
Serge Ratke (serge-ratke) wrote :

no idea why it is rendered like this, but, the actual mappings contain no such characters:

vmap <M-j> :m'>+....
vmap <M-k> :m'<-2...

however, now that i've removed all the mappings i don't use, and set the others to noremap, i can -- finally -- enjoy using ultisnips on windows.

thanks for the patience and the awesome work :)

Revision history for this message
Edwin Bonelli (gr33n3y3s) wrote :

I have exactly the same problem on windows. I used the same configuration on linux without any problems. However on windows by default 'mswin.vim' is loaded, when I disable this ultisnips works fine.

Here's the contents of my (unchanged) mswin.vim: https://gist.github.com/1932294

Revision history for this message
Serge Ratke (serge-ratke) wrote :

thanks edwin for confirming the bug.

have to admit that i still suffer from this misbehaviour. i thought it was gone after removing those mappings :/

Revision history for this message
Edwin Bonelli (gr33n3y3s) wrote :

After reading multiple bug reports about the 'UnicodeDecodeError' and taking another look Serge's bug report, I have to slightly change my description about my issue a bit. I get the UnicodeDecodeError not at startup but more specifically after activating any snippet. Errors weren't shown at starting Vim whatsoever.

I also narrowed the problem down to this bit in mswin.vim:
------------------
if has("gui")
  noremap <M-Space> :simalt ~<CR>
  inoremap <M-Space> <C-O>:simalt ~<CR>
  cnoremap <M-Space> <C-C>:simalt ~<CR>
endif
------------------

After commenting this out I am no longer receiving the UnicodeDecodeError as mentioned above. Now this may be a specific to my issue/configuration, but maybe it affects others as well.

Revision history for this message
Jorge (skeept) wrote :

I have the same problem.
I was able to isolate the cause in my vimrc:

if &filetype != 'tex'
  imap <M-C-J> <Plug>IMAP_JumpForward
  nmap <M-C-J> <Plug>IMAP_JumpForward
  vmap <M-C-J> <Plug>IMAP_JumpForward
  vmap <M-C-J> <Plug>IMAP_DeleteAndJumpForward
endif

if I comment these lines then the plugin doesn't give an error.

Revision history for this message
SirVer (sirver) wrote :

That narrows it quite a bit! Thanks for your digging, people.

Could you please try the following 2 things:

1) edit plugin/UltiSnips/_vim.py and replace the following:

def eval(s):
    rv = vim.eval(as_vimencoding(s))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv

through
def eval(s):
    return vim.eval(s)

See if this solve this particular problem (this might make new problems though).

2) try setting encoding=utf-8 as first thing in your .vimrc (only temporary)

I will try to reproduce this bug in my virtual xp box, but as i am currently travelling this will not be before next week.

Revision history for this message
Edwin Bonelli (gr33n3y3s) wrote :

Hey Silver, I can personally confirm that your above mentioned change in _vim.py solved the issues I had (without ustf-8 first). However option two with setting utf-8 as the first setting works too (without the code change).

Revision history for this message
SirVer (sirver) wrote :

>Hey Silver,
The name's SirVer, mr. redeyes.

> I can personally confirm that your above mentioned change in
>_vim.py solved the issues I had (without ustf-8 first). However option
>two with setting utf-8 as the first setting works too (without the code
>change).
Interesting. Is somebody able to test a current trunk version of
UltiSnips? Maybe your troubles are fixed there already as I made
UltiSnips a bit cleverer concerning vim encodings.

Revision history for this message
SirVer (sirver) wrote :

I cannot reproduce this with current trunk, nor with 2.1 under Windows XP and Gvim. Please do the following: completely *delete* your ultisnips checkout direcotry, then recheckout. If you are not using a trunk version, please get one for testing. Please, also report back then.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for UltiSnips because there has been no activity for 60 days.]

Changed in ultisnips:
status: Incomplete → Expired
Revision history for this message
SirVer (sirver) wrote :

Heard nothing back from anybody. I assume deleting and rechecking out fixes the problem. Closing as Invalid. Please speak up when you see the problem again.

Changed in ultisnips:
status: Expired → Invalid
Revision history for this message
Jan Vlčinský (jan-vlcinsky) wrote :
Download full text (4.0 KiB)

I have exactly the same problem.
Running on Windows 7 Pro SP1
Using gvim 7.3.46

Part of my _vimrc::

setglobal fileencoding=utf-8
"------------------------------------------------------------------------------
" Vundle - plugin management
"------------------------------------------------------------------------------
set nocompatible " be iMproved
filetype off " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'

" My Bundles here:
"
" original repos on github
Bundle 'UltiSnips'
Bundle 'mattn/calendar-vim'
Bundle 'rosenfeld/conque-term'
Bundle 'The-NERD-Commenter'
Bundle 'vimwiki'
Bundle 'surround.vim'
Bundle 'brymck/nekotako'
Bundle 'VST'
Bundle 'vcscommand.vim'
Bundle 'Solarized'
Bundle 'taglist.vim'
Bundle 'Python-mode-klen'
Bundle 'unimpaired.vim'
Bundle 'ctrlp.vim'

filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..

"------------------------------------------------------------------------------
" General
"------------------------------------------------------------------------------
source $VIMRUNTIME/mswin.vim " Some basic MS keybindings
filetype plugin on " Enable filetype plugin
filetype indent on " Enable indent pluing

===end of _vimrc snippet ====================
When trying to use any of snippets (like "def" in python file), it prints out:

===start error printout===
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://bugs.launchpad.net/ultisnips/+filebug.

Following is the full stack trace:
Traceback (most recent call last):
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\__init__.py", line 23, in wrapper
    return f(self, *args, **kwds)
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\__init__.py", line 536, in expand
    if not self._try_expand():
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\__init__.py", line 866, in _try_expand
    self._do_snippet(snippet, before, after)
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\__init__.py", line 848, in _do_snippet
    self._jump()
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\__init__.py", line 731, in _jump
    _vim.select(self._ctab.start, self._ctab.end)
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\_vim.py", line 119, in select
    _unmap_select_mode_mapping()
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\_vim.py", line 207, in _unmap_select_mode_mapping
    all_maps = list(filter(len, eval(r"_tmp_smaps").splitlines()))
  File "C:\Users\jan.vlcinsky\.vim\bundle\UltiSnips\plugin\UltiSnips\_vim.py", line 101, in eval
    return as_unicode(rv)
  File "C:\Users\jan.vl...

Read more...

Revision history for this message
Jan Vlčinský (jan-vlcinsky) wrote :

Changing to the latest version of UltiSnip helped.

I changed line Bundle 'UltiSnips'
into
Bundle 'SirVer/ultisnips'

what returned latest version from github with changelog reporting on top following lines:

 - Various smaller bug fixes.
 - New command to manually add a filetype to the list for the current
   buffer. *:UltiSnipsAddFiletypes*
 - New or improved snippets: snippets, haskell, bindzone, python, golang,
   json, html, coffee, coffee_jasmine, javascript_jasmine, ruby, php,
   markdown.

version 2.1:
 - Python interpolation access to text from visual selection via snip.v.
 - Support for transformations of ${VISUAL} texts.
 - New or improved snippets: python, tex, texmath, ruby, rails, html, django

and all works, as it should.

Thanks a lot. (I would anyway recommend to mark this bug as resolved and not invalid, as it would help anyone, who would install it from release and not from latest development version).

Revision history for this message
SirVer (sirver) wrote :

Thanks for the Feedback Jan. Setting to fix released.

Changed in ultisnips:
status: Invalid → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.