> On Sat, Mar 27, 2010 at 06:48:00PM +0100, Andreas Röhler wrote:
>>> My python-shell invoked via C-c C-c from python buffer can not print unicode characters (emits
>>> UnicodeEncodeError) and sys.stdout.encoding is empty. System wide LANG set to "ru_RU.UTF-8" and
>>> os.environ.get('LANG') in python shell confirms this.
>>> When python-shell invoked manually (M-x python-shell) there is no encoding issues. Any ideas?
>> What you get from
>> C-h v buffer-file-coding-system?
> buffer-file-coding-system is a variable defined in `C source code'.
> Its value is utf-8-unix
> Local in buffer test1.py; global value is utf-8-unix
> It does not apply to sending output to subprocesses, however.
> Python module contains encoding specification # -*- coding: utf-8 -*- at the beginning.
> Emacs version is 23.1.
Hmm, see inside `python-send-region'
;; Fixme: Write a `coding' header to the temp file if the region is
Maybe that indicates the cause?
You could try `py-execute-file' from python-mode.el
> On Sun, Mar 28, 2010 at 09:25:02AM +0200, Andreas Röhler wrote:
>> Hmm, see inside `python-send-region'
>> ;; Fixme: Write a `coding' header to the temp file if the region is
>> ;; non-ASCII.
>> Maybe that indicates the cause?
> I think this is unrelated to the issue because my python code contains no
> unicode characters; they are received from parsed web page and then printed
> to stdout. The problem is with python process spawned by Emacs - its stdout
> encoding is not specified (sys.stdout.encoding is None).
> Maybe this is a python feature: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=415968 >
> But then I do not understand why manually invoked pyton-shell handles unicode
> characters just fine...
Looks like your problem is rather on the python than the emacs side.
If I change the function in the bugreport given above into
# print s.decode('utf-8')
redirecting into FILE with > works
>> You could try `py-execute-file' from python-mode.el
> Sorry, didn't mentioned that I use python.el shipped with emacs. How to disable
> built-in one and enable python-mode.el?
> 3. Close python shell (opened at step 1) and invoke py-execute-buffer again:
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 0: ordinal not in range(128)
> Is this really a python problem? I think there is a difference in how Emacs spawns python
> process in each case.
Hmm, yes, get the same error.
However, if I re-start ipython-shell parallel