Add comments to point out the trouble areas in the string conv
functions.
This commit is contained in:
parent
8c071bedf8
commit
095f7fd867
|
@ -49,9 +49,11 @@ cdef char *_fruni(s):
|
||||||
return NULL
|
return NULL
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
string = s.encode('UTF-8')
|
string = s.encode('UTF-8')
|
||||||
|
# XXX: We lose reference here
|
||||||
c_string = string
|
c_string = string
|
||||||
elif isinstance(s, str):
|
elif isinstance(s, str):
|
||||||
c_string = s
|
c_string = s
|
||||||
|
# XXX: Reference is lost unless the user keeps the string object around
|
||||||
else:
|
else:
|
||||||
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
|
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
|
||||||
return c_string
|
return c_string
|
||||||
|
@ -63,9 +65,11 @@ cdef const_char *_cfruni(s):
|
||||||
return NULL
|
return NULL
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
string = s.encode('UTF-8')
|
string = s.encode('UTF-8')
|
||||||
|
# XXX: We lose reference here
|
||||||
c_string = string
|
c_string = string
|
||||||
elif isinstance(s, str):
|
elif isinstance(s, str):
|
||||||
c_string = s
|
c_string = s
|
||||||
|
# XXX: Reference is lost unless the user keeps the string object around
|
||||||
else:
|
else:
|
||||||
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
|
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
|
||||||
return c_string
|
return c_string
|
||||||
|
|
Loading…
Reference in New Issue