From ea2249464d6957d3403201e72adabaa0c26c41fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Tue, 6 Dec 2016 18:43:34 +0000 Subject: Cope with bytestrings in utf8_bytes_string() helper. LP: #1647101 --- fastimport/helpers.py | 7 +++++-- 1 file 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') -- cgit v1.2.1