kuuko pushed a commit to branch master.
commit f1972f6a6e49a9d81e0c5211472e8cc5cbc9a110
Author: Kai Huuhko <[email protected]>
Date: Thu Apr 4 11:28:09 2013 +0000
Place the remnants of _cfruni and _fruni under six feet of soil.
Fix a braino in the py list to string array conversion function.
---
efl/eo/efl.eo.pyx | 60 ++++--------------------------------------------------
include/efl.eo.pxd | 2 --
2 files changed, 4 insertions(+), 58 deletions(-)
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index 50a4d5b..81ecbb4 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -69,58 +69,6 @@ cdef unicode _ctouni(const_char *s):
return s.decode('UTF-8', 'strict') if s else None
-cdef char *_fruni(object s):
- """
-
- Converts a python string object to a char *
-
- """
- cdef:
- char *c_string
- bytes string
- unicode unistr
-
- if s is None:
- return NULL
-
- if isinstance(s, unicode):
- unistr = s
- string = unistr.encode('UTF-8')
- c_string = string
- return c_string
- elif isinstance(s, str):
- c_string = s
- return c_string
- else:
- raise TypeError("Expected str or unicode object, got %s" %
(type(s).__name__))
-
-
-cdef const_char *_cfruni(object s):
- """
-
- Converts a python string object to a const_char *
-
- """
- cdef:
- const_char *c_string
- bytes string
- unicode unistr
-
- if s is None:
- return NULL
-
- if isinstance(s, unicode):
- unistr = s
- string = unistr.encode('UTF-8')
- c_string = string
- return c_string
- elif isinstance(s, str):
- c_string = s
- return c_string
- else:
- raise TypeError("Expected str or unicode object, got %s" %
(type(s).__name__))
-
-
cdef list convert_array_of_strings_to_python_list(char **array, int
array_length):
"""
@@ -147,10 +95,9 @@ cdef const_char **
convert_python_list_strings_to_array_of_strings(list strings)
"""
cdef:
const_char **array = NULL
- unsigned int arr_len = len(strings)
const_char *string
- unsigned int str_len
- unsigned int i
+ unsigned int str_len, i
+ unsigned int arr_len = len(strings)
# TODO: Should we just return NULL in this case?
if len(strings) is 0:
@@ -165,7 +112,8 @@ cdef const_char **
convert_python_list_strings_to_array_of_strings(list strings)
raise MemoryError()
for i in range(arr_len):
- if isinstance(strings[i], unicode): s = strings[i].encode("UTF-8")
+ s = strings[i]
+ if isinstance(s, unicode): s = s.encode("UTF-8")
array[i] = <const_char *>strdup(s)
return array
diff --git a/include/efl.eo.pxd b/include/efl.eo.pxd
index 75f7ee8..39c60df 100644
--- a/include/efl.eo.pxd
+++ b/include/efl.eo.pxd
@@ -36,9 +36,7 @@ cdef void _object_mapping_register(char *name, object cls)
except *
cdef void _object_mapping_unregister(char *name)
cdef unicode _touni(char* s)
-cdef char* _fruni(s)
cdef unicode _ctouni(const_char *s)
-cdef const_char *_cfruni(s)
cdef list convert_array_of_strings_to_python_list(char **array, int
array_length)
cdef const_char ** convert_python_list_strings_to_array_of_strings(list
strings) except NULL
--
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html