Francisco Vila schreef op vr 18-03-2011 om 12:46 [+0100]:
> 2011/3/14 Graham Percival <[email protected]>:

>   File "/usr/local/bin/midi2ly", line 1047, in convert_midi
>     progress (_ ("%s output to `%s'...") % ('LY', out_file))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 4: ordinal not in range(128)
> 
> patch in 
> http://lists.gnu.org/archive/html/lilypond-devel/2011-03/msg00420.html
> from Jan is applied.

Interesting.  For me it works (see below).  I assume you did
make -C python?

Waitaminute.  Ah, I have a utf-8 locale.  You must set LANG=C
for it to break. see below below.  With new patch.

Jan.


16:11:00 janneke@vuurvlieg:~/vc/lilypond
$ PATH=~/vc/lilypond/out/bin:$PATH lilypond minué
GNU LilyPond 2.13.55
Verwerken van `minué.ly'
Ontleden...
minué.ly:0: waarschuwing:  geen \version uitdrukking gevonden, voeg

\version "2.13.55"

toe voor toekomstige compatibiliteit
Vertolken van muziek...
MIDI uitvoer naar minué.midi...
succes: Samenstellen met succes voltooid
16:11:18 janneke@vuurvlieg:~/vc/lilypond
$ PATH=~/vc/lilypond/out/bin:$PATH midi2ly minué
LY uitvoer naar `minué-midi.ly'...


=====

$ PATH=~/vc/lilypond/out/bin:$PATH LANG=c midi2ly minué
Traceback (most recent call last):
  File "/home/janneke/vc/lilypond/out/bin/midi2ly", line 1207, in
<module>
    main ()
  File "/home/janneke/vc/lilypond/out/bin/midi2ly", line 1204, in main
    convert_midi (f, o)
  File "/home/janneke/vc/lilypond/out/bin/midi2ly", line 1047, in
convert_midi
    progress (_ ("%s output to `%s'...") % ('LY', out_file))
  File "/home/janneke/vc/lilypond/out/bin/midi2ly", line 106, in
progress
    ly.encoded_write (errorport, s + '\n')
  File
"/home/janneke/vc/lilypond/out/lib/lilypond/current/python/lilylib.py",
line 57, in encoded_write
    f.write (s.encode (f.encoding or 'utf-8'))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 18: ordinal not in range(128)

-- 
Jan Nieuwenhuizen <[email protected]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  
>From e72b10e90e8fec6f19866f2165bc1f16179426f9 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <[email protected]>
Date: Thu, 17 Mar 2011 21:44:05 +0100
Subject: [PATCH] lilylib: handle encodings.  Fixes #1073 and u#714213.

---
 python/lilylib.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/python/lilylib.py b/python/lilylib.py
index 3bf77f6..6fb96bb 100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -47,13 +47,19 @@ underscore = _
 # Urg, Python 2.4 does not define stderr/stdout encoding
 # Maybe guess encoding from LANG/LC_ALL/LC_CTYPE?
 
+reload (sys)
+sys.setdefaultencoding ('utf-8')
+import codecs
+sys.stdout = codecs.getwriter ('utf8') (sys.stdout)
+sys.stderr = codecs.getwriter ('utf8') (sys.stderr)
+
 def encoded_write(f, s):
-    f.write (s.encode (f.encoding or 'utf_8'))
+    f.write (s.encode (f.encoding or 'utf-8', 'replace'))
 
 # ugh, Python 2.5 optparse requires Unicode strings in some argument
 # functions, and refuse them in some other places
 def display_encode (s):
-    return s.encode (sys.stderr.encoding or 'utf_8')
+    return s.encode (sys.stderr.encoding or 'utf-8', 'replace')
 
 # Lilylib globals.
 program_version = '@TOPLEVEL_VERSION@'
-- 
1.7.1

_______________________________________________
bug-lilypond mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to