Re: Unicode error in sax parser

2011-02-09 Thread Rickard Lindberg
On Tue, Feb 8, 2011 at 5:41 PM, Chris Rebert wrote: > On Tue, Feb 8, 2011 at 7:57 AM, Rickard Lindberg wrote: >> Hi, >> >> Here is a bash script to reproduce my error: > > Including the error message and traceback is still helpful, for future > reference. > >>    #!/bin/sh >> >>    cat > å.timeli

Re: Unicode error in sax parser

2011-02-09 Thread Stefan Behnel
Rickard Lindberg, 09.02.2011 14:01: Did you read my reply? Sorry, it was me who failed to read your question properly. Unicode file names aren't really working well, especially not in Py2.x. Python 3.2 provides many improvements here. I assume your file system encoding is UTF-8? What does sys

Re: Unicode error in sax parser

2011-02-09 Thread Rickard Lindberg
>> Did you read my reply? > >Sorry, it was me who failed to read your question properly. > >Unicode file names aren't really working well, especially not in Py2.x. >Python 3.2 provides many improvements here. > >I assume your file system encoding is UTF-8? What does >sys.getfilesystemencoding() giv

Re: Unicode error in sax parser

2011-02-09 Thread Stefan Behnel
Stefan Behnel, 09.02.2011 09:58: Rickard Lindberg, 09.02.2011 09:32: On Tue, Feb 8, 2011 at 5:41 PM, Chris Rebert wrote: Here is a bash script to reproduce my error: Including the error message and traceback is still helpful, for future reference. Thanks for pointing it out. #!/bin/sh ca

Re: Unicode error in sax parser

2011-02-09 Thread Stefan Behnel
Rickard Lindberg, 09.02.2011 09:32: On Tue, Feb 8, 2011 at 5:41 PM, Chris Rebert wrote: Here is a bash script to reproduce my error: Including the error message and traceback is still helpful, for future reference. Thanks for pointing it out. #!/bin/sh cat> å.timeline< EOF

Re: Unicode error in sax parser

2011-02-09 Thread Rickard Lindberg
On Tue, Feb 8, 2011 at 5:41 PM, Chris Rebert wrote: >> Here is a bash script to reproduce my error: > > Including the error message and traceback is still helpful, for future > reference. Thanks for pointing it out. >>    #!/bin/sh >> >>    cat > å.timeline < >>    EOF >> >>    python <>    # e

Re: Unicode error in sax parser

2011-02-08 Thread Stefan Behnel
Rickard Lindberg, 08.02.2011 16:57: Hi, Here is a bash script to reproduce my error: #!/bin/sh cat> å.timeline< 0.13.0devb38ace0a572b+ 2011-02-01 00:00:00 2011-02-03 08:46:00 asdsd

Re: Unicode error in sax parser

2011-02-08 Thread Chris Rebert
On Tue, Feb 8, 2011 at 7:57 AM, Rickard Lindberg wrote: > Hi, > > Here is a bash script to reproduce my error: Including the error message and traceback is still helpful, for future reference. >    #!/bin/sh > >    cat > å.timeline < >    EOF > >    python <    # encoding: utf-8 >    from xml.sa

Re: Unicode error

2010-08-07 Thread kj
In <4c5d4ad9$0$28666$c3e8...@news.astraweb.com> Steven D'Aprano writes: >On Sat, 07 Aug 2010 19:28:56 +1200, Gregory Ewing wrote: >> Steven D'Aprano wrote: >>> "No memory? No disk space? No problem! Just a flesh wound!" What's >>> the point of that? >> >> +1 QOTW >While I'm always happy to

Re: Unicode error

2010-08-07 Thread Gregory Ewing
Steven D'Aprano wrote: "No memory? No disk space? No problem! Just a flesh wound!" What's the point of that? +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode error

2010-08-06 Thread Steven D'Aprano
On Fri, 06 Aug 2010 11:23:50 +, kj wrote: > I don't get your point. Even when I *know* that a certain exception may > happen, I don't necessarily catch it. I catch only those exceptions for > which I can think of a suitable response that is *different* from just > letting the program fail.

Re: Unicode error

2010-08-06 Thread kj
In Nobody writes: >On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: >> Don't write bare excepts, always catch the error you want and nothing >> else. >That advice would make more sense if it was possible to know which >exceptions could be raised. In practice, that isn't possible, a

Re: Unicode error

2010-08-04 Thread Aahz
In article , Nobody wrote: > >Java's checked exception mechanism was based on real-world experience of >the pitfalls of abstract types. And that experience was gained in >environments where interface specifications were far more detailed than is >the norm in the Python world. There are a number

