⇤ ← Revision 1 as of 2005-08-30 01:07:40
Size: 663
Comment:
|
Size: 664
Comment: Make the string containing the backslash a raw string.
|
Deletions are marked like this. | Additions are marked like this. |
Line 12: | Line 12: |
logging._srcfile = "logging\__init__.pyo" | logging._srcfile = r"logging\__init__.pyo" |
logging module and %(filename)s
When using the logging module, the %(filename)s format option doesn't work. It always ends up in the output as "_ _init_ _.pyo".
The problem is that the module uses source file names to determine when it has walked back on the stack to the caller. In the py2exe environment, this (fragile) logic breaks. The following code will workaround the problem.
Example
import sys if hasattr(sys, "frozen"): import logging logging._srcfile = r"logging\__init__.pyo"
Note, this is in a Windows environment. The '\' should probably be replaced with a '/' for a Unix environment.