summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2012-10-04 19:21:16 +0200
committerMarcel Hellkamp <marc@gsites.de>2012-10-04 19:21:16 +0200
commit96645e845b87d87cf3fc4c01b105ff4240c36108 (patch)
tree7296fa200c532eaa48a0432d1c6362a4306eaf04
parentc97c84a47826488a21d2f6fbf8716df914b0fa69 (diff)
downloadbottle-96645e845b87d87cf3fc4c01b105ff4240c36108.tar.gz
Fix #382 "Test failures with Python 3"
-rw-r--r--bottle.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bottle.py b/bottle.py
index f0c1c2a..dfda045 100644
--- a/bottle.py
+++ b/bottle.py
@@ -122,10 +122,11 @@ if py31:
class NCTextIOWrapper(TextIOWrapper):
def close(self): pass # Keep wrapped buffer open.
-# The truth-value of cgi.FieldStorage is misleading.
+# File uploads (which are implemented as empty FiledStorage instances...)
+# have a negative truth value. That makes no sense, here is a fix.
class FieldStorage(cgi.FieldStorage):
- def __nonzero__(self):
- return bool(self.list or self.file)
+ def __nonzero__(self): return bool(self.list or self.file)
+ if py3k: __bool__ = __nonzero__
# A bug in functools causes it to break if the wrapper is an instance method
def update_wrapper(wrapper, wrapped, *a, **ka):