py3: More unicode porting

This commit is contained in:
Kovid Goyal 2019-06-09 11:22:02 +05:30
parent 9316d8d673
commit ef42213ceb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
'''
Interface defining the necessary public functions for a pdb format reader.

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
@ -6,4 +8,3 @@ __docformat__ = 'restructuredtext en'
'''
Used for pdf output for comic2pdf
'''

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -69,7 +69,7 @@ def serialize(o, stream):
# Must check bool before int as bools are subclasses of int
stream.write_raw(b'true' if o else b'false')
elif isinstance(o, numbers.Integral):
stream.write_raw(str(o).encode('ascii') if ispy3 else bytes(o))
stream.write_raw(unicode_type(o).encode('ascii') if ispy3 else bytes(o))
elif hasattr(o, 'pdf_serialize'):
o.pdf_serialize(stream)
elif o is None:

View File

@ -419,7 +419,7 @@ class PDFWriter(QObject):
self.paged_js += P('viewer/hyphenate/Hyphenator.js', data=True).decode('utf-8')
hjs, self.hyphenate_lang = load_hyphenator_dicts({}, self.book_language)
self.paged_js += hjs
self.hf_uuid = str(uuid.uuid4()).replace('-', '')
self.hf_uuid = unicode_type(uuid.uuid4()).replace('-', '')
self.view.page().mainFrame().addToJavaScriptWindowObject("py_bridge", self)
self.view.page().longjs_counter = 0