Re: Unicode error

2010-07-25 Thread Nobody
On Sun, 25 Jul 2010 14:47:11 +, Steven D'Aprano wrote: >>> But in the >>> meanwhile, once you get an error, you know what it is. You can >>> intentionally feed code bad data and see what you get. And then maybe >>> add a test to make sure your code traps such errors. >> >> That doesn't really

Re: Unicode error

2010-07-25 Thread Steven D'Aprano
On Sun, 25 Jul 2010 13:52:33 +0100, Nobody wrote: > On Fri, 23 Jul 2010 18:27:50 -0400, Terry Reedy wrote: > >> But in the >> meanwhile, once you get an error, you know what it is. You can >> intentionally feed code bad data and see what you get. And then maybe >> add a test to make sure your cod

Re: Unicode error

2010-07-25 Thread Nobody
On Fri, 23 Jul 2010 18:27:50 -0400, Terry Reedy wrote: > But in the > meanwhile, once you get an error, you know what it is. You can > intentionally feed code bad data and see what you get. And then maybe > add a test to make sure your code traps such errors. That doesn't really help with exce

Re: Unicode error

2010-07-24 Thread John Machin
dirknbr gmail.com> writes: > I have kind of developped this but obviously it's not nice, any better > ideas? > > try: > text=texts[i] > text=text.encode('latin-1') > text=text.encode('utf-8') > except: > text=' ' As Steven has poin

Re: Unicode error

2010-07-23 Thread Steven D'Aprano
On Fri, 23 Jul 2010 22:46:46 +0100, Nobody wrote: > On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > >> Don't write bare excepts, always catch the error you want and nothing >> else. > > That advice would make more sense if it was possible to know which > exceptions could be raised.

Re: Unicode error

2010-07-23 Thread Terry Reedy
On 7/23/2010 5:46 PM, Nobody wrote: On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: Don't write bare excepts, always catch the error you want and nothing else. That advice would make more sense if it was possible to know which exceptions could be raised. In practice, that isn't pos

Re: Unicode error

2010-07-23 Thread Thomas Jollans
On 07/23/2010 11:46 PM, Nobody wrote: > On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > >> Don't write bare excepts, always catch the error you want and nothing >> else. > > That advice would make more sense if it was possible to know which > exceptions could be raised. In practice,

Re: Unicode error

2010-07-23 Thread Benjamin Kaplan
On Fri, Jul 23, 2010 at 2:46 PM, Nobody wrote: > On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > >> Don't write bare excepts, always catch the error you want and nothing >> else. > > That advice would make more sense if it was possible to know which > exceptions could be raised. In pr

Re: Unicode error

2010-07-23 Thread Nobody
On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > Don't write bare excepts, always catch the error you want and nothing > else. That advice would make more sense if it was possible to know which exceptions could be raised. In practice, that isn't possible, as the documentation seldom

Re: Unicode error

2010-07-23 Thread Thomas Jollans
On 07/23/2010 12:56 PM, dirknbr wrote: > To give a bit of context. I am using twython which is a wrapper for > the JSON API > > > search=twitter.searchTwitter(s,rpp=100,page=str(it),result_type='recent',lang='en') > for u in search[u'results']: > ids.append(u[u'id']) >

Re: Unicode error

2010-07-23 Thread dirknbr
To give a bit of context. I am using twython which is a wrapper for the JSON API search=twitter.searchTwitter(s,rpp=100,page=str(it),result_type='recent',lang='en') for u in search[u'results']: ids.append(u[u'id']) texts.append(u[u'text']) This is where texts com

Re: Unicode error

2010-07-23 Thread Chris Rebert
On Fri, Jul 23, 2010 at 3:14 AM, dirknbr wrote: > I am having some problems with unicode from json. > > This is the error I get > > UnicodeEncodeError: 'ascii' codec can't encode character u'\x93' in > position 61: ordinal not in range(128) Please include the full Traceback and the actual code th

Re: Unicode error

2010-07-23 Thread Steven D'Aprano
On Fri, 23 Jul 2010 03:14:11 -0700, dirknbr wrote: > I am having some problems with unicode from json. > > This is the error I get > > UnicodeEncodeError: 'ascii' codec can't encode character u'\x93' in > position 61: ordinal not in range(128) > > I have kind of developped this but obviously it

Re: Unicode error handler

