[pywin32-bugs] [ pywin32-Bugs-3564527 ] GetShortPathName() fails for 8.3 baltic file names
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2012-09-04 00:18:21
|
Bugs item #3564527, was opened at 2012-09-03 16:35 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3564527&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: win32 Group: None >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Pavel () Assigned to: Nobody/Anonymous (nobody) Summary: GetShortPathName() fails for 8.3 baltic file names Initial Comment: If a 8.3 file name containing at least one baltic character is given to GetShortPathName(), it fails with exception. It does not fails on long file names: Traceback (most recent call last): File "D:\workspace\investigations\audio-hash\invest\GetShortName-bug\bug.py", line 10, in <module> print win32api.GetShortPathName(file) File "C:\Python\27\lib\encodings\cp866.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character u'\xf5' in position 2: character maps to <undefined> õ2345678.txt <-- does fail õ23456789.txt <--- does not See a file attached. Python 2.7.3, Russian WIndows 7 32 bit, PyWin32 ver. 217 ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2012-09-03 17:18 Message: It appears the problem here is actually with "print" attempting to use the cp866 encoding when printing to your terminal. GetShortPathName returns the same type of object as its param (eg, if you pass a byte string, it returns a byte string) and this string is failing to print as it isn't encoded as cp866 (it will be encoded as MBCS). You can confirm this by changing your code to something like: x = win32api.GetShortPathName(file) print x you should then see clearly the exception is from the print, not from win32api. Probably the best solution is just to ensure "file" is a unicode object before passing it to win32api.GetShortPathName. Please reopen this bug and add further information if you believe this is not the case. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3564527&group_id=78018 |