@@@ cython and python 3 wip
[mLib-python] / utils.pyx
index 17fa416..eab722f 100644 (file)
--- a/utils.pyx
+++ b/utils.pyx
 ### along with mLib/Python; if not, write to the Free Software Foundation,
 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-#cdef object _oserror():
-#  raise OSError, (errno, strerror(errno))
+cdef const char *_text_strlen(object s, Py_ssize_t *sz) except NULL:
+  cdef const char *p
+  TEXT_PTRLEN(s, &p, sz)
+  return p
 
-#cdef int _getfd(object fdobj):
-#  try:
-#    fd = int(fdobj)
-#  except TypeError:
-#    ##PyErr_Clear()
-#    fd = fdobj.fileno()
-#  return fd
+cdef object _oserror():
+  raise OSError(errno, strerror(errno))
+
+cdef int _getfd(object fdobj):
+  try:
+    fd = int(fdobj)
+  except TypeError:
+    fd = fdobj.fileno()
+  return fd
 
 #cdef object _checkcallable(object f, object what):
 #  if f is not None and not callable(f):