Issue8924
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010-06-06 19:01 by PeterL, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (5) | |||
---|---|---|---|
msg107208 - (view) | Author: Peter Landgren (PeterL) | Date: 2010-06-06 19:01 | |
This is in Windows. I got an error message in Logging in my application Gramps. However, there is an error message generated by by this logging, so the original message is never output. The last line indicate a problem with bytes in certain positions. I was able to check it and it is the Swedish character "å". The logging call is: ... except (IOError, OSError), msg: msg = unicode(str(msg), sys.getfilesystemencoding()) LOG.error(_("Could not make database directory: ") + msg) which results in: 3165: ERROR: clidbman.py: line 335: Kunde inte skapa databasmappen: [Error 3] Det gÃ¥r inte att hitta sökväge n: u'F:\\' Traceback (most recent call last): File "C:\Python26\lib\logging\__init__.py", line 769, in emit msg = self.format(record) File "C:\Python26\lib\logging\__init__.py", line 649, in format return fmt.format(record) File "C:\Python26\lib\logging\__init__.py", line 448, in format s = s + record.exc_text UnicodeDecodeError: 'utf8' codec can't decode bytes in position 608-610: invalid data 4893: ERROR: gramps.py: line 138: Unhandled exception Traceback (most recent call last): File "C:\Program Files (x86)\gramps\gui\grampsgui.py", line 353, in __startgramps "Error details: %s %s" % (repr(e), fn), exc_info=True) File "C:\Python26\lib\logging\__init__.py", line 1075, in error self._log(ERROR, msg, args, **kwargs) File "C:\Python26\lib\logging\__init__.py", line 1166, in _log self.handle(record) File "C:\Python26\lib\logging\__init__.py", line 1176, in handle self.callHandlers(record) File "C:\Python26\lib\logging\__init__.py", line 1213, in callHandlers hdlr.handle(record) File "C:\Python26\lib\logging\__init__.py", line 674, in handle self.emit(record) File "C:\Program Files (x86)\gramps\GrampsLogger\_GtkHandler.py", line 26, in emit ErrorView(error_detail=self,rotate_handler=self._rotate_handler) File "C:\Program Files (x86)\gramps\GrampsLogger\_ErrorView.py", line 39, in __init__ self.draw_window() File "C:\Program Files (x86)\gramps\GrampsLogger\_ErrorView.py", line 94, in draw_window tb_label.get_buffer().set_text(self._error_detail.get_formatted_log()) File "C:\Program Files (x86)\gramps\GrampsLogger\_GtkHandler.py", line 29, in get_formatted_log return self.format(self._record) File "C:\Python26\lib\logging\__init__.py", line 649, in format return fmt.format(record) File "C:\Python26\lib\logging\__init__.py", line 448, in format s = s + record.exc_text UnicodeDecodeError: 'utf8' codec can't decode bytes in position 608-610: invalid data If I change line 448 in "C:\Python26\lib\logging\__init__.py" to: s = s + unicode(str(record.exc_text), sys.getfilesystemencoding()) I get the correct message: 4523: ERROR: grampsgui.py: line 353: Gramps terminated because of OS Error Error details: WindowsError(3, 'Det g\xe5r inte att hitta s\xf6kv\xe4gen') F:\grdbtest\*.* Traceback (most recent call last): File "C:\Program Files (x86)\gramps\gui\grampsgui.py", line 337, in __startgramps Gramps(argparser) File "C:\Program Files (x86)\gramps\gui\grampsgui.py", line 268, in __init__ gui=True) File "C:\Program Files (x86)\gramps\cli\arghandler.py", line 81, in __init__ self.dbman = CLIDbManager(self.dbstate) File "C:\Program Files (x86)\gramps\cli\clidbman.py", line 100, in __init__ self._populate_cli() File "C:\Program Files (x86)\gramps\cli\clidbman.py", line 175, in _populate_cli for dpath in os.listdir(dbdir): WindowsError: [Error 3] Det gÃ¥r inte att hitta sökvägen: u'F:\\grdbtest\\*.*' (There is a secondary problem with rendering some characers. All strings were generated on a Windows system, but I report using a Linux system.) |
|||
msg107471 - (view) | Author: Vinay Sajip (vinay.sajip) * | Date: 2010-06-10 19:29 | |
It seems like the logging message will be Unicode (as you have specified that it should be so) but the exception message will be string. Can you confirm whether this is the case? What type is the return value of Formatter.formatException for the specific exception you're getting, in your exact environment? If it's not Unicode, can you see what happens if you use a subclassed Formatter whose formatException decodes the returned value from the base class formatException with the appropriate encoding, and return Unicode from your overridden formatException message? |
|||
msg107534 - (view) | Author: Peter Landgren (PeterL) | Date: 2010-06-11 08:22 | |
Answer to your first question: - The variable s is of type 'unicode' - The variable record.exc_text, which is what Formatter.formatException returns, is of type 'str' For your second question; I'm not a python expert, so I can't follow you there. I don't know what to do to test this. |
|||
msg107598 - (view) | Author: Vinay Sajip (vinay.sajip) * | Date: 2010-06-11 22:57 | |
Fix checked into trunk and release26-maint. |
|||
msg107601 - (view) | Author: Éric Araujo (eric.araujo) * | Date: 2010-06-11 23:00 | |
Suggestion: To help people involved in the discussion or landing here from a Web search, you can write “fixed in rNNN” to make Roundup produce a link link this one: r81919 Thanks! |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:01 | admin | set | github: 53170 |
2010-06-11 23:00:49 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg107601 stage: resolved |
2010-06-11 22:57:43 | vinay.sajip | set | status: open -> closed resolution: fixed messages: + msg107598 |
2010-06-11 08:22:50 | PeterL | set | messages: + msg107534 |
2010-06-10 19:30:00 | vinay.sajip | set | messages: + msg107471 |
2010-06-10 12:04:37 | vinay.sajip | set | assignee: vinay.sajip nosy: + vinay.sajip |
2010-06-06 19:01:50 | PeterL | create |