aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2013-02-04 21:35:47 +0000
committerTom Christie2013-02-04 21:35:47 +0000
commit7dc4bce4e2d8bd21ba383ae1d62fdacf4998742e (patch)
tree7544827416d24edba3441c6227122b97746355e6 /rest_framework/compat.py
parent937ef008081fb20907494eb888e7374a8eb51a4f (diff)
downloaddjango-rest-framework-7dc4bce4e2d8bd21ba383ae1d62fdacf4998742e.tar.bz2
Fix 2.6 compat
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py9
1 files changed, 9 insertions, 0 deletions
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()