-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Python 3's 2to3 does not handle non-ascii source files #52170
Comments
given the following Python 2 source file:
It can be converted to Python 3 using 2's 2to3 tool:
However that of Python 3.1.1 fails: classic$ 2to3-3.1 test.py
... omitted ...
--- test.py (original)
+++ test.py (refactored)
@@ -1,3 +1,3 @@
# -*- encoding: utf-8
Traceback (most recent call last):
File "/usr/local/bin/2to3-3.1", line 6, in <module>
sys.exit(main("lib2to3.fixes"))
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/main.py", line 159, in main
options.processes)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/refactor.py", line 616, in refactor
items, write, doctests_only)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/refactor.py", line 276, in refactor
self.refactor_file(dir_or_file, write, doctests_only)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/refactor.py", line 656, in refactor_file
*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/refactor.py", line 332, in refactor_file
write=write, encoding=encoding)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/refactor.py", line 432, in processed_file
self.print_output(old_text, new_text, filename, equal)
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib2to3/main.py", line 64, in print_output
print(line)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 17: ordinal not in range(128) |
Please try 2to3 from 2.7a3 or the 2to3 trunk. |
Sorry, I meant from the py3k branch. |
yes, its handled: WARNING: couldn't encode test.py's diff for your terminal is that fix specific to 2to3 or is that just how "print" works in 3.2 ? |
2010/2/12 mike bayer <report@bugs.python.org>:
It's just that whatever python guesses your terminal encoding is (try |
You can just use the --no-diffs option, btw, to avoid this problem on earlier versions. |
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: