diff --git a/cps/helper.py b/cps/helper.py index b4d2ceed..3430de97 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -245,9 +245,9 @@ def get_valid_filename(value, replace_whitespace=True): value=value.replace(u'ß',u'ss') value = unicodedata.normalize('NFKD', value) re_slugify = re.compile('[\W\s-]', re.UNICODE) - try: - value = str(re_slugify.sub('', value).strip()) - except UnicodeEncodeError as e: #will exception on Python2.7 + if type(value) is str: #Python3 str, Python2 unicode + value = re_slugify.sub('', value).strip() + else: value = unicode(re_slugify.sub('', value).strip()) if replace_whitespace: #*+:\"/<>? werden durch _ ersetzt diff --git a/cps/web.py b/cps/web.py index 560ddd67..fc3e81ad 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1052,8 +1052,10 @@ def stats(): stdin=subprocess.PIPE) p.wait() for lines in p.stdout.readlines(): - if re.search('Amazon kindlegen\(', str(lines)): - versions['KindlegenVersion'] = str(lines) + if type(lines) is bytes: + lines = lines.decode('utf-8') + if re.search('Amazon kindlegen\(', lines): + versions['KindlegenVersion'] = lines versions['PythonVersion'] = sys.version versions['babel'] = babelVersion versions['sqlalchemy'] = sqlalchemyVersion