@@ -98,18 +98,18 @@ def _UUID(self, v):
9898 self .stream .writelines ([b'<uuid>' , str (v ).encode ('utf-8' ), b'</uuid>' , self ._eol ])
9999 def _BINARY (self , v ):
100100 self .stream .writelines ([b'<binary>' , base64 .b64encode (v ).strip (), b'</binary>' , self ._eol ])
101- def _STRING (self , v ):
102- # We don't simply have a function that encapsulates the PY2 vs PY3 calls,
103- # as that results in another function call and is slightly less performant
104- if PY2 : # pragma: no cover
101+
102+ if PY2 :
103+ def _STRING (self , v ):
105104 return self .stream .writelines ([b'<string>' , _str_to_bytes (xml_esc (v )), b'</string>' , self ._eol ])
106- self .stream .writelines ([b'<string>' , v .translate (XML_ESC_TRANS ).encode ('utf-8' ), b'</string>' , self ._eol ])
107- def _URI (self , v ):
108- # We don't simply have a function that encapsulates the PY2 vs PY3 calls,
109- # as that results in another function call and is slightly less performant
110- if PY2 : # pragma: no cover
105+ def _URI (self , v ):
111106 return self .stream .writelines ([b'<uri>' , _str_to_bytes (xml_esc (v )), b'</uri>' , self ._eol ])
112- self .stream .writelines ([b'<uri>' , str (v ).translate (XML_ESC_TRANS ).encode ('utf-8' ), b'</uri>' , self ._eol ])
107+ else :
108+ def _STRING (self , v ):
109+ self .stream .writelines ([b'<string>' , v .translate (XML_ESC_TRANS ).encode ('utf-8' ), b'</string>' , self ._eol ])
110+ def _URI (self , v ):
111+ self .stream .writelines ([b'<uri>' , str (v ).translate (XML_ESC_TRANS ).encode ('utf-8' ), b'</uri>' , self ._eol ])
112+
113113 def _DATE (self , v ):
114114 self .stream .writelines ([b'<date>' , _format_datestr (v ), b'</date>' , self ._eol ])
115115 def _ARRAY (self , v ):
0 commit comments