From ce377076b9ef74bee88a0d0574a51ba6f4cc6068 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 10 Sep 2018 16:04:47 +0530 Subject: [PATCH] Some py3 fixes for the setup module --- setup/__init__.py | 4 ++-- setup/translations.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/__init__.py b/setup/__init__.py index ccc353a936..ea8c658092 100644 --- a/setup/__init__.py +++ b/setup/__init__.py @@ -86,13 +86,13 @@ def require_clean_git(): def initialize_constants(): global __version__, __appname__, modules, functions, basenames, scripts - src = open(os.path.join(SRC, 'calibre/constants.py'), 'rb').read() + src = open(os.path.join(SRC, 'calibre/constants.py'), 'rb').read().decode('utf-8') nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src) __version__ = '%s.%s.%s'%(nv.group(1), nv.group(2), nv.group(3)) __appname__ = re.search(r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]', src).group(2) epsrc = re.compile(r'entry_points = (\{.*?\})', re.DOTALL).\ - search(open(os.path.join(SRC, 'calibre/linux.py'), 'rb').read()).group(1) + search(open(os.path.join(SRC, 'calibre/linux.py'), 'rb').read().decode('utf-8')).group(1) entry_points = eval(epsrc, {'__appname__': __appname__}) def e2b(ep): diff --git a/setup/translations.py b/setup/translations.py index bea99b2e8a..b356fef04d 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -657,7 +657,7 @@ class GetTranslations(Translations): # {{{ def check_for_control_chars(f): raw = open(f, 'rb').read().decode('utf-8') - pat = re.compile(ur'[\0-\x08\x0b\x0c\x0e-\x1f\x7f\x80-\x9f]') + pat = re.compile(type(u'')(r'[\0-\x08\x0b\x0c\x0e-\x1f\x7f\x80-\x9f]')) errs = [] for i, line in enumerate(raw.splitlines()): if pat.search(line) is not None: