From 68e1e9dfb29ae6297799a95427019c031a0146e1 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 2 Sep 2016 11:04:29 +0200 Subject: [PATCH] Don't use mutables in constants or parameters --- radicale/__init__.py | 45 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index b1f2d97..346b08b 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -50,23 +50,30 @@ from . import auth, rights, storage, xmlutils VERSION = "2.0.0rc0" -NOT_ALLOWED = (client.FORBIDDEN, {"Content-type": "text/plain"}, - "Access to the requested resource forbidden.") -NOT_FOUND = (client.NOT_FOUND, {"Content-type": "text/plain"}, - "The requested resource could not be found.") -WEBDAV_PRECONDITION_FAILED = (client.CONFLICT, {"Content-type": "text/plain"}, - "WebDAV precondition failed.") -PRECONDITION_FAILED = (client.PRECONDITION_FAILED, - {"Content-type": "text/plain"}, "Precondition failed.") -REQUEST_TIMEOUT = (client.REQUEST_TIMEOUT, {"Content-type": "text/plain"}, - "Connection timed out.") -REQUEST_ENTITY_TOO_LARGE = (client.REQUEST_ENTITY_TOO_LARGE, - {"Content-type": "text/plain"}, - "Request body too large.") -REMOTE_DESTINATION = (client.BAD_GATEWAY, {"Content-type": "text/plain"}, - "Remote destination not supported.") -DIRECTORY_LISTING = (client.FORBIDDEN, {"Content-type": "text/plain"}, - "Directory listings are not supported.") +NOT_ALLOWED = ( + client.FORBIDDEN, (("Content-type", "text/plain"),), + "Access to the requested resource forbidden.") +NOT_FOUND = ( + client.NOT_FOUND, (("Content-type", "text/plain"),), + "The requested resource could not be found.") +WEBDAV_PRECONDITION_FAILED = ( + client.CONFLICT, (("Content-type", "text/plain"),), + "WebDAV precondition failed.") +PRECONDITION_FAILED = ( + client.PRECONDITION_FAILED, + (("Content-type", "text/plain"),), "Precondition failed.") +REQUEST_TIMEOUT = ( + client.REQUEST_TIMEOUT, (("Content-type", "text/plain"),), + "Connection timed out.") +REQUEST_ENTITY_TOO_LARGE = ( + client.REQUEST_ENTITY_TOO_LARGE, (("Content-type", "text/plain"),), + "Request body too large.") +REMOTE_DESTINATION = ( + client.BAD_GATEWAY, (("Content-type", "text/plain"),), + "Remote destination not supported.") +DIRECTORY_LISTING = ( + client.FORBIDDEN, (("Content-type", "text/plain"),), + "Directory listings are not supported.") DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol" @@ -264,8 +271,8 @@ class Application: def __call__(self, environ, start_response): """Manage a request.""" - def response(status, headers={}, answer=None): - headers = headers.copy() + def response(status, headers=(()), answer=None): + headers = dict(headers) # Set content length if answer: self.logger.debug("Response content:\n%s", answer)