Your message dated Sat, 9 Dec 2006 13:20:34 -0500 with message-id <[EMAIL PROTECTED]> and subject line python2.3-htmlgen: can not specify encoding? has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what I am talking about this indicates a serious mail system misconfiguration somewhere. Please contact me immediately.) Debian bug tracking system administrator (administrator, Debian Bugs database)
--- Begin Message ---Package: python2.3-htmlgen Version: 2.2.2-10 Severity: normal htmlgen raise an exception with utf-8 is used. Note: unicode can easily be used in python.: 1/ in second line of script file # -*- coding: utf-8 -*- 2/ import codecs 3/ assumig you want to read a file in utf-8 or latin1, or ascii: try: f = codecs.open(filename, "r", 'utf-8') content = f.read() except: try: f = codecs.open(filename, "r", 'latin1') content = f.read() except: f = codecs.open(filename, "r", 'ascii') content = f.read() f.close() here after the exception raised by the bug. [EMAIL PROTECTED]:/home/gay/Prestations/2006/....../....._26$ ~/cvs_localdirectory/browser/ptu/ptu_parser.py ./......._B_3_1/..._..._...._........__2.ptu > /dev/null Traceback (most recent call last): File "/home/users/gay/cvs_localdirectory/browser/ptu/ptu_parser.py", line 122, in ? main() File "/home/users/gay/cvs_localdirectory/browser/ptu/ptu_parser.py", line 119, in main a(content) File "/home/users/gay/cvs_localdirectory/browser/ptu/ptu_parser.py", line 88, in a doc.write ('toto.html') File "/usr/lib/python2.3/site-packages/HTMLgen/HTMLgen.py", line 188, in write f.write(str(self)) File "/usr/lib/python2.3/site-packages/HTMLgen/HTMLgen.py", line 406, in __str__ s.append((bodystring % tuple(self.contents))) File "/usr/lib/python2.3/site-packages/HTMLgen/HTMLgen.py", line 1835, in __str__ s.append(str(item)) File "/usr/lib/python2.3/site-packages/HTMLgen/HTMLgen.py", line 1835, in __str__ s.append(str(item)) File "/usr/lib/python2.3/site-packages/HTMLgen/HTMLgen.py", line 1835, in __str__ s.append(str(item)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 2: ordinal not in range(128) -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.12-1-686 Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15) Versions of packages python2.3-htmlgen depends on: ii python2.3 2.3.5-8 An interactive high-level object-o Versions of packages python2.3-htmlgen recommends: pn python2.3-imaging <none> (no description available) -- no debconf information
--- End Message ---
--- Begin Message ---Package: python2.3-htmlgen Version: 2.2.2-10 Severity: normal I cannot trace this problem as being directly related to python-htmlgen. I tested it with the following script: -------------------------------------- #!/usr/bin/env python # -*- coding: utf-8 -*- import codecs, os, HTMLgen filename = '/home/kevin/tmp/pt.po' try: f = codecs.open(filename, "r", 'utf-8') content = f.read() except: try: f = codecs.open(filename, "r", 'latin1') content = f.read() except: f = codecs.open(filename, "r", 'ascii') content = f.read() f.close() content = content.encode("utf-8") doc = HTMLgen.SimpleDocument(title="bug") doc.append(HTMLgen.Paragraph(content)) print doc -------------------------------------- My script is essentially the same as the bug submitter's with the exception of this line: content = content.encode("utf-8") This line stores the UTF-8 representation of 'content' in a byte string, which can then be passed on to HTMLgen without generating an error. Hope this helps. Closing this bug. -- Kevin Coyner GnuPG key: 1024D/8CE11941
signature.asc
Description: Digital signature
--- End Message ---

