Skip to content
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

werid behavior #486

Closed
czhang03 opened this issue Mar 21, 2016 · 10 comments
Closed

werid behavior #486

czhang03 opened this issue Mar 21, 2016 · 10 comments
Labels

Comments

@czhang03
Copy link

python 2.7.10
windows powershell

when I type:

> git comit -am 'test'
> fuck

it gives me something that is completely weird:

C:\Python27\lib\site-packages\win_unicode_console\__init__.py:27: RuntimeWarning: sys.stdin.encoding == 'utf-8', whereas sys.stdout.encoding == None, readline hook consumer may assume they are the same
  readline_hook.enable(use_pyreadline=use_pyreadline)
�[1mgit commit -am 'test'�[0m [�[32menter�[0m/�[34m↑�[0m/�[34m↓�[0m/�[31mctrl+c�[0m]

and then give an exception:

Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\thefuck.exe\__main__.py", line 9, in <module>
  File "C:\Python27\lib\site-packages\thefuck\main.py", line 80, in main
    fix_command()
  File "C:\Python27\lib\site-packages\thefuck\main.py", line 32, in fix_command
    selected_command = select_command(corrected_commands)
  File "C:\Python27\lib\site-packages\thefuck\ui.py", line 80, in select_command
    for action in read_actions():
  File "C:\Python27\lib\site-packages\thefuck\ui.py", line 13, in read_actions
    key = get_key()
  File "C:\Python27\lib\site-packages\thefuck\system\win32.py", line 25, in get_key
    return ch.decode(sys.stdout.encoding)
TypeError: decode() argument 1 must be string, not None

I think this is related to UTF-8 encoding in python2...
I cannot add python3 to path, because my vim plugins will require python2 in the path...

Is there any way I can fix this?

@scorphus
Copy link
Collaborator

Yes, there is. I'll send a fix very soon. Thank you for reporting this
issue.
Em 21/03/2016 20:29, "Cheng Zhang" notifications@github.com escreveu:

python 2.7.10
windows powershell

when I type:

git comit -am 'test'> fuck

it gives me something that is completely weird:

C:\Python27\lib\site-packages\win_unicode_console__init__.py:27: RuntimeWarning: sys.stdin.encoding == 'utf-8', whereas sys.stdout.encoding == None, readline hook consumer may assume they are the same
readline_hook.enable(use_pyreadline=use_pyreadline)
�[1mgit commit -am 'test'�[0m [�[32menter�[0m/�[34m↑�[0m/�[34m↓�[0m/�[31mctrl+c�[0m]

and then give an exception:

Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in run_module_as_main
"main", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\Python27\Scripts\thefuck.exe__main
.py", line 9, in
File "C:\Python27\lib\site-packages\thefuck\main.py", line 80, in main
fix_command()
File "C:\Python27\lib\site-packages\thefuck\main.py", line 32, in fix_command
selected_command = select_command(corrected_commands)
File "C:\Python27\lib\site-packages\thefuck\ui.py", line 80, in select_command
for action in read_actions():
File "C:\Python27\lib\site-packages\thefuck\ui.py", line 13, in read_actions
key = get_key()
File "C:\Python27\lib\site-packages\thefuck\system\win32.py", line 25, in get_key
return ch.decode(sys.stdout.encoding)
TypeError: decode() argument 1 must be string, not None

I think this is related to UTF-8 encoding in python2...
I cannot add python3 to path, because my vim plugins will require python2
in the path...

Is there any way I can fix this?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#486

@scorphus
Copy link
Collaborator

Sorry for the delay.

@czhang03
Copy link
Author

Thanks hope this is pushed to pip as soon as possible.

@scorphus
Copy link
Collaborator

@chantisnake: No problem 😃 In the meantime you can update to master with pip install -U git+https://github.com/nvbn/thefuck.git.

@nvbn nvbn closed this as completed in #487 Mar 23, 2016
nvbn added a commit that referenced this issue Mar 23, 2016
#486: Use alternative encoding when sys.stdout.encoding is None
@nvbn
Copy link
Owner

nvbn commented Mar 23, 2016

@chantisnake already in pip =)

@czhang03
Copy link
Author

Thanks, I just got the fix, it is awesome, but there is still decoding error like

�[1mgit commit -am 'test'�[0m [�[32menter�[0m/�[34m↑�[0m/�[34m↓�[0m/�[31mctrl+c�[0m]

this... Is there a way to fix this?

@nvbn nvbn reopened this Mar 23, 2016
@scorphus
Copy link
Collaborator

I can hunt this one at some easy pace. Subshell execution for variable definition is probably messing color sequences.

In the meantime I've already setup a Windows build on AppVeyor and things are looking good.

BTW, @nvbn, what do you think of these fancy badges?

thefuck-badges

@nvbn
Copy link
Owner

nvbn commented Mar 25, 2016

@scorphus it woild be nice to have them.

scorphus added a commit to scorphus/thefuck that referenced this issue Mar 30, 2016
scorphus added a commit to scorphus/thefuck that referenced this issue Mar 30, 2016
scorphus added a commit to scorphus/thefuck that referenced this issue Mar 30, 2016
scorphus added a commit to scorphus/thefuck that referenced this issue Mar 30, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
nvbn#486: Use alternative encoding when sys.stdout.encoding is None
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
nvbn#486: Use alternative encoding when sys.stdout.encoding is None
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
amtrivedi91 added a commit to amtrivedi91/thefuck that referenced this issue Aug 31, 2016
@kondr1
Copy link

kondr1 commented Nov 22, 2016

I have problem like this. How fix it?

konstantin@pc MSYS /c/Users/konstantin
$ fuck
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\thefuck.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\thefuck\main.py", line 82, in main
    fix_command()
  File "c:\python27\lib\site-packages\thefuck\main.py", line 26, in fix_command
    command = types.Command.from_raw_script(sys.argv[1:])
  File "c:\python27\lib\site-packages\thefuck\types.py", line 124, in from_raw_script
    stderr = result.stderr.read().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 0xad in position 6: invalid start byte

@nvbn nvbn added the windows label Mar 14, 2017
@scorphus
Copy link
Collaborator

scorphus commented Aug 8, 2021

Please check #673 for hints/solutions.

@scorphus scorphus closed this as completed Aug 8, 2021
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
nvbn#486: Use alternative encoding when sys.stdout.encoding is None
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants