Some py3 fixes for the setup module

This commit is contained in:
Kovid Goyal 2018-09-10 16:04:47 +05:30
parent d62d9dc2e6
commit ce377076b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -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):

View File

@ -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: