Python 2 (only?): log-pane is unicode unfriendly

Bug #1276236 reported by Jake Peck
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
leo-editor
Fix Released
Wishlist
Edward K. Ream

Bug Description

When using python 2, it seems the log pane is unicode unfriendly. The following script demonstrates this:

g.es('é')

Log output:

exception executing script
  File "C:\Documents and Settings\PeckJ\.leo\scriptFile.py", line 12
SyntaxError: Non-ASCII character '\xc3' in file C:\Documents and Settings\PeckJ\.leo\scriptFile.py on line 12, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
--------------------
  line 11:
* line 12: g.es('��')
<...snip...>

Simple fix to stop the error, but not fix the log output:

@first # -*- coding: utf-8 -*-
g.es('é')

New log output:

��

That doesn't look like é to me.

I can fix this by setting 'console_encoding' to 'utf-8' in g.translateArgs (forcing unicode encoding), but this is an ugly fix.

Jake Peck (gatesphere)
Changed in leo-editor:
importance: Undecided → Low
Revision history for this message
Jake Peck (gatesphere) wrote :

As a side note: should Leo insert a '# -*- coding: utf-8 -*-' into scriptFile.py? I think it would be far more convenient for users if it did...

Revision history for this message
tbnorth (terry-n-brown) wrote : Re: [Bug 1276236] Re: Python 2 (only?): log-pane is unicode unfriendly

On Tue, 04 Feb 2014 16:57:59 -0000
Jake Peck <email address hidden> wrote:

> As a side note: should Leo insert a '# -*- coding: utf-8 -*-' into
> scriptFile.py? I think it would be far more convenient for users if it
> did...

+1

Revision history for this message
Edward K. Ream (edreamleo) wrote :

Strictly speaking, this bug is invalid. Inserting '# -*- coding: utf-8 -*-' causes the script to execute correctly.

However, the idea of inserting such a line automatically for all scripts is worthwhile, so I've "promoted" this item to a wish list.

The fix isn't entirely trivial: Leo should scan all the opening lines of a script before inserting the coding line.

Changed in leo-editor:
status: New → Invalid
assignee: nobody → Edward K. Ream (edreamleo)
status: Invalid → Confirmed
importance: Low → Wishlist
Changed in leo-editor:
status: Confirmed → Fix Released
Revision history for this message
Jake Peck (gatesphere) wrote :

Inserting that line doesn't change the fact that without setting
console_encoding to 'utf-8' in g.translateArgs, the log still does not
print unicode characters.

That is, even with # -*- coding: utf-8 -*- in the scripts, the log still
prints garbage for unicode characters. Only when console_encoding is
set to 'utf-8' does the log print unicode characters correctly.

-->Jake

On 2/9/2014 8:11 AM, Edward K. Ream wrote:
> Strictly speaking, this bug is invalid. Inserting '# -*- coding: utf-8
> -*-' causes the script to execute correctly.
>
> However, the idea of inserting such a line automatically for all scripts
> is worthwhile, so I've "promoted" this item to a wish list.
>
> The fix isn't entirely trivial: Leo should scan all the opening lines of
> a script before inserting the coding line.
>
> ** Changed in: leo-editor
> Status: New => Invalid
>
> ** Changed in: leo-editor
> Assignee: (unassigned) => Edward K. Ream (edreamleo)
>
> ** Changed in: leo-editor
> Status: Invalid => Confirmed
>
> ** Changed in: leo-editor
> Importance: Low => Wishlist
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.