From 485e375139c870941e2a7fc11c5ecc974be724a7 Mon Sep 17 00:00:00 2001 From: Lukasz Langa Date: Tue, 10 May 2011 19:16:03 +0200 Subject: [PATCH] Minor py3k compatibility changes: iteritems() doesn't exist on Python 3.x, logged text must be Unicode. --- radicale/__init__.py | 6 +++++- radicale/xmlutils.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index e446b6c..fcf6265 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -190,7 +190,11 @@ class Application(object): # Set content length if answer: - log.LOGGER.debug("Response content:\n%s" % answer) + # decoding the answer for logging purposes on Python 3 + log_answer = answer + if not isinstance(log_answer, str): + log_answer = log_answer.decode(config.get("encoding", "request")) + log.LOGGER.debug("Response content:\n%s" % log_answer) headers["Content-Length"] = "%i" % len(answer) # Start response diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 0efe37e..2806a32 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -38,7 +38,7 @@ NAMESPACES = { "CS": "http://calendarserver.org/ns/"} -for short, url in NAMESPACES.iteritems(): +for short, url in NAMESPACES.items(): ET._namespace_map[url] = short