diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-12-06 18:43:34 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-12-06 18:43:34 +0000 |
commit | ea2249464d6957d3403201e72adabaa0c26c41fa (patch) | |
tree | 02e9b55857bd7bb163cc9b4dc84eec00f9ed7545 /fastimport | |
parent | 2ebabf9b0f668722f9c50c411aa94f23c8fdedb5 (diff) | |
download | python-fastimport-git-ea2249464d6957d3403201e72adabaa0c26c41fa.tar.gz |
Cope with bytestrings in utf8_bytes_string() helper. LP: #1647101
Diffstat (limited to 'fastimport')
-rw-r--r-- | fastimport/helpers.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fastimport/helpers.py b/fastimport/helpers.py index c27c436..abb7014 100644 --- a/fastimport/helpers.py +++ b/fastimport/helpers.py @@ -99,9 +99,12 @@ def is_inside_any(dir_list, fname): def utf8_bytes_string(s): - """Convert a string to a bytes string encoded in utf8""" + """Convert a string to a bytes string (if necessary, encode in utf8)""" if sys.version_info[0] == 2: - return s.encode('utf8') + if isinstance(s, str): + return s + else: + return s.encode('utf8') else: if isinstance(s, str): return bytes(s, encoding='utf8') |