Add comments to point out the trouble areas in the string conv

functions.
This commit is contained in:
Kai Huuhko 2013-03-24 18:34:19 +00:00
parent 8c071bedf8
commit 095f7fd867
1 changed files with 4 additions and 0 deletions

View File

@ -49,9 +49,11 @@ cdef char *_fruni(s):
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
# XXX: We lose reference here
c_string = string
elif isinstance(s, str):
c_string = s
# XXX: Reference is lost unless the user keeps the string object around
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string
@ -63,9 +65,11 @@ cdef const_char *_cfruni(s):
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
# XXX: We lose reference here
c_string = string
elif isinstance(s, str):
c_string = s
# XXX: Reference is lost unless the user keeps the string object around
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string