Skip to content

Commit 042579d

Browse files
committed
Allow for automatic conversion of string like objects to CEF strings.
For example a QString passed to LoadUrl() method was causing error and now it's handled fine.
1 parent 30439b6 commit 042579d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/string_utils.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,17 @@ cdef void PyToCefString(
103103
CefString& cefString
104104
) except *:
105105
if PY_MAJOR_VERSION < 3:
106+
# Handle objects that may be converted to string e.g. QString
107+
if not isinstance(pyString, str) and not isinstance(pyString, unicode):
108+
pyString = str(pyString)
106109
if type(pyString) == unicode:
107110
pyString = <bytes>(pyString.encode(
108111
g_applicationSettings["string_encoding"],
109112
errors=UNICODE_ENCODE_ERRORS))
110113
else:
114+
# Handle objects that may be converted to string e.g. QString
115+
if not isinstance(pyString, str) and not isinstance(pyString, bytes):
116+
pyString = str(pyString)
111117
# The unicode type is not defined in Python 3.
112118
if type(pyString) == str:
113119
pyString = <bytes>(pyString.encode(

0 commit comments

Comments
 (0)