From 7dc4bce4e2d8bd21ba383ae1d62fdacf4998742e Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 4 Feb 2013 21:35:47 +0000 Subject: Fix 2.6 compat --- rest_framework/compat.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'rest_framework/compat.py') diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 8c64d951..0d512342 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -426,3 +426,12 @@ try: from xml.etree import ParseError as ETParseError except ImportError: # python < 2.7 ETParseError = None + + +# XMLParser only takes an encoding arg from >= 2.7 +def ET_XMLParser(encoding=None): + from xml.etree import ElementTree as ET + try: + return ET.XMLParser(encoding=encoding) + except TypeError: + return ET.XMLParser() -- cgit v1.2.3