Submitter | Gregory Szorc |
---|---|
Date | April 1, 2017, 7:29 a.m. |
Message ID | <f8b9edde1bf2a725d521.1491031745@ubuntu-vm-main> |
Download | mbox | patch |
Permalink | /patch/19887/ |
State | Accepted |
Headers | show |
Comments
Patch
diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -160,9 +160,9 @@ def staticfile(directory, fname, req): try: os.stat(path) ct = mimetypes.guess_type(path)[0] or "text/plain" - fp = open(path, 'rb') - data = fp.read() - fp.close() + with open(path, 'rb') as fh: + data = fh.read() + req.respond(HTTP_OK, ct, body=data) except TypeError: raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')