2007-01-31 Thread Walter Dörwald
[EMAIL PROTECTED] wrote: > On Jan 30, 11:28 pm, Walter Dörwald <[EMAIL PROTECTED]> wrote: > >> codecs.register_error("transliterate", transliterate) >> >>Walter > > Really, really slick solution. > Though, why was it [:1], not [0]? ;-) No particular reason, unicodedata.normalize("NFD", ...)

Re: Unicode error handler

2007-01-31 Thread Walter Dörwald
Martin v. Löwis wrote: > Walter Dörwald schrieb: >> You might try the following: >> >> # -*- coding: iso-8859-1 -*- >> >> import unicodedata, codecs >> >> def transliterate(exc): >> if not isinstance(exc, UnicodeEncodeError): >> raise TypeError("don'ty know how to handle %r" % r)

Re: Unicode error handler

2007-01-31 Thread Gabriel Genellina
En Wed, 31 Jan 2007 01:21:49 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > I don't understand what %r and r are and where they are from. The man > 3 printf page doesn't have %r formatting. Perhaps you should look into the Python docs instead? -- Gabriel Genellina -- http://mail.p

Re: Unicode error handler

2007-01-30 Thread Martin v. Löwis
Walter Dörwald schrieb: > You might try the following: > > # -*- coding: iso-8859-1 -*- > > import unicodedata, codecs > > def transliterate(exc): > if not isinstance(exc, UnicodeEncodeError): > raise TypeError("don'ty know how to handle %r" % r) > return (unicodedata.n

Re: Unicode error handler

2007-01-30 Thread [EMAIL PROTECTED]
On Jan 30, 11:28 pm, Walter Dörwald <[EMAIL PROTECTED]> wrote: > > codecs.register_error("transliterate", transliterate) > >Walter Really, really slick solution. Though, why was it [:1], not [0]? ;-) And one more thing: > def transliterate(exc): > if not isinstance(exc, UnicodeEncode

Re: Unicode error handler

2007-01-30 Thread Walter Dörwald
Rares Vernica wrote: > Hi, > > Does anyone know of any Unicode encode/decode error handler that does a > better replace job than the default replace error handler? > > For example I have an iso-8859-1 string that has an 'e' with an accent > (you know, the French 'e's). When I use s.encode('asci

Re: Unicode error handler

2007-01-26 Thread Rares Vernica
It does the job. Thanks a lot, Ray Peter Otten wrote: > Rares Vernica wrote: > >> Is there an encode/decode error handler that can replace all the >> not-ascii letters from iso-8859-1 with their closest ascii letter? > > A mapping, not an error handler, but it might do the job: > > http://effb

Re: Unicode error handler

2007-01-26 Thread Robert Kern
Rares Vernica wrote: > Is there an encode/decode error handler that can replace all the > not-ascii letters from iso-8859-1 with their closest ascii letter? No, but IBM's ICU library can transform one script to another in very flexible and capable ways. One such configuration can do what you ask.

Re: Unicode error handler

2007-01-26 Thread Peter Otten
Rares Vernica wrote: > Is there an encode/decode error handler that can replace all the > not-ascii letters from iso-8859-1 with their closest ascii letter? A mapping, not an error handler, but it might do the job: http://effbot.org/zone/unicode-convert.htm Peter -- http://mail.python.org/mail

RE: Unicode Error

2006-08-23 Thread Tim Golden
[Gallagher, Tim (NE)] | Hey all I am learning Python and having a fun time doing so. | I have a question for y'all, it has to do with active directory. | I want to get the last login for a computer from Active | Directory. I am using the active_directory module and here | is my code. [START

Re: unicode error

2006-03-17 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > I have this python code: > print >> htmlFile, " style=\"width: 200px; height:18px;\">"; > > > But that caues this error, and I can't figure it out why. Any help is > appreicate > File "./run.py", line 193, in ? > print >> htmlFile, " style=\"width: 200px; height:18

Re: unicode error

2006-03-17 Thread jean-michel bain-cornu
[EMAIL PROTECTED] wrote: > I have this python code: > print >> htmlFile, " style=\"width: 200px; height:18px;\">"; > > > But that caues this error, and I can't figure it out why. Any help is > appreicate > File "./run.py", line 193, in ? > print >> htmlFile, " style=\"width: 200px; height:18

Re: Unicode error in wx_gdi ?

2005-03-04 Thread Serge Orlov
Erik Bethke wrote: > Hello All, > > I still shaking out my last few bugs in my tile matching game: > > I am now down to one stumper for me: > 1) when I initialize wxPython > 2) from an exe that I have created with py2exe > 3) when the executable is located on the desktop as opposed to > somewhe