prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.53k stars 163 forks source link

Command line option -u for pyvimrc fails assert in Python 2.7 #69

Open jacob14916 opened 8 years ago

jacob14916 commented 8 years ago

When I pass a path via the -u option on the command line, the following code raises an AssertError:

    assert isinstance(rc_file, six.text_type)

https://github.com/jonathanslenders/pyvim/blob/master/pyvim/rc_file.py#L30

I believe it fails because it expects a unicode type, while docopt produces a Python 2 string. My workaround is to cast the rc file path to unicode in run_pyvim.py, but I don't know if this will work in Python 3.

jonathanslenders commented 8 years ago

Hi @jacob14916,

Thanks a lot for reporting this bug! I was not aware about the difference between Python 2 and Python 3 regarding docopt. I will decode the string in Python2.

Jonathan

jonathanslenders commented 8 years ago

This should be fixed in: https://github.com/jonathanslenders/pyvim/commit/07fbb2cd45810bfd2ce4676aa5029dfe3e26b405

Actually, I'm not entirely satisfied with the solution. I prefer all strings to be unicode strings, even for Python 2. However it seems that the combination of docopt, Python 2 and unicode strings doesn't work that well out of the box. (See also: https://github.com/docopt/docopt/issues/301 ). So, I consider switching to the "click" library if that fixes my problems.