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
(curses) addstr() takes str in Python 3 #50994
Comments
In Python 3, curses requires a str for addstr() where I think it should See the attached script "umlaut2x.py" for Python 2.6: Outputting The attached script "umlaut3x.py" is the same script translated to A quick test where I changed addstr() to take bytes instead of str |
First, make sure that your Python3 build uses libncursesw and not ldd $(./python -c "import _curses; print(curses.__file_)")|grep curses
Yes, addstr() always uses utf8 to convert unicode to bytes. It's wrong An idea would be to use a configurable charset. Eg. add a 'charset' |
See also issue bpo-4787 |
Yes, it uses a version of ncurses which supports wide characters, I I agree that using bytes instead may not be the preferred solution in |
I don't really understand because your example, umlaut3x.py, works
So the problem is that the charset is hardcoded to utf8. You would like |
Of course it works for you. As you stated in issue bpo-4787, your locale And I don't want Python to guess my terminal's encoding. I want Python |
Here is a first patch to add a method setcharset() to the window class. Using my patch, you can fix your example by adding the line: screen.setcharset(<your charset>) before addstr(). It's an initial hack to fix the issue. Next steps are:
|
We'll try to solve this for 3.2. |
Note that getkey() is broken, too. I attached a simple script to demonstrate that. If you run it and enter some non-ascii input, you can see that getkey() returns an utf-8 encoded str (in my utf-8 environment at least, I haven't check if it's always utf-8 or if it depends on the locale). |
I created issue bpo-12567 to fix the Unicode support of the curses module in Python 3. |
The issue bpo-12567 fixed this one:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: