diff options
Diffstat (limited to 'wsgitools')
-rw-r--r-- | wsgitools/digest.py | 7 | ||||
-rw-r--r-- | wsgitools/filters.py | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py index 4b7dd96..86de17e 100644 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -61,6 +61,7 @@ def parse_digest_response(data, ret=None): ... print("ValueError") ValueError """ + assert isinstance(data, str) if ret is None: ret = {} data = data.strip() @@ -100,6 +101,7 @@ class AbstractTokenGenerator: """ @type realm: str """ + assert isinstance(realm, str) self.realm = realm def __call__(self, username, algo="md5"): @@ -126,6 +128,8 @@ class AbstractTokenGenerator: @param environ: ignored @rtype: bool """ + assert isinstance(username, str) + assert isinstance(password, str) token = md5("%s:%s:%s" % (username, self.realm, password)).hexdigest() return token == self(username) @@ -147,6 +151,7 @@ class AuthTokenGenerator(AbstractTokenGenerator): self.getpass = getpass def __call__(self, username, algo="md5"): + assert isinstance(username, str) assert algo.lower() in ["md5", "md5-sess"] password = self.getpass(username) if password is None: @@ -180,6 +185,7 @@ class HtdigestTokenGenerator(AbstractTokenGenerator): @raises IOError: @raises ValueError: """ + assert isinstance(htdigestfile, str) self.users = {} for line in file(htdigestfile): parts = line.rstrip("\n").split(":") @@ -204,6 +210,7 @@ class UpdatingHtdigestTokenGenerator(HtdigestTokenGenerator): for changes on each invocation. """ def __init__(self, realm, htdigestfile, ignoreparseerrors=False): + assert isinstance(htdigestfile, str) try: self.statcache = os.stat(htdigestfile) except OSError, err: diff --git a/wsgitools/filters.py b/wsgitools/filters.py index 1c3fadc..e455cbe 100644 --- a/wsgitools/filters.py +++ b/wsgitools/filters.py @@ -238,6 +238,7 @@ class RequestLogWSGIFilter(BaseWSGIFilter): """ BaseWSGIFilter.__init__(self) assert hasattr(log, "write") + assert hasattr(log, "flush") or not flush self.log = log self.flush = flush self.remote = "?" @@ -279,6 +280,7 @@ class RequestLogWSGIFilter(BaseWSGIFilter): @type data: str @rtype: str """ + assert isinstance(data, str) self.length += len(data) return data def handle_close(self): |