Unicode filenames

Terry Reedy tjreedy at udel.edu
Fri Dec 6 18:20:26 EST 2019


On 12/6/2019 1:17 PM, Bob van der Poel wrote:
> I have some files which came off the net with, I'm assuming, unicode
> characters in the names. I have a very short program which takes the
> filename and puts into an emacs buffer, and then lets me add information to
> that new file (it's a poor man's DB).
> 
> Next, I can look up text in the file and open the saved filename.
> Everything works great until I hit those darn unicode filenames.
> 
> Just to confuse me even more, the error seems to be coming from a bit of
> tkinter code:
>   if sresults.has_key(textAtCursor):
>          bookname = os.path.expanduser(sresults[textAtCursor].strip())

'textAtCursor' does not appear in any 3.9 tkinter/*.py file

> which generates
> 
>    UnicodeWarning: Unicode equal comparison failed to convert both arguments
> to Unicode - interpreting them as being unequal  if
> sresults.has_key(textAtCursor):
> 
> I really don't understand the business about "both arguments".

'sresults.has_key(textAtCursor)' will see if the hash value of 
textAtCursor matches the hash value of any key and then compare the 
strings.  'failed to convert' suggests to me that you are running 2.x 
and that one of the strings is bytes and the other unicode.


  Not sure how
> to proceed here. Hoping for a guideline!
> 
> Thanks.
> 
> 


-- 
Terry Jan Reedy



More information about the Python-list mailing list