New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Found bug, fixed it, here is my solution.... #1876
Comments
It is not really valid to assume specific encoding of the paths: in linux file name is absolutely any sequence of bytes which does not include |
@ZyX-I While it is true that "os.path.ismount must accept any path-like object, and "path-like" does include bytes". If you notice; I modified the yield statements in generate_directories to cast path from a string to a byte. The original code, when I first opened the file, was:
^Copied from Github repository. The issue was that path was a string and os.path.ismount was expecting a byte(or other "path-like" object I assume). Also, (and I could be wrong on this) but I think I tried casting cmd[0:-1] and cwd to bytes first and that didn't work so I casted it all to strings and that fixed the issue. :) |
“Path-like object” both applies to |
@ZyX-I Oh wow, yeah, I just tested it, you are absolutely right. os.path.ismount() takes bytes AND strings...My question is then; why did python throw an error? and more importantly...how did my code fix it? (⊙ヘ⊙ ; ) |
Yeah...I just reverted the code back to the way it was and threw a print statement in ntpath.py try:
from nt import _getvolumepathname
except ImportError:
_getvolumepathname = None
def ismount(path):
"""Test whether a path is a mount point (a drive root, the root of a
share, or a mounted volume)"""
path = os.fspath(path)
seps = _get_bothseps(path)
path = abspath(path)
root, rest = splitdrive(path)
#I added this line...
print('{0} is of type {1}'.format( path, type(path) ))
if root and root[0] in seps:
return (not rest) or (rest in seps)
if rest in seps:
return True
if _getvolumepathname:
return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
else:
return False This is what I got out:
so as you can see it does confirm that I tried to find the nt module and add some print statements to _getvolumepathname() but it just keeps telling me that nt is a built in module...I guess that probably means it's a binary somewhere in my Python36 directory...There isn't a whole lot of info on it on Google...if you know how I can take a look at it; let me know and I'll go try some more print debugging. I guess for now I'll just uncomment out my code and forget about it...at least until my PC explodes...lol</nervous laughter> |
“built-in” here means that it is in C code, possible, but not necessary, in the Python library/executable itself. Based on what I know on writing C extensions it will just have some call like PyArg_ParseTuple and it is what throws. Note a note near the s format. |
And it appears that Python has placed its |
I already fixed the issue, so I don't need help, but I popped in to let you guys know there is an issue and how I solved it.
So I configured my vimrc to use python3
let g:powerline_pycmd = 'py3'
after that I started getting an exception in my vim console, so I output it to a logfile
This was the file:
turns out it was an issue with python3 using bytes instead of strings for some things now...
So tl;dr I changed these lines of code and it fixed the issue on my end (blocks/lines I added are commented)
IN: .\powerline\lib\vcs\__init__.py:
IN: .\powerline\lib\shell.py:
I'm sure there are more elegant ways of doing this (and that is why I am not issuing a pull request) but feel free to make any modifications to and/or use this solution in your codebase if you want. 👍
The text was updated successfully, but these errors were encountered: