Opened 8 years ago
Last modified 6 years ago
#12352 closed enhancement
Log a warning when interpreter optimization level is nonzero — at Version 5
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description
Documented in #8956 and recently raised in gmessage:trac-users:AQpVWTXVwsg/Rkey-2SHFQAJ, the header and footer are non displayed when Python interpreter optimizations are enabled.
The issue can be reproduced with TracStandalone using the PYTHONOPTIMIZE
environment variable.
$PYTHONOPTIMIZE=1 tracd -r -s -p 8000 proj-1.0
The optimization level can be retrieved at runtime, so we could log a warning, raise an error or display the optimization level in the System Information on the About Trac page.
$python -OO Python 2.7.11 (default, Dec 5 2015, 14:44:53) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.flags.optimize 2 $python Python 2.7.11 (default, Dec 5 2015, 14:44:53) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.flags.optimize 0
Change History (5)
comment:2 by , 8 years ago
Replying to Ryan J Ollos:
Another idea is to raise an exception in the
Environment
initializer.
I'm tending to favor this approach because I think the error message will be more clear.
comment:3 by , 8 years ago
Raising an EnvironmentError
sounds good. I consider we should check sys.flags.optimize
every time rather than first time. If checking only first time, it might be ignored. Also, it would be good to add the same check to run()
in trac/admin/console.py
.
comment:4 by , 8 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:5 by , 8 years ago
Release Notes: | modified (diff) |
---|
I'm unsure of the best location to do this check. Here is a proposed patch, which puts the check next to
warn_setuptools_issue
:trac/web/main.py
warn_setuptools = FalseThe
EnvironmentError
is used because it's also used here: tags/trac-1.0.10/trac/web/main.py@:486-490#L441. However, this results in an empty response.Another idea is to raise an exception in the
Environment
initializer.