jaxbot / github-issues.vim

Github issue lookup in Vim
http://jaxbot.me/articles/github-issues-vim-plugin-5-7-2014
Other
405 stars 28 forks source link

Closing/Opening issues throws an error #176

Closed parmort closed 4 years ago

parmort commented 5 years ago

Hi, I just got into this plugin, and I can't figure out how to get the access token working. The token has all possible permissions (I've tried this a few times, so I've ruled out the permissiveness of the token). Just taking a glance at the error, it looks very much like a python 2/3 discrepancy. I can't figure out how to force vim to use python 2 rather than python 3.

Vim version: 8.1.408 with python and python3 support Python 2 version: 2.7.15 Python 3 version: 3.7.0 Here is the error message:

Traceback (most recent call last):                                                                                                        
  File "<string>", line 1, in <module>                                                                                                    
  File "<string>", line 883, in setIssueData                                                                                              
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen                                                                       
    return opener.open(url, data, timeout)                                                                                                
  File "/usr/lib/python3.7/urllib/request.py", line 523, in open                                                                          
    req = meth(req)                                                                                                                       
  File "/usr/lib/python3.7/urllib/request.py", line 1247, in do_request_                                                                  
    raise TypeError(msg)                                                                                                                  
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
Fubukimaru commented 5 years ago

I have seen this in the case you mention: python2 and python3 discrepancies.

For the moment the way to force python2, at least for this plugin, would be to change the following lines:

In https://github.com/jaxbot/github-issues.vim/blob/master/autoload/ghissues.vim

if has("python3")
    command! -nargs=1 Python python3 <args>
else
    command! -nargs=1 Python python <args>
endif

to

if has("python")
    command! -nargs=1 Python python <args>
else
    command! -nargs=1 Python python3 <args>
endif

I understand that you get the issues listed and so on. Does this happen when creating an issue? I have python 3.6.5 and I'm not getting any issue at the moment.

parmort commented 5 years ago

No, it works fine to add issues. Closing (and I assume opening) issues seem to be the problem. Unfortunately, I only got the list up by using the original python3 command code. It seems that the function setIssueState throws a TypeError that says POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str. It could be a small change in 3.7, but I doubt it. Any ideas?

Edit: After looking through the code, line 902 in the plugin file seems to be the culprit, although I don't know why:

urllib2.urlopen(request, timeout = 2)
osleg commented 5 years ago

Just tested with python 3.7.1 works without any issue. Using the master branch from this repo. Could you try to use this PR #175

osleg commented 4 years ago

Should be fixed now, reopen if not