14885: Reverts back to parse_datetime_as_naive
[arvados.git] / sdk / python / arvados / _normalize_stream.py
index a119da2387a2620e886ce6325aebab76c5fcddbf..b579d41ed2839b73fa72c6486101abe97e46a0cc 100644 (file)
@@ -8,11 +8,8 @@ from . import config
 import re
 
 def escape(path):
-    # Escape literal backslash
     path = re.sub('\\\\', lambda m: '\\134', path)
-    # Escape other special chars. Py3's oct() output differs from Py2, this takes
-    # care of those differences.
-    path = re.sub('([\t\n\r: ])', lambda m: '\\'+oct(ord(m.group(1))).replace('o', '')[-3:], path)
+    path = re.sub('[:\000-\040]', lambda m: "\\%03o" % ord(m.group(0)), path)
     return path
 
 def normalize_stream(stream_name, stream):