# HG changeset patch # User Aurelien Campeas # Date 1334139513 -7200 # Node ID 7f356ba4181c280fbc6ea900b85b0c2d50b9f53a # Parent 8b16593abd859f8e65d4be952a7c20191b0612f7 [web/views/staticcontrollers] restore windows compat diff -r 8b16593abd85 -r 7f356ba4181c web/views/staticcontrollers.py --- a/web/views/staticcontrollers.py Tue Apr 10 21:52:23 2012 +0200 +++ b/web/views/staticcontrollers.py Wed Apr 11 12:18:33 2012 +0200 @@ -82,7 +82,8 @@ # XXX elif uri.startswith('/https/'): uri = uri[6:] mimetype, encoding = mimetypes.guess_type(path) self._cw.set_content_type(mimetype, osp.basename(path), encoding) - return file(path).read() + with open(path, 'rb') as resource: + return resource.read() @property def relpath(self): @@ -152,8 +153,9 @@ if self.config.debugmode: raise NotFound(path) else: - for line in open(osp.join(dirpath, rid)): - f.write(line) + with open(osp.join(dirpath, rid), 'rb') as source: + for line in source: + f.write(line) f.write('\n') return filepath