1 """This module provides core functions for handling unicode and UNIX quirks
3 The @interruptable functions retry when system calls are interrupted,
4 e.g. when python raises an IOError or OSError with errno == EINTR.
7 from cola
.decorators
import interruptable
9 # Some files are not in UTF-8; some other aren't in any codification.
10 # Remember that GIT doesn't care about encodings (saves binary data)
16 # <-- add encodings here
20 """decode(encoded_string) returns an unencoded unicode string
22 for encoding
in _encoding_tests
:
24 return unicode(enc
.decode(encoding
))
27 # this shouldn't ever happen... FIXME
32 """encode(unencoded_string) returns a string encoded in utf-8
34 return unenc
.encode('utf-8', 'replace')
39 """Read from a filehandle and retry when interrupted"""
44 def write(fh
, content
):
45 """Write to a filehandle and retry when interrupted"""
46 return fh
.write(content
)
51 """Wait on a subprocess and retry when interrupted"""