py3: use unicode literals for casting strings

Since unicode_type cannot be used in dynamically updated code, cast to
the same type as type('') -- which we know will be unicode because of
unicode_literals.
This commit is contained in:
Eli Schwartz 2019-06-20 22:43:33 -04:00
parent 7c89277408
commit 0048c43a9e
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
3 changed files with 4 additions and 4 deletions

View File

@ -351,7 +351,7 @@ class Worker(Thread): # Get details {{{
if self.testing:
import tempfile
import uuid
with tempfile.NamedTemporaryFile(prefix=(asin or str(uuid.uuid4())) + '_',
with tempfile.NamedTemporaryFile(prefix=(asin or type('')(uuid.uuid4())) + '_',
suffix='.html', delete=False) as f:
f.write(raw)
print('Downloaded html for', asin, 'saved in', f.name)

View File

@ -139,7 +139,7 @@ def get_basic_data(browser, log, *skus):
'orderID': '0',
'mailingID': '',
'tContentWidth': '926',
'originalOrder': ','.join(str(i) for i in range(len(skus))),
'originalOrder': ','.join(type('')(i) for i in range(len(skus))),
'selectedOrderID': '0',
'selectedSortColumn': '0',
'listType': '1',
@ -255,7 +255,7 @@ class Edelweiss(Source):
return None
params = {
'q': (' '.join(keywords)).encode('utf-8'),
'_': str(int(time.time()))
'_': type('')(int(time.time()))
}
return BASE_URL+urlencode(params)

View File

@ -121,7 +121,7 @@ def to_metadata(browser, log, entry_, timeout): # {{{
# ISBN
isbns = []
for x in identifier(extra):
t = str(x.text).strip()
t = type('')(x.text).strip()
if t[:5].upper() in ('ISBN:', 'LCCN:', 'OCLC:'):
if t[:5].upper() == 'ISBN:':
t = check_isbn(t[5:])