summaryrefslogtreecommitdiff
path: root/fastimport/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'fastimport/helpers.py')
-rw-r--r--fastimport/helpers.py7
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')