Skip to content

Commit f69b05b

Browse files
committed
Some comments on the code in utils.pyx and string_utils.pyx.
And a comment about basestring usage.
1 parent ff0458a commit f69b05b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

cefpython/imports.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ import weakref
3131

3232
# We should allow multiple string types: str, unicode, bytes.
3333
# PyToCefString() can handle them all.
34+
# Important:
35+
# If you set it to basestring, Cython will accept exactly(!)
36+
# str/unicode in Py2 and str in Py3. This won't work in Py3
37+
# as we might want to pass bytes as well. Also it will
38+
# reject string subtypes, so using it in publi API functions
39+
# would be a bad idea.
3440
ctypedef object py_string
3541

3642
# You can't use "void" along with cpdef function returning None, it is planned to be

cefpython/string_utils.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
# License: New BSD License.
33
# Website: http://code.google.com/p/cefpython/
44

5-
# @TODO: make this configurable through ApplicationSettings.
5+
# TODO: cleanup the code in string_utils.pyx and string_utils_win.pyx,
6+
# see this topic for a review of the code in this file, see the
7+
# posts by Stefan Behnel:
8+
# https://groups.google.com/d/topic/cython-users/VICzhVn-zPw/discussion
9+
10+
# TODO: make this configurable through ApplicationSettings.
611
UNICODE_ENCODE_ERRORS = "replace"
712
BYTES_DECODE_ERRORS = "replace"
813

cefpython/utils.pyx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ cpdef py_bool IsString(object maybeString):
1717
cpdef py_bool IsThread(int threadID):
1818
return bool(CefCurrentlyOn(<CefThreadId>threadID))
1919

20+
# TODO: this function needs to accept unicode strings, use the
21+
# logic from wxpython.py/ExceptHook to handle printing
22+
# unicode strings and writing them to file (codecs.open).
23+
# This change is required to work with Cython 0.20.
24+
2025
cpdef object Debug(str msg):
2126
if not g_debug:
2227
return
@@ -29,7 +34,7 @@ cpdef object Debug(str msg):
2934
except:
3035
print("cefpython: WARNING: failed writing to debug file: %s" % (
3136
g_debugFile))
32-
37+
3338

3439
cpdef str GetSystemError():
3540
IF UNAME_SYSNAME == "Windows":
@@ -75,7 +80,7 @@ cpdef str GetModuleDirectory():
7580
else:
7681
path = os.getcwd()
7782
if platform.system() == "Windows":
78-
# On linux this regexp would give:
83+
# On linux this regexp would give:
7984
# "\/home\/czarek\/cefpython\/cefpython\/cef1\/linux\/binaries"
8085
path = re.sub(r"[/\\]+", re.escape(os.sep), path)
8186
path = re.sub(r"[/\\]+$", "", path)

0 commit comments

Comments
 (0)