  
  
  # xml.etree.parse only throws ParseError for python >= 2.7
  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()
 
</s> remove # xml.etree.parse only throws ParseError for python >= 2.7
 </s> add # XML is optional </s> remove from xml.etree import ElementTree as ET
from xml.parsers.expat import ExpatError
 </s> add  </s> remove from rest_framework.compat import yaml, ETParseError, ET_XMLParser
 </s> add from rest_framework.compat import yaml, etree </s> remove             tree = ET.parse(stream, parser=parser)
        except (ExpatError, ETParseError, ValueError) as exc:
 </s> add             tree = etree.parse(stream, parser=parser)
        except (etree.ParseError, ValueError) as exc:
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
  
  
  # xml.etree.parse only throws ParseError for python >= 2.7
  try:
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
    import defusedxml.ElementTree as etree
except ImportError:
    etree = None
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace
 defusedxml for security fix.

As per:
http://blog.python.org/2013/02/announcing-defusedxml-fixes-for-xml.html 
rest_framework/compat.py