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

Playback fails when file includes non-ASCII characters #5

Open
jeremy-w opened this issue Sep 10, 2015 · 7 comments
Open

Playback fails when file includes non-ASCII characters #5

jeremy-w opened this issue Sep 10, 2015 · 7 comments

Comments

@jeremy-w
Copy link

I have a file whose default template-generated content includes the copyright circle-c symbol, u'\xa9'.

Attempting to run git playback file leads to an exception:

Traceback (most recent call last):
  File "/usr/local/bin/git-playback", line 11, in <module>
    sys.exit(playback())
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 145, in playback
    curses.wrapper(function)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 136, in function
    display_line(window, row, line, color)
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 37, in display_line
    display_row, display_column * col_width, line[:col_width], color)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 16: ordinal not in range(128)
@jianli
Copy link
Owner

jianli commented Nov 6, 2015

I tried adding © to a file and wasn't able to trigger an exception. What do you get when you run git-playback on this file?

@jeremy-w
Copy link
Author

jeremy-w commented Nov 8, 2015

Same problem. Is this intended to be used with Python 2.x or only Python 3+? I wonder if that might be the root of the issue. (OS X still ships 2.7.x as system Python.)

Shell transcript for reference:

~/Github> git clone jianli/git-playback                                                                                                     [1]
Cloning into 'git-playback'...
remote: Counting objects: 147, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 147 (delta 0), reused 0 (delta 0), pack-reused 140
Receiving objects: 100% (147/147), 2.73 MiB | 406.00 KiB/s, done.
Resolving deltas: 100% (50/50), done.
Checking connectivity... done.
~/Github> cd git-playback/
~/G/git-playback (master|√)> git checkout test-copyright-symbol
Branch test-copyright-symbol set up to track remote branch test-copyright-symbol from origin.
Switched to a new branch 'test-copyright-symbol'
~/G/git-playback (test-copyright-symbol|√)> ls
README.md     animation.gif playback      setup.py
~/G/git-playback (test-copyright-symbol|√)> git-playback README.md
Traceback (most recent call last):
  File "/usr/local/bin/git-playback", line 11, in <module>
    sys.exit(playback())
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 145, in playback
    curses.wrapper(function)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 136, in function
    display_line(window, row, line, color)
  File "/usr/local/lib/python2.7/site-packages/playback/__init__.py", line 37, in display_line
    display_row, display_column * col_width, line[:col_width], color)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-31: ordinal not in range(128)
~/G/git-playback (test-copyright-symbol|√)> pip show git-playback
---
Metadata-Version: 2.0
Name: git-playback
Version: 0.2
Summary: A git command to play back file history.
Home-page: https://github.com/jianli/git-playback
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /usr/local/lib/python2.7/site-packages
Requires: gitpython
You are using pip version 1.4.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
~/G/git-playback (test-copyright-symbol|√)> python --version
Python 2.7.10

@jeremy-w
Copy link
Author

jeremy-w commented Nov 8, 2015

Yup, looks like I 2 vs 3 issue. I used pyenv global 3.5.0 then pyenv rehash and git-playback README.md worked fine after.

Does pip allow to set a minimum Python version requirement?

@jeremy-w
Copy link
Author

jeremy-w commented Nov 8, 2015

@jianli
Copy link
Owner

jianli commented Nov 9, 2015

Is this intended to be used with Python 2.x or only Python 3+? I wonder if that might be the root of the issue.

Actually I've been running 2.7.10 within Terminal.app on OS X this whole time. And curses is at 2.2 in case that's not determined by the Python version. Does the following work using 2.7?

# -*- coding: utf-8 -*-
import curses
import time


def function(window):
    window.addstr(0, 0, '©')
    window.refresh()
    time.sleep(10)

curses.wrapper(function)

@jeremy-w
Copy link
Author

Weird: That worked fine with 2.7.10.

@inakiabt
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants