diff options
author | Marcel Hellkamp <marc@gsites.de> | 2012-05-14 16:26:37 +0200 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2012-05-14 16:27:43 +0200 |
commit | 85aa8c26235bc3415ed9d78571639d700703631d (patch) | |
tree | 63e1e58064787f6ac8f5191aa0316b1eebbf68bc | |
parent | fe21d79106d13aa349aaea3bd6e42573608af0d8 (diff) | |
download | bottle-85aa8c26235bc3415ed9d78571639d700703631d.tar.gz |
Fix: IOError with mod_wsgi
mod_wsgi restricts sys.stdin attribute access.
-rw-r--r-- | bottle.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -64,8 +64,13 @@ py25 = py < (2,6,0) # Workaround for the missing "as" keyword in py3k. def _e(): return sys.exc_info()[1] -# Workaround for the "print is a keyword/function" dilemma. -_stdout, _stderr = sys.stdout.write, sys.stderr.write +# Workaround for the "print is a keyword/function" Python 2/3 dilemma +# and a fallback for mod_wsgi (resticts stdout/err attribute access) +try: + _stdout, _stderr = sys.stdout.write, sys.stderr.write +except IOError: + _stdout = lambda x: sys.stdout.write(x) + _stderr = lambda x: sys.stderr.write(x) # Lots of stdlib and builtin differences. if py3k: |