Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 1st, 2003, 10:44 AM
krumms krumms is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Brisbane, Australia
Posts: 12 krumms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Python, wxPython and Unicode errors

Hi there,

I'm implementing a recursive file search in Python (in Windows XP, latest versions of wxPython and Python) and have come across a particularly frustrating Unicode exception in a completely unexpected place ...

File "....\search\Search.py", line 312, in __search_directory_recurse
results.extend( self.__search_directory_recurse( full_path, pattern, re_mode, flags ) )
File ".....\search\Search.py", line 304, in __search_directory_recurse
for fname in outfiles:
UnicodeError: ASCII decoding error: ordinal not in range(128)

How can a for loop cause a UnicodeError?

Also, I get the exact same error (same type, different location) if I try to print messages to standard output at too great a rate (from within a for loop, presumably because wxPython catches output in the special stdout window, and I'm guessing that the toes of GUI threads are getting trampled - but a UnicodeError??).

If anyone could offer some insight as to what would cause the former error to occur, please let me know.

Thanks!

Reply With Quote
  #2  
Old July 6th, 2003, 05:08 AM
krumms krumms is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Brisbane, Australia
Posts: 12 krumms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem fixed with a bit of a hack:

The problem, as the error indicated, was with the following line

for fname in outfiles:

I replaced it with a while loop, using an integer index into outfiles, and the error disappeared.

Still not sure what was going on.

- Tom

Reply With Quote
  #3  
Old July 22nd, 2003, 07:49 AM
Zoso's Avatar
Zoso Zoso is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: France
Posts: 53 Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 47 m 5 sec
Reputation Power: 13
I don't think the Unicode error doesn't come from the loop you use but from your fname variable. This is typically the kind of error you get when you create a string variable that contain an invalid character (for example a letter with an accent).

To solve this problem, you'll certainly have to use the unicode() function. But I don't know much more...

I suggest you print all the filenames that you treat and try to see which filename causes the Unicode exception. It surely contains an invalid ascii character.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Python, wxPython and Unicode errors

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap