|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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! |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Python, wxPython and Unicode errors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|